[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[vidalia-svn] r3948: Added code to detect if the proxy is running. HomePanel uses (in vidalia/branches/extension-api/src/vidalia: . HomePlugin)
Author: tyree731
Date: 2009-07-08 03:00:52 -0400 (Wed, 08 Jul 2009)
New Revision: 3948
Modified:
vidalia/branches/extension-api/src/vidalia/HomePlugin/HomePanel.cpp
vidalia/branches/extension-api/src/vidalia/HomePlugin/HomePanel.h
vidalia/branches/extension-api/src/vidalia/HomePlugin/HomePlugin.cpp
vidalia/branches/extension-api/src/vidalia/MainWindow.cpp
vidalia/branches/extension-api/src/vidalia/MainWindow.h
vidalia/branches/extension-api/src/vidalia/PluginManager.cpp
vidalia/branches/extension-api/src/vidalia/PluginManager.h
Log:
Added code to detect if the proxy is running. HomePanel uses this to update its status/
Modified: vidalia/branches/extension-api/src/vidalia/HomePlugin/HomePanel.cpp
===================================================================
--- vidalia/branches/extension-api/src/vidalia/HomePlugin/HomePanel.cpp 2009-07-08 05:48:55 UTC (rev 3947)
+++ vidalia/branches/extension-api/src/vidalia/HomePlugin/HomePanel.cpp 2009-07-08 07:00:52 UTC (rev 3948)
@@ -75,6 +75,32 @@
}
void
+HomePanel::proxyStarted()
+{
+ ui.lblProxyStatusImg->setPixmap(QPixmap(":/images/48x48/tor-on.png"));
+ ui.lblProxyStatus->setText(tr("Your proxy server appears to be up and running."));
+ ui.lblStartProxyImg->setPixmap(QPixmap(":/images/48x48/media-playback-stop.png"));
+ ui.lblStartProxy->setText("Stop Proxy");
+
+ /* Disconnect and reconnect proxy start signals */
+ disconnect(ui.lblStartProxy, SIGNAL(clicked()), this, 0);
+ connect(ui.lblStartProxy, SIGNAL(clicked()), this, SIGNAL(stopProxy()));
+}
+
+void
+HomePanel::proxyStopped()
+{
+ ui.lblProxyStatusImg->setPixmap(QPixmap(":/images/48x48/tor-off.png"));
+ ui.lblProxyStatus->setText(tr("Polipo does not appear to be running."));
+ ui.lblStartProxyImg->setPixmap(QPixmap(":/images/48x48/media-playback-start.png"));
+ ui.lblStartProxy->setText(tr("Start Proxy"));
+
+ /* Disconnect and reconnect proxy start signals */
+ disconnect(ui.lblStartProxy, SIGNAL(clicked()), this, 0);
+ connect(ui.lblStartProxy, SIGNAL(clicked()), this, SIGNAL(startProxy()));
+}
+
+void
HomePanel::torStarting()
{
#if 0
Modified: vidalia/branches/extension-api/src/vidalia/HomePlugin/HomePanel.h
===================================================================
--- vidalia/branches/extension-api/src/vidalia/HomePlugin/HomePanel.h 2009-07-08 05:48:55 UTC (rev 3947)
+++ vidalia/branches/extension-api/src/vidalia/HomePlugin/HomePanel.h 2009-07-08 07:00:52 UTC (rev 3948)
@@ -52,6 +52,11 @@
void proxyFrameChanged(int frame);
/** Update status to next frame of animation */
void torFrameChanged(int frame);
+
+ /** Updates interface to show proxy started */
+ void proxyStarted();
+ /** Updates interface to show proxy stopped */
+ void proxyStopped();
/** Updates interface to show tor starting */
void torStarting();
/** Updates interface to show tor started */
Modified: vidalia/branches/extension-api/src/vidalia/HomePlugin/HomePlugin.cpp
===================================================================
--- vidalia/branches/extension-api/src/vidalia/HomePlugin/HomePlugin.cpp 2009-07-08 05:48:55 UTC (rev 3947)
+++ vidalia/branches/extension-api/src/vidalia/HomePlugin/HomePlugin.cpp 2009-07-08 07:00:52 UTC (rev 3948)
@@ -68,6 +68,10 @@
_homePanel, SLOT(torStopping()));
connect(_pluginManager, SIGNAL(torStopped()),
_homePanel, SLOT(torStopped()));
+ connect(_pluginManager, SIGNAL(proxyStarted()),
+ _homePanel, SLOT(proxyStarted()));
+ connect(_pluginManager, SIGNAL(proxyStopped()),
+ _homePanel, SLOT(proxyStopped()));
/* Connect panel signals to the plugin manager */
connect(_homePanel, SIGNAL(newIdentity()),
Modified: vidalia/branches/extension-api/src/vidalia/MainWindow.cpp
===================================================================
--- vidalia/branches/extension-api/src/vidalia/MainWindow.cpp 2009-07-08 05:48:55 UTC (rev 3947)
+++ vidalia/branches/extension-api/src/vidalia/MainWindow.cpp 2009-07-08 07:00:52 UTC (rev 3948)
@@ -179,17 +179,23 @@
/* Create a new HelperProcess object, used to start the proxy server */
_proxyProcess = new HelperProcess(this);
connect(_proxyProcess, SIGNAL(startFailed(QString)),
- this, SLOT(onProxyFailed(QString)));
+ this, SLOT(onProxyFailed(QString)));
+ connect(_proxyProcess, SIGNAL(started()), this, SLOT(onProxyStarted()));
+ connect(_proxyProcess, SIGNAL(finished(int,QProcess::ExitStatus)),
+ this, SLOT(onProxyTerminated(int,QProcess::ExitStatus)));
/* Catch signals when the application is running or shutting down */
connect(vApp, SIGNAL(running()), this, SLOT(running()));
connect(vApp, SIGNAL(aboutToQuit()), this, SLOT(aboutToQuit()));
- /* Allow plugin manager to start/stop tor, request new identity */
+ /* Allow plugin manager to start/stop tor, request new identity, etc */
connect(_pluginManager, SIGNAL(newIdentityRequest()),
this, SLOT(newIdentity()));
connect(_pluginManager, SIGNAL(startTorRequest()), this, SLOT(start()));
connect(_pluginManager, SIGNAL(stopTorRequest()), this, SLOT(stop()));
+ connect(_pluginManager, SIGNAL(startProxyRequest()),
+ this, SLOT(startProxy()));
+ connect(_pluginManager, SIGNAL(stopProxyRequest()), this, SLOT(stopProxy()));
#if defined(USE_AUTOUPDATE)
/* Create a timer used to remind us to check for software updates */
@@ -846,6 +852,13 @@
_proxyProcess->start(executable, settings.getProxyExecutableArguments());
}
+/** Stops the proxy server, if thats what you want to do */
+void
+MainWindow::stopProxy()
+{
+ _proxyProcess->terminate();
+}
+
/** Called when the proxy server fails to start, for example, because
* the path specified didn't lead to an executable. */
void
@@ -859,6 +872,20 @@
VMessageBox::Ok|VMessageBox::Default|VMessageBox::Escape);
}
+void
+MainWindow::onProxyStarted()
+{
+ /* Notify the Plugin Manager */
+ _pluginManager->sendProxyStatus(pmStarted);
+}
+
+void
+MainWindow::onProxyTerminated(int exitCode, QProcess::ExitStatus exitStatus)
+{
+ /* Notify the Plugin Manager */
+ _pluginManager->sendProxyStatus(pmStopped);
+}
+
/** Called when Tor's bootstrapping status changes. <b>bse</b> represents
* Tor's current estimate of its bootstrapping progress. */
void
@@ -965,7 +992,7 @@
_startStopAct->setIcon(QIcon(IMG_START_TOR_16));
/* Notify plugin manager */
- _pluginManager->sendStatus(pmStopped);
+ _pluginManager->sendTorStatus(pmStopped);
/* XXX: This might need to be smarter if we ever start connecting other
* slots to these triggered() and clicked() signals. */
@@ -983,7 +1010,7 @@
statusIconFile = IMG_TOR_STOPPING_16;
/* Notify plugin manager */
- _pluginManager->sendStatus(pmStopping);
+ _pluginManager->sendTorStatus(pmStopping);
} else if (status == Started) {
actionText = tr("Stop Tor");
_startStopAct->setEnabled(true);
@@ -1003,7 +1030,7 @@
setStartupProgress(STARTUP_PROGRESS_STARTING, statusText);
/* Notify plugin manager */
- _pluginManager->sendStatus(pmStarting);
+ _pluginManager->sendTorStatus(pmStarting);
} else if (status == CircuitEstablished) {
statusText = tr("Connected to the Tor network!");
trayIconFile = IMG_TOR_RUNNING;
@@ -1011,7 +1038,7 @@
setStartupProgressVisible(false);
/* Notify plugin manager */
- _pluginManager->sendStatus(pmStarted);
+ _pluginManager->sendTorStatus(pmStarted);
}
/* Update the tray icon */
Modified: vidalia/branches/extension-api/src/vidalia/MainWindow.h
===================================================================
--- vidalia/branches/extension-api/src/vidalia/MainWindow.h 2009-07-08 05:48:55 UTC (rev 3947)
+++ vidalia/branches/extension-api/src/vidalia/MainWindow.h 2009-07-08 07:00:52 UTC (rev 3948)
@@ -136,6 +136,10 @@
void onIMFailed(QString errmsg);
/** Called when the proxy server fails to start */
void onProxyFailed(QString errmsg);
+ /** Called when the proxy server is started */
+ void onProxyStarted();
+ /** Called when the proxy server is terminated */
+ void onProxyTerminated(int exitCode, QProcess::ExitStatus exitStatus);
#if defined(USE_AUTOUPDATE)
/** Called when the user clicks the 'Check Now' button in the General
@@ -198,6 +202,8 @@
void startSubprocesses();
/** Starts the proxy server, if appropriately configured */
void startProxy();
+ /** Terminates the proxy server. */
+ void stopProxy();
/** Converts a TorStatus enum value to a string for debug logging purposes. */
QString toString(TorStatus status);
/** Authenticates Vidalia to Tor's control port. */
Modified: vidalia/branches/extension-api/src/vidalia/PluginManager.cpp
===================================================================
--- vidalia/branches/extension-api/src/vidalia/PluginManager.cpp 2009-07-08 05:48:55 UTC (rev 3947)
+++ vidalia/branches/extension-api/src/vidalia/PluginManager.cpp 2009-07-08 07:00:52 UTC (rev 3948)
@@ -128,10 +128,25 @@
}
void
-PluginManager::sendStatus(PMTorStatus status)
+PluginManager::sendProxyStatus(PMStatus status)
{
switch(status) {
case pmStarting:
+ case pmStarted:
+ emit proxyStarted();
+ break;
+ case pmStopping:
+ case pmStopped:
+ emit proxyStopped();
+ break;
+ }
+}
+
+void
+PluginManager::sendTorStatus(PMStatus status)
+{
+ switch(status) {
+ case pmStarting:
emit torStarting();
break;
case pmStarted:
Modified: vidalia/branches/extension-api/src/vidalia/PluginManager.h
===================================================================
--- vidalia/branches/extension-api/src/vidalia/PluginManager.h 2009-07-08 05:48:55 UTC (rev 3947)
+++ vidalia/branches/extension-api/src/vidalia/PluginManager.h 2009-07-08 07:00:52 UTC (rev 3948)
@@ -27,7 +27,7 @@
class VidaliaPluginInterface;
/** Used to simply signal emission for PluginManager */
-enum PMTorStatus {
+enum PMStatus {
pmStarting = 0,
pmStarted,
pmStopping,
@@ -99,8 +99,10 @@
/** Send a signal signifying that the Proxy server is stopped */
void proxyStopped();
private:
- /** Emit tor status signal based on provided TorStatus value */
- void sendStatus(PMTorStatus status);
+ /** Emit proxy status signal based on provided status value */
+ void sendProxyStatus(PMStatus status);
+ /** Emit tor status signal based on provided status value */
+ void sendTorStatus(PMStatus status);
QList<VidaliaPluginInterface*> _pluginList;
const QString _dataDirectory;