 -    return @" sentsince ";
 -  if (sel_eq(lselector, EOQualifierOperatorLessThan))
 -    return @" sentbefore ";
-+    dateOperator = @"on";
+-  
+-  return nil;
++    dateOperator = @"ON";
 +  else if (sel_eq(lselector, EOQualifierOperatorGreaterThan))
-+    dateOperator = @"since";
++    dateOperator = @"SINCE";
 +  else if (sel_eq(lselector, EOQualifierOperatorLessThan))
-+    dateOperator = @"before";
-   
--  return nil;
-+  return [NSString stringWithFormat: @" %@%@ ", operatorPrefix, dateOperator];
++    dateOperator = @"BEFORE";
++  else
++    dateOperator = nil;
++ 
++  if (dateOperator) {
++    if ([dkey isEqualToString: @"DATE"])
++      operatorPrefix = @"SENT";
++    else
++      operatorPrefix = @"";
++    imap4Operator = [NSString stringWithFormat: @"%@%@ ",
++                              operatorPrefix, dateOperator];
++  }
++  else
++    imap4Operator = nil;
++
++  return imap4Operator;
  }
  
  - (NSException *)appendToImap4SearchString:(NSMutableString *)search 
-@@ -314,7 +321,7 @@
+@@ -300,11 +316,11 @@
+   id       lvalue;
+   SEL      lselector;
+   
+-  lkey      = [[self key] lowercaseString];
++  lkey      = [[self key] uppercaseString];
+   lvalue    = [self value];
+   lselector = [self selector];
+     
+-  if ([lkey isEqualToString:@"flags"]) {
++  if ([lkey isEqualToString:@"FLAGS"]) {
+     /* NOTE: special "not" processing! */
+     return [self appendFlagsCheckToImap4SearchString:search 
+                  insertNot:insertNot];
+@@ -312,9 +328,9 @@
+   
+   /* not a flag */
    if (insertNot) 
-     [search appendString:@"not "];
+-    [search appendString:@"not "];
++    [search appendString:@"NOT "];
    
 -  if ([lkey isEqualToString:@"date"]) {
-+  if ([lkey isEqualToString:@"date"] || [lkey isEqualToString:@"receive-date"]) {
++  if ([lkey isEqualToString:@"DATE"] || [lkey isEqualToString:@"RECEIVE-DATE"]) {
      NSString *s;
      
      if (![lvalue isKindOfClass:[NSCalendarDate class]]) {
-@@ -322,7 +329,8 @@
+@@ -322,35 +338,38 @@
  		     @"expected a NSDate as value"];
      }
      

 2009-04-02  Wolfgang Sourdeau  <wsourdeau@inverse.ca>
 
 	* NGLdapConnection.m (useSSL,startTLS): new method enabling
Index: sope-mime/NGImap4/NGImap4Functions.m
===================================================================
--- sope-mime/NGImap4/NGImap4Functions.m	(revision 1660)

+                         andComparisonSelector:lselector]) == nil)
       return [self invalidImap4SearchQualifier:@"unexpected selector"];
     
-    // TODO: operator created but NOT added?
+    [search appendString:s];
     
     // TODO: much faster without descriptionWithCalendarFormat:?!
-    s = [lvalue descriptionWithCalendarFormat:@"%d-%b-%Y"];
+    s = [lvalue descriptionWithCalendarFormat:@"\"%d-%b-%Y\""];
     [search appendString:s];
     return nil;
   }
 
-  if ([lkey isEqualToString:@"uid"]) {
-    if (!sel_eq(lselector, EOQualifierOperatorEqual))
+  if ([lkey isEqualToString:@"UID"]) {
+    if (!sel_eq(lselector, EOQualifierOperatorEqual)) {
       return [self invalidImap4SearchQualifier:@"unexpected qualifier 2"];
+    }
     
-    [search appendString:@"uid "];
+    [search appendString:@"UID "];
     [search appendString:[lvalue stringValue]];
     return nil;
   }
   
-  if ([lkey isEqualToString:@"size"]) {
+  if ([lkey isEqualToString:@"SIZE"]) {
     if (sel_eq(lselector, EOQualifierOperatorGreaterThan))
-      [search appendString:@"larger "];
+      [search appendString:@"LARGER "];
     else if (sel_eq(lselector, EOQualifierOperatorLessThan))
-      [search appendString:@"smaller "];
+      [search appendString:@"SMALLER "];
     else
       return [self invalidImap4SearchQualifier:@"unexpected qualifier 3"];
         
     [search appendString:[lvalue stringValue]];
+
     return nil;
   }
   
@@ -386,7 +405,7 @@
   if (!sel_eq(lselector, EOQualifierOperatorEqual))
     return [self invalidImap4SearchQualifier:@"unexpected qualifier 5"];
   
-  [search appendString:@"header "];
+  [search appendString:@"HEADER "];
   [search appendString:lkey];
   [search appendString:@" \""];
   [search appendString:[lvalue stringValue]];
Index: sope-mime/NGImap4/NGImap4ResponseParser.m
===================================================================
--- sope-mime/NGImap4/NGImap4ResponseParser.m	(revision 1660)
