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 00004 ** you did not receive the LICENSE file with this file, you may obtain it 00005 ** from the 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 00008 ** the terms described in the LICENSE file. 00009 */ 00010 00011 /* 00012 ** \file UPNPTestDialog.h 00013 ** \version $Id: UPNPTestDialog.h 3735 2009-04-28 20:28:01Z edmanm $ 00014 ** \brief Dialog that displays the progress of a UPnP configuration test 00015 */ 00016 00017 #ifndef _UPNPTESTDIALOG_H 00018 #define _UPNPTESTDIALOG_H 00019 00020 #include "ui_UPNPTestDialog.h" 00021 #include "UPNPControl.h" 00022 00023 #include <QDialog> 00024 #include <QAbstractButton> 00025 #include <QTimer> 00026 00027 00028 class UPNPTestDialog : public QDialog 00029 { 00030 Q_OBJECT 00031 00032 public: 00033 /** Default constructor. <b>orPort</b> and <b>dirPort</b> specify the ports 00034 * used to test UPnP port forwarding. The original UPnP state will be 00035 * restored when the test dialog is closed. */ 00036 UPNPTestDialog(quint16 orPort, quint16 dirPort, QWidget *parent = 0); 00037 00038 signals: 00039 /** Emitted when the user clicks the 'Help' button requesting the help topic 00040 * on port forwarding. */ 00041 void help(); 00042 00043 protected slots: 00044 /** Shows or hides the dialog based on <b>visible</b>. The UPnP test will be 00045 * started when the dialog is first shown. */ 00046 void setVisible(bool visible); 00047 00048 /** Called when a user clicks on a button in the dialog's button box. If 00049 * Retry is clicked, another UPnP test will be conducted. If Close is clicked, 00050 * then the dialog is closed and the original UPnP state restored. */ 00051 void clicked(QAbstractButton *button); 00052 00053 /** Updates the test UI based on the UPnP <b>state</b>. */ 00054 void upnpStateChanged(UPNPControl::UPNPState state); 00055 00056 /** Updates the progress bar to indicate the device discovery portion of the 00057 * test is still in progress. */ 00058 void discoverTimeout(); 00059 00060 protected: 00061 /** Initiates a UPnP test. */ 00062 void startTest(); 00063 00064 /** Called when the UPnP test successfully enables port forwarding. Enables 00065 * the Close button, allowing the user to exit the test dialog. */ 00066 void testSuccessful(); 00067 00068 /** Called when the UPnP test fails due to an error. Enables the Close and 00069 * Retry buttons, allowing the user to either rerun the test or give up. */ 00070 void testFailed(); 00071 00072 private: 00073 /** Pointer to the UPNPControl singleton instance. */ 00074 UPNPControl *_upnp; 00075 00076 /** Timer used to update the progress bar while during the device discovery 00077 * portion of the test. */ 00078 QTimer _discoverTimer; 00079 00080 quint16 _oldOrPort; /**< Original (pre-test) forwarded ORPort. */ 00081 quint16 _oldDirPort; /**< Original (pre-test) forwarded DirPort. */ 00082 quint16 _orPort; /**< ORPort used during the test. */ 00083 quint16 _dirPort; /**< DirPort used during the test. */ 00084 00085 Ui::UPNPTestDialog ui; 00086 }; 00087 00088 #endif 00089