Show
Ignore:
Timestamp:
08/02/08 05:15:29 PM (5 months ago)
Author:
octorian
Message:

UID support for messages

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/LogicMail/src/org/logicprobe/LogicMail/mail/imap/ImapClient.java

    r259 r262  
    377377        FolderMessage[] folderMessages = new FolderMessage[response.length]; 
    378378        for(int i=0;i<response.length;i++) { 
    379             folderMessages[i] = new FolderMessage(response[i].envelope, response[i].index); 
     379            folderMessages[i] = new FolderMessage(response[i].envelope, response[i].index, response[i].uid); 
    380380            folderMessages[i].setSeen(response[i].flags.seen); 
    381381            folderMessages[i].setAnswered(response[i].flags.answered); 
     
    391391 
    392392    public Message getMessage(FolderMessage folderMessage) throws IOException, MailException { 
    393         ImapParser.MessageSection structure = getMessageStructure(folderMessage.getIndex()); 
     393        ImapParser.MessageSection structure = getMessageStructure(folderMessage.getUid()); 
    394394        MessagePart rootPart = 
    395             getMessagePart(folderMessage.getIndex(), 
     395            getMessagePart(folderMessage.getUid(), 
    396396                           structure, globalConfig.getImapMaxMsgSize()); 
    397397        Message msg = new Message(folderMessage.getEnvelope(), rootPart); 
     
    399399    } 
    400400 
    401     private MessagePart getMessagePart(int index, 
     401    private MessagePart getMessagePart(int uid, 
    402402                                       ImapParser.MessageSection structure, 
    403403                                       int maxSize) 
     
    411411            else { 
    412412                if(structure.size < maxSize) { 
    413                     data = getMessageBody(index, structure.address); 
     413                    data = getMessageBody(uid, structure.address); 
    414414                    maxSize -= structure.size; 
    415415                } 
     
    426426        if((part instanceof MultiPart)&&(structure.subsections != null)&&(structure.subsections.length > 0)) { 
    427427            for(int i=0;i<structure.subsections.length;i++) { 
    428                 MessagePart subPart = getMessagePart(index, structure.subsections[i], maxSize); 
     428                MessagePart subPart = getMessagePart(uid, structure.subsections[i], maxSize); 
    429429                if(subPart != null) { 
    430430                    ((MultiPart)part).addPart(subPart); 
     
    439439     * This tree is used to build the final message tree. 
    440440     */ 
    441     private ImapParser.MessageSection getMessageStructure(int msgIndex) throws IOException, MailException { 
     441    private ImapParser.MessageSection getMessageStructure(int uid) throws IOException, MailException { 
    442442        if(activeMailbox.equals("")) { 
    443443            throw new MailException("Mailbox not selected"); 
    444444        } 
    445445 
    446         return imapProtocol.executeFetchBodystructure(msgIndex); 
     446        return imapProtocol.executeFetchBodystructure(uid); 
    447447    } 
    448448 
     
    466466    } 
    467467 
    468     private String getMessageBody(int index, String address) throws IOException, MailException { 
     468    private String getMessageBody(int uid, String address) throws IOException, MailException { 
    469469        if(activeMailbox.equals("")) { 
    470470            throw new MailException("Mailbox not selected"); 
    471471        } 
    472472         
    473         return imapProtocol.executeFetchBody(index, address); 
     473        return imapProtocol.executeFetchBody(uid, address); 
    474474    } 
    475475     
    476476    public void deleteMessage(FolderMessage folderMessage) throws IOException, MailException { 
    477477        ImapProtocol.MessageFlags updatedFlags = 
    478             imapProtocol.executeStore(folderMessage.getIndex(), true, new String[] { "\\Deleted" }); 
     478            imapProtocol.executeStore(folderMessage.getUid(), true, new String[] { "\\Deleted" }); 
    479479        refreshMessageFlags(updatedFlags, folderMessage); 
    480480    } 
     
    483483    public void undeleteMessage(FolderMessage folderMessage) throws IOException, MailException { 
    484484        ImapProtocol.MessageFlags updatedFlags = 
    485             imapProtocol.executeStore(folderMessage.getIndex(), false, new String[] { "\\Deleted" }); 
     485            imapProtocol.executeStore(folderMessage.getUid(), false, new String[] { "\\Deleted" }); 
    486486        refreshMessageFlags(updatedFlags, folderMessage); 
    487487    } 
     
    495495    public void messageAnswered(FolderMessage folderMessage) throws IOException, MailException { 
    496496        ImapProtocol.MessageFlags updatedFlags = 
    497             imapProtocol.executeStore(folderMessage.getIndex(), true, new String[] { "\\Answered" }); 
     497            imapProtocol.executeStore(folderMessage.getUid(), true, new String[] { "\\Answered" }); 
    498498        refreshMessageFlags(updatedFlags, folderMessage); 
    499499    }