diff --git a/SoObjects/Mailer/SOGoMailFolder.h b/SoObjects/Mailer/SOGoMailFolder.h index 35e75ca12..dd7c0b99f 100644 --- a/SoObjects/Mailer/SOGoMailFolder.h +++ b/SoObjects/Mailer/SOGoMailFolder.h @@ -49,7 +49,10 @@ /* messages */ - (NSException *) deleteUIDs: (NSArray *) uids inContext: (id) context; -- (WOResponse *) archiveUIDs: (NSArray *) uids inContext: (id) context; +- (WOResponse *) archiveUIDs: (NSArray *) uids + inArchiveNamed: (NSString *) archiveName + inContext: (id) context; +- (WOResponse *) archiveAllMessagesInContext: (id) localContext; - (NSArray *) fetchUIDsMatchingQualifier: (id)_q sortOrdering: (id) _so; - (NSArray *) fetchUIDs: (NSArray *) _uids parts: (NSArray *) _parts; diff --git a/SoObjects/Mailer/SOGoMailFolder.m b/SoObjects/Mailer/SOGoMailFolder.m index cde36f4ba..a5b6d6eaa 100644 --- a/SoObjects/Mailer/SOGoMailFolder.m +++ b/SoObjects/Mailer/SOGoMailFolder.m @@ -331,11 +331,12 @@ static NSString *defaultUserID = @"anyone"; } - (WOResponse *) archiveUIDs: (NSArray *) uids + inArchiveNamed: (NSString *) archiveName inContext: (id) localContext { NSException *error; NSFileManager *fm; - NSString *spoolPath, *fileName, *zipPath; + NSString *spoolPath, *fileName, *zipPath, *qpFileName; NSDictionary *msgs; NSArray *messages; NSData *content, *zipContent; @@ -344,6 +345,9 @@ static NSString *defaultUserID = @"anyone"; WOResponse *response; int i; + if (!archiveName) + archiveName = @"SavedMessages.zip"; + #warning this method should be rewritten according to our coding styles spoolPath = [self userSpoolFolderPath]; if (![self ensureSpoolFolderPath]) { @@ -369,18 +373,16 @@ static NSString *defaultUserID = @"anyone"; [zipTaskArguments addObject: @"SavedMessages.zip"]; msgs = (NSDictionary *)[self fetchUIDs: uids - parts: [NSArray arrayWithObject: @"RFC822"]]; + parts: [NSArray arrayWithObject: @"RFC822"]]; messages = [msgs objectForKey: @"fetch"]; for (i = 0; i < [messages count]; i++) { content = [[messages objectAtIndex: i] objectForKey: @"message"]; - - [content writeToFile: - [NSString stringWithFormat:@"%@/%d.eml", spoolPath, [uids objectAtIndex: i]] - atomically: YES]; + fileName = [NSString stringWithFormat:@"%@/%@.eml", spoolPath, [uids objectAtIndex: i]];; + [content writeToFile: fileName atomically: YES]; [zipTaskArguments addObject: - [NSString stringWithFormat:@"%d.eml", [uids objectAtIndex: i]]]; + [NSString stringWithFormat:@"%@.eml", [uids objectAtIndex: i]]]; } [zipTask setArguments: zipTaskArguments]; @@ -400,15 +402,46 @@ static NSString *defaultUserID = @"anyone"; response = [[WOResponse alloc] init]; [response autorelease]; - [response setHeader: @"application/zip" forKey:@"content-type"]; - [response setHeader: @"attachment;filename=SavedMessages.zip" forKey: @"Content-Disposition"]; + qpFileName = [archiveName asQPSubjectString: @"utf-8"]; + [response setHeader: [NSString stringWithFormat: @"application/zip;" + @" name=\"%@\"", + qpFileName] + forKey:@"content-type"]; + [response setHeader: [NSString stringWithFormat: @"attachment; filename=\"%@\"", + qpFileName] + forKey: @"Content-Disposition"]; [response setContent: zipContent]; - + [zipContent release]; return response; } +- (WOResponse *) archiveAllMessagesInContext: (id) localContext +{ + WOResponse *response; + NSArray *uids; + NSString *archiveName; + EOQualifier *notDeleted; + + if ([[self imap4Connection] doesMailboxExistAtURL: [self imap4URL]]) + { + notDeleted = [EOQualifier qualifierWithQualifierFormat: + @"(not (flags = %@))", @"deleted"]; + uids = [self fetchUIDsMatchingQualifier: notDeleted + sortOrdering: @"ARRIVAL"]; + archiveName = [NSString stringWithFormat: @"%@.zip", [self relativeImap4Name]]; + response = [self archiveUIDs: uids inArchiveNamed: archiveName + inContext: localContext]; + } + else + response = (WOResponse *) + [NSException exceptionWithHTTPStatus: 404 + reason: @"Folder does not exist."]; + + return response; +} + - (WOResponse *) copyUIDs: (NSArray *) uids toFolder: (NSString *) destinationFolder inContext: (id) localContext diff --git a/SoObjects/SOGo/NSString+Utilities.m b/SoObjects/SOGo/NSString+Utilities.m index 27daaf6a5..48a9c7ee9 100644 --- a/SoObjects/SOGo/NSString+Utilities.m +++ b/SoObjects/SOGo/NSString+Utilities.m @@ -401,7 +401,7 @@ static int cssEscapingCount; if ([qpString length] > [self length]) { qpString = [qpString stringByReplacingString: @" " withString: @"_"]; - subjectString = [NSString stringWithFormat: @"=?%@?Q?%@?=", + subjectString = [NSString stringWithFormat: @"=?%@?q?%@?=", encoding, qpString]; } else diff --git a/UI/MailerUI/BrazilianPortuguese.lproj/Localizable.strings b/UI/MailerUI/BrazilianPortuguese.lproj/Localizable.strings index b33ace8c9..32bd6e2d7 100644 --- a/UI/MailerUI/BrazilianPortuguese.lproj/Localizable.strings +++ b/UI/MailerUI/BrazilianPortuguese.lproj/Localizable.strings @@ -76,8 +76,11 @@ "Remove this folder" = "Apagar esta pasta"; "Erase mails from this folder" = "Apagar emails desta pasta"; "Expunge this folder" = "Expurgar esta pasta"; +"Archive This Folder" = "Archive This Folder"; "Modify the acl of this folder" = "Modificar os direitos desta pasta"; +"Saved Messages.zip" = "Saved Messages.zip"; + "Update" = "Atualizar"; "Cancel" = "Cancelar"; diff --git a/UI/MailerUI/Czech.lproj/Localizable.strings b/UI/MailerUI/Czech.lproj/Localizable.strings index c24a8b702..b9e95a44c 100644 --- a/UI/MailerUI/Czech.lproj/Localizable.strings +++ b/UI/MailerUI/Czech.lproj/Localizable.strings @@ -76,8 +76,11 @@ "Remove this folder" = "Odebrat tuto složku"; "Erase mails from this folder" = "Vymazat maily v této složce"; "Expunge this folder" = "Vyškrtnout tuto složku"; +"Archive This Folder" = "Archive This Folder"; "Modify the acl of this folder" = "Upravit acl této složky"; +"Saved Messages.zip" = "Saved Messages.zip"; + "Update" = "Aktualizace"; "Cancel" = "Storno"; diff --git a/UI/MailerUI/Dutch.lproj/Localizable.strings b/UI/MailerUI/Dutch.lproj/Localizable.strings index 6067cac76..f29698795 100644 --- a/UI/MailerUI/Dutch.lproj/Localizable.strings +++ b/UI/MailerUI/Dutch.lproj/Localizable.strings @@ -76,8 +76,11 @@ "Remove this folder" = "Deze map verwijderen"; "Erase mails from this folder" = "E-mails in in deze map verwijderen"; "Expunge this folder" = "Deze map leegmaken"; +"Archive This Folder" = "Archive This Folder"; "Modify the acl of this folder" = "Machtigingen van deze map aanpassen"; +"Saved Messages.zip" = "Saved Messages.zip"; + "Update" = "Opslaan"; "Cancel" = "Sluiten"; diff --git a/UI/MailerUI/English.lproj/Localizable.strings b/UI/MailerUI/English.lproj/Localizable.strings index 4ac6e075d..257b29193 100644 --- a/UI/MailerUI/English.lproj/Localizable.strings +++ b/UI/MailerUI/English.lproj/Localizable.strings @@ -76,8 +76,11 @@ "Remove this folder" = "Remove this folder"; "Erase mails from this folder" = "Erase mails from this folder"; "Expunge this folder" = "Expunge this folder"; +"Archive This folder" = "Archive This folder"; "Modify the acl of this folder" = "Modify the acl of this folder"; +"Saved Messages.zip" = "Saved Messages.zip"; + "Update" = "Update"; "Cancel" = "Cancel"; diff --git a/UI/MailerUI/French.lproj/Localizable.strings b/UI/MailerUI/French.lproj/Localizable.strings index cc4634f84..e93d3b52e 100644 --- a/UI/MailerUI/French.lproj/Localizable.strings +++ b/UI/MailerUI/French.lproj/Localizable.strings @@ -76,8 +76,11 @@ "Remove this folder" = "Effacer ce dossier"; "Erase mails from this folder" = "Effacer des messages de ce dossier"; "Expunge this folder" = "Compacter ce dossier"; +"Archive This Folder" = "Archiver ce dossier"; "Modify the acl of this folder" = "Administrer les droits sur ce dossier"; +"Saved Messages.zip" = "Messages sauvegardés.zip"; + "Update" = "Mettre à jour"; "Cancel" = "Annuler"; diff --git a/UI/MailerUI/German.lproj/Localizable.strings b/UI/MailerUI/German.lproj/Localizable.strings index e5203a3cc..7406ab71f 100644 --- a/UI/MailerUI/German.lproj/Localizable.strings +++ b/UI/MailerUI/German.lproj/Localizable.strings @@ -76,8 +76,11 @@ "Remove this folder" = "Diesen Ordner löschen"; "Erase mails from this folder" = "E-Mails in diesem Ordner löschen"; "Expunge this folder" = "Diesen Ordner komprimieren"; +"Archive This Folder" = "Archive This Folder"; "Modify the acl of this folder" = "Benutzerrechte dieses Ordners verändern"; +"Saved Messages.zip" = "Saved Messages.zip"; + "Update" = "Speichern"; "Cancel" = "Abbrechen"; diff --git a/UI/MailerUI/Hungarian.lproj/Localizable.strings b/UI/MailerUI/Hungarian.lproj/Localizable.strings index 0afe493e1..c9d0fcd79 100644 --- a/UI/MailerUI/Hungarian.lproj/Localizable.strings +++ b/UI/MailerUI/Hungarian.lproj/Localizable.strings @@ -76,8 +76,11 @@ "Remove this folder" = "Mappa törlése"; "Erase mails from this folder" = "Üzenetek törlése a mappából"; "Expunge this folder" = "Mappa megjelölése töröltként"; +"Archive This Folder" = "Archive This Folder"; "Modify the acl of this folder" = "Mappa jogosultságainak szerkesztése"; +"Saved Messages.zip" = "Saved Messages.zip"; + "Update" = "Mentés"; "Cancel" = "Mégsem"; diff --git a/UI/MailerUI/Italian.lproj/Localizable.strings b/UI/MailerUI/Italian.lproj/Localizable.strings index 773ac4fb6..771e79125 100644 --- a/UI/MailerUI/Italian.lproj/Localizable.strings +++ b/UI/MailerUI/Italian.lproj/Localizable.strings @@ -76,8 +76,11 @@ "Remove this folder" = "Rimuovi questa cartella"; "Erase mails from this folder" = "Elimina emails da questa cartella"; "Expunge this folder" = "Pulisci questa cartella"; +"Archive This Folder" = "Archive This Folder"; "Modify the acl of this folder" = "Modifica i permessi per questa cartella"; +"Saved Messages.zip" = "Saved Messages.zip"; + "Update" = "Aggiorna"; "Cancel" = "Annulla"; diff --git a/UI/MailerUI/Russian.lproj/Localizable.strings b/UI/MailerUI/Russian.lproj/Localizable.strings index 772ce0e36..8a40d5c85 100644 --- a/UI/MailerUI/Russian.lproj/Localizable.strings +++ b/UI/MailerUI/Russian.lproj/Localizable.strings @@ -76,8 +76,11 @@ "Remove this folder" = "Удалять эту папку"; "Erase mails from this folder" = "Удалять сообщения из этой папки"; "Expunge this folder" = "Помечать письма как удаленные"; +"Archive This Folder" = "Archive This Folder"; "Modify the acl of this folder" = "Управлять правами доступа к этой папке"; +"Saved Messages.zip" = "Saved Messages.zip"; + "Update" = "Обновить"; "Cancel" = "Отмена"; diff --git a/UI/MailerUI/Spanish.lproj/Localizable.strings b/UI/MailerUI/Spanish.lproj/Localizable.strings index bd08de9de..bc71d01d3 100644 --- a/UI/MailerUI/Spanish.lproj/Localizable.strings +++ b/UI/MailerUI/Spanish.lproj/Localizable.strings @@ -76,8 +76,11 @@ "Remove this folder" = "Borrar esta carpeta"; "Erase mails from this folder" = "Borrar los correos de esta carpeta"; "Expunge this folder" = "Compactar esta carpeta."; +"Archive This Folder" = "Archive This Folder"; "Modify the acl of this folder" = "Modificar la lista de permisos de esta carpeta"; +"Saved Messages.zip" = "Saved Messages.zip"; + "Update" = "Actualizar"; "Cancel" = "Cancelar"; diff --git a/UI/MailerUI/Swedish.lproj/Localizable.strings b/UI/MailerUI/Swedish.lproj/Localizable.strings index cc5e5f457..c2432e8b8 100644 --- a/UI/MailerUI/Swedish.lproj/Localizable.strings +++ b/UI/MailerUI/Swedish.lproj/Localizable.strings @@ -76,8 +76,11 @@ "Remove this folder" = "Ta bort mappen"; "Erase mails from this folder" = "Radera meddelanden från mappen"; "Expunge this folder" = "Radera mappen"; +"Archive This Folder" = "Archive This Folder"; "Modify the acl of this folder" = "Ändra åtkomsträttigheter på mappen"; +"Saved Messages.zip" = "Saved Messages.zip"; + "Update" = "Uppdatera"; "Cancel" = "Avbryt"; diff --git a/UI/MailerUI/UIxMailFolderActions.m b/UI/MailerUI/UIxMailFolderActions.m index 60739298f..f865acc51 100644 --- a/UI/MailerUI/UIxMailFolderActions.m +++ b/UI/MailerUI/UIxMailFolderActions.m @@ -270,7 +270,9 @@ if ([value length] > 0) { uids = [value componentsSeparatedByString: @","]; - response = [co archiveUIDs: uids inContext: context]; + response = [co archiveUIDs: uids + inArchiveNamed: [self labelForKey: @"Saved Messages.zip"] + inContext: context]; if (!response) response = [self responseWith204]; } @@ -283,6 +285,15 @@ return response; } +- (WOResponse *) exportFolderAction +{ + WOResponse *response; + + response = [[self clientObject] archiveAllMessagesInContext: context]; + + return response; +} + - (WOResponse *) copyMessagesAction { SOGoMailFolder *co; diff --git a/UI/MailerUI/Welsh.lproj/Localizable.strings b/UI/MailerUI/Welsh.lproj/Localizable.strings index 99cdb47bc..d911866cd 100644 --- a/UI/MailerUI/Welsh.lproj/Localizable.strings +++ b/UI/MailerUI/Welsh.lproj/Localizable.strings @@ -76,8 +76,11 @@ "Remove this folder" = "Dileu'r ffolder hwn"; "Erase mails from this folder" = "Dileu ebost o'r ffolder hwn"; "Expunge this folder" = "Dileu'r ffolder hwn"; +"Archive This Folder" = "Archive This Folder"; "Modify the acl of this folder" = "Newid acl y ffolder"; +"Saved Messages.zip" = "Saved Messages.zip"; + "Update" = "Diweddaru"; "Cancel" = "Canslo"; diff --git a/UI/MailerUI/product.plist b/UI/MailerUI/product.plist index 932e6d6c7..ccaf4c286 100644 --- a/UI/MailerUI/product.plist +++ b/UI/MailerUI/product.plist @@ -143,6 +143,11 @@ actionClass = "UIxMailFolderActions"; actionName = "saveMessages"; }; + exportFolder = { + protectedBy = "View"; + actionClass = "UIxMailFolderActions"; + actionName = "exportFolder"; + }; copyMessages = { protectedBy = "View"; actionClass = "UIxMailFolderActions"; diff --git a/UI/Templates/MailerUI/UIxMailMainFrame.wox b/UI/Templates/MailerUI/UIxMailMainFrame.wox index 575f89e39..ea70743d5 100644 --- a/UI/Templates/MailerUI/UIxMailMainFrame.wox +++ b/UI/Templates/MailerUI/UIxMailMainFrame.wox @@ -50,6 +50,7 @@