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 StatusEventWidget.h 00013 ** \version $Id: StatusEventWidget.h 4122 2009-09-16 01:22:27Z edmanm $ 00014 ** \brief Displays information on Tor status events 00015 */ 00016 00017 #ifndef _STATUSEVENTWIDGET_H 00018 #define _STATUSEVENTWIDGET_H 00019 00020 #include <QTreeWidget> 00021 00022 #include "TorControl.h" 00023 00024 #include <QList> 00025 00026 class QPixmap; 00027 class QString; 00028 class QPoint; 00029 class QStringList; 00030 00031 class StatusEventItem; 00032 00033 class StatusEventWidget : public QTreeWidget 00034 { 00035 Q_OBJECT 00036 00037 public: 00038 /** Default constructor. 00039 */ 00040 StatusEventWidget(QWidget *parent = 0); 00041 00042 /** Sets the maximum number of status event items displayed to 00043 * <b>maximumItemCount</b>. If the current number of items displayed 00044 * exceeds <b>maximumItemCount</b>, the oldest items will be removed until 00045 * topLevelItemCount() is equal to the new limit. 00046 */ 00047 void setMaximumItemCount(int maximumItemCount); 00048 00049 /** Returns the maximum number of status items that can be displayed in 00050 * this StatusEventWidget. 00051 */ 00052 int maximumItemCount() const; 00053 00054 /** Returns a QStringList of the currently selected status events formatted 00055 * as human-readable text. Each item in the returned QStringList represents 00056 * a single status event. 00057 */ 00058 QStringList selectedEvents() const; 00059 00060 /** Returns a QStringList of all current status events formatted as 00061 * human-readable text. Each item in the returned QStringList represents 00062 * a single status event. 00063 */ 00064 QStringList allEvents() const; 00065 00066 /** Searches the list of current status event items for any items that 00067 * contain <b>text</b> in either the event title or description. Searching 00068 * is done case-insensitively. If <b>highlight</b> is true, any previously 00069 * selected items will be deselected and the matching items will be 00070 * highlighted. Returns a (possibly empty) list of matching items. 00071 */ 00072 QList<StatusEventItem *> find(const QString &text, bool highlight = true); 00073 00074 protected: 00075 /** Called when the user has changed the UI display language in Vidalia 00076 * indicating all the displayed text widgets need to be updated to 00077 * display their value in the newly chosen language. 00078 */ 00079 virtual void retranslateUi(); 00080 00081 private slots: 00082 /** Copies the text for all selected event items to the system 00083 * clipboard. 00084 * \sa selectedEvents() 00085 */ 00086 void customContextMenuRequested(const QPoint &pos); 00087 00088 /** Called when the control socket is connected and authenticated. */ 00089 void authenticated(); 00090 00091 /** Called when the controller has disconnected from Tor */ 00092 void disconnected(); 00093 00094 /** Indicates that Tor has decided the user's Tor software <b>version</b> 00095 * is no longer recommended for some <b>reason</b>. <b>recommended</b> is 00096 * a list of Tor software versions that are considered current. 00097 */ 00098 void dangerousTorVersion(tc::TorVersionStatus reason, 00099 const QString &version, 00100 const QStringList &recommended); 00101 00102 /** Indicates Tor has been able to successfully establish one or more 00103 * circuits. 00104 */ 00105 void circuitEstablished(); 00106 00107 /** Emitted when Tor has encountered an internal bug. <b>reason</b> is 00108 * Tor's description of the bug. 00109 */ 00110 void bug(const QString &reason); 00111 00112 /** Indicates that Tor has determined the client's clock is potentially 00113 * skewed by <b>skew</b> seconds relative to <b>source</b>. 00114 */ 00115 void clockSkewed(int skew, const QString &source); 00116 00117 /** Called when the user attempts to establish a connection to some 00118 * destination on port <b>port</b>, which is a port known to use 00119 * plaintext connections (as determined by Tor's WarnPlaintextPorts and 00120 * RejectPlaintextPorts torrc options). <b>rejected</b> indicates whether 00121 * Tor rejected the connection or permitted it to connect anyway. 00122 */ 00123 void dangerousPort(quint16 port, bool rejected); 00124 00125 /** Called when Tor detects a problem with a SOCKS connection from the 00126 * user, such as a bad hostname, dangerous SOCKS protocol type, or a bad 00127 * hostname. <b>type</b> indicates the type of error encountered and 00128 * <b>destination</b> (if non-empty) specifies the attempted connection 00129 * destination address or hostname. 00130 */ 00131 void socksError(tc::SocksError type, const QString &destination); 00132 00133 /** Called when Tor decides the client's external IP address has changed 00134 * to <b>ip</b>. If <b>hostname</b> is non-empty, Tor obtained the new 00135 * value for <b>ip</b> by resolving <b>hostname</b>. 00136 */ 00137 void externalAddressChanged(const QHostAddress &ip, const QString &hostname); 00138 00139 /** Called when Tor determines that the user's DNS provider is providing 00140 * an address for non-existent domains when it should really be saying 00141 * "NXDOMAIN". 00142 */ 00143 void dnsHijacked(); 00144 00145 /** Called when Tor determines that the user's DNS provider is providing 00146 * a hijacked address even for well-known websites. 00147 */ 00148 void dnsUseless(); 00149 00150 /** Indicates Tor has started testing the reachability of its OR port 00151 * using the IP address <b>ip</b> and port <b>port</b>. 00152 */ 00153 void checkingOrPortReachability(const QHostAddress &ip, quint16 port); 00154 00155 /** Tor has completed testing the reachability of its OR port using 00156 * the IP address <b>ip</b> and port <b>port</b>. If the user's OR port 00157 * was reachable, <b>reachable</b> will be set to true. 00158 */ 00159 void orPortReachabilityFinished(const QHostAddress &ip, quint16 port, 00160 bool reachable); 00161 00162 /** Indicates Tor has started testing the reachability of its directory 00163 * port using the IP address <b>ip</b> and port <b>port</b>. 00164 */ 00165 void checkingDirPortReachability(const QHostAddress &ip, quint16 port); 00166 00167 /** Tor has completed testing the reachability of its directory port using 00168 * the IP address <b>ip</b> and port <b>port</b>. If the user's directory 00169 * port was reachable, <b>reachable</b> will be set to true. 00170 */ 00171 void dirPortReachabilityFinished(const QHostAddress &ip, quint16 port, 00172 bool reachable); 00173 00174 /** Called when the directory authority with IP address <b>ip</b> and 00175 * port <b>port</b> rejected the user's server descriptor. <b>reason</b> 00176 * describes why the descriptor was rejected (e.g., malformed, skewed 00177 * clock, etc.). 00178 */ 00179 void serverDescriptorRejected(const QHostAddress &ip, quint16 port, 00180 const QString &reason); 00181 00182 /** Emitted when the directory authority with IP address <b>ip</b> and 00183 * port <b>port</b> accepted the user's server descriptor. 00184 */ 00185 void serverDescriptorAccepted(const QHostAddress &ip, quint16 port); 00186 00187 private: 00188 /** Adds a new status event notification item to the widget. The item will 00189 * be drawn using the specified <b>icon</b>, short event <b>title</b>, 00190 * and a longer detailed <b>description</b>. If <b>helpUrl</b> is not 00191 * empty, the item will also have a clickable question mark icon in the 00192 * corner. 00193 */ 00194 void addNotification(const QPixmap &icon, 00195 const QString &title, 00196 const QString &description, 00197 const QString &helpUrl = QString()); 00198 00199 /** Creates a new QPixmap using <b>pixmap</b> as the main image and 00200 * overlays <b>badge</b> in the lower-right corner of the image. 00201 */ 00202 static QPixmap addBadgeToPixmap(const QPixmap &pixmap, 00203 const QPixmap &badge); 00204 00205 /** Overloaded method provided for convenience. Constructs QPixmap objects 00206 * from the Qt resource URLs <b>pixmap</b> and <b>badge</b>. 00207 * \sa addBadgeToPixmap(QPixmap, QPixmap) 00208 */ 00209 static QPixmap addBadgeToPixmap(const QString &pixmap, 00210 const QString &badge); 00211 00212 /** Overloaded method provided for convenience. Constructs a QPixmap object 00213 * for the Qt resource URL <b>badge</b>, and applies it to <b>pixmap</b>. 00214 * \sa addBadgeToPixmap(QPixmap, QPixmap) 00215 */ 00216 static QPixmap addBadgeToPixmap(const QPixmap &pixmap, 00217 const QString &badge); 00218 00219 /** Maximum number of event notifications contained in the StatusEventWidget 00220 * at any given time. 00221 * \sa setMaximumItemCount() 00222 */ 00223 int _maximumItemCount; 00224 00225 /** Tor sends a ACCEPTED_SERVER_DESCRIPTOR event every time it manages to 00226 * upload the user's relay's descriptor to a directory authority. So we 00227 * squelch any such events after the first to avoid blasting the user with 00228 * "Hey, your relay is working!" messages. 00229 */ 00230 bool _squelchDescriptorAcceptedEvent; 00231 }; 00232 00233 #endif 00234