/** * Generate a QRESYNC argument list based on the ResyncData. */ private static Argument resyncArgs(ResyncData rd) { Argument cmd = new Argument(); cmd.writeAtom("QRESYNC"); Argument args = new Argument(); args.writeNumber(rd.getUIDValidity()); args.writeNumber(rd.getModSeq()); UIDSet[] uids = Utility.getResyncUIDSet(rd); if (uids != null) args.writeString(UIDSet.toString(uids)); cmd.writeArgument(args); return cmd; }
protected Argument not(NotTerm term, String charset) throws SearchException, IOException { Argument result = new Argument(); // Add the NOT search-key result.writeAtom("NOT"); /* If this term is an AND expression, we need to enclose it * within paranthesis. * * AND expressions are either AndTerms or FlagTerms */ SearchTerm nterm = term.getTerm(); if (nterm instanceof AndTerm || nterm instanceof FlagTerm) result.writeArgument(generateSequence(nterm, charset)); else result.append(generateSequence(nterm, charset)); return result; }
public void write(Protocol protocol) throws IOException, ProtocolException { int size = items != null ? items.size() : 0; DataOutputStream os = (DataOutputStream)protocol.getOutputStream(); for (int i=0; i < size; i++) { if (i > 0) // write delimiter if not the first item os.write(' '); Object o = items.get(i); if (o instanceof Atom) { os.writeBytes(((Atom)o).string); } else if (o instanceof Number) { os.writeBytes(((Number)o).toString()); } else if (o instanceof AString) { astring(((AString)o).bytes, protocol); } else if (o instanceof NString) { nstring(((NString)o).bytes, protocol); } else if (o instanceof byte[]) { literal((byte[])o, protocol); } else if (o instanceof ByteArrayOutputStream) { literal((ByteArrayOutputStream)o, protocol); } else if (o instanceof Literal) { literal((Literal)o, protocol); } else if (o instanceof Argument) { os.write('('); // open parans ((Argument)o).write(protocol); os.write(')'); // close parans } } }
protected Argument from(String address, String charset) throws SearchException, IOException { Argument result = new Argument(); result.writeAtom("FROM"); result.writeString(address, charset); 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 { Argument result = new Argument(); result.writeAtom("YOUNGER"); result.writeNumber(term.getInterval()); return result; }
/** * Convert the client parameters into an argument list for the ID command. */ static Argument getArgumentList(Map<String,String> clientParams) { Argument arg = new Argument(); if (clientParams == null) { arg.writeAtom("NIL"); return arg; } Argument list = new Argument(); // add params to list for (Map.Entry<String, String> e : clientParams.entrySet()) { list.writeNString(e.getKey()); list.writeNString(e.getValue()); } arg.writeArgument(list); return arg; } }
Argument args = new Argument(); args.writeString(mbox); args.writeAtom(createFlagList(f)); args.writeString(INTERNALDATE.format(d)); args.writeBytes(data);
Argument args = new Argument(); writeMailboxName(args, mbox); if (!hasCapability("CONDSTORE")) throw new BadCommandException("CONDSTORE not supported"); args.writeArgument(new Argument().writeAtom("CONDSTORE")); } else { if (!hasCapability("QRESYNC")) throw new BadCommandException("QRESYNC not supported"); args.writeArgument(resyncArgs(rd));
public void write(Protocol protocol) throws IOException, ProtocolException { int size = items != null ? items.size() : 0; DataOutputStream os = (DataOutputStream)protocol.getOutputStream(); for (int i=0; i < size; i++) { if (i > 0) // write delimiter if not the first item os.write(' '); Object o = items.elementAt(i); if (o instanceof Atom) { os.writeBytes(((Atom)o).string); } else if (o instanceof Number) { os.writeBytes(((Number)o).toString()); } else if (o instanceof AString) { astring(((AString)o).bytes, protocol); } else if (o instanceof byte[]) { literal((byte[])o, protocol); } else if (o instanceof ByteArrayOutputStream) { literal((ByteArrayOutputStream)o, protocol); } else if (o instanceof Literal) { literal((Literal)o, protocol); } else if (o instanceof Argument) { os.write('('); // open parans ((Argument)o).write(protocol); os.write(')'); // close parans } } }
/** * Write out given byte[] as a literal */ private void literal(byte[] b, Protocol protocol) throws IOException, ProtocolException { startLiteral(protocol, b.length).write(b); }
/** * PROXYAUTH Command. * * @param u the PROXYAUTH user name * @exception ProtocolException for protocol failures * @see "Netscape/iPlanet/SunONE Messaging Server extension" */ public void proxyauth(String u) throws ProtocolException { Argument args = new Argument(); args.writeString(u); simpleCommand("PROXYAUTH", args); proxyAuthUser = u; }
protected Argument and(AndTerm term, String charset) throws SearchException, IOException { // Combine the sequences for both terms SearchTerm[] terms = term.getTerms(); // Generate the search sequence for the first term Argument result = generateSequence(terms[0], charset); // Append other terms for (int i = 1; i < terms.length; i++) result.append(generateSequence(terms[i], charset)); return result; }
public String writeCommand(String command, Argument args) throws IOException, ProtocolException { // assert Thread.holdsLock(this); // can't assert because it's called from constructor String tag = "A" + Integer.toString(tagCounter++, 10); // unique tag output.writeBytes(tag + " " + command); if (args != null) { output.write(' '); args.write(this); } output.write(CRLF); output.flush(); return tag; }
/** * DELETE Command. * * @param mbox the mailbox to delete * @exception ProtocolException for protocol failures * @see "RFC2060, section 6.3.4" */ public void delete(String mbox) throws ProtocolException { Argument args = new Argument(); writeMailboxName(args, mbox); simpleCommand("DELETE", args); }
public AppendUID appenduid(String mbox, Flags f, Date d, Literal data, boolean uid) throws ProtocolException { Argument args = new Argument(); writeMailboxName(args, mbox); args.writeAtom(createFlagList(f)); args.writeString(INTERNALDATE.format(d)); args.writeBytes(data);
protected Argument from(String address, String charset) throws SearchException, IOException { Argument result = new Argument(); result.writeAtom("FROM"); result.writeString(address, charset); return result; }
/** * 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 { Argument result = new Argument(); result.writeAtom("OLDER"); result.writeNumber(term.getInterval()); return result; }
/** * Convert the client parameters into an argument list for the ID command. */ static Argument getArgumentList(Map<String,String> clientParams) { Argument arg = new Argument(); if (clientParams == null) { arg.writeAtom("NIL"); return arg; } Argument list = new Argument(); // add params to list for (Map.Entry<String, String> e : clientParams.entrySet()) { list.writeNString(e.getKey()); // assume these are ASCII only list.writeNString(e.getValue()); } arg.writeArgument(list); return arg; } }
Argument args = new Argument(); writeMailboxName(args, mbox); if (!hasCapability("CONDSTORE")) throw new BadCommandException("CONDSTORE not supported"); args.writeArgument(new Argument().writeAtom("CONDSTORE")); } else { if (!hasCapability("QRESYNC")) throw new BadCommandException("QRESYNC not supported"); args.writeArgument(resyncArgs(rd));