+2005-03-03 Helge Hess <helge.hess@opengroupware.org>
+
+ * NGImap4: added some debugging facilities (v4.5.215)
+
2005-02-14 Helge Hess <helge.hess@skyrix.com>
* NGImap4: changed base64 encoding in Sieve client to fix OGo bug #1228
+2005-03-03 Helge Hess <helge.hess@opengroupware.org>
+
+ * NGImap4FileManager.m: added debug logs which can be enabled using
+ the 'NGImap4FileManagerDebugEnabled' default, improved handling of
+ root folder in -fileExists method
+
+ * NGImap4Context.m: improved -description
+
+ * NGImap4Functions.m: added some debugging facilities
+
2005-02-14 Helge Hess <helge.hess@skyrix.com>
* NGSieveClient.m: encode base64 with a large line break to fix OGo
/* description */
-- (NSString *)description {
- NSMutableString *ms;
+- (void)appendAttributesToDescription:(NSMutableString *)ms {
NSString *tmp;
-
- ms = [NSMutableString stringWithCapacity:64];
-
- [ms appendFormat:@"<0x%08X[%@]:", self, NSStringFromClass([self class])];
-
- if ((tmp = [self host]))
+
+ if ((tmp = [self host]) != nil)
[ms appendFormat:@" host=%@", tmp];
- if ((tmp = [self login]))
+ if ((tmp = [self login]) != nil)
[ms appendFormat:@" login=%@", tmp];
- [ms appendFormat:@" server='%@'/%@/%@.%@/%@",
+ if ((tmp = [self serverName]) != nil)
+ [ms appendFormat:@" server='%@'", tmp];
+
+ [ms appendFormat:@" kind=%@/v%@.%@/tag=%@",
[self serverName],
[self serverKind],
[self serverVersion],
if (self->syncMode)
[ms appendString:@" syncmode"];
+}
+
+- (NSString *)description {
+ NSMutableString *ms;
+ ms = [NSMutableString stringWithCapacity:64];
+ [ms appendFormat:@"<0x%08X[%@]:", self, NSStringFromClass([self class])];
+ [self appendAttributesToDescription:ms];
[ms appendString:@">"];
-
return ms;
}
@implementation NGImap4FileManager
+static BOOL debugOn = NO;
+
+ (int)version {
return [super version] + 0 /* v0 */;
}
+ (void)initialize {
+ NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
+
NSAssert2([super version] == 0,
@"invalid superclass (%@) version %i !",
NSStringFromClass([self superclass]), [super version]);
+
+ if ((debugOn = [ud boolForKey:@"NGImap4FileManagerDebugEnabled"]))
+ NSLog(@"NGImap4FileManager debugging is enabled.");
}
- (id)initWithUser:(NSString *)_user
NSEnumerator *e;
NGImap4Folder *tmp;
NGImap4Message *msg;
-
+
if (![_path isAbsolutePath])
_path = [[self currentDirectoryPath] stringByAppendingPathComponent:_path];
- if ((folder = [self _lookupFolderAtPath:[_path pathComponents]]) == nil)
+ if ((folder = [self _lookupFolderAtPath:[_path pathComponents]]) == nil) {
/* folder does not exist */
+ if (debugOn) [self debugWithFormat:@"did not find folder."];
return nil;
-
+ }
+
results = [NSMutableArray arrayWithCapacity:64];
-
+
/* add folders */
if (_dirs) {
+ if (debugOn)
+ [self debugWithFormat:@" add subfolders: %@", [folder subFolders]];
+
e = [[folder subFolders] objectEnumerator];
- while ((tmp = [e nextObject]))
+ while ((tmp = [e nextObject]) != nil)
[results addObject:[tmp name]];
}
[results addObject:[NSString stringWithFormat:@"%d", [msg uid]]];
}
+ if (debugOn)
+ [self debugWithFormat:@" dir contents: %@", results];
return results;
}
if (![_path isAbsolutePath])
_path = [[self currentDirectoryPath] stringByAppendingPathComponent:_path];
+
+ if ([_path isEqualToString:@"/"]) {
+ if (_isDir) *_isDir = YES;
+ return self->rootFolder != nil ? YES : NO;
+ }
fileName = [_path lastPathComponent];
_path = [_path stringByDeletingLastPathComponent];
paths = [_path pathComponents];
-
- folder = [self _lookupFolderAtPath:paths];
-
- // NSLog(@"paths: %@, file %@, folder %@", paths, fileName, folder);
+ folder = [self _lookupFolderAtPath:paths];
+
+ if (debugOn) {
+ [self debugWithFormat:
+ @"base '%@' file '%@' paths: %@, file %@, folder %@",
+ _path, fileName, paths, fileName, folder];
+ }
if (folder == nil)
return NO;
return YES;
}
- if ([folder subFolderWithName:fileName caseInsensitive:NO]) {
+ // TODO: what is the caseInsensitive good for?
+ if (debugOn) [self debugWithFormat:@" lookup '%@' in %@", fileName, folder];
+ if ([folder subFolderWithName:fileName caseInsensitive:NO] != nil) {
*_isDir = YES;
return YES;
}
-
+
*_isDir = NO;
/* check for message 'file' */
return dict;
}
-/* description */
-
-- (NSString *)description {
- NSMutableString *ms;
-
- ms = [NSMutableString stringWithCapacity:64];
-
- [ms appendFormat:@"<0x%08X[%@]:", self, NSStringFromClass([self class])];
- [ms appendFormat:@" ctx=%@", self->imapContext];
- [ms appendFormat:@" root=%@", self->rootFolder];
- [ms appendFormat:@" wd=%@", self->currentFolder];
- [ms appendString:@">"];
-
- return ms;
-}
- (EODataSource *)dataSourceAtPath:(NSString *)_path {
NGImap4Folder *f;
[self->imapContext leaveSyncMode];
}
+/* debugging */
+
+- (BOOL)isDebuggingEnabled {
+ return debugOn;
+}
+
+/* description */
+
+- (void)appendAttributesToDescription:(NSMutableString *)ms {
+ [ms appendFormat:@" ctx=%@", self->imapContext];
+ [ms appendFormat:@" root=%@", self->rootFolder];
+ [ms appendFormat:@" wd=%@", self->currentFolder];
+}
+
+- (NSString *)description {
+ NSMutableString *ms;
+
+ ms = [NSMutableString stringWithCapacity:64];
+
+ [ms appendFormat:@"<0x%08X[%@]:", self, NSStringFromClass([self class])];
+ [self appendAttributesToDescription:ms];
+ [ms appendString:@">"];
+ return ms;
+}
+
@end /* NGImap4FileManager */
}
- (NGImap4Folder *)subFolderWithName:(NSString *)_name
- caseInsensitive:(BOOL)_caseIns {
+ caseInsensitive:(BOOL)_caseIns
+{
return _subFolderWithName(self, _name, _caseIns);
}
static int LogImapEnabled = -1;
static NGImap4FolderHandler *sharedHandler = nil; // THREAD
+static BOOL debugFolderLookup = NO;
+ (id)sharedImap4FolderHandler {
if (sharedHandler == nil)
if (_caseIns)
_name = [_name lowercaseString];
-
+
+ if (debugFolderLookup)
+ NSLog(@"LOOKUP %@ IN %@", _name, [_parent subFolders]);
+
enumerator = [[_parent subFolders] objectEnumerator];
- while ((f = [enumerator nextObject])) {
+ while ((f = [enumerator nextObject]) != nil) {
NSString *n;
n = [f name];
if (_caseIns)
n = [n lowercaseString];
- if ([n isEqualToString:_name])
+ if ([n isEqualToString:_name]) {
+ if (debugFolderLookup) NSLog(@" FOUND: %@", f);
return f;
+ }
- if ([[_parent context] lastException])
+ if ([[_parent context] lastException] != nil) {
+ if (debugFolderLookup) {
+ NSLog(@" FAILED: %@", [[_parent context] lastException]);
+ }
return NO;
+ }
}
+ if (debugFolderLookup) NSLog(@" NOT FOUND.");
return nil;
}
MAJOR_VERSION:=4
MINOR_VERSION:=5
-SUBMINOR_VERSION:=214
+SUBMINOR_VERSION:=215
# v4.5.214 requires libNGExtensions v4.5.146
# v4.2.149 requires libNGStreams v4.2.34
+2005-03-03 Helge Hess <helge.hess@opengroupware.org>
+
+ * ImapListTool.m: improved output with directories
+
2004-09-26 Helge Hess <helge.hess@opengroupware.org>
* GNUmakefile: added imap_tool to compilation
NSString *cpath, *apath;
NSDictionary *info;
NSString *mid;
+ const unsigned char *datestr;
if (!self->useDataSource) {
cpath = [dirContents objectAtIndex:i];
mid = [mid substringToIndex:37];
mid = [mid stringByAppendingString:@"..."];
}
-
+
/* id uid date name */
if (_part) {
printf("%10d ",
[[fm contentsAtPath:[info valueForKey:@"NSFilePath"]
part:_part] length]);
}
+
+ datestr = [[[info valueForKey:NSFileModificationDate]
+ description] cString];
+
printf("%-40s %8s %8i %-32s %s",
- [mid cString],
+ (mid ? [mid cString] : ""),
[[info valueForKey:NSFileOwnerAccountName] cString],
[[info valueForKey:NSFileSize] intValue],
- [[[info valueForKey:NSFileModificationDate]
- description] cString],
+ (datestr ? (char *)datestr : ""),
[apath cString]);
if ([[info valueForKey:NSFileType]
printf("/\n");
else
printf("\n");
-
-
}
return YES;
}
if (![fm changeCurrentDirectoryPath:path]) {
NSLog(@"%s: could not change to directory: '%@'", path);
}
-
+
ds = self->useDataSource
? [(id<NGFileManagerDataSources>)fm dataSourceAtPath:path]
: nil;
return;
}
- if (isDir) {
+ if (isDir)
[self processFolder:path fileManager:fm part:part];
- }
- else {
+ else
[self processFile:path fileManager:fm part:part];
- }
}
/* tool operation */