[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[vidalia-svn] r4043: Relay status notifications working. Need to fix proxy notifi (in vidalia/branches/extension-api/src: plugins torcontrol vidalia vidalia/HomePlugin)



Author: tyree731
Date: 2009-08-14 22:01:54 -0400 (Fri, 14 Aug 2009)
New Revision: 4043

Removed:
   vidalia/branches/extension-api/src/vidalia/HomePlugin/AnimatedPixmap.cpp
   vidalia/branches/extension-api/src/vidalia/HomePlugin/AnimatedPixmap.h
Modified:
   vidalia/branches/extension-api/src/plugins/CMakeLists.txt
   vidalia/branches/extension-api/src/plugins/PluginManager.cpp
   vidalia/branches/extension-api/src/plugins/PluginManager.h
   vidalia/branches/extension-api/src/plugins/VidaliaPluginInterface.cpp
   vidalia/branches/extension-api/src/plugins/VidaliaPluginInterface.h
   vidalia/branches/extension-api/src/torcontrol/TorEvents.cpp
   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/HomePanel.ui
   vidalia/branches/extension-api/src/vidalia/HomePlugin/HomePlugin.cpp
   vidalia/branches/extension-api/src/vidalia/MainWindow.cpp
Log:
Relay status notifications working. Need to fix proxy notifications before Home Panel is happy.

Modified: vidalia/branches/extension-api/src/plugins/CMakeLists.txt
===================================================================
--- vidalia/branches/extension-api/src/plugins/CMakeLists.txt	2009-08-15 01:25:00 UTC (rev 4042)
+++ vidalia/branches/extension-api/src/plugins/CMakeLists.txt	2009-08-15 02:01:54 UTC (rev 4043)
@@ -37,5 +37,8 @@
 )
 
 add_library(vidaliaplugin SHARED ${plugin_SRCS})
-target_link_libraries(vidaliaplugin ${QT_LIBRARIES})
+target_link_libraries(vidaliaplugin 
+  ${QT_LIBRARIES}
+  torcontrol
+)
 

Modified: vidalia/branches/extension-api/src/plugins/PluginManager.cpp
===================================================================
--- vidalia/branches/extension-api/src/plugins/PluginManager.cpp	2009-08-15 01:25:00 UTC (rev 4042)
+++ vidalia/branches/extension-api/src/plugins/PluginManager.cpp	2009-08-15 02:01:54 UTC (rev 4043)
@@ -21,16 +21,16 @@
 #include <QPluginLoader>
 #include <QStringList>
 
+#include "ServerStatusEvent.h"
+
 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() 
@@ -104,6 +104,23 @@
   }
 }
 
+void
+PluginManager::customEvent(QEvent* event)
+{
+  if (event->type() == CustomEventType::ServerStatusEvent) {
+    ServerStatusEvent *sse = dynamic_cast<ServerStatusEvent *>(event);
+    if (!sse)
+      return;
+
+    if (sse->status() == ServerStatusEvent::GoodServerDescriptor) {
+      emit relayStarted();
+    }
+    else if (sse->status() == ServerStatusEvent::ReachabilityFailed) {
+      emit relayStopped();
+    }
+  }
+}
+
 TorControl*
 PluginManager::torControl() const
 {
@@ -205,3 +222,9 @@
       break;
   }
 }
+
+void
+PluginManager::settingsChanged()
+{
+  emit vidaliaSettingsChanged();
+}

Modified: vidalia/branches/extension-api/src/plugins/PluginManager.h
===================================================================
--- vidalia/branches/extension-api/src/plugins/PluginManager.h	2009-08-15 01:25:00 UTC (rev 4042)
+++ vidalia/branches/extension-api/src/plugins/PluginManager.h	2009-08-15 02:01:54 UTC (rev 4043)
@@ -70,6 +70,8 @@
   /** Displays the Vidalia help viewer with the current page set to
    * <b>topic</b>. */
   void showHelpTopic(const QString &topic);
+protected:
+  void customEvent(QEvent* event);
 
 signals:
   /** Sends a signal to MainWindow requesting the Vidalia Help Dialog */
@@ -81,6 +83,10 @@
   /** Sends a signal to MainWindow requesting the Proxy server be stopped */
   void stopProxyRequest();
 
+  /** Send a signal signifying that Tor is functioning as a relay */
+  void relayStarted();
+  /** Send a signal signifying that Tor is not functioning as a relay */
+  void relayStopped();
   /** Send a signal signifying that Tor is starting */
   void torStarting();
   /** Send a signal signifying that Tor is started */
@@ -98,6 +104,8 @@
   /** Send a signal signifying that the Proxy server is stopped */
   void proxyStopped();
 
+  /** Send a signal signifying that the Vidalia Settings have changed */
+  void vidaliaSettingsChanged();
 private:
   /** Returns a StringList of the default plugins */
   QStringList defaultPlugins() const;
@@ -107,6 +115,8 @@
   void sendProxyStatus(PMStatus status);
   /** Emit tor status signal based on provided status value */
   void sendTorStatus(PMStatus status);
+  /** Emit settings changed signal */
+  void settingsChanged();
 
   QList<VidaliaPluginInterface*> _pluginList;
   const QString _dataDirectory;

Modified: vidalia/branches/extension-api/src/plugins/VidaliaPluginInterface.cpp
===================================================================
--- vidalia/branches/extension-api/src/plugins/VidaliaPluginInterface.cpp	2009-08-15 01:25:00 UTC (rev 4042)
+++ vidalia/branches/extension-api/src/plugins/VidaliaPluginInterface.cpp	2009-08-15 02:01:54 UTC (rev 4043)
@@ -24,8 +24,16 @@
 QString 
 VidaliaPluginInterface::dataDirectory() const
 {
+  QString dir = _pluginManager->dataDirectory();
+  return dir;
+}
+
+QString
+VidaliaPluginInterface::pluginDataDirectory() const
+{
   QString dir = _pluginManager->dataDirectory() + id();
   return dir;
+  
 }
 
 QSettings*

Modified: vidalia/branches/extension-api/src/plugins/VidaliaPluginInterface.h
===================================================================
--- vidalia/branches/extension-api/src/plugins/VidaliaPluginInterface.h	2009-08-15 01:25:00 UTC (rev 4042)
+++ vidalia/branches/extension-api/src/plugins/VidaliaPluginInterface.h	2009-08-15 02:01:54 UTC (rev 4043)
@@ -62,9 +62,10 @@
   virtual QString id() const = 0;
   /** Virtual function to return a plugin's description. */
   virtual QString description() const { return QString(); }
+  /** Returns the application data directory. */
+  QString dataDirectory() const;
   /** Returns a plugins data directory. */
-  QString dataDirectory() const;
-  
+  QString pluginDataDirectory() const;
   /** Returns a QSettings object for plugins to load and save configurations. 
    * Plugin is responsible for managing the QSettings object.
    */

Modified: vidalia/branches/extension-api/src/torcontrol/TorEvents.cpp
===================================================================
--- vidalia/branches/extension-api/src/torcontrol/TorEvents.cpp	2009-08-15 01:25:00 UTC (rev 4042)
+++ vidalia/branches/extension-api/src/torcontrol/TorEvents.cpp	2009-08-15 02:01:54 UTC (rev 4043)
@@ -84,7 +84,7 @@
 TorEvents::dispatch(TorEvent e, QEvent *event)
 {
   foreach (QObject *obj, _eventList.values(e)) {
-    QApplication::postEvent(obj, event);
+    QApplication::sendEvent(obj, event);
   }
 }
 

Modified: vidalia/branches/extension-api/src/vidalia/HomePlugin/HomePanel.cpp
===================================================================
--- vidalia/branches/extension-api/src/vidalia/HomePlugin/HomePanel.cpp	2009-08-15 01:25:00 UTC (rev 4042)
+++ vidalia/branches/extension-api/src/vidalia/HomePlugin/HomePanel.cpp	2009-08-15 02:01:54 UTC (rev 4043)
@@ -21,25 +21,12 @@
 {
   ui.setupUi(this);
 
-  /* Create animated pixmaps and connect animation signal to slots */
-#if 0
-  _torStatusAnimatedPixmap = 
-    new AnimatedPixmap(":/images/48x48/process-working.png");
-  _proxyStatusAnimatedPixmap = 
-    new AnimatedPixmap(":/images/48x48/process-working.png");
-  connect(_torStatusAnimatedPixmap, SIGNAL(frameChanged(int)),
-	  this, SLOT(torFrameChanged(int)));
-  connect(_proxyStatusAnimatedPixmap, SIGNAL(frameChanged(int)),
-	  this, SLOT(proxyFrameChanged(int)));
-#endif
+  /* If Vidalia Settings change, notify the Home Panel */
+  updateSettings();
 }
 
 HomePanel::~HomePanel()
 {
-#if 0
-  delete _torStatusAnimatedPixmap;
-  delete _proxyStatusAnimatedPixmap;
-#endif
 }
 
 QString 
@@ -55,17 +42,20 @@
 }
 
 void
-HomePanel::proxyFrameChanged(int frame)
+HomePanel::relayStarted()
 {
-  ui.lblProxyStatusImg->setPixmap(_proxyStatusAnimatedPixmap->currentFrame());
+  ui.lblRelayStatus->setText("Your relay appears to be up and running!");
+  ui.lblRelayStatusImg->setPixmap(QPixmap(":/images/48x48/tor-on.png"));
 }
 
 void
-HomePanel::torFrameChanged(int frame)
+HomePanel::relayStopped()
 {
-  ui.lblTorStatusImg->setPixmap(_torStatusAnimatedPixmap->currentFrame());
+  ui.lblRelayStatus->setText("Your relay appears to be down.");
+  ui.lblRelayStatusImg->setPixmap(QPixmap(":/images/48x48/tor-stopping.png"));
 }
 
+
 void
 HomePanel::proxyStarted()
 {
@@ -76,26 +66,19 @@
 void
 HomePanel::proxyStopped()
 {
-  ui.lblProxyStatusImg->setPixmap(QPixmap(":/images/48x48/tor-off.png"));
-  ui.lblProxyStatus->setText(tr("Polipo does not appear to be running."));
+  ui.lblProxyStatusImg->setPixmap(QPixmap(":/images/48x48/tor-stopping.png"));
+  ui.lblProxyStatus->setText(tr("Your proxy server does not appear to be running."));
 }
 
 void
 HomePanel::torStarting()
 {
-#if 0
-  _torStatusAnimatedPixmap->start();
-  ui.lblTorStatusImg->setPixmap(_torStatusAnimatedPixmap->currentFrame());
-#endif
   ui.lblTorStatus->setText(tr("Tor is starting."));
 }
 
 void
 HomePanel::torStarted()
 {
-#if 0
-  _torStatusAnimatedPixmap->stop();
-#endif
   ui.lblTorStatusImg->setPixmap(QPixmap(":/images/48x48/tor-on.png"));
   ui.lblTorStatus->setText(tr("You are connected to Tor!"));
 }
@@ -103,19 +86,49 @@
 void
 HomePanel::torStopping()
 {
-#if 0
-  _torStatusAnimatedPixmap->start();
-  ui.lblTorStatusImg->setPixmap(_torStatusAnimatedPixmap->currentFrame());
-#endif
   ui.lblTorStatus->setText(tr("Tor is stopping."));
 }
 
 void
 HomePanel::torStopped()
 {
-#if 0
-  _torStatusAnimatedPixmap->stop();
-#endif
   ui.lblTorStatusImg->setPixmap(QPixmap(":/images/48x48/tor-off.png"));
   ui.lblTorStatus->setText(tr("Tor does not appear to be running."));
 }
+
+void
+HomePanel::updateSettings()
+{
+  QSettings vidaliaSettings(plugin()->dataDirectory() + "/vidalia.conf",
+                            QSettings::IniFormat);
+
+  bool proxySettings = vidaliaSettings.value("RunProxyAtStart", false).toBool();
+  if (!proxySettings) {
+    ui.lblProxyStatus->setText("It does not appear that Vidalia is configured"
+                               " to handle starting the proxy server.");
+    ui.lblProxyStatusImg->setPixmap(QPixmap(":/images/48x48/tor-off.png"));
+  }
+  else {
+    if (ui.lblProxyStatus->text().contains("handle starting")) {
+      ui.lblProxyStatus->setText("Vidalia is now configured to start the proxy"
+                                 " server on startup. Restart Vidalia in order"
+                                 " to start the proxy server.");
+    }
+  }
+
+  vidaliaSettings.beginGroup("Server");
+  bool relaySettings = vidaliaSettings.value("Enabled", false).toBool();
+  if (!relaySettings) {
+    ui.lblRelayRunning->setText("It does not appear that you are currently"
+                                " running Tor as a relay.");
+    ui.lblRelayRunningImg->setPixmap(QPixmap(":/images/48x48/tor-off.png"));
+    ui.lblRelayStatus->hide();
+    ui.lblRelayStatusImg->hide();
+  }
+  else {
+    ui.lblRelayRunning->setText("You are running Tor as a relay!");
+    ui.lblRelayRunningImg->setPixmap(QPixmap(":/images/48x48/tor-on.png"));
+    ui.lblRelayStatus->show();
+    ui.lblRelayStatusImg->show();
+  }
+}

Modified: vidalia/branches/extension-api/src/vidalia/HomePlugin/HomePanel.h
===================================================================
--- vidalia/branches/extension-api/src/vidalia/HomePlugin/HomePanel.h	2009-08-15 01:25:00 UTC (rev 4042)
+++ vidalia/branches/extension-api/src/vidalia/HomePlugin/HomePanel.h	2009-08-15 02:01:54 UTC (rev 4043)
@@ -22,7 +22,6 @@
 #include <QIcon>
 #include <QString>
 
-#include "AnimatedPixmap.h"
 #include "ui_HomePanel.h"
 
 class HomePlugin;
@@ -41,11 +40,9 @@
   QIcon tabIcon() const;
 
 private slots:
-  /** Update status to next frame of animation */
-  void proxyFrameChanged(int frame);
-  /** Update status to next frame of animation */
-  void torFrameChanged(int frame);
-
+  /** Updates interface to show relay status */
+  void relayStarted();
+  void relayStopped();
   /** Updates interface to show proxy started */
   void proxyStarted();
   /** Updates interface to show proxy stopped */
@@ -58,12 +55,11 @@
   void torStopping();
   /** Update interface to show tor stopped */
   void torStopped();
+  /** Update interface to matched changed settings */
+  void updateSettings();
 private:
   /** Qt Designer Object */
   Ui::HomePanel ui;
-  /** Circular indeterminate progress animation object */
-  AnimatedPixmap* _torStatusAnimatedPixmap;
-  AnimatedPixmap* _proxyStatusAnimatedPixmap;
 };
 
 #endif

Modified: vidalia/branches/extension-api/src/vidalia/HomePlugin/HomePanel.ui
===================================================================
--- vidalia/branches/extension-api/src/vidalia/HomePlugin/HomePanel.ui	2009-08-15 01:25:00 UTC (rev 4042)
+++ vidalia/branches/extension-api/src/vidalia/HomePlugin/HomePanel.ui	2009-08-15 02:01:54 UTC (rev 4043)
@@ -57,7 +57,7 @@
           <string/>
          </property>
          <property name="pixmap">
-          <pixmap resource="../res/vidalia.qrc">:/images/48x48/tor-stopping.png</pixmap>
+          <pixmap resource="../res/vidalia.qrc">:/images/48x48/tor-off.png</pixmap>
          </property>
         </widget>
        </item>
@@ -82,7 +82,7 @@
         </spacer>
        </item>
        <item row="2" column="0">
-        <widget class="QLabel" name="label">
+        <widget class="QLabel" name="lblRelayStatusImg">
          <property name="text">
           <string/>
          </property>
@@ -133,7 +133,7 @@
        <item row="0" column="1">
         <widget class="QLabel" name="lblProxyStatus">
          <property name="text">
-          <string>Polipo does not appear to be running.</string>
+          <string>Your proxy server does not appear to be running.</string>
          </property>
         </widget>
        </item>

Modified: vidalia/branches/extension-api/src/vidalia/HomePlugin/HomePlugin.cpp
===================================================================
--- vidalia/branches/extension-api/src/vidalia/HomePlugin/HomePlugin.cpp	2009-08-15 01:25:00 UTC (rev 4042)
+++ vidalia/branches/extension-api/src/vidalia/HomePlugin/HomePlugin.cpp	2009-08-15 02:01:54 UTC (rev 4043)
@@ -72,6 +72,12 @@
 	  _homePanel, SLOT(proxyStarted()));
   connect(_pluginManager, SIGNAL(proxyStopped()),
 	  _homePanel, SLOT(proxyStopped()));
+  connect(_pluginManager, SIGNAL(relayStarted()),
+          _homePanel, SLOT(relayStarted()));
+  connect(_pluginManager, SIGNAL(relayStopped()),
+          _homePanel, SLOT(relayStopped()));
+  connect(_pluginManager, SIGNAL(vidaliaSettingsChanged()),
+          _homePanel, SLOT(updateSettings()));
 }
 
 Q_EXPORT_PLUGIN2(homeplugin, HomePlugin)

Modified: vidalia/branches/extension-api/src/vidalia/MainWindow.cpp
===================================================================
--- vidalia/branches/extension-api/src/vidalia/MainWindow.cpp	2009-08-15 01:25:00 UTC (rev 4042)
+++ vidalia/branches/extension-api/src/vidalia/MainWindow.cpp	2009-08-15 02:01:54 UTC (rev 4043)
@@ -934,11 +934,7 @@
 void
 MainWindow::onSettingsChange()
 {
-  VidaliaPluginInterface* homePlugin =
-    _pluginManager->getPluginById("home");
-  if (homePlugin) {
-    
-  }
+  _pluginManager->settingsChanged();
 }
 
 /** Called when Tor's bootstrapping status changes. <b>bse</b> represents