args.writeString(Integer.toString(start) + ":" + Integer.toString(end)); args.writeString("BODY[]"); Response[] r = protocol.command("FETCH", args); Response response = r[r.length - 1]; if (response.isOK()) {
private void storeFlags(String msgset, Flags flags, boolean set) throws ProtocolException { Response[] r; if (set) r = command("STORE " + msgset + " +FLAGS " + createFlagList(flags), null); else r = command("STORE " + msgset + " -FLAGS " + createFlagList(flags), null); // Dispatch untagged responses notifyResponseHandlers(r); handleResult(r[r.length-1]); }
private void storeFlags(String msgset, Flags flags, boolean set) throws ProtocolException { Response[] r; if (set) r = command("STORE " + msgset + " +FLAGS " + createFlagList(flags), null); else r = command("STORE " + msgset + " -FLAGS " + createFlagList(flags), null); // Dispatch untagged responses notifyResponseHandlers(r); handleResult(r[r.length-1]); }
/** * LOGOUT Command. * * @exception ProtocolException for protocol failures * @see "RFC2060, section 6.1.3" */ public void logout() throws ProtocolException { try { Response[] r = command("LOGOUT", null); authenticated = false; // dispatch any unsolicited responses. // NOTE that the BYE response is dispatched here as well notifyResponseHandlers(r); } finally { disconnect(); } }
/** * LOGOUT Command. * * @exception ProtocolException for protocol failures * @see "RFC2060, section 6.1.3" */ public void logout() throws ProtocolException { try { Response[] r = command("LOGOUT", null); authenticated = false; // dispatch any unsolicited responses. // NOTE that the BYE response is dispatched here as well notifyResponseHandlers(r); } finally { disconnect(); } }
/** * CAPABILITY command. * * @exception ProtocolException for protocol failures * @see "RFC2060, section 6.1.1" */ public void capability() throws ProtocolException { // Check CAPABILITY Response[] r = command("CAPABILITY", null); Response response = r[r.length-1]; if (response.isOK()) handleCapabilityResponse(r); handleResult(response); }
/** * CAPABILITY command. * * @exception ProtocolException for protocol failures * @see "RFC2060, section 6.1.1" */ public void capability() throws ProtocolException { // Check CAPABILITY Response[] r = command("CAPABILITY", null); Response response = r[r.length-1]; if (response.isOK()) { capabilities = new HashMap<String, String>(10); authmechs = new ArrayList<String>(5); for (int i = 0, len = r.length; i < len; i++) { if (!(r[i] instanceof IMAPResponse)) continue; IMAPResponse ir = (IMAPResponse)r[i]; // Handle *all* untagged CAPABILITY responses. // Though the spec seemingly states that only // one CAPABILITY response string is allowed (6.1.1), // some server vendors claim otherwise. if (ir.keyEquals("CAPABILITY")) parseCapabilities(ir); } } handleResult(response); }
/** * DELETEACL Command. * * @param mbox the mailbox * @param user the user * @exception ProtocolException for protocol failures * @see "RFC2086" */ public void deleteACL(String mbox, String user) throws ProtocolException { if (!hasCapability("ACL")) throw new BadCommandException("ACL not supported"); Argument args = new Argument(); writeMailboxName(args, mbox); args.writeString(user); // XXX - could be UTF-8? Response[] r = command("DELETEACL", args); Response response = r[r.length-1]; // dispatch untagged responses notifyResponseHandlers(r); handleResult(response); }
private CopyUID copyuid(String msgSequence, String mbox, boolean uid) throws ProtocolException { if (uid && !hasCapability("UIDPLUS")) throw new BadCommandException("UIDPLUS not supported"); Argument args = new Argument(); args.writeAtom(msgSequence); writeMailboxName(args, mbox); Response[] r = command("COPY", args); // dispatch untagged responses notifyResponseHandlers(r); // Handle result of this command handleResult(r[r.length-1]); if (uid) return getCopyUID(r); else return null; }
/** * DELETEACL Command. * * @param mbox the mailbox * @param user the user * @exception ProtocolException for protocol failures * @see "RFC2086" */ public void deleteACL(String mbox, String user) throws ProtocolException { if (!hasCapability("ACL")) throw new BadCommandException("ACL not supported"); // encode the mbox as per RFC2060 mbox = BASE64MailboxEncoder.encode(mbox); Argument args = new Argument(); args.writeString(mbox); args.writeString(user); Response[] r = command("DELETEACL", args); Response response = r[r.length-1]; // dispatch untagged responses notifyResponseHandlers(r); handleResult(response); }
throw new BadCommandException("NAMESPACE not supported"); Response[] r = command("NAMESPACE", null);
throw new BadCommandException("NAMESPACE not supported"); Response[] r = command("NAMESPACE", null);
private CopyUID copyuid(String msgSequence, String mbox, boolean uid) throws ProtocolException { if (uid && !hasCapability("UIDPLUS")) throw new BadCommandException("UIDPLUS not supported"); // encode the mbox as per RFC2060 mbox = BASE64MailboxEncoder.encode(mbox); Argument args = new Argument(); args.writeAtom(msgSequence); args.writeString(mbox); Response[] r = command("COPY", args); // dispatch untagged responses notifyResponseHandlers(r); // Handle result of this command handleResult(r[r.length-1]); if (uid) return getCopyUID(r); else return null; }
/** * MOVE Command, return uid from COPYUID response code. * * @see "RFC 6851" * @see "RFC 4315, section 3" * @since JavaMail 1.5.4 */ private CopyUID moveuid(String msgSequence, String mbox, boolean uid) throws ProtocolException { if (!hasCapability("MOVE")) throw new BadCommandException("MOVE not supported"); if (uid && !hasCapability("UIDPLUS")) throw new BadCommandException("UIDPLUS not supported"); Argument args = new Argument(); args.writeAtom(msgSequence); writeMailboxName(args, mbox); Response[] r = command("MOVE", args); // dispatch untagged responses notifyResponseHandlers(r); // Handle result of this command handleResult(r[r.length-1]); if (uid) return getCopyUID(r); else return null; }
/** * SETACL Command. * * @param mbox the mailbox * @param modifier the ACL modifier * @param acl the ACL * @exception ProtocolException for protocol failures * @see "RFC2086" */ public void setACL(String mbox, char modifier, ACL acl) throws ProtocolException { if (!hasCapability("ACL")) throw new BadCommandException("ACL not supported"); Argument args = new Argument(); writeMailboxName(args, mbox); args.writeString(acl.getName()); String rights = acl.getRights().toString(); if (modifier == '+' || modifier == '-') rights = modifier + rights; args.writeString(rights); Response[] r = command("SETACL", args); Response response = r[r.length-1]; // dispatch untagged responses notifyResponseHandlers(r); handleResult(response); }
/** * MOVE Command, return uid from COPYUID response code. * * @see "RFC 6851" * @see "RFC 4315, section 3" * @since JavaMail 1.5.4 */ private CopyUID moveuid(String msgSequence, String mbox, boolean uid) throws ProtocolException { if (!hasCapability("MOVE")) throw new BadCommandException("MOVE not supported"); if (uid && !hasCapability("UIDPLUS")) throw new BadCommandException("UIDPLUS not supported"); // encode the mbox as per RFC2060 mbox = BASE64MailboxEncoder.encode(mbox); Argument args = new Argument(); args.writeAtom(msgSequence); args.writeString(mbox); Response[] r = command("MOVE", args); // dispatch untagged responses notifyResponseHandlers(r); // Handle result of this command handleResult(r[r.length-1]); if (uid) return getCopyUID(r); else return null; }
/** * SETACL Command. * * @param mbox the mailbox * @param modifier the ACL modifier * @param acl the ACL * @exception ProtocolException for protocol failures * @see "RFC2086" */ public void setACL(String mbox, char modifier, ACL acl) throws ProtocolException { if (!hasCapability("ACL")) throw new BadCommandException("ACL not supported"); // encode the mbox as per RFC2060 mbox = BASE64MailboxEncoder.encode(mbox); Argument args = new Argument(); args.writeString(mbox); args.writeString(acl.getName()); String rights = acl.getRights().toString(); if (modifier == '+' || modifier == '-') rights = modifier + rights; args.writeString(rights); Response[] r = command("SETACL", args); Response response = r[r.length-1]; // dispatch untagged responses notifyResponseHandlers(r); handleResult(response); }
suspendTracing(); r = command("LOGIN", args); } finally { resumeTracing();