public int getMailsCount() throws IOException, ProtocolException { int count = 0; Socket s = this.getIncommingSocket(); ReceiveProtocol protocol = this.getIncommingProtocol(s); protocol.startSession(); protocol.authorization(info.getUsername(), info.getPassword()); count = protocol.letterCount(); protocol.closeSession(); s.close(); return count; }
public LetterInfo[] getMailsInfoList() throws IOException, ProtocolException { LetterInfo[] letterInfo; Socket s = this.getIncommingSocket(); ReceiveProtocol protocol = this.getIncommingProtocol(s); protocol.startSession(); protocol.authorization(info.getUsername(), info.getPassword()); int letterCount = protocol.letterCount(); letterInfo = new LetterInfo[letterCount]; for (int i = 0; i < letterCount; i++) { letterInfo[i] = protocol.messageInfo(letterCount - i); } protocol.closeSession(); s.close(); return letterInfo; }