diff --git a/ChangeLog b/ChangeLog index 2239ac960..35a2b3add 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2007-10-26 Wolfgang Sourdeau + + * UI/MailerUI/UIxMailListView.m ([UIxMailListView + -defaultAction]): now expunges the last folder marked for expunge. + + * SoObjects/Mailer/SOGoMailObject.m ([SOGoMailObject + -trashInContext:_ctx]): now marks the container folder for + expunge. + + * SoObjects/Mailer/SOGoMailFolder.m ([SOGoMailFolder + -markForExpunge]): new method that marks the folder for the next + automatic expunge operation in the user settings. + ([SOGoMailFolder -expungeLastMarkedFolder]): new methods that + takes the last folder marked for expunge, expunges it and removes + it from the user settings, if it exists. + 2007-10-25 Wolfgang Sourdeau * UI/MailerUI/UIxMailListView.m ([UIxMailListView diff --git a/SoObjects/Mailer/SOGoMailFolder.h b/SoObjects/Mailer/SOGoMailFolder.h index 3cd98c20a..3de6f3ee8 100644 --- a/SoObjects/Mailer/SOGoMailFolder.h +++ b/SoObjects/Mailer/SOGoMailFolder.h @@ -52,6 +52,9 @@ - (NSException *) postData: (NSData *) _data flags: (id) _flags; +- (void) markForExpunge; +- (void) expungeLastMarkedFolder; + - (NSException *) expunge; /* flags */ diff --git a/SoObjects/Mailer/SOGoMailFolder.m b/SoObjects/Mailer/SOGoMailFolder.m index 50f2484b0..ec66e3669 100644 --- a/SoObjects/Mailer/SOGoMailFolder.m +++ b/SoObjects/Mailer/SOGoMailFolder.m @@ -19,9 +19,12 @@ 02111-1307, USA. */ +#import +#import #import #import +#import #import #import #import @@ -236,6 +239,47 @@ static NSString *defaultUserID = @"anyone"; return [[self imap4Connection] expungeAtURL: [self imap4URL]]; } +- (void) markForExpunge +{ + NSUserDefaults *ud; + NSMutableDictionary *mailSettings; + + ud = [[context activeUser] userSettings]; + mailSettings = [ud objectForKey: @"Mail"]; + if (!mailSettings) + { + mailSettings = [NSMutableDictionary dictionaryWithCapacity: 1]; + [ud setObject: mailSettings forKey: @"Mail"]; + } + + [mailSettings setObject: [self imap4URLString] forKey: @"folderForExpunge"]; + [ud synchronize]; +} + +- (void) expungeLastMarkedFolder +{ + NSUserDefaults *ud; + NSMutableDictionary *mailSettings; + NSString *expungeURL; + NSURL *folderURL; + + ud = [[context activeUser] userSettings]; + mailSettings = [ud objectForKey: @"Mail"]; + if (mailSettings) + { + expungeURL = [mailSettings objectForKey: @"folderForExpunge"]; + if (expungeURL) + { + folderURL = [NSURL URLWithString: expungeURL]; + if (![[self imap4Connection] expungeAtURL: folderURL]) + { + [mailSettings removeObjectForKey: @"folderForExpunge"]; + [ud synchronize]; + } + } + } +} + /* flags */ - (NSException *) addFlagsToAllMessages: (id) _f diff --git a/SoObjects/Mailer/SOGoMailObject.m b/SoObjects/Mailer/SOGoMailObject.m index 86eb94e8e..e126222f3 100644 --- a/SoObjects/Mailer/SOGoMailObject.m +++ b/SoObjects/Mailer/SOGoMailObject.m @@ -874,7 +874,9 @@ static BOOL debugSoParts = NO; error = [[self imap4Connection] markURLDeleted: [self imap4URL]]; if (error != nil) return error; - + + [container markForExpunge]; + [self flushMailCaches]; return nil; diff --git a/UI/MailerUI/UIxMailListView.m b/UI/MailerUI/UIxMailListView.m index 7c6a855bb..162514211 100644 --- a/UI/MailerUI/UIxMailListView.m +++ b/UI/MailerUI/UIxMailListView.m @@ -516,10 +516,13 @@ static int attachmentFlagSize = 8096; { WORequest *request; NSString *specificMessage, *searchCriteria, *searchValue; + SOGoUserFolder *co; request = [context request]; - [[self clientObject] flushMailCaches]; + co = [self clientObject]; + [co flushMailCaches]; + [co expungeLastMarkedFolder]; specificMessage = [request formValueForKey: @"pageforuid"]; searchCriteria = [request formValueForKey: @"search"]; @@ -532,6 +535,7 @@ static int attachmentFlagSize = 8096; = ((specificMessage) ? [self firstMessageOfPageFor: [specificMessage intValue]] : [[request formValueForKey:@"idx"] intValue]); + return self; }