/** * Delete (permanently) the specified message. */ synchronized boolean dele(int msg) throws IOException { Response r = simpleCommand("DELE " + msg); return r.ok; }
/** * Do a NOOP. */ synchronized boolean noop() throws IOException { Response r = simpleCommand("NOOP"); return r.ok; }
/** * Do an RSET. */ synchronized boolean rset() throws IOException { Response r = simpleCommand("RSET"); return r.ok; }
/** * Do a NOOP. */ synchronized boolean noop() throws IOException { Response r = simpleCommand("NOOP"); return r.ok; }
/** * Do an RSET. */ synchronized boolean rset() throws IOException { Response r = simpleCommand("RSET"); return r.ok; }
/** * Delete (permanently) the specified message. */ synchronized boolean dele(int msg) throws IOException { Response r = simpleCommand("DELE " + msg); return r.ok; }
/** * Return the UIDL string for the message. */ synchronized String uidl(int msg) throws IOException { Response r = simpleCommand("UIDL " + msg); if (!r.ok) return null; int i = r.data.indexOf(' '); if (i > 0) return r.data.substring(i + 1); else return null; }
/** * Return the UIDL string for the message. */ synchronized String uidl(int msg) throws IOException { Response r = simpleCommand("UIDL " + msg); if (!r.ok) return null; int i = r.data.indexOf(' '); if (i > 0) return r.data.substring(i + 1); else return null; }
/** * Return the size of the message using the LIST command. */ synchronized int list(int msg) throws IOException { Response r = simpleCommand("LIST " + msg); int size = -1; if (r.ok && r.data != null) { try { StringTokenizer st = new StringTokenizer(r.data); st.nextToken(); // skip message number size = Integer.parseInt(st.nextToken()); } catch (RuntimeException e) { // ignore it } } return size; }
/** * Return the size of the message using the LIST command. */ synchronized int list(int msg) throws IOException { Response r = simpleCommand("LIST " + msg); int size = -1; if (r.ok && r.data != null) { try { StringTokenizer st = new StringTokenizer(r.data); st.nextToken(); // skip message number size = Integer.parseInt(st.nextToken()); } catch (RuntimeException e) { // ignore it } } return size; }
/** * Close down the connection, sending the QUIT command. */ synchronized boolean quit() throws IOException { boolean ok = false; try { Response r = simpleCommand("QUIT"); ok = r.ok; } finally { close(); } return ok; }
/** * Close down the connection, sending the QUIT command. */ synchronized boolean quit() throws IOException { boolean ok = false; try { Response r = simpleCommand("QUIT"); ok = r.ok; } finally { close(); } return ok; }
/** * Return the total number of messages and mailbox size, * using the STAT command. */ synchronized Status stat() throws IOException { Response r = simpleCommand("STAT"); Status s = new Status(); /* * Normally the STAT command shouldn't fail but apparently it * does when accessing Hotmail too often, returning: * -ERR login allowed only every 15 minutes * (Why it doesn't just fail the login, I don't know.) * This is a serious failure that we don't want to hide * from the user. */ if (!r.ok) throw new IOException("STAT command failed: " + r.data); if (r.data != null) { try { StringTokenizer st = new StringTokenizer(r.data); s.total = Integer.parseInt(st.nextToken()); s.size = Integer.parseInt(st.nextToken()); } catch (RuntimeException e) { } } return s; }
/** * Return the total number of messages and mailbox size, * using the STAT command. */ synchronized Status stat() throws IOException { Response r = simpleCommand("STAT"); Status s = new Status(); /* * Normally the STAT command shouldn't fail but apparently it * does when accessing Hotmail too often, returning: * -ERR login allowed only every 15 minutes * (Why it doesn't just fail the login, I don't know.) * This is a serious failure that we don't want to hide * from the user. */ if (!r.ok) throw new IOException("STAT command failed: " + r.data); if (r.data != null) { try { StringTokenizer st = new StringTokenizer(r.data); s.total = Integer.parseInt(st.nextToken()); s.size = Integer.parseInt(st.nextToken()); } catch (RuntimeException e) { } } return s; }
/** * Start TLS using STLS command specified by RFC 2595. * If already using SSL, this is a nop and the STLS command is not issued. */ synchronized boolean stls() throws IOException { if (socket instanceof SSLSocket) return true; // nothing to do Response r = simpleCommand("STLS"); if (r.ok) { // it worked, now switch the socket into TLS mode try { socket = SocketFetcher.startTLS(socket, host, props, prefix); initStreams(); } catch (IOException ioex) { try { socket.close(); } finally { socket = null; input = null; output = null; } IOException sioex = new IOException("Could not convert socket to TLS"); sioex.initCause(ioex); throw sioex; } } return r.ok; }
/** * Start TLS using STLS command specified by RFC 2595. * If already using SSL, this is a nop and the STLS command is not issued. */ synchronized boolean stls() throws IOException { if (socket instanceof SSLSocket) return true; // nothing to do Response r = simpleCommand("STLS"); if (r.ok) { // it worked, now switch the socket into TLS mode try { socket = SocketFetcher.startTLS(socket, host, props, prefix); initStreams(); } catch (IOException ioex) { try { socket.close(); } finally { socket = null; input = null; output = null; } IOException sioex = new IOException("Could not convert socket to TLS"); sioex.initCause(ioex); throw sioex; } } return r.ok; }
r = simpleCommand(null); } catch (IOException ioe) { try {
dpw = getDigest(password); if (apopChallenge != null && dpw != null) { r = simpleCommand("APOP " + user + " " + dpw); } else if (batch) { String cmd = "USER " + user; batchCommandEnd(); } else { r = simpleCommand("USER " + user); if (!r.ok) return r.data != null ? r.data : "USER command failed"; r = simpleCommand("PASS " + password);
dpw = getDigest(password); if (apopChallenge != null && dpw != null) { r = simpleCommand("APOP " + user + " " + dpw); } else if (batch) { String cmd = "USER " + user; batchCommandEnd(); } else { r = simpleCommand("USER " + user); if (!r.ok) return r.data != null ? r.data : "USER command failed"; r = simpleCommand("PASS " + password);
r = simpleCommand(null); } catch (IOException ioe) { throw cleanupAndThrow(socket, ioe);