[Mtbrowser-developers] SF.net SVN: mtbrowser: [21] trunk
Status: Beta
Brought to you by:
ipv6guru
From: <cod...@us...> - 2007-06-15 21:29:28
|
Revision: 21 http://mtbrowser.svn.sourceforge.net/mtbrowser/?rev=21&view=rev Author: coder_2020 Date: 2007-06-15 14:29:20 -0700 (Fri, 15 Jun 2007) Log Message: ----------- I added some code that start browser too in linux Added Paths: ----------- trunk/ExecuteBrowser.class trunk/ExecuteBrowser.java trunk/FindBrowserTest.class trunk/FindBrowserTest.java trunk/FindBrowsers.class trunk/FindBrowsers.java trunk/GenericFunctions.class trunk/GenericFunctions.java Added: trunk/ExecuteBrowser.class =================================================================== (Binary files differ) Property changes on: trunk/ExecuteBrowser.class ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/ExecuteBrowser.java =================================================================== --- trunk/ExecuteBrowser.java (rev 0) +++ trunk/ExecuteBrowser.java 2007-06-15 21:29:20 UTC (rev 21) @@ -0,0 +1,34 @@ +package mtbrowser; + +public class ExecuteBrowser { + private String browserName, link; + public ExecuteBrowser() + { + this("",""); + } + public ExecuteBrowser(String browserName, String link) + { + this.browserName = browserName; + this.link = link; + } + public void startBrowser() throws Exception + { + if(browserName == "" || link == "") + throw new Exception("Browser or Link is missing\n"); + + String cmd = "./startbrowser " + browserName + " " + link; + Process p = Runtime.getRuntime().exec(cmd); + + /*BufferedReader stdInput = new BufferedReader(new + InputStreamReader(p.getInputStream())); + String s = stdInput.readLine(); + return s != null ? s : "";*/ + } + public static void startBrowser(String browserName, String link)throws Exception + { + if(browserName == "" || link == "") + throw new Exception("Browser or Link is missing"); + String cmd = "./startbrowser " + browserName + " " + link; + Process p = Runtime.getRuntime().exec(cmd); + } +} Added: trunk/FindBrowserTest.class =================================================================== (Binary files differ) Property changes on: trunk/FindBrowserTest.class ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/FindBrowserTest.java =================================================================== --- trunk/FindBrowserTest.java (rev 0) +++ trunk/FindBrowserTest.java 2007-06-15 21:29:20 UTC (rev 21) @@ -0,0 +1,23 @@ +package mtbrowser; + +public class FindBrowserTest +{ + public static void main(String [] arg) + { + for(int i = 0; i < GenericFunctions.BROWSERS.length; i++) + { + if(FindBrowsers.check(GenericFunctions.BROWSERS[i]).equals("")) + System.out.println(GenericFunctions.BROWSERS[i] + " is not installed"); + else + { + System.out.println(GenericFunctions.BROWSERS[i] + " is installed"); + try{ + ExecuteBrowser.startBrowser(GenericFunctions.BROWSERS[i],"www.google.com"); + }catch(Exception e) + { + System.out.println(e.getMessage()); + } + } + } + } +} Added: trunk/FindBrowsers.class =================================================================== (Binary files differ) Property changes on: trunk/FindBrowsers.class ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/FindBrowsers.java =================================================================== --- trunk/FindBrowsers.java (rev 0) +++ trunk/FindBrowsers.java 2007-06-15 21:29:20 UTC (rev 21) @@ -0,0 +1,63 @@ +package mtbrowser; + +/* Execute a script that will find the browsers installed + */ +import java.io.*; + +public class FindBrowsers { + protected String browserName; + + public FindBrowsers(String browserName) + { + this.browserName = browserName; + } + + public FindBrowsers() + { + this(""); + } + public String Find() + { + return check(browserName); + } + public void setBrowserName(String name) + { + browserName = name; + } + public String getBrowserName() + { + return browserName; + } + + public static String check(String browserName) { + + try { + + Process p = Runtime.getRuntime().exec("./findbrowsers " + browserName); + + BufferedReader stdInput = new BufferedReader(new + InputStreamReader(p.getInputStream())); + + /*BufferedReader stdError = new BufferedReader(new + InputStreamReader(p.getErrorStream())); + + //If needed to read the whole message + /* while ((s = stdInput.readLine()) != null) { + System.out.println(s); + } + + while ((s = stdError.readLine()) != null) { + System.out.println(s); + } + + System.exit(0);*/ + String s = stdInput.readLine(); + return s != null ? s : ""; + } + catch (IOException e) { + System.out.println("exception happened: "); + e.printStackTrace(); + } + return ""; + } +} Added: trunk/GenericFunctions.class =================================================================== (Binary files differ) Property changes on: trunk/GenericFunctions.class ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/GenericFunctions.java =================================================================== --- trunk/GenericFunctions.java (rev 0) +++ trunk/GenericFunctions.java 2007-06-15 21:29:20 UTC (rev 21) @@ -0,0 +1,8 @@ +package mtbrowser; +/* + * Contains Shared Data across other classes + */ +public class GenericFunctions { + public final static String []BROWSERS = + {"firefox", "mozilla", "konqueror", "mybrowser"}; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |