[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[vidalia-svn] r3962: Added code for torControl support in pluginManager. Rearrang (in vidalia/branches/extension-api/src: torcontrol vidalia)
Author: tyree731
Date: 2009-07-14 00:05:29 -0400 (Tue, 14 Jul 2009)
New Revision: 3962
Modified:
vidalia/branches/extension-api/src/torcontrol/TorEvents.cpp
vidalia/branches/extension-api/src/vidalia/MainWindow.cpp
vidalia/branches/extension-api/src/vidalia/PluginManager.cpp
vidalia/branches/extension-api/src/vidalia/PluginManager.h
Log:
Added code for torControl support in pluginManager. Rearranged the MainWindow constructor and added support for emission of ServerStatus tor control messages.
Modified: vidalia/branches/extension-api/src/torcontrol/TorEvents.cpp
===================================================================
--- vidalia/branches/extension-api/src/torcontrol/TorEvents.cpp 2009-07-12 01:53:33 UTC (rev 3961)
+++ vidalia/branches/extension-api/src/torcontrol/TorEvents.cpp 2009-07-14 04:05:29 UTC (rev 3962)
@@ -444,8 +444,12 @@
= ServerStatusEvent::statusFromString(action);
switch (status) {
+ case ServerStatusEvent::UnrecognizedStatus:
+ event = new UnrecognizedServerStatusEvent(severity, action, args);
+ break;
+
default:
- event = new UnrecognizedServerStatusEvent(severity, action, args);
+ event = new ServerStatusEvent(severity, status);
}
dispatch(ServerStatus, event);
}
Modified: vidalia/branches/extension-api/src/vidalia/MainWindow.cpp
===================================================================
--- vidalia/branches/extension-api/src/vidalia/MainWindow.cpp 2009-07-12 01:53:33 UTC (rev 3961)
+++ vidalia/branches/extension-api/src/vidalia/MainWindow.cpp 2009-07-14 04:05:29 UTC (rev 3962)
@@ -114,22 +114,43 @@
ui.setupUi(this);
- /* Creates the plugin manager and load relevant plugins */
- _pluginManager = new PluginManager(Vidalia::dataDirectory());
- _pluginManager->loadPlugins("");
-
/* Create all the dialogs of which we only want one instance */
_bandwidthGraph = new BandwidthGraph();
_configDialog = new ConfigDialog();
_menuBar = 0;
+ /* Create a new TorControl object, used to communicate with Tor */
+ _torControl = Vidalia::torControl();
+ connect(_torControl, SIGNAL(started()), this, SLOT(started()));
+ connect(_torControl, SIGNAL(startFailed(QString)),
+ this, SLOT(startFailed(QString)));
+ connect(_torControl, SIGNAL(stopped(int, QProcess::ExitStatus)),
+ this, SLOT(stopped(int, QProcess::ExitStatus)));
+ connect(_torControl, SIGNAL(connected()), this, SLOT(connected()));
+ connect(_torControl, SIGNAL(disconnected()), this, SLOT(disconnected()));
+ connect(_torControl, SIGNAL(connectFailed(QString)),
+ this, SLOT(connectFailed(QString)));
+ connect(_torControl, SIGNAL(authenticated()), this, SLOT(authenticated()));
+ connect(_torControl, SIGNAL(authenticationFailed(QString)),
+ this, SLOT(authenticationFailed(QString)));
+ _torControl->setEvent(TorEvents::ClientStatus, this, true);
+ _torControl->setEvent(TorEvents::GeneralStatus, this, true);
+ _torControl->setEvent(TorEvents::ServerStatus, this, true);
+
+ /* Creates the plugin manager and load relevant plugins */
+ _pluginManager = new PluginManager(_torControl, Vidalia::dataDirectory());
+ _pluginManager->loadPlugins("");
+
+ /* Connect help dialog requests to the help dialog */
connect(_configDialog, SIGNAL(helpRequested(QString)),
this, SLOT(showHelpDialog(QString)));
connect(_pluginManager, SIGNAL(helpRequested(QString)),
this, SLOT(showHelpDialog(QString)));
- /* Create the actions that will go in the tray menu */
+ /* Create the actions that will go in the tray and file menu */
createActions();
+ /* Create the menu bar */
+ createMenuBar();
/* Create the statusbar and its permanant widget */
createStatusBar();
/* Creates a tray icon with a context menu and adds it to the system's
@@ -147,23 +168,6 @@
connect(ui.tabMainPanel, SIGNAL(currentChanged(int)),
this, SLOT(updateStatusControl(int)));
- /* Create a new TorControl object, used to communicate with Tor */
- _torControl = Vidalia::torControl();
- connect(_torControl, SIGNAL(started()), this, SLOT(started()));
- connect(_torControl, SIGNAL(startFailed(QString)),
- this, SLOT(startFailed(QString)));
- connect(_torControl, SIGNAL(stopped(int, QProcess::ExitStatus)),
- this, SLOT(stopped(int, QProcess::ExitStatus)));
- connect(_torControl, SIGNAL(connected()), this, SLOT(connected()));
- connect(_torControl, SIGNAL(disconnected()), this, SLOT(disconnected()));
- connect(_torControl, SIGNAL(connectFailed(QString)),
- this, SLOT(connectFailed(QString)));
- connect(_torControl, SIGNAL(authenticated()), this, SLOT(authenticated()));
- connect(_torControl, SIGNAL(authenticationFailed(QString)),
- this, SLOT(authenticationFailed(QString)));
- _torControl->setEvent(TorEvents::ClientStatus, this, true);
- _torControl->setEvent(TorEvents::GeneralStatus, this, true);
-
/* Create a new HelperProcess object, used to start the web browser */
_browserProcess = new HelperProcess(this);
connect(_browserProcess, SIGNAL(finished(int, QProcess::ExitStatus)),
@@ -495,22 +499,10 @@
}
/** Creates a tray icon with a context menu and adds it to the system
- * notification area. On Mac, we also set up an application menubar. */
+ * notification area. */
void
MainWindow::createTrayIcon()
{
- /* Create the default menu bar (Mac) */
- createMenuBar();
- /* Create a tray menu and add it to the tray icon */
- _trayIcon.setContextMenu(createTrayMenu());
- connect(&_trayIcon, SIGNAL(doubleClicked()), this, SLOT(show()));
-}
-
-/** Creates a QMenu object that contains QActions which compose the system
- * tray menu. */
-QMenu*
-MainWindow::createTrayMenu()
-{
QMenu *menu = new QMenu(this);
menu->addAction(_startStopAct);
menu->addSeparator();
@@ -518,7 +510,7 @@
menu->addAction(_newIdentityAct);
menu->addSeparator();
menu->addAction(_controlPanelAct);
-
+
#if !defined(Q_WS_MAC)
/* These aren't added to the dock menu on Mac, since they are in the
* standard Mac locations in the menu bar. */
@@ -528,7 +520,10 @@
menu->addSeparator();
menu->addAction(_exitAct);
#endif
- return menu;
+
+ /* Create a tray menu and add it to the tray icon */
+ _trayIcon.setContextMenu(menu);
+ connect(&_trayIcon, SIGNAL(doubleClicked()), this, SLOT(show()));
}
/** Creates a new menubar with no parent, so Qt will use this as the "default
@@ -562,9 +557,10 @@
if (_menuBar)
delete _menuBar;
_menuBar = menuBar();
+
QMenu *fileMenu = _menuBar->addMenu("File");
- fileMenu->addAction(_exitAct);
fileMenu->addAction(_configAct);
+ fileMenu->addAction(_exitAct);
QMenu *torMenu = _menuBar->addMenu(tr("Tor"));
torMenu->addAction(_startStopAct);
Modified: vidalia/branches/extension-api/src/vidalia/PluginManager.cpp
===================================================================
--- vidalia/branches/extension-api/src/vidalia/PluginManager.cpp 2009-07-12 01:53:33 UTC (rev 3961)
+++ vidalia/branches/extension-api/src/vidalia/PluginManager.cpp 2009-07-14 04:05:29 UTC (rev 3962)
@@ -20,9 +20,16 @@
#include <QPluginLoader>
#include <QStringList>
-PluginManager::PluginManager(const QString& dataDirectory)
-: _dataDirectory(dataDirectory)
+PluginManager::PluginManager(TorControl* torControl,
+ const QString& dataDirectory)
+: _dataDirectory(dataDirectory),
+ _torControl(torControl)
{
+#if 0
+ _torControl->setEvent(TorEvents::ClientStatus, this, true);
+ _torControl->setEvent(TorEvents::GeneralStatus, this, true);
+ _torControl->setEvent(TorEvents::ServerStatus, this, true);
+#endif
}
PluginManager::~PluginManager()
Modified: vidalia/branches/extension-api/src/vidalia/PluginManager.h
===================================================================
--- vidalia/branches/extension-api/src/vidalia/PluginManager.h 2009-07-12 01:53:33 UTC (rev 3961)
+++ vidalia/branches/extension-api/src/vidalia/PluginManager.h 2009-07-14 04:05:29 UTC (rev 3962)
@@ -17,6 +17,7 @@
#ifndef _PLUGINMANAGER_H
#define _PLUGINMANAGER_H
+#include "TorControl.h"
#include "VidaliaPluginInterface.h"
#include <QList>
@@ -46,7 +47,7 @@
public:
/** PluginManager constructor. */
- PluginManager(const QString& dataDirectory);
+ PluginManager(TorControl* torControl, const QString& dataDirectory);
/** PluginManager destructor. */
~PluginManager();
/** Loads all included static and dynamic plugins. */
@@ -110,6 +111,7 @@
QList<VidaliaPluginInterface*> _pluginList;
const QString _dataDirectory;
+ TorControl* _torControl;
};
#endif