X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Forg%2Fxwt%2FPlatform.java;h=39a480f91b329984a07119b7c27a759345871b20;hb=36c7cba0672b0b0ac61f484a918a34969100ca92;hp=a4b67db75d92c3137e37c6be1f0cec0d3adf07cf;hpb=bcc8b1b4cf4e4801d218151e6a7f9961972d91c1;p=org.ibex.core.git diff --git a/src/org/xwt/Platform.java b/src/org/xwt/Platform.java index a4b67db..39a480f 100644 --- a/src/org/xwt/Platform.java +++ b/src/org/xwt/Platform.java @@ -21,14 +21,20 @@ public class Platform { // Static Data ///////////////////////////////////////////////////////////////////////////////////// - /** set to true during the delivery of a KeyPressed:C-v/A-v or Press3; it is safe to use a 'global' here, - * since message delivery is single-threaded and non-preemptable + /** + * set to true during the delivery of a KeyPressed:C-v/A-v or Press3; it is safe to use a + * 'global' here, since message delivery is single-threaded and non-preemptable */ static boolean clipboardReadEnabled = false; /** The appropriate Platform object for this JVM */ static Platform platform = null; + /** true if proxy autodetection has already been run */ + static boolean alreadyDetectedProxy = false; + + /** the result of proxy autodetection */ + static HTTP.ProxyInfo cachedProxyInfo = null; // VM Detection Logic ///////////////////////////////////////////////////////////////////// @@ -47,8 +53,8 @@ public class Platform { String os_name = System.getProperty("os.name", ""); String platform_class = null; - if (os_name.startsWith("Mac OS X")) platform_class = "MacOSX"; - else if (vendor.startsWith("Free Software Foundation")) platform_class = "Win32"; + //if (os_name.startsWith("Mac OS X")) platform_class = "MacOSX"; + if (vendor.startsWith("Free Software Foundation")) platform_class = "Win32"; 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"; @@ -58,6 +64,7 @@ public class Platform { platform = (Platform)Class.forName("org.xwt.plat." + platform_class).newInstance(); platform.init(); } + 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); @@ -162,6 +169,12 @@ public class Platform { return; } + /** Returns true iff the platform detected that it should be using a proxy. + * The platform implementation should cache the result. + * This method will only be called if a connection attempt failed + */ + protected synchronized HTTP.ProxyInfo _detectProxy() { return null; } + // Static methods -- thunk to the instance ///////////////////////////////////////////////////////////////////////// /** if true, org.xwt.Surface should generate Click messages automatically when a Release happens after a Press and the mouse has not moved much */ @@ -218,7 +231,7 @@ public class Platform { /** creates and returns a picture */ public static Picture createPicture(ImageDecoder i) { return platform._createPicture(i.getData(), i.getWidth(), i.getHeight()); } - /** creates and returns a picture */ + /** opens a new browser window */ public static void newBrowserWindow(String url) { if (!(url.startsWith("https://") || url.startsWith("http://") || url.startsWith("ftp://") || url.startsWith("mailto:"))) { if (Log.on) Log.log(Platform.class, "xwt.newBrowserWindow() only supports http and https urls"); @@ -270,6 +283,28 @@ public class Platform { return ret; } + /** detects proxy settings */ + public static synchronized HTTP.ProxyInfo detectProxy() { + + if (cachedProxyInfo != null) return cachedProxyInfo; + if (alreadyDetectedProxy) return null; + alreadyDetectedProxy = true; + + if (Log.on) Log.log(Platform.class, "attempting xwt-proxy DNS proxy detection"); + cachedProxyInfo = HTTP.ProxyInfo.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; + } + // Helpful font parsing stuff ////////////////////////////////////////////////////// public static class ParsedFont { @@ -322,3 +357,4 @@ public class Platform { } +