import org.ibex.io.*;
import org.ibex.jinetd.Listener;
import org.ibex.jinetd.Worker;
-import org.ibex.net.*;
import org.ibex.mail.*;
import org.ibex.util.*;
import org.ibex.mail.target.*;
String response = "";
for(int i=0; i<list.length; i++) {
String s = list[i].atom().toUpperCase();
+ if (i>0) response += " ";
if (s.equals("MESSAGES")) response += "MESSAGES " + api.count(mailbox);
if (s.equals("RECENT")) response += "RECENT " + api.recent(mailbox);
if (s.equals("UIDNEXT")) response += "UIDNEXT " + api.uidNext(mailbox);
if (s.equals("UIDVALIDITY")) response += "UIDVALIDITY " + api.uidValidity(mailbox);
if (s.equals("UNSEEN")) response += "UNSEEN " + api.unseen(mailbox);
}
- println("* STATUS " + selectedName + " (" + response + ")");
+ println("* STATUS " + mailbox + " (" + response + ")");
break;
}
case APPEND: {
- String m = token().atom();
+ String m = token().astring();
int flags = 0;
- Date arrival = null;
+ Date arrival = new Date();
Parser.Token t = token();
if (t.type == t.LIST) { flags = t.flags(); t = token(); }
- if (t.type == t.QUOTED) { arrival = t.datetime(); t = token(); }
- api.append(m, flags, arrival, token().q());
+ if (t.type != t.QUOTED) { arrival = t.datetime(); t = token(); }
+ api.append(m, flags, arrival, t.q());
break; }
case STORE: {
selected();
if (c == '\r' || c == '\n') { if (freak) bad("unexpected end of line"); return null; }
else if (c == '{') {
while(stream.peekc() != '}') sb.append(stream.getc());
+ stream.getc();
stream.println("+ Ready when you are...");
int octets = Integer.parseInt(sb.toString());
while(stream.peekc() == ' ') stream.getc(); // whitespace
- while (stream.getc() != '\n' && stream.getc() != '\r') { }
+ while(stream.peekc() == '\n' || stream.peekc() == '\r') stream.getc();
byte[] bytes = new byte[octets];
- stream.read(bytes, 0, bytes.length);
+ int numread = 0;
+ while(numread < bytes.length) {
+ int n = stream.read(bytes, numread, bytes.length - numread);
+ if (n == -1) bad("end of stream while reading IMAP qstring");
+ numread += n;
+ }
return new Token(new String(bytes), true);
} else if (c == '\"') {
while(true) {