/*
 * UbdateSearch.java
 *
 * Created on 22 maggio 2005, 2.00
 */

package it.businesslogic.ireport.plugin.checkupdate;

/**
 *
 * @author  Administrator
 */
public class UpgradeSearch implements Runnable {
    
    private CheckUpdateDialog win = null;
    public void run() {
        try {
            java.net.URL url = new java.net.URL("http://ireport.sf.net/lastversion.php");
            byte[] webBuffer = new byte[100];
            java.io.InputStream is = url.openStream();
            int readed = is.read(webBuffer);
            String version = new String(webBuffer,0,readed);
            if (version.toLowerCase().startsWith("ireport")) {
                if (version.compareTo(it.businesslogic.ireport.gui.MainFrame.constTitle) > 0) {
                    javax.swing.JOptionPane.showMessageDialog(it.businesslogic.ireport.gui.MainFrame.getMainInstance(),version +" is available on http://ireport.sf.net!");
                }
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        
        if (win != null)   win.setVisible(false);
    }

    public CheckUpdateDialog getWin() {
        return win;
    }

    public void setWin(CheckUpdateDialog win) {
        this.win = win;
    }
}

