Vidalia  0.3.1
UPNPTestDialog.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
4 ** you did not receive the LICENSE file with this file, you may obtain it
5 ** from the 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 UPNPTestDialog.h
13 ** \brief Dialog that displays the progress of a UPnP configuration test
14 */
15 
16 #ifndef _UPNPTESTDIALOG_H
17 #define _UPNPTESTDIALOG_H
18 
19 #include "ui_UPNPTestDialog.h"
20 #include "UPNPControl.h"
21 
22 #include <QDialog>
23 #include <QAbstractButton>
24 #include <QTimer>
25 
26 
27 class UPNPTestDialog : public QDialog
28 {
29  Q_OBJECT
30 
31 public:
32  /** Default constructor. <b>orPort</b> and <b>dirPort</b> specify the ports
33  * used to test UPnP port forwarding. The original UPnP state will be
34  * restored when the test dialog is closed. */
35  UPNPTestDialog(quint16 orPort, quint16 dirPort, QWidget *parent = 0);
36 
37 signals:
38  /** Emitted when the user clicks the 'Help' button requesting the help topic
39  * on port forwarding. */
40  void help();
41 
42 protected slots:
43  /** Shows or hides the dialog based on <b>visible</b>. The UPnP test will be
44  * started when the dialog is first shown. */
45  void setVisible(bool visible);
46 
47  /** Called when a user clicks on a button in the dialog's button box. If
48  * Retry is clicked, another UPnP test will be conducted. If Close is clicked,
49  * then the dialog is closed and the original UPnP state restored. */
50  void clicked(QAbstractButton *button);
51 
52  /** Updates the test UI based on the UPnP <b>state</b>. */
54 
55  /** Updates the progress bar to indicate the device discovery portion of the
56  * test is still in progress. */
57  void discoverTimeout();
58 
59 protected:
60  /** Initiates a UPnP test. */
61  void startTest();
62 
63  /** Called when the UPnP test successfully enables port forwarding. Enables
64  * the Close button, allowing the user to exit the test dialog. */
65  void testSuccessful();
66 
67  /** Called when the UPnP test fails due to an error. Enables the Close and
68  * Retry buttons, allowing the user to either rerun the test or give up. */
69  void testFailed();
70 
71 private:
72  /** Pointer to the UPNPControl singleton instance. */
74 
75  /** Timer used to update the progress bar while during the device discovery
76  * portion of the test. */
78 
79  quint16 _oldOrPort; /**< Original (pre-test) forwarded ORPort. */
80  quint16 _oldDirPort; /**< Original (pre-test) forwarded DirPort. */
81  quint16 _orPort; /**< ORPort used during the test. */
82  quint16 _dirPort; /**< DirPort used during the test. */
83 
84  Ui::UPNPTestDialog ui;
85 };
86 
87 #endif
88 
UPNPTestDialog(quint16 orPort, quint16 dirPort, QWidget *parent=0)
quint16 _oldDirPort
Ui::UPNPTestDialog ui
void setVisible(bool visible)
UPNPControl * _upnp
quint16 _oldOrPort
void clicked(QAbstractButton *button)
QTimer _discoverTimer
void upnpStateChanged(UPNPControl::UPNPState state)