Example #1
0
  public boolean deleteMessage(int number) throws IOException, ProtocolException {
    boolean result = false;
    Socket s = this.getIncommingSocket();
    ReceiveProtocol protocol = this.getIncommingProtocol(s);

    protocol.startSession();
    protocol.authorization(info.getUsername(), info.getPassword());
    result = protocol.deleteMessage(number);
    protocol.closeSession();
    s.close();
    return result;
  }
Example #2
0
  public Letter getLetter(int number) throws IOException, ProtocolException {
    Letter l;
    Socket s = this.getIncommingSocket();
    ReceiveProtocol protocol = this.getIncommingProtocol(s);

    protocol.startSession();
    protocol.authorization(info.getUsername(), info.getPassword());
    l = protocol.openMessage(number);
    protocol.closeSession();
    s.close();
    return l;
  }
Example #3
0
  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;
  }
Example #4
0
  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;
  }