1 /* 2 * This program is free software; you can redistribute it and/or 3 * modify it under the terms of the GNU General Public License as 4 * published by the Free Software Foundation; either version 2 of the 5 * License, or (at your option) any later version. 6 * 7 * This program is distributed in the hope that it will be useful, but 8 * WITHOUT ANY WARRANTY; without even the implied warranty of 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOUSE. See the GNU 10 * General Public License for more details. 11 * 12 * You should have recieved a copy of the GNU General Public License 13 * along with this program; if not write to the Free Software 14 * Foundation, inc., 59 Temple Place, Suite 330, Boston MA 02111-1307 15 * USA 16 */ 17 18 package gui; 19 20 /** 21 * 22 * @author Yuriy Mikhaylovskiy 23 * @email YuriyMikhaylovskiy@yahoo.com 24 * 25 */ 26 27 import javax.swing.*; 28 import java.awt.*; 29 import java.io.*; 30 import java.net.*; 31 import java.util.*; 32 33 public class ImpactGUINewVersionInfo extends Thread{ 34 String VERSION; 35 ImpactGUINewVersionInfo(String version)36 public ImpactGUINewVersionInfo(String version){ 37 VERSION = version; 38 } 39 run()40 public void run() { 41 String st = ""; 42 try { 43 Thread.sleep(10000); 44 URL url = new URL("ftp://www.mirrorservice.org/sites/kent.dl.sourceforge.net/pub/sourceforge/i/project/im/impact/impact/"); 45 URLConnection urlc = url.openConnection(); 46 InputStream in = urlc.getInputStream(); 47 int b; 48 while((b=in.read())!=-1){ 49 st+=(char)b; 50 } 51 in.close(); 52 StringTokenizer stt = new StringTokenizer(st," \t\n"); 53 int ver_ftp = 0; 54 int ver_impact = getVersion(VERSION); 55 while(stt.hasMoreTokens()){ 56 String st1 = stt.nextToken(); 57 ver_ftp = Math.max(ver_ftp, getVersion(st1)); 58 } 59 System.out.println("New Impact Version: "+ver_ftp); 60 System.out.println("Current Impact Version: "+ver_impact); 61 if(ver_ftp>ver_impact){ 62 int res = JOptionPane.showConfirmDialog(null,"A new version Impact "+ver_ftp+" is available!"+"\n"+"Current version Impact "+ver_impact+"\n"+"Open site for downloading?","A new version Impact is available!",JOptionPane.YES_NO_OPTION); 63 if(res==0) try{ Desktop.getDesktop().browse( new URI("http://sourceforge.net/projects/impact/")); }catch(Exception e1) { } 64 } 65 }catch(Exception e){} 66 } 67 getVersion(String st)68 private int getVersion(String st){ 69 int v = 0; 70 String res = ""; 71 try { 72 if(st.indexOf('.')!=-1){ 73 StringTokenizer stt = new StringTokenizer(st,"impactIMPACTjmcadJMCAD_=+!@#$%^&*()|[]{}:;\"',`~/-.zipZIPtTrRlLwWnNeEbBqQyYuUoOsSfFgGhHkKxXvV \t\n"); 74 while(stt.hasMoreTokens()){ 75 res += stt.nextToken(); 76 77 } 78 v = Integer.parseInt(res); 79 } 80 }catch(Exception e){} 81 return v; 82 } 83 84 } 85