2003/02/25 22:09:41
[org.ibex.core.git] / src / org / xwt / Platform.java
index dc706f5..1b6056a 100644 (file)
@@ -34,7 +34,7 @@ public class Platform {
     static boolean alreadyDetectedProxy = false;
 
     /** the result of proxy autodetection */
-    static HTTP.ProxyInfo cachedProxyInfo = null;
+    static Proxy cachedProxyInfo = null;
 
     /** the current build */
     public static String build = "unknown";
@@ -49,21 +49,25 @@ public class Platform {
     // reflection.
 
     static {
-        System.out.println("Detecting JVM...");
+        System.err.println("Detecting JVM...");
         try {
             String vendor = System.getProperty("java.vendor", "");
             String version = System.getProperty("java.version", "");
             String os_name = System.getProperty("os.name", "");
+            String os_version = System.getProperty("os.version", "");
             String platform_class = null;
             
             //if (os_name.startsWith("Mac OS X")) platform_class = "MacOSX";
             if (vendor.startsWith("Free Software Foundation")) {
                 if (os_name.startsWith("Window")) platform_class = "Win32";
-                else platform_class = "POSIX";
+                else platform_class = "X11";
             } else if (version.startsWith("1.1") && vendor.startsWith("Netscape")) platform_class = "Netscape";
             else if (version.startsWith("1.1") && vendor.startsWith("Microsoft")) platform_class = "Microsoft";
-            else if (version.startsWith("1.4")) platform_class = "Java14";
-            else if (!version.startsWith("1.0") && !version.startsWith("1.1")) platform_class = "Java12";
+            else if (!version.startsWith("1.0") && !version.startsWith("1.1")) platform_class = "Java2";
+
+        // Disable 2d hardware acceleration on Jaguar
+        if (os_name.equals("Mac OS X") && os_version.equals("10.2"))
+        System.setProperty("com.apple.hwaccel", "false");
 
             if (platform_class != null) {
                 platform = (Platform)Class.forName("org.xwt.plat." + platform_class).newInstance();
@@ -81,7 +85,7 @@ public class Platform {
 
             if (Log.on) Log.log(Platform.class, "XWT VM detection:   vendor = " + vendor);
             if (Log.on) Log.log(Platform.class, "                   version = " + version);
-            if (Log.on) Log.log(Platform.class, "                        os = " + os_name);
+            if (Log.on) Log.log(Platform.class, "                        os = " + os_name + " [version " + os_version + "]");
             if (Log.on && Main.applet != null) Log.log(Platform.class, "                   browser = " + Main.applet.getParameter("browser"));
 
             if (platform_class == null) {
@@ -201,7 +205,7 @@ public class Platform {
     }
 
     /** Returns null if XWT should always use direct connection; otherwise returns a ProxyInfo object with proxy settings */
-    protected synchronized HTTP.ProxyInfo _detectProxy() { return null; }
+    protected synchronized Proxy _detectProxy() { return null; }
 
     /** displays a platform-specific "open file" dialog and returns the chosen filename, or null if the user hit cancel */
     protected String _fileDialog(String suggestedFileName, boolean write) { return null; }
@@ -214,9 +218,13 @@ public class Platform {
         try {
             String os = System.getProperty("os.name").toLowerCase();
             Process p;
-            if (os.indexOf("windows 9") > -1) {
+            if (os.indexOf("windows 9") != -1 || os.indexOf("windows me") != -1) {
+                // hack -- jdk1.2/1.3 on Win32 pop open an ugly DOS box; 1.4 does not
+                if (platform.getClass().getName().endsWith("Java12")) return null;
                 p = Runtime.getRuntime().exec("command.com /c set");
-            } else if ( (os.indexOf("nt") > -1) || (os.indexOf("windows 2000") > -1) ) {
+            } else if (os.indexOf("windows") > -1) {
+                // hack -- jdk1.2/1.3 on Win32 pop open an ugly DOS box; 1.4 does not
+                if (platform.getClass().getName().endsWith("Java12")) return null;
                 p = Runtime.getRuntime().exec("cmd.exe /c set");
             } else {  
                 p = Runtime.getRuntime().exec("env");
@@ -376,24 +384,20 @@ public class Platform {
     }
 
     /** detects proxy settings */
-    public static synchronized HTTP.ProxyInfo detectProxy() {
+    public static synchronized Proxy detectProxy() {
 
         if (cachedProxyInfo != null) return cachedProxyInfo;
         if (alreadyDetectedProxy) return null;
         alreadyDetectedProxy = true;
 
         if (Log.on) Log.log(Platform.class, "attempting environment-variable DNS proxy detection");
-        cachedProxyInfo = HTTP.ProxyInfo.detectProxyViaManual();
+        cachedProxyInfo = Proxy.detectProxyViaManual();
         if (cachedProxyInfo != null) return cachedProxyInfo;
 
         if (Log.on) Log.log(Platform.class, "attempting " + platform.getClass().getName() + " proxy detection");
         cachedProxyInfo = platform._detectProxy();
         if (cachedProxyInfo != null) return cachedProxyInfo;
 
-        if (Log.on) Log.log(Platform.class, "attempting WPAD proxy detection");
-        cachedProxyInfo = HTTP.ProxyInfo.detectProxyViaWPAD();
-        if (cachedProxyInfo != null) return cachedProxyInfo;
-
         return cachedProxyInfo;
     }