Menu

#564 Moving / copying messages in public mailbox

v4.4.1
closed-fixed
nobody
None
5
2014-06-03
2014-04-27
chris
No

In a "public mailbox" configured by a username as "domain/user/otheruser", messages can be read from subfolders, however they can not be moved or copied around in subfolders.
Such an attempt results in a message "folder not found".

Discussion

  • chris

    chris - 2014-04-27

    This is because the base mailbox path is only respected for LSUB, LIST, SELECT, and EXAMINE.

    Here is a patch, which adds public-mailbox support for MOVE and COPY. Probably, the new method "buildFolderContent" should be also called from many other IMAP commands.

    Index: src/java/davmail/imap/ImapConnection.java
    ===================================================================
    --- src/java/davmail/imap/ImapConnection.java   (revision 2286)
    +++ src/java/davmail/imap/ImapConnection.java   (working copy)
    @@ -156,12 +156,7 @@
                                     session = ExchangeSessionFactory.getInstance(session, userName, password);
                                     if ("lsub".equalsIgnoreCase(command) || "list".equalsIgnoreCase(command)) {
                                         if (tokens.hasMoreTokens()) {
    -                                        String folderContext;
    -                                        if (baseMailboxPath == null) {
    -                                            folderContext = BASE64MailboxDecoder.decode(tokens.nextToken());
    -                                        } else {
    -                                            folderContext = baseMailboxPath + BASE64MailboxDecoder.decode(tokens.nextToken());
    -                                        }
    +                                        String folderContext = buildFolderContext(tokens.nextToken());
                                             if (tokens.hasMoreTokens()) {
                                                 String folderQuery = folderContext + BASE64MailboxDecoder.decode(tokens.nextToken());
                                                 if (folderQuery.endsWith("%/%") && !"/%/%".equals(folderQuery)) {
    @@ -344,7 +339,7 @@
                                             } else if ("copy".equalsIgnoreCase(subcommand) || "move".equalsIgnoreCase(subcommand)) {
                                                 try {
                                                     UIDRangeIterator uidRangeIterator = new UIDRangeIterator(currentFolder.messages, tokens.nextToken());
    -                                                String targetName = BASE64MailboxDecoder.decode(tokens.nextToken());
    +                                                String targetName = buildFolderContext(tokens.nextToken());
                                                     if (!uidRangeIterator.hasNext()) {
                                                         sendClient(commandId + " NO " + "No message found");
                                                     } else {
    @@ -708,6 +703,14 @@
             }
         }
    
    +    private String buildFolderContext(String folderToken) {
    +        if (baseMailboxPath == null) {
    +            return BASE64MailboxDecoder.decode(folderToken);
    +        } else {
    +            return baseMailboxPath + BASE64MailboxDecoder.decode(folderToken);
    +        }
    +    }
    +
         /**
          * Send expunge untagged response for removed IMAP message uids.
          *
    
     

    Last edit: chris 2014-04-27
  • Mickael Guessant

    Patch merged, thanks for your feedback

     
  • Mickael Guessant

    • status: open --> open-fixed
     
  • Mickael Guessant

    • status: open-fixed --> closed-fixed
     
  • Mickael Guessant

    released in 4.5.0

     

Log in to post a comment.