tn5250j/src/org/tn5250j/mailtools SendEMailDialog.java,1.19,1.20

"Kenneth J. Pouncey" <[email protected]> Sat, 26 Jun 2004 11:35:54 +0000
Newsgroups gmane.comp.java.tn5250j.cvs
Message-ID <[email protected]>
Update of /cvsroot/tn5250j/tn5250j/src/org/tn5250j/mailtools
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv879

Modified Files:
	SendEMailDialog.java 
Log Message:
Fix e-mail to send

Index: SendEMailDialog.java
===================================================================
RCS file: /cvsroot/tn5250j/tn5250j/src/org/tn5250j/mailtools/SendEMailDialog.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** SendEMailDialog.java	31 Mar 2004 12:25:08 -0000	1.19
--- SendEMailDialog.java	26 Jun 2004 11:35:52 -0000	1.20
***************
*** 42,50 ****
  import org.tn5250j.tools.LangTool;
  import org.tn5250j.tools.encoder.EncodeComponent;
  
  /**
   * Send E-Mail dialog
   */
! public class SendEMailDialog implements Runnable {
  
  	JComboBox toAddress;
--- 42,51 ----
  import org.tn5250j.tools.LangTool;
  import org.tn5250j.tools.encoder.EncodeComponent;
+ import org.tn5250j.gui.TN5250jFrame;
  
  /**
   * Send E-Mail dialog
   */
! public class SendEMailDialog extends TN5250jFrame implements Runnable  {
  
  	JComboBox toAddress;
***************
*** 63,66 ****
--- 64,68 ----
     boolean sendScreen;
     SendEMail sendEMail;
+    Thread myThread = new Thread(this);
  
  	/**
***************
*** 124,137 ****
  				switch (result) {
  					case 0 : // Send it
! 						SendEMail sem = new SendEMail();
! 						sem.setConfigFile("SMTPProperties.cfg");
! 						sem.setTo((String) toAddress.getSelectedItem());
! 						sem.setSubject(subject.getText());
  						if (bodyText.getText().length() > 0)
! 							sem.setMessage(bodyText.getText());
  
  						if (attachmentName.getText().length() > 0)
! 							if (!normal.isSelected()) sem.setAttachmentName(attachmentName.getText());
! 							else sem.setAttachmentName(fileName);
  
  						if (text.isSelected()) {
--- 126,141 ----
  				switch (result) {
  					case 0 : // Send it
! 						sendEMail = new SendEMail();
! 						sendEMail.setConfigFile("SMTPProperties.cfg");
! 						sendEMail.setTo((String) toAddress.getSelectedItem());
! 						sendEMail.setSubject(subject.getText());
  						if (bodyText.getText().length() > 0)
! 							sendEMail.setMessage(bodyText.getText());
  
  						if (attachmentName.getText().length() > 0)
! 							if (!normal.isSelected())
!                         sendEMail.setAttachmentName(attachmentName.getText());
! 							else
!                         sendEMail.setAttachmentName(fileName);
  
  						if (text.isSelected()) {
***************
*** 150,154 ****
  							}
  
! 							sem.setAttachment(sb.toString());
  						}
  						else if (graphic.isSelected()){
--- 154,158 ----
  							}
  
! 							sendEMail.setAttachment(sb.toString());
  						}
  						else if (graphic.isSelected()){
***************
*** 174,178 ****
  									session,
  									f);
! 								sem.setFileName(f.getName());
  							}
  							catch (Exception ex) {
--- 178,182 ----
  									session,
  									f);
! 								sendEMail.setFileName(f.getName());
  							}
  							catch (Exception ex) {
***************
*** 183,194 ****
  						else if (attachmentName.getText().length() > 0) {
  							File f = new File(attachmentName.getText());
! 							sem.setFileName(f.toString());
  						}
  
  						// send the information
! 						sendIt(parent, sem);
  
! 						sem.release();
! 						sem = null;
  
  						break;
--- 187,198 ----
  						else if (attachmentName.getText().length() > 0) {
  							File f = new File(attachmentName.getText());
! 							sendEMail.setFileName(f.toString());
  						}
  
  						// send the information
! 						sendIt(parent, sendEMail);
  
! //						sendEMail.release();
! //						sendEMail = null;
  
  						break;
***************
*** 253,274 ****
  					case 0 : // Send it
  
! 						SendEMail sem = new SendEMail();
! 						sem.setConfigFile("SMTPProperties.cfg");
! 						sem.setTo((String) toAddress.getSelectedItem());
! 						sem.setSubject(subject.getText());
  						if (bodyText.getText().length() > 0)
! 							sem.setMessage(bodyText.getText());
  
  						if (attachmentName.getText().length() > 0)
! 							sem.setAttachmentName(attachmentName.getText());
  
  						if (fileName != null && fileName.length() > 0)
! 							sem.setFileName(fileName);
  
  						// send the information
! 						sendIt(parent, sem);
  
! 						sem.release();
! 						sem = null;
  
  						break;
--- 257,279 ----
  					case 0 : // Send it
  
!                   sendEMail = new SendEMail();
! 
! 						sendEMail.setConfigFile("SMTPProperties.cfg");
! 						sendEMail.setTo((String) toAddress.getSelectedItem());
! 						sendEMail.setSubject(subject.getText());
  						if (bodyText.getText().length() > 0)
! 							sendEMail.setMessage(bodyText.getText());
  
  						if (attachmentName.getText().length() > 0)
! 							sendEMail.setAttachmentName(attachmentName.getText());
  
  						if (fileName != null && fileName.length() > 0)
! 							sendEMail.setFileName(fileName);
  
  						// send the information
! 						sendIt(parent, sendEMail);
  
! //						sendEMail.release();
! //						sendEMail = null;
  
  						break;
***************
*** 293,298 ****
  	private void sendIt(Frame parent, SendEMail sem) {
  
!       setSendEMail(sem);
!       new Thread(this).start();
  //		if (parent == null)
  //			parent = new JFrame();
--- 298,305 ----
  	private void sendIt(Frame parent, SendEMail sem) {
  
! //      setSendEMail(sem);
! 
! //      new Thread(this).start();
!       myThread.start();
  //		if (parent == null)
  //			parent = new JFrame();
***************
*** 329,332 ****
--- 336,340 ----
        sendEMail = sem;
     }
+ 
     public void run() {
  
***************
*** 336,340 ****
  		try {
  			if (sendEMail.send()) {
! 
  //				JOptionPane.showMessageDialog(
  //					parent,
--- 344,349 ----
  		try {
  			if (sendEMail.send()) {
!             sendEMail.release();
!             sendEMail = null;
  //				JOptionPane.showMessageDialog(
  //					parent,
***************
*** 432,436 ****
  			JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
  		attachmentName = new JTextField(fileName, 30);
! 		attachmentName.setText("");
  
  		text.addItemListener(new java.awt.event.ItemListener() {
--- 441,448 ----
  			JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
  		attachmentName = new JTextField(fileName, 30);
!       if (fileName != null || fileName.length() > 0)
!          attachmentName.setText(fileName);
!       else
!    		attachmentName.setText("");
  
  		text.addItemListener(new java.awt.event.ItemListener() {



-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com