Return the total number of messages and mailbox size, using the STAT command.
()
| 828 | * using the STAT command. |
| 829 | */ |
| 830 | synchronized Status stat() throws IOException { |
| 831 | Response r = simpleCommand("STAT"); |
| 832 | Status s = new Status(); |
| 833 | |
| 834 | /* |
| 835 | * Normally the STAT command shouldn't fail but apparently it |
| 836 | * does when accessing Hotmail too often, returning: |
| 837 | * -ERR login allowed only every 15 minutes |
| 838 | * (Why it doesn't just fail the login, I don't know.) |
| 839 | * This is a serious failure that we don't want to hide |
| 840 | * from the user. |
| 841 | */ |
| 842 | if (!r.ok) |
| 843 | throw new IOException("STAT command failed: " + r.data); |
| 844 | |
| 845 | if (r.data != null) { |
| 846 | try { |
| 847 | StringTokenizer st = new StringTokenizer(r.data); |
| 848 | s.total = Integer.parseInt(st.nextToken()); |
| 849 | s.size = Integer.parseInt(st.nextToken()); |
| 850 | } catch (RuntimeException e) { |
| 851 | } |
| 852 | } |
| 853 | return s; |
| 854 | } |
| 855 | |
| 856 | /** |
| 857 | * Return the size of the message using the LIST command. |
no test coverage detected