From 5dd663b316e10edeef1ecdc626634c7a2116ed86 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marko=20Gr=C3=B6nroos?= Date: Thu, 28 May 2009 08:14:57 +0000 Subject: [PATCH] Do not launch Konqueror also when it is set as the default browser. Fixes #2737. svn changeset:8047/svn branch:6.0 --- .../vaadin/launcher/util/BrowserLauncher.java | 40 +++++++++++++++---- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/src/com/vaadin/launcher/util/BrowserLauncher.java b/src/com/vaadin/launcher/util/BrowserLauncher.java index f55c1bef3e..9775bdc48e 100644 --- a/src/com/vaadin/launcher/util/BrowserLauncher.java +++ b/src/com/vaadin/launcher/util/BrowserLauncher.java @@ -4,7 +4,11 @@ package com.vaadin.launcher.util; +import java.io.BufferedInputStream; +import java.io.BufferedReader; +import java.io.File; import java.io.IOException; +import java.io.InputStreamReader; /** * This class opens default browser for DemoLauncher class. Default browser is @@ -28,14 +32,36 @@ public class BrowserLauncher { // Linux if (os.indexOf("linux") >= 0) { + // See if the default browser is Konqueror by resolving the symlink. + boolean isDefaultKonqueror = false; + try { + // Find out the location of the x-www-browser link from path. + Process process = runtime.exec("which x-www-browser"); + BufferedInputStream ins = new BufferedInputStream(process.getInputStream()); + BufferedReader bufreader = new BufferedReader(new InputStreamReader(ins)); + String defaultLinkPath = bufreader.readLine(); + ins.close(); + + // The path is null if the link did not exist. + if (defaultLinkPath != null) { + // See if the default browser is Konqueror. + File file = new File(defaultLinkPath); + String canonical = file.getCanonicalPath(); + if (canonical.indexOf("konqueror") != -1) + isDefaultKonqueror = true; + } + } catch (IOException e1) { + // The symlink was probably not found, so this is ok. + } - // Try x-www-browser - if (!started) { - try { - runtime.exec("x-www-browser " + url); - started = true; - } catch (final IOException e) { - } + // Try x-www-browser, which is symlink to the default browser, + // except if we found that it is Konqueror. + if (!started && !isDefaultKonqueror) { + try { + runtime.exec("x-www-browser " + url); + started = true; + } catch (final IOException e) { + } } // Try firefox -- 2.39.5