Show
Ignore:
Timestamp:
08/03/08 02:00:51 PM (5 months ago)
Author:
octorian
Message:

More UID FETCH code

Files:
1 modified

Legend:

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

    r262 r264  
    477477                                   Integer.toString(lastIndex) + 
    478478                                   " (FLAGS UID ENVELOPE)"); 
    479          
    480         FetchEnvelopeResponse[] envResponses = new FetchEnvelopeResponse[(lastIndex - firstIndex)+1]; 
    481          
    482         // Pre-process the returned text to clean up mid-field line breaks 
     479        return prepareFetchEnvelopeResponse(rawList); 
     480    } 
     481 
     482    /** 
     483     * Execute the "UID FETCH (FLAGS UID ENVELOPE)" command 
     484     * @param uidNext Unique ID of the next message 
     485     * @return Array of FetchEnvelopeResponse objects 
     486     */ 
     487    public FetchEnvelopeResponse[] executeFetchEnvelopeUid(int uidNext) throws IOException, MailException { 
     488        if(EventLogger.getMinimumLevel() >= EventLogger.DEBUG_INFO) { 
     489            EventLogger.logEvent( 
     490            AppInfo.GUID, 
     491            ("ImapProtocol.executeFetchEnvelopeUid("+uidNext+")").getBytes(), 
     492            EventLogger.DEBUG_INFO); 
     493        } 
     494         
     495        String[] rawList = execute("UID FETCH", 
     496                Integer.toString(uidNext) + ":*" + 
     497                " (FLAGS UID ENVELOPE)"); 
     498         
     499        return prepareFetchEnvelopeResponse(rawList); 
     500    } 
     501     
     502    private FetchEnvelopeResponse[] prepareFetchEnvelopeResponse(String[] rawList) throws IOException, MailException { 
     503        // Preprocess the returned text to clean up mid-field line breaks 
    483504        // This should all become unnecessary once execute() 
    484505        // becomes more intelligent in how it handles replies 
     
    500521        } 
    501522         
    502         int index = 0; 
     523        Vector envResponses = new Vector(); 
    503524        int size = rawList2.size(); 
    504525        for(int i=0;i<size;i++) { 
     
    558579                envRespItem.index = midx; 
    559580                envRespItem.envelope = env; 
    560                 envResponses[index++] = envRespItem; 
     581                envResponses.addElement(envRespItem); 
    561582            } catch (Exception exp) { 
    562583                System.err.println("Parse error: " + exp); 
     
    564585        } 
    565586 
    566         return envResponses; 
    567     } 
    568  
     587        FetchEnvelopeResponse[] result = new FetchEnvelopeResponse[envResponses.size()]; 
     588        envResponses.copyInto(result); 
     589        return result; 
     590    } 
     591     
    569592    /** 
    570593     * Execute the "FETCH (BODYSTRUCTURE)" command