summaryrefslogtreecommitdiff
path: root/Azureus-platform.patch
blob: f59baff1b2f6b25de8d974762c662a73a1736016 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
--- Azureus-3.0.3.4/com/aelitis/azureus/core/update/impl/AzureusRestarterImpl.java	2007-11-25 16:13:19.744461541 +0200
+++ Azureus-3.0.3.4-new/com/aelitis/azureus/core/update/impl/AzureusRestarterImpl.java	2007-11-25 16:07:36.824808968 +0200
@@ -30,8 +30,6 @@
 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.update.UpdaterUtils;
 
 import com.aelitis.azureus.core.AzureusCore;
@@ -297,141 +295,6 @@
 		return null;
 	}
 
-  private boolean restartViaEXE(PrintWriter log,
-  		String exeUpdater,
-      String[]  properties,
-      String[]  parameters,
-      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 + "\"";
-					FileUtil.writeBytesAsFile(fileRestart.getAbsolutePath(), s.getBytes());
-
-					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;
-	}
-  
 
   // ****************** This code is copied into Restarter / Updater so make changes there too !!!
   
@@ -446,107 +309,9 @@
     String[]  parameters,
     boolean update_only) 
   {
-    if(Constants.isOSX){
-    	
-    	restartAzureus_OSX(log,mainClass,properties,parameters);
-    	
-    }else if( Constants.isUnix ){
-    	
-    	restartAzureus_Unix(log,mainClass,properties,parameters);
-      
-    }else{
-    	
-    	restartAzureus_win32(log,mainClass,properties,parameters,update_only);
-    }
+	restartAzureus_Unix(log,mainClass,properties,parameters);
   }
   
-  private void 
-  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) {
-			restartViaEXE(log, exeUpdater, properties, parameters, exec, update_only);
-		} else {
-			if (log != null) {
-				log.println("  " + exec);
-			}
-
-			if (!win32NativeRestart(log, exec)) {
-				javaSpawn(log, exec);
-			}
-		}
-	}
-  
-
-	private boolean
-	javaSpawn(
-		PrintWriter log, 
-		String execString) 
-	{
-		try {
-			// hmm, try java method - this WILL inherit handles but might work :)
-
-			log.println("Using java spawn");
-
-			//NOTE: no logging done here, as we need the method to return right away, before the external process completes
-			Process p = Runtime.getRuntime().exec(execString);
-
-			log.println("    -> " + p);
-
-			return true;
-		} catch (Throwable g) {
-
-			g.printStackTrace();
-			return false;
-		}
-	}
-
-	private void 
-  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] + "\"";
-     }
-
-     runExternalCommandViaUnixShell( log, exec );
-  }
-  
-  
-  
   private int getUnixScriptVersion() {
 		String sVersion = System.getProperty("azureus.script.version", "0");
 		int version = 0;
--- Azureus-3.0.3.4/com/aelitis/azureus/ui/swt/views/skin/TorrentListViewsUtils.java	2007-11-25 16:13:20.004476443 +0200
+++ Azureus-3.0.3.4-new/com/aelitis/azureus/ui/swt/views/skin/TorrentListViewsUtils.java	2007-11-25 16:08:41.120493661 +0200
@@ -64,7 +64,6 @@
 import com.aelitis.azureus.ui.swt.views.TorrentListViewListener;
 import com.aelitis.azureus.util.AdManager;
 import com.aelitis.azureus.util.Constants;
-import com.aelitis.azureus.util.win32.Win32Utils;
 
 import org.gudy.azureus2.plugins.PluginInterface;
 import org.gudy.azureus2.plugins.PluginManager;
@@ -602,17 +601,6 @@
 	 * @param string
 	 */
 	private static boolean runInMediaPlayer(String mediaFile) {
-		if (Constants.isWindows) {
-			String wmpEXE = Win32Utils.getWMP();
-			if (new File(wmpEXE).exists()) {
-				try {
-					Runtime.getRuntime().exec(wmpEXE + " \"" + mediaFile + "\"");
-					return true;
-				} catch (IOException e) {
-					Debug.out("error playing " + mediaFile + " via WMP " + mediaFile, e);
-				}
-			}
-		}
 		return false;
 	}
 
--- Azureus-3.0.3.4/org/gudy/azureus2/platform/PlatformManagerFactory.java	2007-11-25 16:13:20.840524357 +0200
+++ Azureus-3.0.3.4-new/org/gudy/azureus2/platform/PlatformManagerFactory.java	2007-11-25 16:10:50.123886748 +0200
@@ -44,34 +44,8 @@
 			class_mon.enter();
 		
 			if ( platform_manager == null ){
-										  
-				try{
-					if ( getPlatformType() == PlatformManager.PT_WINDOWS ){
-						
-						platform_manager = org.gudy.azureus2.platform.win32.PlatformManagerImpl.getSingleton();
-						
-					}else if( getPlatformType() == PlatformManager.PT_MACOSX ){
-						
-	                    platform_manager = org.gudy.azureus2.platform.macosx.PlatformManagerImpl.getSingleton();
-	                    
-					}else if( getPlatformType() == PlatformManager.PT_UNIX ){
-						
-            platform_manager = org.gudy.azureus2.platform.unix.PlatformManagerImpl.getSingleton();
-
-					}
-				}catch( PlatformManagerException e ){
-					
-						// exception will already have been logged
-					
-				}catch( Throwable e ){
-					
-					Debug.printStackTrace(e);
-				}
-			}
-			
-			if ( platform_manager == null ){
 				
-				platform_manager = org.gudy.azureus2.platform.dummy.PlatformManagerImpl.getSingleton();
+				platform_manager = org.gudy.azureus2.platform.unix.PlatformManagerImpl.getSingleton();
 			}
 			
 			return( platform_manager );
--- Azureus-3.0.3.4/org/gudy/azureus2/platform/PlatformManagerPluginDelegate.java	2007-11-25 16:13:20.840524357 +0200
+++ Azureus-3.0.3.4-new/org/gudy/azureus2/platform/PlatformManagerPluginDelegate.java	2007-11-25 16:12:12.344598819 +0200
@@ -23,7 +23,6 @@
 import java.util.Properties;
 
 import org.gudy.azureus2.platform.unix.PlatformManagerUnixPlugin;
-import org.gudy.azureus2.platform.win32.PlatformManagerUpdateChecker;
 
 import org.gudy.azureus2.plugins.Plugin;
 import org.gudy.azureus2.plugins.PluginException;
@@ -45,10 +44,7 @@
 		PlatformManager platform = PlatformManagerFactory.getPlatformManager();
 
 		int platformType = platform.getPlatformType();
-		if (platformType == PlatformManager.PT_WINDOWS) {
-			PlatformManagerUpdateChecker plugin = new PlatformManagerUpdateChecker();
-			plugin.initialize(pluginInterface);
-		} else if (platformType == PlatformManager.PT_UNIX) {
+		if (platformType == PlatformManager.PT_UNIX) {
 			PlatformManagerUnixPlugin plugin = new PlatformManagerUnixPlugin();
 			plugin.initialize(pluginInterface);
 		} else {