]> err.no Git - sope/commitdiff
some debugging in NGImap4
authorhelge <helge@e4a50df8-12e2-0310-a44c-efbce7f8a7e3>
Thu, 3 Mar 2005 00:43:11 +0000 (00:43 +0000)
committerhelge <helge@e4a50df8-12e2-0310-a44c-efbce7f8a7e3>
Thu, 3 Mar 2005 00:43:11 +0000 (00:43 +0000)
git-svn-id: http://svn.opengroupware.org/SOPE/trunk@610 e4a50df8-12e2-0310-a44c-efbce7f8a7e3

sope-mime/ChangeLog
sope-mime/NGImap4/ChangeLog
sope-mime/NGImap4/NGImap4Context.m
sope-mime/NGImap4/NGImap4FileManager.m
sope-mime/NGImap4/NGImap4Folder.m
sope-mime/NGImap4/NGImap4Functions.m
sope-mime/Version
sope-mime/samples/ChangeLog
sope-mime/samples/ImapListTool.m

index 0bf8627f1fb44c639c1b674b3d03b1c430fb713b..3e7e5e5a93261f684015f90389765a5a5723d35f 100644 (file)
@@ -1,3 +1,7 @@
+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
index 05ae3f405375e21325d571a4b7b954229812b409..60bb5a77d92d221ec1a4e93ff8536647b119a764 100644 (file)
@@ -1,3 +1,13 @@
+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
index 357f125708a821767da8a148c28d4f626449e307..645f8c3b5df59e75d4f23837671dec465bb63f41 100644 (file)
@@ -929,20 +929,18 @@ static int ImapLogEnabled                           = -1;
 
 /* 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],
@@ -951,9 +949,15 @@ static int ImapLogEnabled                           = -1;
   
   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;
 }
 
index 6e411bae639e6b9697d44f67ba53f4cb968e1daf..fbfacb12347b356ba1e1ba72610580b98aeab156 100644 (file)
 
 @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 */
index 4c6af2c184c293485d9cb81a95b535ccf1cd6019..2d90dd9c00b2e802625ccc5eae6f599280595287 100644 (file)
@@ -368,7 +368,8 @@ static int FetchNewUnseenMessagesInSubFoldersOnDemand = -1;
 }
 
 - (NGImap4Folder *)subFolderWithName:(NSString *)_name
-  caseInsensitive:(BOOL)_caseIns {
+  caseInsensitive:(BOOL)_caseIns
+{
   return _subFolderWithName(self, _name, _caseIns);
 }
 
index c0e6e5c49b8b6a8765de2214a9e13c7ef8f91095..9d881724c65f5c7657c89b8676bcfeea6daf2492 100644 (file)
@@ -34,6 +34,7 @@
 
 static int                  LogImapEnabled = -1;
 static NGImap4FolderHandler *sharedHandler = nil; // THREAD
+static BOOL                 debugFolderLookup = NO;
 
 + (id)sharedImap4FolderHandler {
   if (sharedHandler == nil)
@@ -106,21 +107,31 @@ NGImap4Folder *_subFolderWithName
 
   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;
 }
 
index 8f5d80cb9aa4535433f9a35e1e7094a29ef39508..c61276a2ef80a807e04de8abbe7602d6bd752ab8 100644 (file)
@@ -2,7 +2,7 @@
 
 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
index dcd9fe64e6b5da8033cedc7bf4bf292e98756212..024ae5bdf760bc33e39190d7d0e3077c3d0dd2e4 100644 (file)
@@ -1,3 +1,7 @@
+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
index 02bfbc7495db250ae72289bf224f6c39fe8ce35b..9256b42f3654a4646066841ad5860a81ba062d72 100644 (file)
@@ -40,6 +40,7 @@
     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]
@@ -81,8 +85,6 @@
       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 */