diff --git a/contrib/javasupport/Email.java b/contrib/javasupport/Email.java new file mode 100644 index 0000000000..747ba16bb4 --- /dev/null +++ b/contrib/javasupport/Email.java @@ -0,0 +1,472 @@ +//////////////////////////////////////////////////////// +// +// Simple Email Class +// +// SMPT mail sender to email a message to port 25 (the standard SMPT socket) +// Adheres to TCP/SMTP specs (RFC 821) +// +// Written in Java 1.1 by Chris Parkinson, 1997 +// +//////////////////////////////////////////////////////// +// $Id: Email.java,v 1.1 1998-03-17 07:55:28 d3e129 Exp $ + + + +import java.awt.event.*; +import java.io.*; +import java.net.*; +import java.util.Vector; + +public class Email { + + //ID's for action messages + public static final int MESSAGE = 0; + public static final int ERROR = 1; + + //Mail server and port information + private int mailPort; //SMPT PORT - should usually be 25 + private String mailServer; //Host name or IP address + + //Individual mail information + private String mailFrom; //Who is sending this message + private String[] mailTo; //Who are the recipients + private String mailSubject; //The subject line of the message + private String mailMessage; //The actual mail message + + //Transient variables + private Socket socket; //Socket to talk to host + private BufferedReader dataInput; //Receive from sockets + private PrintWriter dataOutput; //Send to socket + private String heloHost; //The server identity + private ActionListener actionListener; //Who is monitoring us + + +//////////////////////////////////////////////////////// +// +// Constructor +// +//////////////////////////////////////////////////////// +/** + * Construct a simple emailer + */ + public Email() { + setMailPort(25); //Set up some defaults + setMailServer("pnl.gov"); + } + +//////////////////////////////////////////////////////// +// +// Set the mail port number +// +//////////////////////////////////////////////////////// +/** + * Set the mail port number + */ + public void setMailPort(int portNumber) { + mailPort = portNumber; +} + +//////////////////////////////////////////////////////// +// +// Set the mail server (a string of name or number) +// +//////////////////////////////////////////////////////// +/** + * Set the mail server + */ + public void setMailServer(String server) { + mailServer = new String(server); +} + +//////////////////////////////////////////////////////// +// +// Set the from email address +// +//////////////////////////////////////////////////////// +/** + * Set the mail sender + */ + public void setMailFrom(String from) { + mailFrom = new String(from); +} + +//////////////////////////////////////////////////////// +// +// Set the to email address(s) +// +//////////////////////////////////////////////////////// +/** + * Set the 'to' email address(s) + */ + public void setMailTo(String to) { + mailTo = new String[1]; + mailTo[0] = new String(to); +} + +/** + * Set the 'to' email address(s) + */ + public void setMailTo(String to[]) { + for (int i =0; i 0) + { support.addMailTo(edit3.getText()); } + if (edit7.getText().length() > 0) + { support.addMailTo(edit7.getText()); } + if (edit8.getText().length() > 0) + { support.addMailTo(edit8.getText()); } + +////////subject is set to text from textfield edit2 + String subject = edit2.getText().toString(); + support.setMailSubject(subject); + + String start = ""; + support.setMailMessage(start); + +////////if "Yes" has been checked off under "Receipt:", "X-Special: Receipt" flag will be added to message + if (group1.getSelectedCheckbox() == check2 ) + { + String receipt = "X-Special: Receipt"; + support.addMailMessage(receipt); + } +////////all other flags + String bug = "X-Bug: " + choice2.getSelectedItem(); + support.addMailMessage(bug); + + String Module = "X-Module: " + choice3.getSelectedItem(); + support.addMailMessage(Module); + + String Operation = "X-Operation: " + choice4.getSelectedItem(); + support.addMailMessage(Operation); + + String Platform = "X-Platform: " + choice5.getSelectedItem(); + support.addMailMessage(Platform); + + String Priority = "X-Priority: " + choice1.getSelectedItem(); + support.addMailMessage(Priority); + + String message = "--- QMH Annotations ---"; +// support.addMailMessage(message); + +////////choice box information will be sent only if choice has been changed from default. + if (choice1.getSelectedItem() != "user_priority") { + String message0 = "User Priority\t:\t" + choice1.getSelectedItem().toString(); + support.addMailMessage(message0); + } + if (choice2.getSelectedItem() != "Problem?") { + String message1 = "Problem\t\t:\t" + choice2.getSelectedItem().toString(); + support.addMailMessage(message1); + } + if (choice3.getSelectedItem() != "Module/Theory?") { + String message2 = "Module/Theory\t:\t" + choice3.getSelectedItem().toString(); + support.addMailMessage(message2); + } + if (choice4.getSelectedItem() != "Operation?") { + String message3 = "Operation\t:\t" + choice4.getSelectedItem().toString(); + support.addMailMessage(message3); + } + if (choice5.getSelectedItem() != "Platform?") { + String message4 = "Platform\t:\t" + choice5.getSelectedItem().toString(); + support.addMailMessage(message4); + } + +////////message body, including date, sender, reciever, cc, subject, etc + String message5 ="\n" + "--- Request Message ---"; +// support.addMailMessage(message5); + Date thedate = new Date(); + String message6 = "Date\t\t:\t" + thedate.toString(); +// support.addMailMessage(message6); + String message7 = "To\t\t\t:\t nwchem-support@emsl.pnl.gov"; +// support.addMailMessage(message7); + String message8 = "From\t\t:\t" + sender; +// support.addMailMessage(message8); + String message9 = "cc\t\t\t:\t" + edit3.getText().toString() + edit7.getText() + edit8.getText(); +// support.addMailMessage(message9); + String message10 = "Subject\t\t:\t" + subject; +// support.addMailMessage(message10); + String message11 = "\n" + edit4.getText().toString() + "\r\n\r\n"; + support.addMailMessage(message11); + +////////retrieves filename from textfield edit5 to send "input file" as attachment appended to e-mail, +////////attachment doesn't need to be included for message to be sent + File filename = new File(edit5.getText()); + if (filename.exists()) { + String message12 = "***************INPUT FILE*****************\r\n\r\n"; + support.addMailMessage(message12); + RandomAccessFile File = new RandomAccessFile(filename, "rw"); + String attach0 = edit5.getText().toString(); + while (File.getFilePointer() < File.length()) { + String message13 = File.readLine(); + support.addMailMessage(message13); + } + } + +////////retrieves filename from textfield edit6 to send "output file" as an additional attachment appended to e-mail + File filename1 = new File(edit6.getText()); + if (filename1.exists()) { + String messagenull = "\r\n\r\n"; + support.addMailMessage(messagenull); + String message14 = "***************OUTPUT FILE*****************\r\n\r\n"; + support.addMailMessage(message14); + RandomAccessFile File1 = new RandomAccessFile(filename1, "rw"); + String attach = edit6.getText(); + while (File1.getFilePointer() < File1.length()) { + String message15 = File1.readLine(); + support.addMailMessage(message15); + }} + +////////if all has been entered correctly, dialog box reading "You're message has been submitted" appears +////////and screen is reset + if (support.sendMail() == true) { + submitted thesubmitted = new submitted(); + thesubmitted.setVisible(true); + clickedButton2(); + } + } catch (IOException e) {System.out.println("Error:" + e.toString());} +} + +public void clickedButton2() { +////////clears all textfields and choiceboxes back to default + edit1.setText(""); + edit2.setText(""); + edit3.setText(""); + edit4.setText(""); + edit5.setText(""); + edit6.setText(""); + edit7.setText(""); + edit8.setText(""); + group1.setSelectedCheckbox(check1); + choice1.select("user_priority"); + choice2.select("Problem?"); + choice3.select("Module/Theory?"); + choice3.select("Module/Theory?"); + choice4.select("Operation?"); + choice5.select("Platform?"); + + + + } + +} + diff --git a/contrib/javasupport/submitted.java b/contrib/javasupport/submitted.java new file mode 100644 index 0000000000..8e4a49d73d --- /dev/null +++ b/contrib/javasupport/submitted.java @@ -0,0 +1,53 @@ +// $id$ + +import java.awt.*; +import java.awt.event.*; + +public class submitted extends Frame { + + public submitted() { + + super(" "); + + //{{INIT_CONTROLS + setLayout(null); + addNotify(); + setSize(400,200); + label1=new Label("Your request has been submitted"); + label1.setFont(new Font("Dialog",Font.BOLD,14)); + add(label1); + label1.setBounds(65,75,270,25); + button1=new Button("Okay"); + add(button1); + button1.setBounds(150,100,70,30); + //}} + button1.addActionListener(new ActionListener() + { + public void actionPerformed(ActionEvent e) { + clickedButton1(); + }}); + + + } + + public synchronized void setVisible() { + setLocation(50, 50); + + } + + Label label1; + Button button1; + + public void clickedButton1() { + + setVisible(false); + } + public void windowClosing(WindowEvent event){ } + public void windowClosed(WindowEvent event) { } + public void windowDeiconified(WindowEvent event) {} + public void windowIconified(WindowEvent event) {} + public void windowActivated(WindowEvent event) {} + public void windowOpened(WindowEvent event) {} +} + + diff --git a/contrib/javasupport/whichjava.java b/contrib/javasupport/whichjava.java new file mode 100644 index 0000000000..119385ff37 --- /dev/null +++ b/contrib/javasupport/whichjava.java @@ -0,0 +1,23 @@ +// $Id: whichjava.java,v 1.1 1998-03-17 07:55:30 d3e129 Exp $ + +public class whichjava implements Runnable { + public static void main(String[] args){ + System.out.println("The Java Version in your path is " + System.getProperty("java.version")); + if (System.getProperty("java.version").indexOf("1.1")>=0){ + // System.out.println(" should be zero status" + System.getProperty("java.version").substring(0,3)); + System.exit((int)0); + } else { + // System.out.println(" should be nonzero status " + System.getProperty("java.version").substring(0,3)); + System.out.println (" This code requires Java 1.1 or greater"); + System.exit((int)1); + }; + } + + public void init(){}; + + public void start(){}; + + public void run(){}; + +} +