[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[vidalia-svn] r3024: Add very simple Firefox launcher (in vidalia/branches/alt-launcher/src/vidalia: . config)
Author: sjmurdoch
Date: 2008-08-30 17:09:37 -0400 (Sat, 30 Aug 2008)
New Revision: 3024
Modified:
vidalia/branches/alt-launcher/src/vidalia/config/vidaliasettings.cpp
vidalia/branches/alt-launcher/src/vidalia/config/vidaliasettings.h
vidalia/branches/alt-launcher/src/vidalia/mainwindow.cpp
vidalia/branches/alt-launcher/src/vidalia/mainwindow.h
Log:
Add very simple Firefox launcher
Modified: vidalia/branches/alt-launcher/src/vidalia/config/vidaliasettings.cpp
===================================================================
--- vidalia/branches/alt-launcher/src/vidalia/config/vidaliasettings.cpp 2008-08-30 20:28:25 UTC (rev 3023)
+++ vidalia/branches/alt-launcher/src/vidalia/config/vidaliasettings.cpp 2008-08-30 21:09:37 UTC (rev 3024)
@@ -32,6 +32,7 @@
#define SETTING_DATA_DIRECTORY "DataDirectory"
#define SETTING_SHOW_MAINWINDOW_AT_START "ShowMainWindowAtStart"
#define SETTING_BROWSER_EXECUTABLE "BrowserExecutable"
+#define SETTING_BROWSER_DIRECTORY "BrowserDirectory"
#define SETTING_IM_EXECUTABLE "IMExecutable"
#define SETTING_RUN_PROXY_AT_START "RunProxyAtStart"
#define SETTING_PROXY_EXECUTABLE "ProxyExecutable"
@@ -183,6 +184,21 @@
setValue(SETTING_BROWSER_EXECUTABLE, browserExecutable);
}
+/** Returns a fully-qualified path to the web browser directory */
+QString
+VidaliaSettings::getBrowserDirectory() const
+{
+ return QDir::convertSeparators(value(SETTING_BROWSER_DIRECTORY).toString());
+}
+
+/** Sets the location and name of the web browser directory to the given string.
+ * If set to the empty string, the browser will not be started. */
+void
+VidaliaSettings::setBrowserDirectory(const QString &browserDirectory)
+{
+ setValue(SETTING_BROWSER_DIRECTORY, browserDirectory);
+}
+
/** Returns a fully-qualified path to the IM client, including the
* executable name. */
QString
Modified: vidalia/branches/alt-launcher/src/vidalia/config/vidaliasettings.h
===================================================================
--- vidalia/branches/alt-launcher/src/vidalia/config/vidaliasettings.h 2008-08-30 20:28:25 UTC (rev 3023)
+++ vidalia/branches/alt-launcher/src/vidalia/config/vidaliasettings.h 2008-08-30 21:09:37 UTC (rev 3024)
@@ -68,6 +68,12 @@
* string. If set to the empty string, the browser will not be started. */
void setBrowserExecutable(const QString &browserExecutable);
+ /** Returns a fully-qualified path to the web browser directory */
+ QString getBrowserDirectory() const;
+ /** Sets the location and name of the web browser directory to the given string.
+ * If set to the empty string, the browser will not be started. */
+ void setBrowserDirectory(const QString &browserDirectory);
+
/** Returns a fully-qualified path to the IM client, including the
* executable name. */
QString getIMExecutable() const;
Modified: vidalia/branches/alt-launcher/src/vidalia/mainwindow.cpp
===================================================================
--- vidalia/branches/alt-launcher/src/vidalia/mainwindow.cpp 2008-08-30 20:28:25 UTC (rev 3023)
+++ vidalia/branches/alt-launcher/src/vidalia/mainwindow.cpp 2008-08-30 21:09:37 UTC (rev 3024)
@@ -141,7 +141,6 @@
this, SLOT(onSubprocessFinished(int, QProcess::ExitStatus)));
connect(_browserProcess, SIGNAL(startFailed(QString)),
this, SLOT(onBrowserFailed(QString)));
- _browserProcess->setEnvironment(QProcess::systemEnvironment() << "TZ=UTC");
/* Create a new HelperProcess object, used to start the IM client */
_imProcess = new HelperProcess(this);
@@ -449,20 +448,55 @@
#endif
}
+/** Start a web browser when given the directory containing the executable and profile */
+void
+MainWindow::launchBrowserFromDirectory(const QString &browserDirectory)
+{
+ /* Set TZ=UTC (to stop leaking timezone information) and
+ * MOZ_NO_REMOTE=1 (to allow multiple instances of Firefox */
+ QStringList env = QProcess::systemEnvironment();
+ env << "TZ=UTC";
+ env << "MOZ_NO_REMOTE=1";
+ _browserProcess->setEnvironment(env);
+
+ /* The browser is in DIR/App/Firefox/firefox.exe */
+ QString browserExecutable =
+ QDir::toNativeSeparators(browserDirectory + "/App/Firefox/firefox.exe");
+ /* The profile is in DIR/Data/Firefox/profile */
+ QString profileDir =
+ QDir::toNativeSeparators(browserDirectory + "/Data/Firefox/profile");
+
+ /* Build the command line arguments */
+ QStringList commandLine;
+ commandLine << "-profile";
+ commandLine << profileDir;
+
+ /* Launch the browser */
+ _browserProcess->start(browserExecutable, commandLine);
+}
+
/** Starts the web browser and IM client, if appropriately configured */
void
MainWindow::startSubprocesses()
{
VidaliaSettings settings;
- QString executable = settings.getBrowserExecutable();
-
- if (!executable.isEmpty())
- _browserProcess->start(executable, QStringList());
+ QString subprocess;
- executable = settings.getIMExecutable();
+ /* Launch the web browser */
+ if (!(subprocess = settings.getBrowserDirectory()).isEmpty()) {
+ /* The user has set BrowserDirectory; use this */
+ launchBrowserFromDirectory(subprocess);
+ } else if (!(subprocess = settings.getBrowserExecutable()).isEmpty()) {
+ /* BrowserDirectory is not set, but BrowserExecutable is; use this */
+ _browserProcess->setEnvironment(QProcess::systemEnvironment() << "TZ=UTC");
+ _browserProcess->start(subprocess, QStringList());
+ }
- if (!executable.isEmpty())
- _imProcess->start(executable, QStringList());
+ /* Launch the IM client */
+ subprocess = settings.getIMExecutable();
+
+ if (!subprocess.isEmpty())
+ _imProcess->start(subprocess, QStringList());
}
Modified: vidalia/branches/alt-launcher/src/vidalia/mainwindow.h
===================================================================
--- vidalia/branches/alt-launcher/src/vidalia/mainwindow.h 2008-08-30 20:28:25 UTC (rev 3023)
+++ vidalia/branches/alt-launcher/src/vidalia/mainwindow.h 2008-08-30 21:09:37 UTC (rev 3024)
@@ -139,6 +139,8 @@
/** Updates the UI to reflect Tor's current <b>status</b>. Returns the
* previously set TorStatus value. */
TorStatus updateTorStatus(TorStatus status);
+ /** Start a web browser when given the directory containing the executable and profile */
+ void launchBrowserFromDirectory(const QString &browserDirectory);
/** Starts the web browser, if appropriately configured */
void startSubprocesses();
/** Starts the proxy server, if appropriately configured */