]> err.no Git - scalable-opengroupware.org/commitdiff
implemented folder expunge
authorhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Mon, 31 Jan 2005 02:57:49 +0000 (02:57 +0000)
committerhelge <helge@d1b88da0-ebda-0310-925b-ed51d893ca5b>
Mon, 31 Jan 2005 02:57:49 +0000 (02:57 +0000)
git-svn-id: http://svn.opengroupware.org/SOGo/trunk@516 d1b88da0-ebda-0310-925b-ed51d893ca5b

SOGo/SoObjects/Mailer/ChangeLog
SOGo/SoObjects/Mailer/SOGoMailFolder.h
SOGo/SoObjects/Mailer/SOGoMailFolder.m
SOGo/SoObjects/Mailer/SOGoMailManager.h
SOGo/SoObjects/Mailer/SOGoMailManager.m
SOGo/SoObjects/Mailer/SOGoMailObject.m
SOGo/SoObjects/Mailer/Version
SOGo/UI/Mailer/ChangeLog
SOGo/UI/Mailer/UIxMailListView.m
SOGo/UI/Mailer/Version
SOGo/UI/Mailer/product.plist

index d1c11d8a2692cbeb66da27d6256135f94b37c2d5..312caaf75980d0bd02c39901e224fea88eb58884 100644 (file)
@@ -1,5 +1,11 @@
 2005-01-31  Helge Hess  <helge.hess@opengroupware.org>
 
+       * v0.9.65
+
+       * SOGoMailManager.m, SOGoMailFolder.m: added expunge method
+
+       * SOGoMailObject.m: improve bulk key collector
+
        * SOGoMailObject.m: moved more bulk fetching to SoObject (v0.9.64)
 
        * SOGoMailObject.m: moved in plain/text bulk fetch method from mail
index ad9d6acbe656fbe60f1b1e2bed68499ae5f43b7c..ddb014d10fa8f4a7d60b74e9e775c72cfa550983 100644 (file)
@@ -47,6 +47,8 @@
 
 - (NSException *)postData:(NSData *)_data flags:(id)_flags;
 
+- (NSException *)expunge;
+
 @end
 
 #endif /* __Mailer_SOGoMailFolder_H__ */
index 05b2d905d44c88b81da4bd1ae8e4a3f9a4df2414..7493989d14f46da3b867ce35b7cdd92c964542bc 100644 (file)
                             password:[self imap4Password]];
 }
 
+- (NSException *)expunge {
+  return [[self mailManager] expungeAtURL:[self imap4URL]
+                            password:[self imap4Password]];
+}
+
 /* name lookup */
 
 - (BOOL)isMessageKey:(NSString *)_key inContext:(id)_ctx {
index 0888bf84a9bbfc2b204ab7b7d3857a09fb1619d5..726226c77eb13ed0a6ef581436ddde97a9d7cb07 100644 (file)
@@ -62,6 +62,8 @@
 - (NSArray *)fetchUIDs:(NSArray *)_uids inURL:(NSURL *)_url
   parts:(NSArray *)_parts password:(NSString *)_pwd;
 
+- (NSException *)expungeAtURL:(NSURL *)_url password:(NSString *)_pwd;
+
 /* individual message */
 
 - (id)fetchURL:(NSURL *)_url parts:(NSArray *)_parts password:(NSString *)_pwd;
index 3bdbfe7e0de668c6041a86df3320137556c8ad0e..d92c2000f8c5afb35d4c3da7f3873ed8386f0b7a 100644 (file)
@@ -518,6 +518,35 @@ static NSString       *imap4Separator  = nil;
   return (id)result;
 }
 
+- (NSException *)expungeAtURL:(NSURL *)_url password:(NSString *)_pwd {
+  NGImap4Client *client;
+  NSString *p;
+  id result;
+  
+  if ((client = [self imap4ClientForURL:_url password:_pwd]) == nil)
+    return nil; // TODO: return error?
+  
+  /* select folder */
+  
+  p = [self imap4FolderNameForURL:_url removeFileName:NO];
+  result = [client select:p];
+  if (![[result valueForKey:@"result"] boolValue]) {
+    [self errorWithFormat:@"could not select URL: %@: %@", _url, result];
+    return nil;
+  }
+
+  /* expunge */
+  
+  result = [client expunge];
+
+  if (![[result valueForKey:@"result"] boolValue]) {
+    [self errorWithFormat:@"could not expunge url: %@", _url];
+    return nil;
+  }
+  //[self logWithFormat:@"RESULT: %@", result];
+  return nil;
+}
+
 - (id)fetchURL:(NSURL *)_url parts:(NSArray *)_parts password:(NSString *)_pwd{
   // currently returns a dict
   NGImap4Client *client;
index 0935ed303dd5e2c7790570a97b0fabb256456d68..008fc8f66626922db9090139606f82abcb77125e 100644 (file)
@@ -200,6 +200,7 @@ static BOOL debugBodyStructure = NO;
     [self debugWithFormat:@"check PATH: %@", p];
     idx = [p intValue] - 1;
 
+    parts = [info valueForKey:@"parts"];
     mt = [[info valueForKey:@"type"] lowercaseString];
     if ([mt isEqualToString:@"message"]) {
       /* we have special behaviour for message types */
@@ -213,8 +214,6 @@ static BOOL debugBodyStructure = NO;
          parts = [NSArray arrayWithObject:body];
       }
     }
-    else
-      parts = [info valueForKey:@"parts"];
     
     if (idx >= [parts count]) {
       [self errorWithFormat:
@@ -301,6 +300,7 @@ static BOOL debugBodyStructure = NO;
 
 - (void)addRequiredKeysOfStructure:(id)_info path:(NSString *)_p
   toArray:(NSMutableArray *)_keys
+  recurse:(BOOL)_recurse
 {
   NSArray  *parts;
   unsigned i, count;
@@ -326,6 +326,9 @@ static BOOL debugBodyStructure = NO;
     [_keys addObject:k];
   }
   
+  if (!_recurse)
+    return;
+  
   /* recurse */
   
   parts = [_info objectForKey:@"parts"];
@@ -339,7 +342,8 @@ static BOOL debugBodyStructure = NO;
     
     childInfo = [parts objectAtIndex:i];
     
-    [self addRequiredKeysOfStructure:childInfo path:sp toArray:_keys];
+    [self addRequiredKeysOfStructure:childInfo path:sp toArray:_keys
+         recurse:YES];
   }
   
   /* check body */
@@ -352,7 +356,8 @@ static BOOL debugBodyStructure = NO;
       sp = _p;
     else
       sp = [_p length] > 0 ? [_p stringByAppendingString:@".1"] : @"1";
-    [self addRequiredKeysOfStructure:body path:sp toArray:_keys];
+    [self addRequiredKeysOfStructure:body path:sp toArray:_keys
+         recurse:YES];
   }
 }
 
@@ -361,7 +366,7 @@ static BOOL debugBodyStructure = NO;
   
   ma = [NSMutableArray arrayWithCapacity:4];
   [self addRequiredKeysOfStructure:[[self clientObject] bodyStructure]
-       path:@"" toArray:ma];
+       path:@"" toArray:ma recurse:YES];
   return ma;
 }
 
index 4d027ef17216299c6d52a9c3166353bd9e5708ad..9c2c63c614057933ed526e0580a062c52170d5c4 100644 (file)
@@ -1,6 +1,6 @@
 # Version file
 
-SUBMINOR_VERSION:=64
+SUBMINOR_VERSION:=65
 
 # v0.9.55 requires NGExtensions v4.5.136
 # v0.9.44 requires libNGMime    v4.3.194
index 2a11a029f21755873a9915cd527bd3719e3b96c0..be1020b7af5f57dc2eec6348ea796d911a5576b0 100644 (file)
@@ -1,5 +1,8 @@
 2005-01-31  Helge Hess  <helge.hess@opengroupware.org>
 
+       * UIxMailView.m: implemented 'expunge' action (delete button in the
+         toolbar) (v0.9.87)
+
        * UIxMailView.m, UIxMailRenderingContext.m: moved more bulk fetching
          to SoObject (v0.9.86)
 
index 3e061676d253f4b42aa2c7cf45b72bbec61448a5..8b36b5d6123e94474d01a4ef14dc51aa07f61b19 100644 (file)
@@ -439,4 +439,22 @@ static int attachmentFlagSize = 8096;
   return [self redirectToLocation:@"view"];
 }
 
+- (id)expungeAction {
+  // TODO: we might want to flush the caches?
+  NSException *error;
+  id client;
+  
+  if ((client = [self clientObject]) == nil) {
+    return [NSException exceptionWithHTTPStatus:404 /* Not Found */
+                       reason:@"did not find mail folder"];
+  }
+  
+  if ((error = [[self clientObject] expunge]) != nil)
+    return error;
+  
+  if ([client respondsToSelector:@selector(flushMailCaches)])
+    [client flushMailCaches];
+  return [self redirectToLocation:@"view"];
+}
+
 @end /* UIxMailListView */
index 22c1ab4783c1f9a204602ce84360e2c407ca47cd..53efe52364db252385d921307b4f742d721b78d9 100644 (file)
@@ -1,7 +1,8 @@
 # version file
 
-SUBMINOR_VERSION:=86
+SUBMINOR_VERSION:=87
 
+# v0.9.87 requires SoObjects/Mailer v0.9.65
 # v0.9.86 requires SoObjects/Mailer v0.9.64
 # v0.9.85 requires SoObjects/Mailer v0.9.63
 # v0.9.84 requires libNGMime        v4.5.209
index 1b9774ce4664abb163b753b526a2358ac6969cf4..fda2a6a7a83355abe45587434b46832b1f8f08d9 100644 (file)
               { link = "#"; cssClass = "tbicon_forward";  label = "Forward";   },
             ),
 */
-/* TODO: enable when implemented
             ( // third group
+              { link = "expunge"; 
+                cssClass = "tbicon_delete"; label = "Expunge"; },
+/* TODO: enable when implemented
 // TODO: enable when delete works (#1212)
               { link = "#"; 
                 cssClass = "tbicon_delete"; label = "Delete"; },
 // TODO: enable when we know how to mark junk (#971)
               { link = "#"; 
                 cssClass = "tbicon_junk";   label = "Junk";   },
-            ),
 */
+            ),
             ( /* fourth group */
 /* TODO: enable when we can print (#1207)
               { link = "#"; cssClass = "tbicon_print"; label = "Print"; },
           pageName    = "UIxMailListView"; 
           actionName  = "getMail";
         };
+        expunge = {
+          protectedBy = "View";
+          pageName    = "UIxMailListView"; 
+          actionName  = "expunge";
+        };
 
         compose = {
           protectedBy = "View";