D:\DEV\PROJECTS\Harbor_Mailer_Lib\src\kewlstuff\mailer\test\ui\CDTestUnit.java
/*
 * CDTestUnit.java
 */

package kewlstuff.mailer.test.ui;
import kewlstuff.mailer.test.ui.interfaces.*;
import kewlstuff.harbor.mailer.MailEngine;
import kewlstuff.harbor.mailer.interfaces.*;

/**
 *
 * @author Johnny Kewl
 * The Coherent Disintegration unit, *this* is the heart of the control.
 * In the sample UI test we did it differently, we passed all the objects
 * into the UI test... had to do that there because its a very good way to
 * test if those remote objects can still be used in another object.
 * But the way I prefer is to actually do everything in the CDUnit, and then
 * only it gets passed into the UI... it makes the UI program very clean
 * but more important, it makes the CD Unit the absolute remote control.
 * If you ever wanted to dump this UI, you will find with just a few changes
 * this CD unit can be used in a million other things... ie all the MailEngine
 * controls needed are already sitting here.
 * As you know the *Harbor CD unit* (ship) mimics this one... and in fact you will be
 * able to embed that CD unit in just about anything... see where this is going?
 * If I gave you (where ever you are), the actual Harbor CD Unit Code (The Ship), then
 * if you (where ever you are) put that into your program (there), it would use
 * my MailEngine (here).... 
 * 
 */
public class CDTestUnit  implements I_CDTestUnit{
    I_MailEngine i_MailEngine = null;
    
    
    /** Creates a new instance of CDTestUnit */
    public CDTestUnit() {
    }
    
    public boolean startServer(String smtp){
        if(!i_MailEngine.isRunning()){
            if(i_MailEngine.prepareSession(smtp)){
                 i_MailEngine.startMailer(true); //turn on debug
                 return true;
            }
        }
        return false;
    }
    
    
    public I_MailPackage getFirstFailedMail(){
        return i_MailEngine.getFirstFailedMail();
    }
    
    public void stopServer(){
        i_MailEngine.stopMailer();
    }
    
    public boolean qEmail(String to, String from, String subject, String sMessage){
        return i_MailEngine.queueMail(to, from, subject, sMessage,null, null);
    } 
    
    public int getQSize(){
        return i_MailEngine.getMailQueueSize();
    }    
    
    public void start(){
        i_MailEngine = new MailEngine();
        I_UI i_UI = new UI();
        i_UI.start(this); //pass in callback so UI program can use CD_Unit
    }
    
    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        new CDTestUnit().start();
    }
}


Models, Models, Models! Free Modeling Portfolio! ModelCoast. Photographers! Free Photographic Portfolios. Imagegods. Visit The Best Free Image Hosting.