    [self debugWithFormat:@"should collect IMAP4 channels (%d active)",
  	  [self->urlToEntry count]];
  }
+@@ -105,34 +126,42 @@
+   NGImap4Connection *entry;
+   NGImap4Client *client;
+ 
++  if (poolingOff) {
++    client = [self imap4ClientForURL:_url password:_p];
++    entry = [[NGImap4Connection alloc] initWithClient:client 
++				       password:_p];
++    return [entry autorelease];
++  }
++  else {
+   /* check cache */
+   
+-  if ((entry = [self entryForURL:_url]) != nil) {
+-    if ([entry isValidPassword:_p]) {
++    if ((entry = [self entryForURL:_url]) != nil) {
++      if ([entry isValidPassword:_p]) {
++	if (debugCache)
++	  [self logWithFormat:@"valid password, reusing cache entry ..."];
++	return entry;
++      }
++    
++      /* different password, password could have changed! */
+       if (debugCache)
+-	[self logWithFormat:@"valid password, reusing cache entry ..."];
+-      return entry;
++	[self logWithFormat:@"different password than cached entry: %@", _url];
++      entry = nil;
+     }
+-    
+-    /* different password, password could have changed! */
+-    if (debugCache)
+-      [self logWithFormat:@"different password than cached entry: %@", _url];
+-    entry = nil;
+-  }
+-  else
+-    [self debugWithFormat:@"no connection cached yet for url: %@", _url];
++    else
++      [self debugWithFormat:@"no connection cached yet for url: %@", _url];
+   
+-  /* try to login */
++    /* try to login */
+   
+-  client = [entry isValidPassword:_p]
+-    ? [entry client]
+-    : [self imap4ClientForURL:_url password:_p];
++    client = [entry isValidPassword:_p]
++      ? [entry client]
++      : [self imap4ClientForURL:_url password:_p];
++    
++    if (client == nil)
++      return nil;
+   
+-  if (client == nil)
+-    return nil;
+-  
+   /* sideeffect of -imap4ClientForURL:password: is to create a cache entry */
+-  return [self entryForURL:_url];
++    return [self entryForURL:_url];
++  }
+ }
+ 
+ /* client object */
 Index: sope-mime/NGMail/NGSmtpClient.m
 ===================================================================
 --- sope-mime/NGMail/NGSmtpClient.m	(révision 1626)

 @end
 
 /*
@@ -508,6 +512,7 @@
 
   map = [self processCommand:@"logout"];
   [self closeConnection];
+  [self->selectedFolder release]; self->selectedFolder = nil;
   
   return [self->normer normalizeResponse:map];
 }
@@ -635,6 +640,10 @@
   return [self->normer normalizeSelectResponse:[self processCommand:s]];
 }
 

===================================================================
--- sope-mime/NGImap4/NGImap4Client.h	(révision 1626)
+++ sope-mime/NGImap4/NGImap4Client.h	(copie de travail)
@@ -62,6 +62,8 @@
   NGImap4ResponseNormalizer *normer;
   NSMutableArray            *responseReceiver;  
 
+  BOOL	   loggedIn;
+
   BOOL     isLogin;
   unsigned tagId;
 
@@ -120,6 +122,7 @@
 - (NSDictionary *)list:(NSString *)_folder pattern:(NSString *)_pattern;
 - (NSDictionary *)lsub:(NSString *)_folder pattern:(NSString *)_pattern;
 - (NSDictionary *)select:(NSString *)_folder;
