]> source.dussan.org Git - vaadin-framework.git/commitdiff
Do not launch Konqueror also when it is set as the default browser. Fixes #2737.
authorMarko Grönroos <magi@iki.fi>
Thu, 28 May 2009 08:14:57 +0000 (08:14 +0000)
committerMarko Grönroos <magi@iki.fi>
Thu, 28 May 2009 08:14:57 +0000 (08:14 +0000)
svn changeset:8047/svn branch:6.0

src/com/vaadin/launcher/util/BrowserLauncher.java

index f55c1bef3ec95c08b6ab4fb7856ed8e6c59123f6..9775bdc48e79220070fc6beefd7f64a0a749cc3e 100644 (file)
@@ -4,7 +4,11 @@
 \r
 package com.vaadin.launcher.util;\r
 \r
+import java.io.BufferedInputStream;\r
+import java.io.BufferedReader;\r
+import java.io.File;\r
 import java.io.IOException;\r
+import java.io.InputStreamReader;\r
 \r
 /**\r
  * This class opens default browser for DemoLauncher class. Default browser is\r
@@ -28,14 +32,36 @@ public class BrowserLauncher {
 \r
         // Linux\r
         if (os.indexOf("linux") >= 0) {\r
+            // See if the default browser is Konqueror by resolving the symlink.\r
+            boolean isDefaultKonqueror = false;\r
+            try {\r
+               // Find out the location of the x-www-browser link from path.\r
+               Process process = runtime.exec("which x-www-browser");\r
+               BufferedInputStream ins = new BufferedInputStream(process.getInputStream());\r
+               BufferedReader bufreader = new BufferedReader(new InputStreamReader(ins));\r
+               String defaultLinkPath = bufreader.readLine();\r
+               ins.close();\r
+\r
+               // The path is null if the link did not exist.\r
+               if (defaultLinkPath != null) {\r
+                       // See if the default browser is Konqueror.\r
+                       File file = new File(defaultLinkPath);\r
+                       String canonical = file.getCanonicalPath();\r
+                       if (canonical.indexOf("konqueror") != -1)\r
+                               isDefaultKonqueror = true;\r
+               }\r
+            } catch (IOException e1) {\r
+               // The symlink was probably not found, so this is ok.\r
+            }\r
 \r
-            // Try x-www-browser\r
-            if (!started) {\r
-                try {\r
-                    runtime.exec("x-www-browser " + url);\r
-                    started = true;\r
-                } catch (final IOException e) {\r
-                }\r
+            // Try x-www-browser, which is symlink to the default browser,\r
+            // except if we found that it is Konqueror.\r
+            if (!started && !isDefaultKonqueror) {\r
+               try {\r
+                       runtime.exec("x-www-browser " + url);\r
+                       started = true;\r
+               } catch (final IOException e) {\r
+               }\r
             }\r
 \r
             // Try firefox\r