Vidalia 0.2.12

StatusEventWidget.h

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