Changeset 618
- Timestamp:
- 01/19/10 21:41:34 (2 years ago)
- Location:
- trunk/LogicMail/src/org/logicprobe/LogicMail
- Files:
-
- 2 edited
-
model/MailboxNode.java (modified) (3 diffs)
-
ui/MessageActions.java (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LogicMail/src/org/logicprobe/LogicMail/model/MailboxNode.java
r591 r618 44 44 import org.logicprobe.LogicMail.AppInfo; 45 45 import org.logicprobe.LogicMail.mail.FolderTreeItem; 46 import org.logicprobe.LogicMail.mail.MailStoreRequestCallback; 46 47 import org.logicprobe.LogicMail.mail.MessageToken; 47 48 import org.logicprobe.LogicMail.message.Message; … … 411 412 * Copies a message into this mailbox from another mailbox within the same account. 412 413 * This method will request the underlying mail store to copy the message 413 * on the server side. If the mail store does not support this operation, then 414 * this method will have no effect. 414 * on the server side. 415 * <p> 416 * If the mail store does not support this operation, then this method will 417 * have no effect. 418 * </p> 415 419 * 416 420 * @param messageNode Message to copy into this mailbox … … 426 430 } 427 431 432 /** 433 * Moves a message into this mailbox from another mailbox within the same account. 434 * This method will request the underlying mail store to copy the message 435 * on the server side. If and only if the copy is successful, the source message 436 * will be marked as deleted. 437 * <p> 438 * If the mail store does not support this operation, then this method will 439 * have no effect. 440 * </p> 441 * 442 * @param messageNode Message to copy into this mailbox 443 */ 444 public void moveMessageInto(MessageNode messageNode) { 445 // Sanity check 446 if(!(this.hasAppend 447 && this.hasCopy() 448 && messageNode.getParent().getParentAccount() == this.parentAccount)) { 449 return; 450 } 451 parentAccount.getMailStore().requestMessageCopy( 452 messageNode.getMessageToken(), 453 this.folderTreeItem, 454 new MoveMessageIntoCallback(messageNode)); 455 } 456 457 /** 458 * Callback to handle the result of the copy operation dispatched 459 * from <code>moveMessageInto(messageNode)</code>. If that operation 460 * succeeds, then a request is dispatched to mark the original message 461 * as deleted. If it fails, then nothing happens. 462 */ 463 private class MoveMessageIntoCallback implements MailStoreRequestCallback { 464 private MessageNode messageNode; 465 466 /** 467 * Instantiates a new callback for handling the result 468 * of the copy operation involved in a message move. 469 * 470 * @param messageNode the source message node 471 */ 472 public MoveMessageIntoCallback(MessageNode messageNode) { 473 this.messageNode = messageNode; 474 } 475 476 public void mailStoreRequestComplete() { 477 // If the move request succeeded, then dispatch a request 478 // to have the original message marked as deleted. 479 parentAccount.getMailStore().requestMessageDelete( 480 messageNode.getMessageToken(), 481 MessageNode.createMessageFlags(messageNode.getFlags())); 482 } 483 484 public void mailStoreRequestFailed(Throwable exception) { 485 // Do nothing if the request failed 486 } 487 } 488 428 489 /** 429 490 * Adds a mailbox to this mailbox. -
trunk/LogicMail/src/org/logicprobe/LogicMail/ui/MessageActions.java
r615 r618 200 200 201 201 // Move-To is currently only supported if the underlying mail store 202 // supports protocol-level copy, since it is the only safe way to 203 // ensure no message data is lost. 202 // supports protocol-level copy, and then only between folders on that 203 // mail store. These limitations have been chosen because it is the 204 // simplest way to be absolutely sure that a user cannot mess up their 205 // data with a message move. 204 206 if(mailboxNode.hasCopy()) { 205 207 menu.add(moveToItem); … … 378 380 public void copyToMailbox(MessageNode messageNode) { 379 381 if(messageNode.hasMessageContent()) { 382 // Normal case where the message has been loaded within the 383 // data model and all copy options should be made available. 380 384 AccountNode[] accountNodes = MailManager.getInstance().getMailRootNode().getAccounts(); 381 385 MailboxSelectionDialog dialog = new MailboxSelectionDialog( … … 390 394 if(selectedMailbox.hasCopy() 391 395 && selectedMailbox.getParentAccount() == messageNode.getParent().getParentAccount()) { 396 // The source and destination are on the same mail store, 397 // and that mail store supports protocol-level copy. 392 398 selectedMailbox.copyMessageInto(messageNode); 393 399 } 394 400 else { 401 // Protocol-level copy is not possible, so just append 402 // to the destination mailbox. 395 403 selectedMailbox.appendMessage(messageNode); 396 404 } 397 405 } 398 406 } 407 else if(messageNode.getParent().hasCopy()) { 408 // Alternate case where the message has not been loaded, but is 409 // on a mail store that supports protocol-level copy. In this 410 // situation, only other mailboxes on the same mail store are 411 // to be considered valid destinations. 412 MailboxSelectionDialog dialog = new MailboxSelectionDialog( 413 resources.getString(LogicMailResource.MESSAGE_SELECT_FOLDER_COPY_TO), 414 new AccountNode[] { messageNode.getParent().getParentAccount() }); 415 dialog.setSelectedMailboxNode(messageNode.getParent()); 416 dialog.addUnselectableNode(messageNode.getParent()); 417 dialog.doModal(); 418 419 MailboxNode selectedMailbox = dialog.getSelectedMailboxNode(); 420 if(selectedMailbox != null && selectedMailbox != messageNode.getParent()) { 421 selectedMailbox.copyMessageInto(messageNode); 422 } 423 } 399 424 } 400 425 … … 405 430 */ 406 431 public void moveToMailbox(MessageNode messageNode) { 407 if(messageNode.hasMessageContent()) { 408 AccountNode[] accountNodes = MailManager.getInstance().getMailRootNode().getAccounts(); 432 if(messageNode.getParent().hasCopy()) { 409 433 MailboxSelectionDialog dialog = new MailboxSelectionDialog( 410 434 resources.getString(LogicMailResource.MESSAGE_SELECT_FOLDER_MOVE_TO), 411 accountNodes);435 new AccountNode[] { messageNode.getParent().getParentAccount() }); 412 436 dialog.setSelectedMailboxNode(messageNode.getParent()); 413 437 dialog.addUnselectableNode(messageNode.getParent()); … … 415 439 416 440 MailboxNode selectedMailbox = dialog.getSelectedMailboxNode(); 417 if(selectedMailbox != null && selectedMailbox != messageNode.getParent()) { 418 selectedMailbox.appendMessage(messageNode); 419 //TODO: Move To Folder should delete after append 420 //This should only be executed after the append was successful 421 //messageNode.deleteMessage(); 422 } 441 if(selectedMailbox != null && selectedMailbox != messageNode.getParent()) { 442 selectedMailbox.moveMessageInto(messageNode); 443 } 423 444 } 424 445 }
Note: See TracChangeset
for help on using the changeset viewer.
