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

[vidalia-svn] r3330: Add some code for launching a thandy client via the Python i (in vidalia/branches/auto-updates: . src/vidalia src/vidalia/config)



Author: edmanm
Date: 2008-11-20 22:49:46 -0500 (Thu, 20 Nov 2008)
New Revision: 3330

Modified:
   vidalia/branches/auto-updates/CMakeLists.txt
   vidalia/branches/auto-updates/config.h.in
   vidalia/branches/auto-updates/src/vidalia/CMakeLists.txt
   vidalia/branches/auto-updates/src/vidalia/config/generalpage.cpp
   vidalia/branches/auto-updates/src/vidalia/mainwindow.cpp
   vidalia/branches/auto-updates/src/vidalia/mainwindow.h
   vidalia/branches/auto-updates/src/vidalia/updateprocess.cpp
   vidalia/branches/auto-updates/src/vidalia/updateprocess.h
Log:
Add some code for launching a thandy client via the Python interpreter for some
/bundleinfo/ path. Currently this won't work for anybody but me, unless you
change the hardcoded path to ClientCLI.py. Also add some CMake fu for
disabling this stuff.


Modified: vidalia/branches/auto-updates/CMakeLists.txt
===================================================================
--- vidalia/branches/auto-updates/CMakeLists.txt	2008-11-21 02:04:34 UTC (rev 3329)
+++ vidalia/branches/auto-updates/CMakeLists.txt	2008-11-21 03:49:46 UTC (rev 3330)
@@ -75,6 +75,11 @@
 ## UPnP support is currently optional (enabled by default)
 option(USE_MINIUPNPC "Enable UPnP support using the MiniUPnPc library." ON)
 
+## Automatic osftware update is optional (enabled by default)
+if (WIN32)
+  option(USE_AUTOUPDATE "Enable automatic software update support." ON)
+endif(WIN32)
+
 ## Check for system header files
 check_include_file("limits.h" HAVE_LIMITS_H)
 check_include_file("sys/limits.h" HAVE_SYS_LIMITS_H)

Modified: vidalia/branches/auto-updates/config.h.in
===================================================================
--- vidalia/branches/auto-updates/config.h.in	2008-11-21 02:04:34 UTC (rev 3329)
+++ vidalia/branches/auto-updates/config.h.in	2008-11-21 03:49:46 UTC (rev 3330)
@@ -1,5 +1,5 @@
 /*
-**  $Id: $
+**  $Id$
 ** 
 **  This file is part of Vidalia, and is subject to the license terms in the 
 **  LICENSE file, found in the top level directory of this distribution. If  
@@ -28,5 +28,7 @@
 
 #cmakedefine USE_MINIUPNPC
 
+#cmakedefine USE_AUTOUPDATE
+
 #endif
 

Modified: vidalia/branches/auto-updates/src/vidalia/CMakeLists.txt
===================================================================
--- vidalia/branches/auto-updates/src/vidalia/CMakeLists.txt	2008-11-21 02:04:34 UTC (rev 3329)
+++ vidalia/branches/auto-updates/src/vidalia/CMakeLists.txt	2008-11-21 03:49:46 UTC (rev 3330)
@@ -186,7 +186,6 @@
   vmessagebox.cpp
   helperprocess.cpp
   controlpasswordinputdialog.cpp
-  updateprocess.cpp
 )
 qt4_wrap_cpp(vidalia_SRCS
   vidalia.h
@@ -195,7 +194,6 @@
   vidaliawindow.h
   vmessagebox.h
   helperprocess.h
-  updateprocess.h
   controlpasswordinputdialog.h
 )
 
@@ -227,6 +225,15 @@
   qt4_wrap_ui(vidalia_SRCS config/upnptestdialog.ui)
 endif(USE_MINIUPNPC)
 
+if (USE_AUTOUPDATE)
+  set(vidalia_SRCS ${vidalia_SRCS}
+    updateprocess.cpp
+  )
+  qt4_wrap_cpp(vidalia_SRCS
+    updateprocess.h
+  )
+endif(USE_AUTOUPDATE)
+
 ## Add the resource files (icons, etc.)
 qt4_add_resources(vidalia_SRCS
   res/vidalia.qrc

Modified: vidalia/branches/auto-updates/src/vidalia/config/generalpage.cpp
===================================================================
--- vidalia/branches/auto-updates/src/vidalia/config/generalpage.cpp	2008-11-21 02:04:34 UTC (rev 3329)
+++ vidalia/branches/auto-updates/src/vidalia/config/generalpage.cpp	2008-11-21 03:49:46 UTC (rev 3330)
@@ -16,6 +16,7 @@
 
 #include <QDateTime>
 #include <stringutil.h>
+#include <config.h>
 #include "generalpage.h"
 
 
@@ -42,6 +43,8 @@
 #ifndef Q_WS_WIN
   ui.chkRunVidaliaAtSystemStartup->setVisible(false);
   ui.lineHorizontalSeparator->setVisible(false);
+#endif
+#ifndef USE_AUTOUPDATE
   ui.grpSoftwareUpdates->setVisible(false);
 #endif
 }

Modified: vidalia/branches/auto-updates/src/vidalia/mainwindow.cpp
===================================================================
--- vidalia/branches/auto-updates/src/vidalia/mainwindow.cpp	2008-11-21 02:04:34 UTC (rev 3329)
+++ vidalia/branches/auto-updates/src/vidalia/mainwindow.cpp	2008-11-21 03:49:46 UTC (rev 3330)
@@ -275,6 +275,7 @@
   if (settings.runProxyAtStart())
     startProxy();
 
+#if defined(USE_AUTOUPDATE)
   if (settings.isAutoUpdateEnabled()) {
     QDateTime lastCheckedAt = settings.lastCheckedForUpdates();
     if (UpdateProcess::shouldCheckForUpdates(lastCheckedAt)) {
@@ -287,6 +288,7 @@
       _updateTimer.start((nextCheckAt.toTime_t() - now.toTime_t()) * 1000);
     }
   }
+#endif
 }
 
 /** Terminate the Tor process if it is being run under Vidalia, disconnect all
@@ -1482,12 +1484,12 @@
 void
 MainWindow::checkForUpdates()
 {
+#if defined(USE_AUTOUPDATE)
   /* Initiate a check for available software updates. This check will
    * be done in the background, notifying the user only if there are
    * updates to be installed.
    */
-  _updateProcess.checkForUpdates("takemeforarideonyourmagicglider.exe",
-                                 QStringList() << "plztohasnewtor");
+  _updateProcess.checkForUpdates(UpdateProcess::TorBundleInfo);
 
   /* XXX: The stuff below should be moved to another method that gets called
    *      when the glider check is complete.
@@ -1497,5 +1499,6 @@
 
   /* Restart the "Check for Updates" timer */
   _updateTimer.start(UpdateProcess::checkForUpdatesInterval() * 1000);
+#endif
 }
 

Modified: vidalia/branches/auto-updates/src/vidalia/mainwindow.h
===================================================================
--- vidalia/branches/auto-updates/src/vidalia/mainwindow.h	2008-11-21 02:04:34 UTC (rev 3329)
+++ vidalia/branches/auto-updates/src/vidalia/mainwindow.h	2008-11-21 03:49:46 UTC (rev 3330)
@@ -33,8 +33,10 @@
 #include "ui_mainwindow.h"
 #include "helperprocess.h"
 #include "config.h"
+
+#if defined(USE_AUTOUPDATE)
 #include "updateprocess.h"
-
+#endif
 #if defined(USE_MINIUPNPC)
 #include "config/upnpcontrol.h"
 #endif
@@ -212,8 +214,10 @@
   TrayIcon _trayIcon;
   /** Timer used to remind us to check for software updates. */
   QTimer _updateTimer;
+#if defined(USE_AUTOUPDATE)
   /** The auto-update process used to check for and download updates. */
   UpdateProcess _updateProcess;
+#endif
   /** The menubar (Mac OS X only). */
   QMenuBar *_menuBar;
 

Modified: vidalia/branches/auto-updates/src/vidalia/updateprocess.cpp
===================================================================
--- vidalia/branches/auto-updates/src/vidalia/updateprocess.cpp	2008-11-21 02:04:34 UTC (rev 3329)
+++ vidalia/branches/auto-updates/src/vidalia/updateprocess.cpp	2008-11-21 03:49:46 UTC (rev 3330)
@@ -23,10 +23,18 @@
 }
 
 void
-UpdateProcess::checkForUpdates(const QString &updaterExecutable,
-                               const QStringList &args)
+UpdateProcess::checkForUpdates(BundleInfo bi)
 {
-  start(updaterExecutable, args);
+  QStringList args;
+
+  /* XXX: Super lame! This is a temporary hack until there is a real
+   *      thandy executable. */
+  args << "E:\\thandy\\lib\\thandy\\ClientCLI.py";
+
+  args << "update" << "--debug"
+       << bundleInfoToString(bi);
+
+  start(updateExecutable(), args);
 }
 
 void
@@ -53,6 +61,16 @@
   }
 }
 
+void
+UpdateProcess::onError(QProcess::ProcessError error)
+{
+  if (error == QProcess::FailedToStart) {
+    emit checkForUpdatesFailed(tr("Vidalia was unable to check for available "
+                                  "software updates because it could not find "
+                                  "'%1'.").arg(updateExecutable()));
+  }
+}
+
 int
 UpdateProcess::checkForUpdatesInterval()
 {
@@ -74,3 +92,21 @@
   return (nextCheck >= QDateTime::currentDateTime().toUTC());
 }
 
+QString
+UpdateProcess::updateExecutable()
+{
+  /* XXX: Super lame. Just use python to run thandy for now. */
+  return "python.exe";
+}
+
+QString
+UpdateProcess::bundleInfoToString(BundleInfo bi)
+{
+  switch (bi) {
+    case TorBundleInfo:
+      return "/bundleinfo/tor/win32/";
+    default:
+      return QString();
+  };
+}
+

Modified: vidalia/branches/auto-updates/src/vidalia/updateprocess.h
===================================================================
--- vidalia/branches/auto-updates/src/vidalia/updateprocess.h	2008-11-21 02:04:34 UTC (rev 3329)
+++ vidalia/branches/auto-updates/src/vidalia/updateprocess.h	2008-11-21 03:49:46 UTC (rev 3330)
@@ -21,6 +21,10 @@
   Q_OBJECT
 
 public:
+  enum BundleInfo {
+    TorBundleInfo,
+  };
+
   /** Default constructor.
    */
   UpdateProcess(QObject *parent = 0);
@@ -29,8 +33,7 @@
    * by <b>updaterExecutable</b>. The arguments in <b>args</b> will be given
    * to the auto-update binary on the command line.
    */
-  void checkForUpdates(const QString &updaterExecutable,
-                       const QStringList &args);
+  void checkForUpdates(BundleInfo bundle);
 
   /** Return the time at which we should next check for available updates, 
    * given the last we checked was at <b>lastCheckedAt</b>.
@@ -47,6 +50,17 @@
    * Glider process to check for available software updates. */
   static int checkForUpdatesInterval();
 
+  /** Returns the path and filename of the software update executable. */
+  static QString updateExecutable();
+
+signals:
+  void checkForUpdatesFailed(QString errmsg);
+
+  void downloadProgressChanged(QString filename,
+                               int bytesReceived, int bytesTotal);
+
+  void updatesAvailable(QStringList updates);
+
 protected slots:
   /** Called when there is data to be read from the update process's stdout.
    * Reads and parses all available data.
@@ -57,6 +71,14 @@
    * Reads and parses all available data.
    */
   void readStandardError();
+
+  /** Called when the underlying QProcess encounters an error. */
+  void onError(QProcess::ProcessError error);
+
+protected:
+  /** Converts a BundleInfo enum value to its proper Thandy-recognized URL
+   * for the current OS and architecture. */
+  QString bundleInfoToString(BundleInfo bundleInfo);
 };
 
 #endif