diff --git a/ChangeLog b/ChangeLog index 7e97907ab..b7c3982eb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ 2007-10-17 Wolfgang Sourdeau + * UI/MailerUI/UIxMailActions.m ([UIxMailActions -copyAction]): + implemented new web method. + + * SoObjects/Mailer/SOGoMailObject.m ([SOGoMailObject + -copyToFolderNamed:folderNameinContext:]): new method with the + code cut/pasted from -moveToFolderNamed:inContext:. + ([SOGoMailObject -moveToFolderNamed:folderNameinContext:]): + modified to use the code from -copyToFolderNamed:inContext:, which + is common between the two actions. + * SoObjects/Mailer/SOGoMailAccount.m ([SOGoMailAccount -draftsFolderNameInContext:_ctx]) ([SOGoMailAccount -sentFolderNameInContext:]) ([SOGoMailAccount -trashFolderNameInContext:]): modified to take diff --git a/NEWS b/NEWS index 3f3b4354f..95e1bff63 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,7 @@ 0.9.0-200710XX -------------- - the user can now configure his folders as drafts, trash or sent folder; +- added the ability the move and copy message across mail folders; 0.9.0-200709XX -------------- diff --git a/SoObjects/Mailer/SOGoMailObject.h b/SoObjects/Mailer/SOGoMailObject.h index c81e4103d..80e095380 100644 --- a/SoObjects/Mailer/SOGoMailObject.h +++ b/SoObjects/Mailer/SOGoMailObject.h @@ -89,6 +89,8 @@ - (BOOL)isDeletionAllowed; - (NSException *) trashInContext:(id)_ctx; +- (NSException *) copyToFolderNamed: (NSString *) folderName + inContext: (id)_ctx; - (NSException *) moveToFolderNamed: (NSString *) folderName inContext: (id)_ctx; diff --git a/SoObjects/Mailer/SOGoMailObject.m b/SoObjects/Mailer/SOGoMailObject.m index c0b4929ff..cd2e8d481 100644 --- a/SoObjects/Mailer/SOGoMailObject.m +++ b/SoObjects/Mailer/SOGoMailObject.m @@ -888,13 +888,12 @@ static BOOL debugSoParts = NO; return nil; } -- (NSException *) moveToFolderNamed: (NSString *) folderName +- (NSException *) copyToFolderNamed: (NSString *) folderName inContext: (id)_ctx { SOGoMailAccounts *destFolder; NSEnumerator *folders; NSString *currentFolderName, *reason; - NSException *error; // TODO: check for safe HTTP method @@ -924,18 +923,27 @@ static BOOL debugSoParts = NO; [destFolder flushMailCaches]; /* a) copy */ - - error = [self davCopyToTargetObject: destFolder - newName: @"fakeNewUnusedByIMAP4" /* autoassigned */ - inContext:_ctx]; - if (error != nil) return error; - /* b) mark deleted */ - - error = [[self imap4Connection] markURLDeleted: [self imap4URL]]; - if (error != nil) return error; + return [self davCopyToTargetObject: destFolder + newName: @"fakeNewUnusedByIMAP4" /* autoassigned */ + inContext:_ctx]; +} - [self flushMailCaches]; +- (NSException *) moveToFolderNamed: (NSString *) folderName + inContext: (id)_ctx +{ + NSException *error; + + if (![self copyToFolderNamed: folderName + inContext: _ctx]) + { + /* b) mark deleted */ + + error = [[self imap4Connection] markURLDeleted: [self imap4URL]]; + if (error != nil) return error; + + [self flushMailCaches]; + } return nil; } diff --git a/UI/MailerUI/English.lproj/Localizable.strings b/UI/MailerUI/English.lproj/Localizable.strings index 96cf5ca59..cf14bf58d 100644 --- a/UI/MailerUI/English.lproj/Localizable.strings +++ b/UI/MailerUI/English.lproj/Localizable.strings @@ -180,6 +180,8 @@ "Print..." = "Print..."; "Delete Message" = "Delete Message"; +"This Folder" = "This Folder"; + /* Label popup menu */ "None" = "None"; "Important" = "Important"; @@ -214,3 +216,8 @@ "You need to choose a non-virtual folder!" = "You need to choose a non-virtual folder!"; "You need to choose a root subfolder!" = "You need to choose a root subfolder!"; + +"Moving a message into its own folder is impossible!" += "Moving a message into its own folder is impossible!"; +"Copying a message into its own folder is impossible!" += "Copying a message into its own folder is impossible!"; diff --git a/UI/MailerUI/French.lproj/Localizable.strings b/UI/MailerUI/French.lproj/Localizable.strings index 3fcae69b3..b68ab6bb3 100644 --- a/UI/MailerUI/French.lproj/Localizable.strings +++ b/UI/MailerUI/French.lproj/Localizable.strings @@ -181,6 +181,8 @@ "Print..." = "Imprimer..."; "Delete Message" = "Supprimer le message"; +"This Folder" = "Ce dossier-ci"; + /* Label popup menu */ "None" = "Aucune"; "Important" = "Important"; @@ -215,3 +217,8 @@ "You need to choose a non-virtual folder!" = "Vous devez choisir un dossier non-virtuel."; "You need to choose a root subfolder!" = "Vous devez choisir un sous-dossier de la racine."; + +"Moving a message into its own folder is impossible!" += "Le déplacement d'un message dans son propre dossier est impossible."; +"Copying a message into its own folder is impossible!" += "La copie d'un message dans son propre dossier est impossible."; diff --git a/UI/MailerUI/German.lproj/Localizable.strings b/UI/MailerUI/German.lproj/Localizable.strings index b464f3f81..31b91fe6b 100644 --- a/UI/MailerUI/German.lproj/Localizable.strings +++ b/UI/MailerUI/German.lproj/Localizable.strings @@ -164,6 +164,8 @@ "Print..." = "Drucken..."; "Delete Message" = "Lõschen"; +"This Folder" = "This Folder"; + /* Label popup menu */ "None" = "Aucune"; "Important" = "Important"; @@ -198,3 +200,8 @@ "You need to choose a non-virtual folder!" = "You need to choose a non-virtual folder!"; "You need to choose a root subfolder!" = "You need to choose a root subfolder!"; + +"Moving a message into its own folder is impossible!" += "Moving a message into its own folder is impossible!"; +"Copying a message into its own folder is impossible!" += "Copying a message into its own folder is impossible!"; diff --git a/UI/MailerUI/UIxMailActions.m b/UI/MailerUI/UIxMailActions.m index 3ebf019c0..7b6d9e13e 100644 --- a/UI/MailerUI/UIxMailActions.m +++ b/UI/MailerUI/UIxMailActions.m @@ -104,7 +104,7 @@ NSString *destinationFolder; id response; - destinationFolder = [[context request] formValueForKey: @"tofolder"]; + destinationFolder = [[context request] formValueForKey: @"folder"]; if ([destinationFolder length] > 0) { response = [[self clientObject] moveToFolderNamed: destinationFolder @@ -119,6 +119,26 @@ return response; } +- (id) copyAction +{ + NSString *destinationFolder; + id response; + + destinationFolder = [[context request] formValueForKey: @"folder"]; + if ([destinationFolder length] > 0) + { + response = [[self clientObject] copyToFolderNamed: destinationFolder + inContext: context]; + if (!response) + response = [self responseWith204]; + } + else + response = [NSException exceptionWithHTTPStatus: 500 /* Server Error */ + reason: @"No destination folder given"]; + + return response; +} + /* active message */ - (id) markMessageUnreadAction diff --git a/UI/MailerUI/product.plist b/UI/MailerUI/product.plist index d04579f11..083bbe403 100644 --- a/UI/MailerUI/product.plist +++ b/UI/MailerUI/product.plist @@ -210,6 +210,11 @@ actionClass = "UIxMailActions"; actionName = "move"; }; + copy = { + protectedBy = "View"; + actionClass = "UIxMailActions"; + actionName = "copy"; + }; trash = { protectedBy = "View"; actionClass = "UIxMailActions"; diff --git a/UI/WebServerResources/MailerUI+dTree.js b/UI/WebServerResources/MailerUI+dTree.js index c5bed5158..42e60b4fb 100644 --- a/UI/WebServerResources/MailerUI+dTree.js +++ b/UI/WebServerResources/MailerUI+dTree.js @@ -24,14 +24,7 @@ var MailerUIdTreeExtension = { }, _addFolder: function (parent, folder) { var thisCounter = this.elementCounter; - var fullName = ""; - var currentFolder = folder; - while (currentFolder.parentFolder) { - fullName = "/folder" + currentFolder.name + fullName; - currentFolder = currentFolder.parentFolder; - } - fullName = "/" + currentFolder.name + fullName; - this._addFolderNode(parent, folder.name, fullName, folder.type); + this._addFolderNode(parent, folder.name, folder.fullName(), folder.type); for (var i = 0; i < folder.children.length; i++) this._addFolder(thisCounter, folder.children[i]); }, diff --git a/UI/WebServerResources/MailerUI.js b/UI/WebServerResources/MailerUI.js index 549554050..f8929f468 100644 --- a/UI/WebServerResources/MailerUI.js +++ b/UI/WebServerResources/MailerUI.js @@ -11,6 +11,8 @@ var currentMailboxType = ""; var usersRightsWindowHeight = 320; var usersRightsWindowWidth = 400; +var pageContent; + /* mail list */ function openMessageWindow(msguid, url) { @@ -330,12 +332,34 @@ function onMailboxTreeItemClick(event) { Event.stop(event); } -function onMailboxMenuMove() { - window.alert("unimplemented"); +function _onMailboxMenuAction(menuEntry, error, actionName) { + var targetMailbox = menuEntry.mailbox.fullName(); + + if (targetMailbox == currentMailbox) + window.alert(labels[error]); + else { + var message; + if (document.menuTarget instanceof HTMLDivElement) + message = currentMessages[currentMailbox]; + else + message = document.menuTarget.getAttribute("id").substr(4); + + var urlstr = (URLForFolderID(currentMailbox) + "/" + message + + "/" + actionName + "?folder=" + targetMailbox); + triggerAjaxRequest(urlstr, folderRefreshCallback, currentMailbox); + } } -function onMailboxMenuCopy() { - window.alert("unimplemented"); +function onMailboxMenuMove(event) { + _onMailboxMenuAction(this, + "Moving a message into its own folder is impossible!", + "move"); +} + +function onMailboxMenuCopy(event) { + _onMailboxMenuAction(this, + "Copying a message into its own folder is impossible!", + "copy"); } function refreshMailbox() { @@ -1141,13 +1165,13 @@ function generateMenuForMailbox(mailbox, prefix, callback) { menuDIV.setAttribute("id", prefix + "Submenu"); var menu = document.createElement("ul"); menuDIV.appendChild(menu); - document.body.appendChild(menuDIV); + pageContent.appendChild(menuDIV); var callbacks = new Array(); if (mailbox.type != "account") { var newNode = document.createElement("li"); newNode.mailbox = mailbox; - newNode.appendChild(document.createTextNode("coucou")); + newNode.appendChild(document.createTextNode(labels["This Folder"])); menu.appendChild(newNode); menu.appendChild(document.createElement("li")); callbacks.push(callback); @@ -1186,14 +1210,15 @@ function updateMailboxMenus() { menuDIV.parentNode.removeChild(menuDIV); menuDIV = document.createElement("div"); - document.body.appendChild(menuDIV); + pageContent = $("pageContent"); + pageContent.appendChild(menuDIV); var menu = document.createElement("ul"); menuDIV.appendChild(menu); $(menuDIV).addClassName("menu"); menuDIV.setAttribute("id", menuId); - + var submenuIds = new Array(); for (var i = 0; i < mailAccounts.length; i++) { var menuEntry = mailboxMenuNode("account", mailAccounts[i]); @@ -1441,6 +1466,18 @@ Mailbox.prototype.dump = function(indent) { } } +Mailbox.prototype.fullName = function() { + var fullName = ""; + + var currentFolder = this; + while (currentFolder.parentFolder) { + fullName = "/folder" + currentFolder.name + fullName; + currentFolder = currentFolder.parentFolder; + } + + return "/" + currentFolder.name + fullName; +} + Mailbox.prototype.findMailboxByName = function(name) { var mailbox = null;