00001 /* 00002 ** This file is part of Vidalia, and is subject to the license terms in the 00003 ** LICENSE file, found in the top level directory of this distribution. If you 00004 ** did not receive the LICENSE file with this file, you may obtain it from the 00005 ** Vidalia source package distributed by the Vidalia Project at 00006 ** http://www.vidalia-project.net/. No part of Vidalia, including this file, 00007 ** may be copied, modified, propagated, or distributed except according to the 00008 ** terms described in the LICENSE file. 00009 */ 00010 00011 /* 00012 ** \file bootstrapstatusevent.h 00013 ** \version $Id: bootstrapstatusevent.h 2780 2008-06-21 21:48:32Z edmanm $ 00014 ** \brief Event sent by Tor when its bootstrapping status changes 00015 */ 00016 00017 #ifndef _BOOTSTRAPSTATUSEVENT_H 00018 #define _BOOTSTRAPSTATUSEVENT_H 00019 00020 #include <QEvent> 00021 #include <QString> 00022 #include "clientstatusevent.h" 00023 #include "bootstrapstatus.h" 00024 00025 00026 class BootstrapStatusEvent : public ClientStatusEvent 00027 { 00028 public: 00029 /** Constructor. */ 00030 BootstrapStatusEvent(const BootstrapStatus &status) 00031 : ClientStatusEvent(status.severity(), ClientStatusEvent::Bootstrap), 00032 _bootstrapStatus(status) {} 00033 00034 /** Returns the BootstrapStatus enum value indicated by this bootstrap 00035 * status event. */ 00036 BootstrapStatus status() const { return _bootstrapStatus; } 00037 00038 /** Returns an integer between 0 and 100 representing an estimate of how 00039 * much of Tor's bootstrapping process it has completed. */ 00040 int percentComplete() const { return status().percentComplete(); } 00041 00042 /** Returns a description of Tor's current bootstrapping status. */ 00043 QString description() const { return status().description(); } 00044 00045 /** Returns a description of the most recent error Tor encountered while 00046 * attempting to bootstrap, if this event's severity is 'warn'. Otherwise, 00047 * this returns a default-constructed QString. */ 00048 QString warning() const { return status().warning(); } 00049 00050 /** Returns a ConnectionStatusReason enum value describing the most recent 00051 * error Tor encountered while attempting to bootstrap, if this event's 00052 * severity is 'warn'. Otherwise, this simply returns 00053 * tc::UnrecognizedReason. */ 00054 tc::ConnectionStatusReason reason() const { return status().reason(); } 00055 00056 /** Returns the action that the Tor software recommended be taken in 00057 * response to this bootstrap status event. */ 00058 BootstrapStatus::Recommendation recommendedAction() const { 00059 return status().recommendedAction(); 00060 } 00061 00062 private: 00063 /** Current bootstrapping status value. 00064 * \sa status 00065 */ 00066 BootstrapStatus _bootstrapStatus; 00067 }; 00068 00069 #endif 00070