1
//=============================================================================
4
// Creation date : Fri Aug 08 18:00:00 2008 GMT by Fabio Bas
6
// This file is part of the KVIrc irc client distribution
7
// Copyright (C) 2008 Fabio Bas (ctrlaltca at gmail dot com)
9
// This program is FREE software. You can redistribute it and/or
10
// modify it under the terms of the GNU General Public License
11
// as published by the Free Software Foundation; either version 2
12
// of the License, or (at your opinion) any later version.
14
// This program is distributed in the HOPE that it will be USEFUL,
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
// See the GNU General Public License for more details.
19
// You should have received a copy of the GNU General Public License
20
// along with this program. If not, write to the Free Software Foundation,
21
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23
// Original Copyright follows:
24
//=============================================================================
26
/***************************************************************************
27
Manager.h - description
29
begin : Fri Aug 05 2005
30
copyright : (C) 2005 by Diederik van der Boor
31
email : vdboor --at-- codingdomain.com
32
***************************************************************************/
40
#include "KviPointerList.h"
41
#include "igdcontrolpoint.h"
42
#include "SsdpConnection.h"
48
* The manager class is the public interface used by other networking classes.
49
* It's implemented as singleton to provide easy access by other classes.
50
* Devices are automatically detected at start-up, and maintained by this class.
51
* Underneath, the actual work is done by the SsdpConnection and IgdControlPoint classes.
53
* @author Diederik van der Boor
54
* @ingroup NetworkUPnP
56
class Manager : public QObject
60
public: // public methods
65
// Return the external IP address
66
QString getExternalIpAddress() const;
68
// Return the instance of the manager class
69
static Manager * instance();
71
// Return true if a controlable gateway is available
72
bool isGatewayAvailable();
75
void addPortMapping(const QString &protocol, const QString &remoteHost, int externalPort, const QString &internalClient, int internalPort, const QString &description, bool enabled = true, int leaseDuration = 0);
76
// Delete a port mapping
77
void deletePortMapping(const QString &protocol, const QString &remoteHost, int externalPort);
80
// The broadcast failed
81
void slotBroadcastTimeout();
82
// A device was discovered by the SSDP broadcast
83
void slotDeviceFound(const QString &hostname, int port, const QString &rootUrl);
86
private: // private methods
87
// The constructor (it's a singleton)
89
// Disable the copy constructor
90
Manager(const Manager &);
91
// Disable the assign operator
92
Manager& operator=(const Manager&);
93
// Initialize the manager, detect all devices
97
// The active control point we're working with
98
IgdControlPoint *m_pActiveIgdControlPoint;
99
// True if the broadcast failed (false during the discovery process)
100
bool m_bBroadcastFailed;
101
// True if the broadcast found a device (false during the discovery process)
102
bool m_bBroadcastFoundIt;
103
// The instance of the singleton class
104
static Manager *m_pInstance;
105
// A list of all detected gateway devices
106
KviPointerList<IgdControlPoint> m_lIgdControlPoints;
107
// The SSDP connection to find all UPnP devices
108
SsdpConnection *m_pSsdpConnection;
109
// The timer to detect a broadcast timeout
110
QTimer *m_pSsdpTimer;
114
} // End of namespace