if (r[i] instanceof IMAPResponse) { fetch = (FetchResponse) r[i]; body = (BODY) fetch.getItem(0); is = body.getByteArrayInputStream(); try {
public BODYSTRUCTURE(FetchResponse r) throws ParsingException { if (parseDebug) System.out.println("DEBUG IMAP: parsing BODYSTRUCTURE"); msgno = r.getNumber(); if (parseDebug) System.out.println("DEBUG IMAP: msgno " + msgno); r.skipSpaces(); if (r.readByte() != '(') throw new ParsingException( "BODYSTRUCTURE parse error: missing ``('' at start"); if (r.peekByte() == '(') { // multipart if (parseDebug) System.out.println("DEBUG IMAP: parsing multipart"); r.skipSpaces(); } while (r.peekByte() == '('); subtype = r.readString(); // subtype if (parseDebug) System.out.println("DEBUG IMAP: subtype " + subtype); if (r.readByte() == ')') { // done if (parseDebug) System.out.println("DEBUG IMAP: parse DONE"); if (r.readByte() == ')') { // done if (parseDebug)
switch (buffer[index]) { case 'E': case 'e': if (match(ENVELOPE.name)) return new ENVELOPE(this); break; case 'F': case 'f': if (match(FLAGS.name)) return new FLAGS((IMAPResponse)this); break; case 'I': case 'i': if (match(INTERNALDATE.name)) return new INTERNALDATE(this); break; case 'B': case 'b': if (match(BODYSTRUCTURE.name)) return new BODYSTRUCTURE(this); else if (match(BODY.name)) { if (buffer[index] == '[') return new BODY(this); if (match(RFC822SIZE.name)) return new RFC822SIZE(this); else if (match(RFC822DATA.name)) { boolean isHeader = false; if (match(HEADER)) isHeader = true; // skip ".HEADER" else if (match(TEXT)) isHeader = false; // skip ".TEXT" return new RFC822DATA(this, isHeader);
/** * Constructor. * * @param r the FetchResponse * @exception ParsingException for parsing failures */ public UID(FetchResponse r) throws ParsingException { seqnum = r.getNumber(); r.skipSpaces(); uid = r.readLong(); } }
/** * Constructor. * * @param r the FetchResponse * @exception ParsingException for parsing failures */ public RFC822SIZE(FetchResponse r) throws ParsingException { msgno = r.getNumber(); r.skipSpaces(); size = r.readNumber(); } }
/** * Constructor, specifying header flag. * * @param r the FetchResponse * @param isHeader just header information? * @exception ParsingException for parsing failures */ public RFC822DATA(FetchResponse r, boolean isHeader) throws ParsingException { this.isHeader = isHeader; msgno = r.getNumber(); r.skipSpaces(); data = r.readByteArray(); }
/** * Constructor * * @param r the FetchResponse * @exception ParsingException for parsing failures */ public BODY(FetchResponse r) throws ParsingException { msgno = r.getNumber(); r.skipSpaces(); if (r.readByte() != '[') throw new ParsingException( "BODY parse error: missing ``['' at section start"); section = r.readString(']'); if (r.readByte() != ']') throw new ParsingException( "BODY parse error: missing ``]'' at section end"); isHeader = section.regionMatches(true, 0, "HEADER", 0, 6); if (r.readByte() == '<') { // origin origin = r.readNumber(); r.skip(1); // skip '>'; } else origin = 0; data = r.readByteArray(); }
/** * Constructor. * * @param r the FetchResponse * @exception ParsingException for parsing failures */ public MODSEQ(FetchResponse r) throws ParsingException { seqnum = r.getNumber(); r.skipSpaces(); if (r.readByte() != '(') throw new ParsingException("MODSEQ parse error"); modseq = r.readLong(); if (r.readByte() != ')') throw new ParsingException("MODSEQ parse error"); } }
((FetchResponse)r[i]).getNumber() != seqnum) continue; int count = f.getItemCount(); for (int j = 0; j < count; j++) { Item item = f.getItem(j);
IMAPMessage msg = getMessageBySeqNumber(f.getNumber()); int count = f.getItemCount(); boolean unsolicitedFlags = false; Item item = f.getItem(j); msg.handleExtensionFetchItems(f.getExtensionItems());
public ENVELOPE(FetchResponse r) throws ParsingException { if (parseDebug) System.out.println("parse ENVELOPE"); msgno = r.getNumber(); r.skipSpaces(); if (r.readByte() != '(') throw new ParsingException("ENVELOPE parse error"); String s = r.readString(); if (s != null) { try { subject = r.readString(); if (parseDebug) System.out.println(" Subject: " + subject); System.out.println(" Bcc addresses:"); bcc = parseAddressList(r); inReplyTo = r.readString(); if (parseDebug) System.out.println(" In-Reply-To: " + inReplyTo); messageId = r.readString(); if (parseDebug) System.out.println(" Message-ID: " + messageId); if (r.readByte() != ')') throw new ParsingException("ENVELOPE parse error");
/** * Constructor. * * @param r the FetchResponse * @exception ParsingException for parsing failures */ public INTERNALDATE(FetchResponse r) throws ParsingException { msgno = r.getNumber(); r.skipSpaces(); String s = r.readString(); if (s == null) throw new ParsingException("INTERNALDATE is NIL"); try { synchronized (mailDateFormat) { date = mailDateFormat.parse(s); } } catch (ParseException pex) { throw new ParsingException("INTERNALDATE parse error"); } }
public FetchResponse(Protocol p) throws IOException, ProtocolException { super(p); fitems = null; parse(); }
/** * Fetch the FLAGS for the given message. * * @param msgno the message number * @return the Flags * @exception ProtocolException for protocol failures */ public Flags fetchFlags(int msgno) throws ProtocolException { Flags flags = null; Response[] r = fetch(msgno, "FLAGS"); // Search for our FLAGS response for (int i = 0, len = r.length; i < len; i++) { if (r[i] == null || !(r[i] instanceof FetchResponse) || ((FetchResponse)r[i]).getNumber() != msgno) continue; FetchResponse fr = (FetchResponse)r[i]; if ((flags = fr.getItem(FLAGS.class)) != null) { r[i] = null; // remove this response break; } } // dispatch untagged responses notifyResponseHandlers(r); handleResult(r[r.length-1]); return flags; }
/** * Read a response from the server. * * @return the response * @exception IOException for I/O errors * @exception ProtocolException for protocol failures */ public Response readResponse() throws IOException, ProtocolException { // assert Thread.holdsLock(this); // can't assert because it's called from constructor IMAPResponse r = new IMAPResponse(this); if (r.keyEquals("FETCH")) r = new FetchResponse(r, getFetchItems()); return r; }
private void parse() throws ParsingException { skipSpaces(); if (buffer[index] != '(') throw new ParsingException( if (match(ENVELOPE.name)) { if (match(FLAGS.name)) { if (match(INTERNALDATE.name)) { if (match(BODY.name)) { if (buffer[index+4] == '[') { if (match(BODYSTRUCTURE.name)) index += BODYSTRUCTURE.name.length; if (match(RFC822SIZE.name)) { if (match(RFC822DATA.name)) { index += RFC822DATA.name.length; if (match(HEADER)) else if (match(TEXT)) if (match(UID.name)) { index += UID.name.length; i = new UID(this);
/** * Constructor * * @param r the FetchResponse * @exception ParsingException for parsing failures */ public BODY(FetchResponse r) throws ParsingException { msgno = r.getNumber(); r.skipSpaces(); if (r.readByte() != '[') throw new ParsingException( "BODY parse error: missing ``['' at section start"); section = r.readString(']'); if (r.readByte() != ']') throw new ParsingException( "BODY parse error: missing ``]'' at section end"); isHeader = section.regionMatches(true, 0, "HEADER", 0, 6); if (r.readByte() == '<') { // origin origin = r.readNumber(); r.skip(1); // skip '>'; } else origin = 0; data = r.readByteArray(); }
/** * Constructor. * * @param r the FetchResponse * @exception ParsingException for parsing failures */ public MODSEQ(FetchResponse r) throws ParsingException { seqnum = r.getNumber(); r.skipSpaces(); if (r.readByte() != '(') throw new ParsingException("MODSEQ parse error"); modseq = r.readLong(); if (!r.isNextNonSpace(')')) throw new ParsingException("MODSEQ parse error"); } }
/** * Constructor. * * @param r the FetchResponse * @exception ParsingException for parsing failures */ public UID(FetchResponse r) throws ParsingException { seqnum = r.getNumber(); r.skipSpaces(); uid = r.readLong(); } }
((FetchResponse)r[i]).getNumber() != seqnum) continue; int count = f.getItemCount(); for (int j = 0; j < count; j++) { Item item = f.getItem(j);