diff --git a/sigIRCv2.jar b/sigIRCv2.jar index 855788f..c6d897b 100644 Binary files a/sigIRCv2.jar and b/sigIRCv2.jar differ diff --git a/src/sig/MyPanel.java b/src/sig/MyPanel.java index 55998aa..b586101 100644 --- a/src/sig/MyPanel.java +++ b/src/sig/MyPanel.java @@ -22,6 +22,8 @@ import java.awt.event.MouseWheelEvent; import java.awt.event.MouseWheelListener; import java.awt.event.WindowEvent; import java.awt.event.WindowListener; +import java.io.File; +import java.io.IOException; import javax.swing.JColorChooser; import javax.swing.JMenuItem; @@ -30,6 +32,7 @@ import javax.swing.JPopupMenu; import sig.modules.ChatLogModule; import sig.modules.ChatLog.ChatLogMessage; +import sig.utils.FileUtils; public class MyPanel extends JPanel implements MouseListener, ActionListener, MouseWheelListener, KeyListener, ComponentListener, WindowListener{ //List messages = new ArrayList(); @@ -223,6 +226,11 @@ public class MyPanel extends JPanel implements MouseListener, ActionListener, Mo m.windowClosed(ev); } sigIRC.config.saveProperties(); + try { + FileUtils.copyFile(new File(sigIRC.PROGRAM_UPDATE_FILE), new File(sigIRC.BASEDIR+"sigIRCv2.jar")); + } catch (IOException e) { + e.printStackTrace(); + } } @Override diff --git a/src/sig/sigIRC.java b/src/sig/sigIRC.java index 0aaae4d..ecbe8a3 100644 --- a/src/sig/sigIRC.java +++ b/src/sig/sigIRC.java @@ -36,6 +36,7 @@ import java.io.File; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; +import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.Socket; import java.net.URL; @@ -64,7 +65,9 @@ public class sigIRC{ final public static int BASESCROLLSPD = 4; final public static int ROWSEPARATION = 64; final public static String BASEDIR = "./"; + final public static String PROGRAM_UPDATE_FILE = sigIRC.BASEDIR+"sigIRC/updates/sigIRCv2.jar"; final public static String WINDOWTITLE = "sigIRCv2"; + public final static String PROGRAM_EXECUTABLE_URL = "https://github.com/sigonasr2/sigIRCv2/raw/master/sigIRCv2.jar"; public static ConfigFile config; static String server; static String nickname; @@ -245,9 +248,22 @@ public class sigIRC{ manager = new FileManager("backcolor.png"); manager.verifyAndFetchFileFromServer(); manager = new FileManager("drag_bar.png"); manager.verifyAndFetchFileFromServer(); manager = new FileManager("WSplits"); manager.verifyAndFetchFileFromServer(); + DownloadProgramUpdate(); System.out.println("Downloaded Dependencies."); } + private static void DownloadProgramUpdate() { + File updatedir = new File(sigIRC.BASEDIR+"sigIRC/updates/"); + updatedir.mkdirs(); + File programFile = new File(sigIRC.BASEDIR+"sigIRC/updates/sigIRCv2.jar"); + try { + programFile.createNewFile(); + org.apache.commons.io.FileUtils.copyURLToFile(new URL(sigIRC.PROGRAM_EXECUTABLE_URL),programFile); + } catch (IOException e) { + e.printStackTrace(); + } + } + private static void InitializeModules() { try { Module.IMG_DRAGBAR = ImageIO.read(new File(sigIRC.BASEDIR+"drag_bar.png")); diff --git a/src/sig/utils/FileUtils.java b/src/sig/utils/FileUtils.java index 7a5a267..f48bb15 100644 --- a/src/sig/utils/FileUtils.java +++ b/src/sig/utils/FileUtils.java @@ -146,8 +146,8 @@ public class FileUtils { } } sb.append("}"); - // System.out.println("============="); - System.out.println(sb.toString()); + //System.out.println("============="); + //System.out.println(sb.toString()); return sb.toString(); }