org/gudy/azureus2/update/Updater.java | 518 +-------------------------------- plugin.properties | 4 +- 2 files changed, 3 insertions(+), 519 deletions(-) diff --git a/org/gudy/azureus2/update/Updater.java b/org/gudy/azureus2/update/Updater.java index dada757..2546400 100644 --- a/org/gudy/azureus2/update/Updater.java +++ b/org/gudy/azureus2/update/Updater.java @@ -30,20 +30,7 @@ import java.net.*; public class Updater { - private static String MAIN_CLASS = "org.gudy.azureus2.ui.swt.Main"; - private static final String UPDATER_JAR = "Updater.jar"; - public static final String LOG_FILE_NAME = "update.log"; - public static final String UPDATE_PROPERTIES = "update.properties"; - - private static String JAVA_EXEC_DIR = System.getProperty("java.home") + - System.getProperty("file.separator") + - "bin" + - System.getProperty("file.separator"); - - - protected static String APPLICATION_NAME = "Azureus"; - protected static String APPLICATION_CMD = null; // change these and you'll need to change the UpdateInstaller !!!! @@ -184,110 +171,12 @@ Updater return; - }else{ - - if ( isWindows ){ - - // 2.2.0.0 shagged restart. unicode still not working. we end up with a user dir - // of, say, C:\Documents and Settings\t?stt?st\Application Data\Azureus - // with the unicode chars replaced with something unspeakable - - try{ - File up_file = new File( user_path ); - - if ( !up_file.exists()){ - - log.println( "user path not found, attempting to fix" ); - - // see if we can patch things up - - String user_home = System.getProperty( "user.home" ); - - File az_config = findConfig(new File( user_home )); - - if ( az_config != null ){ - - log.println( " found config in " + az_config.toString() + ", using parent as user dir" ); - - user_path = az_config.getParent(); - } - - } - }catch( Throwable e ){ - - e.printStackTrace( log ); - } - } } waitForAzureusClose( log ); FileInputStream fis = null; - try{ - - File props_file = new File( user_path, UPDATE_PROPERTIES ); - - if ( props_file.exists()){ - - update_properties.load( new FileInputStream( props_file )); - - Iterator it = update_properties.keySet().iterator(); - - log.println("Loaded 'update.properties'" ); - - while( it.hasNext()){ - - String key = (String)it.next(); - - log.println( " " + key + " = " + update_properties.get(key)); - } - - String app_name = (String)update_properties.get( "app_name" ); - - if ( app_name != null && app_name.trim().length() > 0 ){ - - APPLICATION_NAME = app_name.trim(); - } - - String app_entry = (String)update_properties.get( "app_entry" ); - - if ( app_entry != null && app_entry.trim().length() > 0 ){ - - MAIN_CLASS = app_entry.trim(); - } - - String app_cmd = (String)update_properties.get( "app_cmd" ); - - if ( app_cmd != null && app_cmd.trim().length() > 0 ){ - - APPLICATION_CMD = app_cmd.trim(); - } - - }else{ - - log.println( "No update.properties found" ); - - } - }catch( Throwable e ){ - - log.println( "Failed to read update.properties" ); - - e.printStackTrace( log ); - - }finally{ - if ( fis != null ){ - - try{ - fis.close(); - - }catch( Throwable e ){ - - e.printStackTrace( log ); - } - } - } - File update_dir = new File( user_path, UPDATE_DIR ); File[] inst_dirs = update_dir.listFiles(); @@ -317,79 +206,6 @@ Updater } }finally{ - if ( do_restart ){ - - if ( log != null ){ - - log.println( "Restarting " + APPLICATION_NAME ); - } - - String vendor = System.getProperty( "java.vm.vendor" ); - - Vector vm_args = new Vector(); - - // only for Sun JVM - - if ( vendor != null && vendor.toLowerCase().startsWith( "sun" )){ - - String max_mem = (String)update_properties.get( "max_mem" ); - - // for previous versions we default to 128m - - long max_mem_l = 0; - - if ( max_mem == null ){ - - max_mem_l = 128*1024*1024; - - }else{ - - try{ - - max_mem_l = Long.parseLong( max_mem ); - - }catch( Throwable e ){ - - e.printStackTrace( log ); - } - - } - - // don't allow < 64m to be specified - - if ( max_mem_l < 64*1024*1024 ){ - - max_mem_l = 64*1024*1024; - } - - vm_args.add( "-Xmx" + (max_mem_l/(1024*1024)) + "m" ); - } - - vm_args.add( "-Duser.dir=\"" + app_path + "\"" ); - - if ( config_override.length() > 0 ){ - - vm_args.add( "-Dazureus.config.path=\"" + config_override + "\"" ); - } - - String[] props = new String[vm_args.size()]; - - vm_args.toArray( props ); - - restartAzureus( log, MAIN_CLASS, props, new String[0] ); - - if ( log != null ){ - - log.println( "Restart initiated" ); - } - }else{ - - if ( log != null ){ - - log.println( "Not restarting " + APPLICATION_NAME ); - } - } - if ( log != null ){ log.close(); @@ -397,39 +213,6 @@ Updater } } - protected File - findConfig( - File dir ) - { - File[] files = dir.listFiles(); - - if ( files != null ){ - - for (int i=0;i " + version ); - return version; - } - - private void - restartAzureus_Linux( - PrintWriter log, - String mainClass, - String[] properties, - String[] parameters) - { - if (getUnixScriptVersion( log ) >= 1) { - // Already setup for restart by core and script - - log.println( "restartLinux: script performing restart"); - - return; - } - - String exec = "\"" + JAVA_EXEC_DIR + "java\" " + getClassPath() + getLibraryPath(); - - for (int i=0;i 0 ){ - - libraryPath = "-Djava.library.path=\"" + libraryPath + "\" "; - } - } - - return( libraryPath ); - } - - - private void logStream(String message,InputStream stream,PrintWriter log) { BufferedReader br = new BufferedReader (new InputStreamReader(stream)); String line = null; @@ -1083,24 +609,6 @@ Updater } - private Process runExternalCommandLogged( PrintWriter log, String command ) { //NOTE: will not return until external command process has completed - log.println("About to execute: U:[" +command+ "]" ); - - try { - Process runner = Runtime.getRuntime().exec( command ); - runner.waitFor(); - logStream( "runtime.exec() output:", runner.getInputStream(), log); - logStream( "runtime.exec() error:", runner.getErrorStream(), log); - return runner; - } - catch( Throwable t ) { - log.println( t.getMessage() != null ? t.getMessage() : "" ); - log.println( t ); - t.printStackTrace( log ); - return null; - } - } - private Process runExternalCommandsLogged( PrintWriter log, String[] commands ) { //NOTE: will not return until external command process has completed String cmd = "About to execute: U:["; for( int i=0; i < commands.length; i++ ) { @@ -1127,28 +635,4 @@ Updater } - private void runExternalCommandViaUnixShell( PrintWriter log, String command ) { - String[] to_run = new String[3]; - to_run[0] = "/bin/sh"; - to_run[1] = "-c"; - to_run[2] = command; - - if( log != null ) log.println("Executing: U:[" +to_run[0]+ " " +to_run[1]+ " " +to_run[2]+ "]" ); - - try { - //NOTE: no logging done here, as we need the method to return right away, before the external process completes - Runtime.getRuntime().exec( to_run ); - } - catch(Throwable t) { - if( log != null ) { - log.println( t.getMessage() != null ? t.getMessage() : "" ); - log.println( t ); - t.printStackTrace( log ); - } - else { - t.printStackTrace(); - } - } - } - - } \ No newline at end of file + } diff --git a/plugin.properties b/plugin.properties index e485c9e..ae6718f 100644 --- a/plugin.properties +++ b/plugin.properties @@ -1,3 +1,3 @@ -plugin.class=org.gudy.azureus2.update.UpdaterUpdateChecker;org.gudy.azureus2.update.UpdaterPatcher -plugin.name=Azureus Update Support;Azureus Updater Support Patcher +plugin.class=org.gudy.azureus2.update.UpdaterUpdateChecker +plugin.name=Azureus Update Support plugin.version=1.8.6