Vidalia 0.2.10
Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Protected Types | Protected Slots | Protected Member Functions | Static Protected Member Functions | Private Attributes

UpdateProcess Class Reference

#include <UpdateProcess.h>

List of all members.

Public Types

enum  BundleInfo { TorBundleInfo }

Public Slots

void cancel ()

Signals

void checkForUpdatesFailed (QString errmsg)
void downloadProgress (QString url, int bytesReceived, int bytesTotal)
void updatesAvailable (UpdateProcess::BundleInfo bi, PackageList packages)
void updatesInstalled (int nPackagesInstalled)
void installUpdatesFailed (QString errmsg)

Public Member Functions

 UpdateProcess (QObject *parent=0)
void checkForUpdates (BundleInfo bi)
void installUpdates (BundleInfo bi)
bool isRunning () const
void setSocksPort (quint16 port)

Static Public Member Functions

static QDateTime nextCheckForUpdates (const QDateTime &lastCheckedAt)
static bool shouldCheckForUpdates (const QDateTime &lastCheckedAt)
static int checkForUpdatesInterval ()
static QString updateExecutable ()
static QString updateRepositoryDir ()

Protected Types

enum  UpdateCommand { NoCommand, CheckForUpdates, InstallUpdates }

Protected Slots

void readStandardOutput ()
void readStandardError ()
void onError (QProcess::ProcessError error)
void onFinished (int exitCode, QProcess::ExitStatus exitStatus)

Protected Member Functions

QString bundleInfoToString (BundleInfo bundleInfo)

Static Protected Member Functions

static PackageInfo packageInfo (const QString &package)
static PackageInfo packageInfoFromXml (const QByteArray &xml)

Private Attributes

UpdateCommand _currentCommand
BundleInfo _currentBundle
PackageList _packageList
quint16 _socksPort

Detailed Description

Definition at line 22 of file UpdateProcess.h.


Member Enumeration Documentation

Enumerator:
TorBundleInfo 

Definition at line 27 of file UpdateProcess.h.

enum UpdateProcess::UpdateCommand [protected]
Enumerator:
NoCommand 
CheckForUpdates 
InstallUpdates 

Definition at line 134 of file UpdateProcess.h.


Constructor & Destructor Documentation

UpdateProcess::UpdateProcess ( QObject *  parent = 0)

Default constructor.

Definition at line 22 of file UpdateProcess.cpp.

References _currentCommand, _socksPort, NoCommand, onFinished(), readStandardError(), and readStandardOutput().


Member Function Documentation

QString UpdateProcess::bundleInfoToString ( BundleInfo  bundleInfo) [protected]

Converts a BundleInfo enum value to its proper Thandy-recognized URL for the current OS and architecture.

Definition at line 249 of file UpdateProcess.cpp.

References TorBundleInfo.

Referenced by checkForUpdates(), and installUpdates().

void UpdateProcess::cancel ( ) [slot]

Cancels the currently running software update operation immediately.

Definition at line 94 of file UpdateProcess.cpp.

References _currentCommand, and CheckForUpdates.

void UpdateProcess::checkForUpdates ( BundleInfo  bi)

Begin a check for software updates that may be available for the software package specified by bi.

Definition at line 39 of file UpdateProcess.cpp.

References _currentBundle, _currentCommand, _socksPort, bundleInfoToString(), CheckForUpdates, updateExecutable(), updateRepositoryDir(), and vNotice.

void UpdateProcess::checkForUpdatesFailed ( QString  errmsg) [signal]

Emitted when the check for available software updates failed. errmsg contains a human-readable description of the problem encountered.

Referenced by onError(), and onFinished().

int UpdateProcess::checkForUpdatesInterval ( ) [static]

Returns the preferred interval (in seconds) between executions of the Glider process to check for available software updates.

Definition at line 217 of file UpdateProcess.cpp.

Referenced by nextCheckForUpdates().

void UpdateProcess::downloadProgress ( QString  url,
int  bytesReceived,
int  bytesTotal 
) [signal]

Emitted while an updated package download is in progress. url is location of the update, bytesReceived is how many bytes have been downloaded so far and bytesTotal is the total size of the package being downloaded.

Referenced by readStandardError().

void UpdateProcess::installUpdates ( BundleInfo  bi)

Instructs the software update process to install previously downloaded files for bi.

Definition at line 61 of file UpdateProcess.cpp.

References _currentBundle, _currentCommand, _socksPort, bundleInfoToString(), InstallUpdates, updateExecutable(), updateRepositoryDir(), and vNotice.

void UpdateProcess::installUpdatesFailed ( QString  errmsg) [signal]

Emitted when there is an error installing one or more updated software packages. errmsg might even contain a useful description of the error encountered (but don't bet the farm on it).

Referenced by readStandardError().

bool UpdateProcess::isRunning ( ) const

Returns true if the update process is currently in the middle of an operation, such as checking for or installing updates.

Definition at line 88 of file UpdateProcess.cpp.

QDateTime UpdateProcess::nextCheckForUpdates ( const QDateTime &  lastCheckedAt) [static]

Return the time at which we should next check for available updates, given the last we checked was at lastCheckedAt.

Definition at line 224 of file UpdateProcess.cpp.

References checkForUpdatesInterval().

Referenced by MainWindow::running(), and shouldCheckForUpdates().

void UpdateProcess::onError ( QProcess::ProcessError  error) [protected, slot]

Called when the underlying QProcess encounters an error.

Definition at line 206 of file UpdateProcess.cpp.

References checkForUpdatesFailed(), updateExecutable(), and vWarn.

void UpdateProcess::onFinished ( int  exitCode,
QProcess::ExitStatus  exitStatus 
) [protected, slot]

Called when the auto-update process has terminated.

Definition at line 186 of file UpdateProcess.cpp.

References _currentBundle, _currentCommand, _packageList, CheckForUpdates, checkForUpdatesFailed(), InstallUpdates, updatesAvailable(), updatesInstalled(), and vInfo.

Referenced by UpdateProcess().

PackageInfo UpdateProcess::packageInfo ( const QString &  package) [static, protected]

Returns a PackageInfo object containing information about the updated package specified by the /pkginfo/ URL in package.

Definition at line 260 of file UpdateProcess.cpp.

References packageInfoFromXml(), updateExecutable(), updateRepositoryDir(), and vNotice.

Referenced by readStandardError().

PackageInfo UpdateProcess::packageInfoFromXml ( const QByteArray &  xml) [static, protected]

Returns a PackageInfo object populated with information extracted from a Thandy-formatted XML document given by xml.

Definition at line 282 of file UpdateProcess.cpp.

References err(), PackageInfo::setLongDescription(), PackageInfo::setName(), PackageInfo::setShortDescription(), PackageInfo::setVersion(), and vWarn.

Referenced by packageInfo().

void UpdateProcess::readStandardError ( ) [protected, slot]

Called when there is data to be read from the update process's stderr. Reads and parses all available data.

XXX: This is a fucking kludge. If installation fails, Thandy just dumps a Python traceback that (for obvious reasons) doesn't follow the expected format. There isn't a defined control message type for this yet we'd really like the error, so treat this one specially.

Definition at line 106 of file UpdateProcess.cpp.

References _currentCommand, _packageList, CheckForUpdates, downloadProgress(), installUpdatesFailed(), PackageInfo::isValid(), packageInfo(), string_parse_keyvals(), and vInfo.

Referenced by UpdateProcess().

void UpdateProcess::readStandardOutput ( ) [protected, slot]

Called when there is data to be read from the update process's stdout. Reads and parses all available data.

Definition at line 174 of file UpdateProcess.cpp.

References vInfo.

Referenced by UpdateProcess().

void UpdateProcess::setSocksPort ( quint16  port)

Sets the port to use as a SOCKS proxy to port. If port is set to 0, then no SOCKS proxy will be used when checking for updates.

Definition at line 82 of file UpdateProcess.cpp.

References _socksPort.

bool UpdateProcess::shouldCheckForUpdates ( const QDateTime &  lastCheckedAt) [static]

Return true if we should check for available software udpates, given the last time we checked was at lastCheckedAt. The returned QDateTime will be in UTC.

Definition at line 230 of file UpdateProcess.cpp.

References nextCheckForUpdates().

Referenced by MainWindow::circuitEstablished(), and MainWindow::running().

QString UpdateProcess::updateExecutable ( ) [static]

Returns the path and filename of the software update executable.

Definition at line 237 of file UpdateProcess.cpp.

Referenced by checkForUpdates(), installUpdates(), onError(), and packageInfo().

QString UpdateProcess::updateRepositoryDir ( ) [static]

Returns the path in which the software update executable should write all of its state information.

Definition at line 243 of file UpdateProcess.cpp.

References Vidalia::dataDirectory().

Referenced by checkForUpdates(), installUpdates(), and packageInfo().

void UpdateProcess::updatesAvailable ( UpdateProcess::BundleInfo  bi,
PackageList  packages 
) [signal]

Emitted when updated software packages in bundle bi are are available. packages contains a collection of PackageInfo objects describing the updates available for installation.

Referenced by onFinished().

void UpdateProcess::updatesInstalled ( int  nPackagesInstalled) [signal]

Emitted after all available updated packages have been successfully installed.

Referenced by onFinished().


Member Data Documentation

Enum value of the last bundle for which we performed some action (e.g., check for updates, install an update, etc.

Definition at line 160 of file UpdateProcess.h.

Referenced by checkForUpdates(), installUpdates(), and onFinished().

Enum value of the current auto-update operation.

Definition at line 156 of file UpdateProcess.h.

Referenced by cancel(), checkForUpdates(), installUpdates(), onFinished(), readStandardError(), and UpdateProcess().

List of packages that have available updates.

Definition at line 163 of file UpdateProcess.h.

Referenced by onFinished(), and readStandardError().

quint16 UpdateProcess::_socksPort [private]

Currently configured SOCKS port.

Definition at line 166 of file UpdateProcess.h.

Referenced by checkForUpdates(), installUpdates(), setSocksPort(), and UpdateProcess().


The documentation for this class was generated from the following files: