/** * Returns whether this Protocol supports non-synchronizing literals. * * @return true if non-synchronizing literals are supported */ protected boolean supportsNonSyncLiterals() { return hasCapability("LITERAL+"); }
/** * Returns whether this Protocol supports non-synchronizing literals. * * @return true if non-synchronizing literals are supported */ @Override protected boolean supportsNonSyncLiterals() { return hasCapability("LITERAL+"); }
/** * UNSELECT Command. * * @exception ProtocolException for protocol failures * @see "RFC 3691" * @since JavaMail 1.4.4 */ public void unselect() throws ProtocolException { if (!hasCapability("UNSELECT")) throw new BadCommandException("UNSELECT not supported"); simpleCommand("UNSELECT", null); }
/** * UNSELECT Command. * * @exception ProtocolException for protocol failures * @see "RFC 3691" * @since JavaMail 1.4.4 */ public void unselect() throws ProtocolException { if (!hasCapability("UNSELECT")) throw new BadCommandException("UNSELECT not supported"); simpleCommand("UNSELECT", null); }
/** * UNAUTHENTICATE Command. * * @exception ProtocolException for protocol failures * @see "Netscape/iPlanet/SunONE Messaging Server extension" * @since JavaMail 1.5.1 */ public void unauthenticate() throws ProtocolException { if (!hasCapability("X-UNAUTHENTICATE")) throw new BadCommandException("UNAUTHENTICATE not supported"); simpleCommand("UNAUTHENTICATE", null); authenticated = false; }
/** * UNAUTHENTICATE Command. * * @exception ProtocolException for protocol failures * @see "Netscape/iPlanet/SunONE Messaging Server extension" * @since JavaMail 1.5.1 */ public void unauthenticate() throws ProtocolException { if (!hasCapability("X-UNAUTHENTICATE")) throw new BadCommandException("UNAUTHENTICATE not supported"); simpleCommand("UNAUTHENTICATE", null); authenticated = false; }
/** * ENABLE Command. * * @param cap the name of the capability to enable * @exception ProtocolException for protocol failures * @see "RFC 5161" * @since JavaMail 1.5.1 */ public void enable(String cap) throws ProtocolException { if (!hasCapability("ENABLE")) throw new BadCommandException("ENABLE not supported"); Argument args = new Argument(); args.writeAtom(cap); simpleCommand("ENABLE", args); if (enabled == null) enabled = new HashSet<String>(); enabled.add(cap.toUpperCase(Locale.ENGLISH)); }
/** * UID EXPUNGE Command. * * @param set UIDs to expunge * @exception ProtocolException for protocol failures * @see "RFC4315, section 2" */ public void uidexpunge(UIDSet[] set) throws ProtocolException { if (!hasCapability("UIDPLUS")) throw new BadCommandException("UID EXPUNGE not supported"); simpleCommand("UID EXPUNGE " + UIDSet.toString(set), null); }
/** * UID EXPUNGE Command. * * @param set UIDs to expunge * @exception ProtocolException for protocol failures * @see "RFC4315, section 2" */ public void uidexpunge(UIDSet[] set) throws ProtocolException { if (!hasCapability("UIDPLUS")) throw new BadCommandException("UID EXPUNGE not supported"); simpleCommand("UID EXPUNGE " + UIDSet.toString(set), null); }
/** * Handle the result response for a LOGIN or AUTHENTICATE command. * Look for IMAP login REFERRAL. * * @param r the response * @exception ProtocolException for protocol failures * @since JavaMail 1.5.5 */ protected void handleLoginResult(Response r) throws ProtocolException { if (hasCapability("LOGIN-REFERRALS") && (!r.isOK() || referralException)) checkReferral(r); handleResult(r); }
/** * Handle the result response for a LOGIN or AUTHENTICATE command. * Look for IMAP login REFERRAL. * * @param r the response * @exception ProtocolException for protocol failures * @since JavaMail 1.5.5 */ protected void handleLoginResult(Response r) throws ProtocolException { if (hasCapability("LOGIN-REFERRALS") && (!r.isOK() || referralException)) checkReferral(r); handleResult(r); }
/** * ENABLE Command. * * @param cap the name of the capability to enable * @exception ProtocolException for protocol failures * @see "RFC 5161" * @since JavaMail 1.5.1 */ public void enable(String cap) throws ProtocolException { if (!hasCapability("ENABLE")) throw new BadCommandException("ENABLE not supported"); Argument args = new Argument(); args.writeAtom(cap); simpleCommand("ENABLE", args); if (enabled == null) enabled = new HashSet<>(); enabled.add(cap.toUpperCase(Locale.ENGLISH)); // update the utf8 flag utf8 = isEnabled("UTF8=ACCEPT"); }
/** * Return true if the specified capability string is in the list * of capabilities the server announced. * * @param capability the capability string * @return true if the server supports this capability * @exception MessagingException for failures * @since JavaMail 1.3.3 */ public synchronized boolean hasCapability(String capability) throws MessagingException { IMAPProtocol p = null; try { p = getStoreProtocol(); return p.hasCapability(capability); } catch (ProtocolException pex) { throw new MessagingException(pex.getMessage(), pex); } finally { releaseStoreProtocol(p); } }
/** * Generate argument for OlderTerm. * * @param term the search term * @return the SEARCH Argument * @exception SearchException for failures * @since JavaMail 1.5.1 */ protected Argument older(OlderTerm term) throws SearchException { if (protocol != null && !protocol.hasCapability("WITHIN")) throw new SearchException("Server doesn't support OLDER searches"); Argument result = new Argument(); result.writeAtom("OLDER"); result.writeNumber(term.getInterval()); return result; }
/** * Generate argument for YoungerTerm. * * @param term the search term * @return the SEARCH Argument * @exception SearchException for failures * @since JavaMail 1.5.1 */ protected Argument younger(YoungerTerm term) throws SearchException { if (protocol != null && !protocol.hasCapability("WITHIN")) throw new SearchException("Server doesn't support YOUNGER searches"); Argument result = new Argument(); result.writeAtom("YOUNGER"); result.writeNumber(term.getInterval()); return result; }
/** * Generate argument for ModifiedSinceTerm. * * @param term the search term * @return the SEARCH Argument * @exception SearchException for failures * @since JavaMail 1.5.1 */ protected Argument modifiedSince(ModifiedSinceTerm term) throws SearchException { if (protocol != null && !protocol.hasCapability("CONDSTORE")) throw new SearchException("Server doesn't support MODSEQ searches"); Argument result = new Argument(); result.writeAtom("MODSEQ"); result.writeNumber(term.getModSeq()); return result; } }
/** * 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); }
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; }