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

[vidalia-svn] r2173: Add support for the DANGEROUS_VERSION status event. (in trunk: . src/control)



Author: edmanm
Date: 2007-12-04 15:15:55 -0500 (Tue, 04 Dec 2007)
New Revision: 2173

Added:
   trunk/src/control/dangerousversionevent.cpp
   trunk/src/control/dangerousversionevent.h
Modified:
   trunk/
   trunk/src/control/control.pri
   trunk/src/control/torevents.cpp
Log:
 r2222@lysithea:  edmanm | 2007-12-04 15:15:51 -0500
 Add support for the DANGEROUS_VERSION status event.



Property changes on: trunk
___________________________________________________________________
 svk:merge ticket from /local/vidalia/trunk [r2222] on 0108964c-5b0b-4c9e-969f-e2288315d100

Modified: trunk/src/control/control.pri
===================================================================
--- trunk/src/control/control.pri	2007-12-04 18:00:18 UTC (rev 2172)
+++ trunk/src/control/control.pri	2007-12-04 20:15:55 UTC (rev 2173)
@@ -52,7 +52,8 @@
            $$PWD/circuitestablishedevent.h \
            $$PWD/unrecognizedclientstatusevent.h \
            $$PWD/unrecognizedserverstatusevent.h \
-           $$PWD/unrecognizedgeneralstatusevent.h
+           $$PWD/unrecognizedgeneralstatusevent.h \
+           $$PWD/dangerousversionevent.h
 
 SOURCES += $$PWD/torcontrol.cpp \
            $$PWD/torprocess.cpp \
@@ -73,7 +74,8 @@
            $$PWD/statusevent.cpp \
            $$PWD/generalstatusevent.cpp \
            $$PWD/clientstatusevent.cpp \
-           $$PWD/serverstatusevent.cpp
+           $$PWD/serverstatusevent.cpp \
+           $$PWD/dangerousversionevent.cpp
 
 win32 {
   HEADERS += $$PWD/torservice.h

Added: trunk/src/control/dangerousversionevent.cpp
===================================================================
--- trunk/src/control/dangerousversionevent.cpp	                        (rev 0)
+++ trunk/src/control/dangerousversionevent.cpp	2007-12-04 20:15:55 UTC (rev 2173)
@@ -0,0 +1,44 @@
+/****************************************************************
+ *  Vidalia is distributed under the following license:
+ *
+ *  Copyright (C) 2007,  Matt Edman, Justin Hipple
+ *
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU General Public License
+ *  as published by the Free Software Foundation; either version 2
+ *  of the License, or (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, 
+ *  Boston, MA  02110-1301, USA.
+ ****************************************************************/
+
+/** 
+ * \file dangerousversionevent.h
+ * \version $Id$
+ * \brief Event sent when Tor realizes its version is not recommended
+ */
+
+#include "dangerousversionevent.h"
+
+
+/** Returns a DangerousVersionEvent::Reason enum value for <b>str</b>,
+ * representing the reason why Tor thinks its version is dangerous. */
+DangerousVersionEvent::Reason
+DangerousVersionEvent::reasonFromString(const QString &str)
+{
+  if (!str.compare("UNRECOMMENDED", Qt::CaseInsensitive))
+    return UnrecommendedVersion;
+  if (!str.compare("OLD", Qt::CaseInsensitive))
+    return NewVersion;
+  if (!str.compare("NEW", Qt::CaseInsensitive))
+    return OldVersion;
+  return UnrecognizedReason;
+}
+


Property changes on: trunk/src/control/dangerousversionevent.cpp
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Added: trunk/src/control/dangerousversionevent.h
===================================================================
--- trunk/src/control/dangerousversionevent.h	                        (rev 0)
+++ trunk/src/control/dangerousversionevent.h	2007-12-04 20:15:55 UTC (rev 2173)
@@ -0,0 +1,76 @@
+/****************************************************************
+ *  Vidalia is distributed under the following license:
+ *
+ *  Copyright (C) 2007,  Matt Edman, Justin Hipple
+ *
+ *  This program is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU General Public License
+ *  as published by the Free Software Foundation; either version 2
+ *  of the License, or (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 51 Franklin Street, Fifth Floor, 
+ *  Boston, MA  02110-1301, USA.
+ ****************************************************************/
+
+/** 
+ * \file dangerousversionevent.h
+ * \version $Id$
+ * \brief Event sent when Tor realizes its version is not recommended
+ */
+
+#ifndef _DANGEROUSVERSIONEVENT_H
+#define _DANGEROUSVERSIONEVENT_H
+
+#include <QStringList>
+#include "generalstatusevent.h"
+
+
+class DangerousVersionEvent : public GeneralStatusEvent
+{
+public:
+  /** Possible reasons Tor thinks its version is dangerous. */
+  enum Reason {
+    UnrecognizedReason, 
+    NewVersion, /**< The current version is newer than any recommended
+                     version. */
+    OldVersion, /**< The current version is older than any recommended 
+                     version. */
+    UnrecommendedVersion /**< The current version of Tor should not be used. */
+  };
+
+  /** Constructor. */
+  DangerousVersionEvent(StatusEvent::Severity severity, Reason reason,
+                        const QString &currentVersion,
+                        const QStringList &recommendedVersions)
+    : GeneralStatusEvent(severity, GeneralStatusEvent::DangerousTorVersion),
+        _reason(reason), 
+        _current(currentVersion), 
+        _recommended(recommendedVersions) {}
+
+  /** Returns the Reason enum value indicating the reason Tor thinks its
+   * version is dangerous. */
+  Reason reason() const { return _reason; }
+  /** Returns the user's current Tor version. */
+  QString currentVersion() const { return _current; }
+  /** Returns a list of recommended Tor versions. */
+  QStringList recommendedVersions() const { return _recommended; }
+
+  /** Returns a DangerousVersionEvent::Reason enum value for <b>str</b>,
+   * representing the reason why Tor thinks its version is dangerous. */
+  static Reason reasonFromString(const QString &str);
+
+private:
+  Reason _reason; /**< Reason this Tor version is dangerous. */
+  QString _current; /**< The user's current Tor version. */
+  QStringList _recommended; /**< A list of recommended Tor versions. */
+};
+
+#endif
+


Property changes on: trunk/src/control/dangerousversionevent.h
___________________________________________________________________
Name: svn:keywords
   + Id
Name: svn:eol-style
   + native

Modified: trunk/src/control/torevents.cpp
===================================================================
--- trunk/src/control/torevents.cpp	2007-12-04 18:00:18 UTC (rev 2172)
+++ trunk/src/control/torevents.cpp	2007-12-04 20:15:55 UTC (rev 2173)
@@ -36,8 +36,8 @@
 #include "unrecognizedclientstatusevent.h"
 #include "unrecognizedgeneralstatusevent.h"
 #include "circuitestablishedevent.h"
+#include "dangerousversionevent.h"
 
-
 /** Format of expiry times in address map events. */
 #define DATE_FMT "\"yyyy-MM-dd HH:mm:ss\""
 
@@ -448,6 +448,13 @@
     = GeneralStatusEvent::statusFromString(action);
 
   switch (status) {
+    case GeneralStatusEvent::DangerousTorVersion:
+      /* Dangerous Tor version ("DANGEROUS_VERSION") */
+      event = new DangerousVersionEvent(severity,
+                DangerousVersionEvent::reasonFromString(args.value("REASON")),
+                args.value("CURRENT"),
+                args.value("RECOMMENDED").split(",", QString::SkipEmptyParts));
+      break;
     default:
       event = new UnrecognizedGeneralStatusEvent(severity, action, args);
   }