Vidalia  0.3.1
StatusEventWidget.h
Go to the documentation of this file.
1 /*
2 ** This file is part of Vidalia, and is subject to the license terms in the
3 ** LICENSE file, found in the top level directory of this distribution. If you
4 ** did not receive the LICENSE file with this file, you may obtain it from the
5 ** Vidalia source package distributed by the Vidalia Project at
6 ** http://www.torproject.org/projects/vidalia.html. No part of Vidalia,
7 ** including this file, may be copied, modified, propagated, or distributed
8 ** except according to the terms described in the LICENSE file.
9 */
10 
11 /*
12 ** \file StatusEventWidget.h
13 ** \brief Displays information on Tor status events
14 */
15 
16 #ifndef _STATUSEVENTWIDGET_H
17 #define _STATUSEVENTWIDGET_H
18 
19 #include <QTreeWidget>
20 
21 #include "TorControl.h"
22 
23 #include <QList>
24 
25 class QPixmap;
26 class QString;
27 class QPoint;
28 class QStringList;
29 
30 class StatusEventItem;
31 
32 class StatusEventWidget : public QTreeWidget
33 {
34  Q_OBJECT
35 
36 public:
37  /** Default constructor.
38  */
39  StatusEventWidget(QWidget *parent = 0);
40 
41  /** Sets the maximum number of status event items displayed to
42  * <b>maximumItemCount</b>. If the current number of items displayed
43  * exceeds <b>maximumItemCount</b>, the oldest items will be removed until
44  * topLevelItemCount() is equal to the new limit.
45  */
47 
48  /** Returns the maximum number of status items that can be displayed in
49  * this StatusEventWidget.
50  */
51  int maximumItemCount() const;
52 
53  /** Returns a QStringList of the currently selected status events formatted
54  * as human-readable text. Each item in the returned QStringList represents
55  * a single status event.
56  */
57  QStringList selectedEvents() const;
58 
59  /** Returns a QStringList of all current status events formatted as
60  * human-readable text. Each item in the returned QStringList represents
61  * a single status event.
62  */
63  QStringList allEvents() const;
64 
65  /** Searches the list of current status event items for any items that
66  * contain <b>text</b> in either the event title or description. Searching
67  * is done case-insensitively. If <b>highlight</b> is true, any previously
68  * selected items will be deselected and the matching items will be
69  * highlighted. Returns a (possibly empty) list of matching items.
70  */
71  QList<StatusEventItem *> find(const QString &text, bool highlight = true);
72 
73 protected:
74  /** Called when the user has changed the UI display language in Vidalia
75  * indicating all the displayed text widgets need to be updated to
76  * display their value in the newly chosen language.
77  */
78  virtual void retranslateUi();
79 
80 private slots:
81  /** Copies the text for all selected event items to the system
82  * clipboard.
83  * \sa selectedEvents()
84  */
85  void customContextMenuRequested(const QPoint &pos);
86 
87  /** Called when the control socket is connected and authenticated. */
88  void authenticated();
89 
90  /** Called when the controller has disconnected from Tor */
91  void disconnected();
92 
93  /** Indicates that Tor has decided the user's Tor software <b>version</b>
94  * is no longer recommended for some <b>reason</b>. <b>recommended</b> is
95  * a list of Tor software versions that are considered current.
96  */
98  const QString &version,
99  const QStringList &recommended);
100 
101  /** Indicates Tor has been able to successfully establish one or more
102  * circuits.
103  */
104  void circuitEstablished();
105 
106  /** Emitted when Tor has encountered an internal bug. <b>reason</b> is
107  * Tor's description of the bug.
108  */
109  void bug(const QString &reason);
110 
111  /** Indicates that Tor has determined the client's clock is potentially
112  * skewed by <b>skew</b> seconds relative to <b>source</b>.
113  */
114  void clockSkewed(int skew, const QString &source);
115 
116  /** Called when the user attempts to establish a connection to some
117  * destination on port <b>port</b>, which is a port known to use
118  * plaintext connections (as determined by Tor's WarnPlaintextPorts and
119  * RejectPlaintextPorts torrc options). <b>rejected</b> indicates whether
120  * Tor rejected the connection or permitted it to connect anyway.
121  */
122  void dangerousPort(quint16 port, bool rejected);
123 
124  /** Called when Tor detects a problem with a SOCKS connection from the
125  * user, such as a bad hostname, dangerous SOCKS protocol type, or a bad
126  * hostname. <b>type</b> indicates the type of error encountered and
127  * <b>destination</b> (if non-empty) specifies the attempted connection
128  * destination address or hostname.
129  */
130  void socksError(tc::SocksError type, const QString &destination);
131 
132  /** Called when Tor decides the client's external IP address has changed
133  * to <b>ip</b>. If <b>hostname</b> is non-empty, Tor obtained the new
134  * value for <b>ip</b> by resolving <b>hostname</b>.
135  */
136  void externalAddressChanged(const QHostAddress &ip, const QString &hostname);
137 
138  /** Called when Tor determines that the user's DNS provider is providing
139  * an address for non-existent domains when it should really be saying
140  * "NXDOMAIN".
141  */
142  void dnsHijacked();
143 
144  /** Called when Tor determines that the user's DNS provider is providing
145  * a hijacked address even for well-known websites.
146  */
147  void dnsUseless();
148 
149  /** Indicates Tor has started testing the reachability of its OR port
150  * using the IP address <b>ip</b> and port <b>port</b>.
151  */
152  void checkingOrPortReachability(const QHostAddress &ip, quint16 port);
153 
154  /** Tor has completed testing the reachability of its OR port using
155  * the IP address <b>ip</b> and port <b>port</b>. If the user's OR port
156  * was reachable, <b>reachable</b> will be set to true.
157  */
158  void orPortReachabilityFinished(const QHostAddress &ip, quint16 port,
159  bool reachable);
160 
161  /** Indicates Tor has started testing the reachability of its directory
162  * port using the IP address <b>ip</b> and port <b>port</b>.
163  */
164  void checkingDirPortReachability(const QHostAddress &ip, quint16 port);
165 
166  /** Tor has completed testing the reachability of its directory port using
167  * the IP address <b>ip</b> and port <b>port</b>. If the user's directory
168  * port was reachable, <b>reachable</b> will be set to true.
169  */
170  void dirPortReachabilityFinished(const QHostAddress &ip, quint16 port,
171  bool reachable);
172 
173  /** Called when the directory authority with IP address <b>ip</b> and
174  * port <b>port</b> rejected the user's server descriptor. <b>reason</b>
175  * describes why the descriptor was rejected (e.g., malformed, skewed
176  * clock, etc.).
177  */
178  void serverDescriptorRejected(const QHostAddress &ip, quint16 port,
179  const QString &reason);
180 
181  /** Emitted when the directory authority with IP address <b>ip</b> and
182  * port <b>port</b> accepted the user's server descriptor.
183  */
184  void serverDescriptorAccepted(const QHostAddress &ip, quint16 port);
185 
186 private:
187  /** Adds a new status event notification item to the widget. The item will
188  * be drawn using the specified <b>icon</b>, short event <b>title</b>,
189  * and a longer detailed <b>description</b>. If <b>helpUrl</b> is not
190  * empty, the item will also have a clickable question mark icon in the
191  * corner.
192  */
193  void addNotification(const QPixmap &icon,
194  const QString &title,
195  const QString &description,
196  const QString &helpUrl = QString());
197 
198  /** Creates a new QPixmap using <b>pixmap</b> as the main image and
199  * overlays <b>badge</b> in the lower-right corner of the image.
200  */
201  static QPixmap addBadgeToPixmap(const QPixmap &pixmap,
202  const QPixmap &badge);
203 
204  /** Overloaded method provided for convenience. Constructs QPixmap objects
205  * from the Qt resource URLs <b>pixmap</b> and <b>badge</b>.
206  * \sa addBadgeToPixmap(QPixmap, QPixmap)
207  */
208  static QPixmap addBadgeToPixmap(const QString &pixmap,
209  const QString &badge);
210 
211  /** Overloaded method provided for convenience. Constructs a QPixmap object
212  * for the Qt resource URL <b>badge</b>, and applies it to <b>pixmap</b>.
213  * \sa addBadgeToPixmap(QPixmap, QPixmap)
214  */
215  static QPixmap addBadgeToPixmap(const QPixmap &pixmap,
216  const QString &badge);
217 
218  /** Maximum number of event notifications contained in the StatusEventWidget
219  * at any given time.
220  * \sa setMaximumItemCount()
221  */
223 
224  /** Tor sends a ACCEPTED_SERVER_DESCRIPTOR event every time it manages to
225  * upload the user's relay's descriptor to a directory authority. So we
226  * squelch any such events after the first to avoid blasting the user with
227  * "Hey, your relay is working!" messages.
228  */
230 };
231 
232 #endif
233 
StatusEventWidget::serverDescriptorRejected
void serverDescriptorRejected(const QHostAddress &ip, quint16 port, const QString &reason)
Definition: StatusEventWidget.cpp:576
StatusEventWidget::bug
void bug(const QString &reason)
Definition: StatusEventWidget.cpp:344
StatusEventWidget::dnsUseless
void dnsUseless()
Definition: StatusEventWidget.cpp:489
StatusEventWidget::externalAddressChanged
void externalAddressChanged(const QHostAddress &ip, const QString &hostname)
Definition: StatusEventWidget.cpp:462
StatusEventItem
Definition: StatusEventItem.h:25
StatusEventWidget::maximumItemCount
int maximumItemCount() const
Definition: StatusEventWidget.cpp:113
StatusEventWidget::_squelchDescriptorAcceptedEvent
bool _squelchDescriptorAcceptedEvent
Definition: StatusEventWidget.h:229
StatusEventWidget::customContextMenuRequested
void customContextMenuRequested(const QPoint &pos)
Definition: StatusEventWidget.cpp:159
StatusEventWidget::allEvents
QStringList allEvents() const
Definition: StatusEventWidget.cpp:139
StatusEventWidget::checkingDirPortReachability
void checkingDirPortReachability(const QHostAddress &ip, quint16 port)
Definition: StatusEventWidget.cpp:539
StatusEventWidget::clockSkewed
void clockSkewed(int skew, const QString &source)
Definition: StatusEventWidget.cpp:356
StatusEventWidget::circuitEstablished
void circuitEstablished()
Definition: StatusEventWidget.cpp:334
StatusEventWidget::StatusEventWidget
StatusEventWidget(QWidget *parent=0)
Definition: StatusEventWidget.cpp:39
TorControl.h
StatusEventWidget::dnsHijacked
void dnsHijacked()
Definition: StatusEventWidget.cpp:476
StatusEventWidget::authenticated
void authenticated()
Definition: StatusEventWidget.cpp:259
StatusEventWidget::addBadgeToPixmap
static QPixmap addBadgeToPixmap(const QPixmap &pixmap, const QPixmap &badge)
Definition: StatusEventWidget.cpp:233
StatusEventWidget::setMaximumItemCount
void setMaximumItemCount(int maximumItemCount)
Definition: StatusEventWidget.cpp:96
StatusEventWidget::selectedEvents
QStringList selectedEvents() const
Definition: StatusEventWidget.cpp:119
StatusEventWidget::disconnected
void disconnected()
Definition: StatusEventWidget.cpp:287
StatusEventWidget::_maximumItemCount
int _maximumItemCount
Definition: StatusEventWidget.h:222
StatusEventWidget::dangerousTorVersion
void dangerousTorVersion(tc::TorVersionStatus reason, const QString &version, const QStringList &recommended)
Definition: StatusEventWidget.cpp:302
StatusEventWidget::serverDescriptorAccepted
void serverDescriptorAccepted(const QHostAddress &ip, quint16 port)
Definition: StatusEventWidget.cpp:592
tc::TorVersionStatus
TorVersionStatus
Definition: tcglobal.h:86
StatusEventWidget::addNotification
void addNotification(const QPixmap &icon, const QString &title, const QString &description, const QString &helpUrl=QString())
Definition: StatusEventWidget.cpp:201
StatusEventWidget::retranslateUi
virtual void retranslateUi()
Definition: StatusEventWidget.cpp:84
StatusEventWidget::find
QList< StatusEventItem * > find(const QString &text, bool highlight=true)
Definition: StatusEventWidget.cpp:179
StatusEventWidget::checkingOrPortReachability
void checkingOrPortReachability(const QHostAddress &ip, quint16 port)
Definition: StatusEventWidget.cpp:502
StatusEventWidget::dangerousPort
void dangerousPort(quint16 port, bool rejected)
Definition: StatusEventWidget.cpp:393
StatusEventWidget::socksError
void socksError(tc::SocksError type, const QString &destination)
Definition: StatusEventWidget.cpp:422
StatusEventWidget
Definition: StatusEventWidget.h:32
StatusEventWidget::orPortReachabilityFinished
void orPortReachabilityFinished(const QHostAddress &ip, quint16 port, bool reachable)
Definition: StatusEventWidget.cpp:513
StatusEventWidget::dirPortReachabilityFinished
void dirPortReachabilityFinished(const QHostAddress &ip, quint16 port, bool reachable)
Definition: StatusEventWidget.cpp:550
tc::SocksError
SocksError
Definition: tcglobal.h:79