File azureus-4.0.0.4-boo-updating-w32.diff of Package azureus
diff -up azureus-4.5.0.0/com/aelitis/azureus/core/update/impl/AzureusRestarterImpl.java.boo-updating-w32 azureus-4.5.0.0/com/aelitis/azureus/core/update/impl/AzureusRestarterImpl.java
--- azureus-4.5.0.0/com/aelitis/azureus/core/update/impl/AzureusRestarterImpl.java.boo-updating-w32 2010-05-04 02:58:40.000000000 +0300
+++ azureus-4.5.0.0/com/aelitis/azureus/core/update/impl/AzureusRestarterImpl.java 2010-08-06 22:40:45.000000000 +0300
@@ -30,8 +30,8 @@ import org.gudy.azureus2.core3.util.*;
import org.gudy.azureus2.platform.PlatformManager;
import org.gudy.azureus2.platform.PlatformManagerFactory;
import org.gudy.azureus2.platform.unix.ScriptAfterShutdown;
-import org.gudy.azureus2.platform.win32.access.AEWin32Access;
-import org.gudy.azureus2.platform.win32.access.AEWin32Manager;
+//import org.gudy.azureus2.platform.win32.access.AEWin32Access;
+//import org.gudy.azureus2.platform.win32.access.AEWin32Manager;
import org.gudy.azureus2.plugins.PluginInterface;
import org.gudy.azureus2.plugins.platform.PlatformManagerException;
import org.gudy.azureus2.pluginsimpl.local.PluginInitializer;
@@ -252,20 +252,7 @@ AzureusRestarterImpl
PrintWriter log,
String exec )
{
- try{
- // we need to spawn without inheriting handles
-
- PlatformManager pm = PlatformManagerFactory.getPlatformManager();
-
- pm.createProcess( exec, false );
-
- return( true );
-
- }catch(Throwable e) {
- e.printStackTrace(log);
-
- return( false );
- }
+ return true;
}
@@ -303,147 +290,6 @@ AzureusRestarterImpl
String backupJavaRunString,
boolean update_only)
{
- String azRunner = null;
- File fileRestart = null;
- if (!update_only) {
- try {
- azRunner = PlatformManagerFactory.getPlatformManager().getApplicationCommandLine();
- } catch (PlatformManagerException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
-
- try {
- int result;
- AEWin32Access accessor = AEWin32Manager.getAccessor(true);
- if (accessor == null) {
- result = -123;
- } else {
- if (azRunner != null) {
- // create a batch file to run the updater, then to restart azureus
- // bceause the updater would restart azureus as administrator user
- // and confuse the user
- fileRestart = FileUtil.getUserFile("restart.bat");
- String s = "title Azureus Updater Runner\r\n";
- s += exeUpdater + " \"updateonly\"";
- for (int i = 1; i < parameters.length; i++) {
- s += " \"" + parameters[i].replaceAll("\\\"", "") + "\"";
- }
- s += "\r\n";
- s += "start \"\" \"" + azRunner + "\"";
-
- byte[] bytes;
-
- String encoding = FileUtil.getScriptCharsetEncoding();
-
- if ( encoding == null ){
- bytes = s.getBytes();
- }else{
- try{
- bytes = s.getBytes( encoding );
- }catch( Throwable e){
- e.printStackTrace();
-
- bytes = s.getBytes();
- }
- }
- FileUtil.writeBytesAsFile(fileRestart.getAbsolutePath(),bytes);
-
- result = accessor.shellExecute(null, fileRestart.getAbsolutePath(),
- null, SystemProperties.getApplicationPath(),
- AEWin32Access.SW_SHOWMINIMIZED);
- } else {
- String execEXE = "\"-J" + getClassPath().replaceAll("\\\"", "")
- + "\" ";
-
- for (int i = 0; i < properties.length; i++) {
- execEXE += "\"-J" + properties[i].replaceAll("\\\"", "") + "\" ";
- }
-
- for (int i = 0; i < parameters.length; i++) {
- execEXE += " \"" + parameters[i].replaceAll("\\\"", "") + "\"";
- }
-
- log.println("Launch via " + exeUpdater + " params " + execEXE);
- result = accessor.shellExecute(null, exeUpdater, execEXE,
- SystemProperties.getApplicationPath(), AEWin32Access.SW_NORMAL);
- }
- }
-
- /*
- * Some results:
- * 0: OOM
- * 2: FNF
- * 3: Path Not Foud
- * 5: Access Denied (User clicked cancel on admin access dialog)
- * 8: OOM
- * 11: Bad Format
- * 26: Sharing Violation
- * 27: Association incomplete
- * 28: DDE Timeout
- * 29: DDE Fail
- * 30: DDE Busy
- * 31: No Association
- * 32: DLL Not found
- * >32: OK!
- */
- log.println(" -> " + result);
-
- if (result <= 32) {
- String sErrorReason = "";
- String key = null;
-
- switch (result) {
- case 0:
- case 8:
- key = "oom";
- break;
-
- case 2:
- key = "fnf";
- break;
-
- case 3:
- key = "pnf";
- break;
-
- case 5:
- key = "denied";
- break;
-
- case 11:
- key = "bad";
- break;
-
- case -123:
- key = "nowin32";
- break;
-
- default:
- sErrorReason = "" + result;
- break;
- }
- if (key != null) {
- sErrorReason = MessageText.getString("restart.error." + key,
- new String[] {
- exeUpdater,
- SystemProperties.getApplicationPath(),
- });
- }
- Logger.log(new LogAlert(false, LogAlert.AT_ERROR,
- MessageText.getString("restart.error", new String[] {
- sErrorReason
- })));
- return false;
- }
- } catch (Throwable f) {
-
- f.printStackTrace(log);
-
- return javaSpawn(log, backupJavaRunString);
- }
-
return true;
}
@@ -461,60 +307,15 @@ AzureusRestarterImpl
String[] parameters,
boolean update_only)
{
- if(Constants.isOSX){
-
- return( restartAzureus_OSX(log,mainClass,properties,parameters));
-
- }else if( Constants.isUnix ){
+ if( Constants.isUnix ){
return( restartAzureus_Unix(log,mainClass,properties,parameters));
- }else{
-
- return( restartAzureus_win32(log,mainClass,properties,parameters,update_only));
- }
+ }
+ log.println("Shouldn't get here on Fedora");
+ return false;
}
- private boolean
- restartAzureus_win32(
- PrintWriter log,
- String mainClass,
- String[] properties,
- String[] parameters,
- boolean update_only)
- {
- String exeUpdater = getExeUpdater(log); // Not for Updater.java
-
- String exec;
-
- //Classic restart way using Runtime.exec directly on java(w)
- exec = "\"" + JAVA_EXEC_DIR + "javaw\" " + getClassPath() + getLibraryPath();
-
- for (int i = 0; i < properties.length; i++) {
- exec += properties[i] + " ";
- }
-
- exec += mainClass;
-
- for (int i = 0; i < parameters.length; i++) {
- exec += " \"" + parameters[i] + "\"";
- }
-
- if (exeUpdater != null) {
- return( restartViaEXE(log, exeUpdater, properties, parameters, exec, update_only));
- } else {
- if (log != null) {
- log.println(" " + exec);
- }
-
- if (!win32NativeRestart(log, exec)) {
- return( javaSpawn(log, exec));
- }else{
- return( true );
- }
- }
- }
-
private boolean
javaSpawn(
@@ -539,30 +340,6 @@ AzureusRestarterImpl
}
}
- private boolean
- restartAzureus_OSX(
- PrintWriter log,
- String mainClass,
- String[] properties,
- String[] parameters)
- {
-
- String exec = "\"" + JAVA_EXEC_DIR + "java\" " + getClassPath() + getLibraryPath();
-
- for (int i=0;i<properties.length;i++){
- exec += properties[i] + " ";
- }
-
- exec += mainClass ;
-
- for(int i = 0 ; i < parameters.length ; i++) {
- exec += " \"" + parameters[i] + "\"";
- }
-
- return( runExternalCommandViaUnixShell( log, exec ));
- }
-
-
private int getUnixScriptVersion() {
String sVersion = System.getProperty("azureus.script.version", "0");