public void makeSessionList() { sessionList = new List(5, false); Vector theSessions = theAR.getSessions(); int size = theSessions.size(); for (int j = 0; j < size; j++) { Date d = (Date) theSessions.elementAt(j); sessionList.addItem(d.toString()); } }
/** * Implementing the Observer interface. Receiving the response from the Pdu. * * @param obs the UpSincePdu variable * @param ov the date * @see uk.co.westhawk.snmp.pdu.UpSincePdu */ public void update(Observable obs, Object ov) { Pdu pdu = (Pdu) obs; if (pdu.getErrorStatus() == AsnObject.SNMP_ERR_NOERROR) { Date dres = (Date) ov; if (dres != null) { // TODO: invokeLater v.setText(dres.toString()); } } else { // TODO: invokeLater v.setText(pdu.getErrorStatusString()); } }
int doSMTPTransaction(SMTPInputStream in, SMTPOutputStream out) throws IOException { int replyCode; Date today = new Date(); // GET SERVER RESPONSE on CONNECTION ESTABLISHMENT // WAIT FOR RESPONSE (WAIT_TIMEOUT) millis // NOT RESPONSE ON CONNECT ERROR CODE 1 replyCode = waitForTimeout(in); if (replyCode == 0) { infoArea.Println("NOT RESPONSE ON CONNECT ERROR CODE 1"); return 1; } if (replyCode == -1) { infoArea.Println("UNKNOWN REPLY CODE ERROR CODE 4"); return 4; } if (replyCode != SMTP_RCODE_READY) { infoArea.Println("UNSUCCESS CONNECTION "); return replyCode; } infoArea.Println("connection response is OK"); infoArea.Println("request HELO"); // SEND HELO CRLF out.WriteToStream(SMTPCommand[SMTP_CMD_HELO]); out.WriteToStream(SMTPCommand[SMTP_CMD_SPC]); out.WriteToStream("127.0.0.1"); out.WriteToStream(SMTPCommand[SMTP_CMD_CRLF]); // WAIT FOR RESPONSE ON HELO replyCode = waitForTimeout(in); if (replyCode == 0) { infoArea.Println("NOT RESPONSE TO HELO ERROR CODE 2"); return 2; } if (replyCode == -1) { infoArea.Println("UNKNOWN REPLY CODE ERROR CODE 4"); return 4; } if (replyCode != SMTP_RCODE_COMPLETED) { infoArea.Println("UNABLE TO COMPLETE REPLY"); return replyCode; } infoArea.Println("HELO response is OK"); infoArea.Println("request MAIL FROM"); // SEND MAIL FROM: SPC <sender> CRLF out.WriteToStream(SMTPCommand[SMTP_CMD_MAIL_FROM]); out.WriteToStream(SMTPCommand[SMTP_CMD_SPC]); out.WriteToStream(senderMail.getText()); out.WriteToStream(SMTPCommand[SMTP_CMD_CRLF]); // WAIT FOR RESPONSE ON MAIL FROM replyCode = waitForTimeout(in); if (replyCode == 0) { infoArea.Println("NOT RESPONSE TO HELO ERROR CODE 2"); return 2; } if (replyCode == -1) { infoArea.Println("UNKNOWN REPLY CODE ERROR CODE 4"); return 4; } if (replyCode != SMTP_RCODE_COMPLETED) { infoArea.Println("UNABLE TO COMPLETE REPLY"); return replyCode; } infoArea.Println("MAIL FROM response is OK"); infoArea.Println("request RCPT TO"); // SEND RCPT TO: SPC <sender> CRLF out.WriteToStream(SMTPCommand[SMTP_CMD_RCPT_TO]); out.WriteToStream(SMTPCommand[SMTP_CMD_SPC]); out.WriteToStream(reciverMail.getText()); out.WriteToStream(SMTPCommand[SMTP_CMD_CRLF]); // WAIT FOR RESPONSE ON RCPT TO replyCode = waitForTimeout(in); if (replyCode == 0) { infoArea.Println("NOT RESPONSE TO HELO ERROR CODE 2"); return 2; } if (replyCode == -1) { infoArea.Println("UNKNOWN REPLY CODE ERROR CODE 4"); return 4; } if ((replyCode != SMTP_RCODE_COMPLETED) && (replyCode != SMTP_RCODE_FORWARD)) { infoArea.Println("UNABLE TO COMPLETE REPLY"); return replyCode; } infoArea.Println("RCPT TO response is OK"); // TRY TO SEND TO CC if ((ccMail.getText().length()) > 0) { infoArea.Println("request CC RCPT TO"); // SEND RCPT TO: SPC <sender> CRLF out.WriteToStream(SMTPCommand[SMTP_CMD_RCPT_TO]); out.WriteToStream(SMTPCommand[SMTP_CMD_SPC]); out.WriteToStream(ccMail.getText()); out.WriteToStream(SMTPCommand[SMTP_CMD_CRLF]); // WAIT FOR RESPONSE ON RCPT TO replyCode = waitForTimeout(in); if (replyCode == 0) { infoArea.Println("NOT RESPONSE TO HELO ERROR CODE 2"); return 2; } if (replyCode == -1) { infoArea.Println("UNKNOWN REPLY CODE ERROR CODE 4"); return 4; } if ((replyCode != SMTP_RCODE_COMPLETED) && (replyCode != SMTP_RCODE_FORWARD)) { infoArea.Println("UNABLE TO COMPLETE CC"); } else { infoArea.Println("CC.RCPT TO response is OK"); } } // TRY TO SEND TO BCC if ((bccMail.getText().length()) > 0) { // SEND RCPT TO: SPC <sender> CRLF out.WriteToStream(SMTPCommand[SMTP_CMD_RCPT_TO]); out.WriteToStream(SMTPCommand[SMTP_CMD_SPC]); out.WriteToStream(bccMail.getText()); out.WriteToStream(SMTPCommand[SMTP_CMD_CRLF]); // WAIT FOR RESPONSE ON RCPT TO replyCode = waitForTimeout(in); if (replyCode == 0) { infoArea.Println("NOT RESPONSE TO HELO ERROR CODE 2"); return 2; } if (replyCode == -1) { infoArea.Println("UNKNOWN REPLY CODE ERROR CODE 4"); return 4; } if ((replyCode != SMTP_RCODE_COMPLETED) && (replyCode != SMTP_RCODE_FORWARD)) { infoArea.Println("UNABLE TO COMPLETE BCC"); } else { infoArea.Println("BCC.RCPT TO response is OK"); } } infoArea.Println("request DATA"); // SEND DATA CRLF out.WriteToStream(SMTPCommand[SMTP_CMD_DATA]); out.WriteToStream(SMTPCommand[SMTP_CMD_CRLF]); // WAIT FOR RESPONSE ON DATA replyCode = waitForTimeout(in); if (replyCode == 0) { infoArea.Println("NOT RESPONSE TO HELO ERROR CODE 2"); return 2; } if (replyCode == -1) { infoArea.Println("UNKNOWN REPLY CODE ERROR CODE 4"); return 4; } if (replyCode != SMTP_RCODE_MAIL_START) { infoArea.Println("UNABLE TO COMPLETE REPLY"); return replyCode; } infoArea.Println("DATA response is OK"); infoArea.Println("request DATA"); // SEND mail content CRLF.CRLF out.WriteToStream("Subject: " + subjectMail.getText()); out.WriteToStream(SMTPCommand[SMTP_CMD_CRLF]); out.WriteToStream("From: " + senderMail.getText()); out.WriteToStream(SMTPCommand[SMTP_CMD_CRLF]); out.WriteToStream("To: " + reciverMail.getText()); out.WriteToStream(SMTPCommand[SMTP_CMD_CRLF]); out.WriteToStream("Date: " + today.toString()); out.WriteToStream(SMTPCommand[SMTP_CMD_CRLF]); out.WriteToStream(SMTPCommand[SMTP_CMD_CRLF]); out.WriteToStream(bodyMail.getText()); out.WriteToStream(SMTPCommand[SMTP_CMD_CRLF_CRLF]); // WAIT FOR RESPONSE ON mail content CRLF.CRLF replyCode = waitForTimeout(in); if (replyCode == 0) { infoArea.Println("NOT RESPONSE TO HELO ERROR CODE 2"); return 2; } if (replyCode == -1) { infoArea.Println("UNKNOWN REPLY CODE ERROR CODE 4"); return 4; } if (replyCode != SMTP_RCODE_COMPLETED) { infoArea.Println("UNABLE TO COMPLETE REPLY"); return replyCode; } infoArea.Println("mail content response is OK"); infoArea.Println("request QUIT"); // SEND QUIT CRLF out.WriteToStream(SMTPCommand[SMTP_CMD_QUIT]); out.WriteToStream(SMTPCommand[SMTP_CMD_CRLF]); // WAIT FOR RESPONSE (WAIT_TIMEOUT) millis // NOT RESPONSE TO QUIT ERROR CODE 3 replyCode = waitForTimeout(in); if (replyCode == 0) { infoArea.Println("NOT RESPONSE TO QUIT ERROR CODE 3"); return 3; } if (replyCode == -1) { infoArea.Println("UNKNOWN REPLY CODE ERROR CODE 4"); return 4; } if (replyCode != SMTP_RCODE_CLOSING) { infoArea.Println("UNCLOSED CONNECTION REPLY"); return replyCode; } infoArea.Println("QUIT response is BYE"); infoArea.Println("end of SMTP transaction"); // TRANSACTION OK ERROR CODE 0 return 0; }