KVIrc  4.9.2
DeveloperAPIs
Manager.h
Go to the documentation of this file.
1 //=============================================================================
2 //
3 // File : Manager.h
4 // Creation date : Fri Aug 08 18:00:00 2008 GMT by Fabio Bas
5 //
6 // This file is part of the KVIrc IRC client distribution
7 // Copyright (C) 2008 Fabio Bas (ctrlaltca at gmail dot com)
8 //
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 option) any later version.
13 //
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.
18 //
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.
22 //
23 // Original Copyright follows:
24 //=============================================================================
25 
26 /***************************************************************************
27  Manager.h - description
28  -------------------
29  begin : Fri Aug 05 2005
30  copyright : (C) 2005 by Diederik van der Boor
31  email : vdboor --at-- codingdomain.com
32  ***************************************************************************/
33 
34 #ifndef UPNPMANAGER_H
35 #define UPNPMANAGER_H
36 
37 #include <QObject>
38 #include <QTimer>
39 
40 #include "KviPointerList.h"
41 #include "igdcontrolpoint.h"
42 #include "SsdpConnection.h"
43 
44 namespace UPnP
45 {
46 
56  class Manager : public QObject
57  {
58  Q_OBJECT
59 
60  public: // public methods
61  // The destructor
62  virtual ~Manager();
63 
64  // Return the external IP address
65  QString getExternalIpAddress() const;
66 
67  // Return the instance of the manager class
68  static Manager * instance();
69 
70  // Return true if a controlable gateway is available
71  bool isGatewayAvailable();
72 
73  // Add a port mapping
74  void addPortMapping(const QString & protocol, const QString & remoteHost, int externalPort, const QString & internalClient, int internalPort, const QString & description, bool enabled = true, int leaseDuration = 0);
75  // Delete a port mapping
76  void deletePortMapping(const QString & protocol, const QString & remoteHost, int externalPort);
77 
78  private slots:
79  // The broadcast failed
80  void slotBroadcastTimeout();
81  // A device was discovered by the SSDP broadcast
82  void slotDeviceFound(const QString & hostname, int port, const QString & rootUrl);
83 
84  private: // private methods
85  // The constructor (it's a singleton)
86  Manager();
87  // Disable the copy constructor
88  Manager(const Manager &);
89  // Disable the assign operator
90  Manager & operator=(const Manager &);
91  // Initialize the manager, detect all devices
92  void initialize();
93 
94  private:
95  // The active control point we're working with
97  // True if the broadcast failed (false during the discovery process)
99  // True if the broadcast found a device (false during the discovery process)
101  // The instance of the singleton class
103  // A list of all detected gateway devices
105  // The SSDP connection to find all UPnP devices
107  // The timer to detect a broadcast timeout
108  QTimer * m_pSsdpTimer;
109  };
110 
111 } // End of namespace
112 
113 #endif
KviPointerList< IgdControlPoint > m_lIgdControlPoints
Definition: Manager.h:104
void slotBroadcastTimeout()
Definition: Manager.cpp:125
static Manager * instance()
Definition: Manager.cpp:85
void initialize()
Definition: Manager.cpp:63
QString getExternalIpAddress() const
Definition: Manager.cpp:98
QTimer * m_pSsdpTimer
Definition: Manager.h:108
Definition: SsdpConnection.h:55
SsdpConnection * m_pSsdpConnection
Definition: Manager.h:106
bool isGatewayAvailable()
Definition: Manager.cpp:105
bool m_bBroadcastFoundIt
Definition: Manager.h:100
IgdControlPoint * m_pActiveIgdControlPoint
Definition: Manager.h:96
C++ Template based double linked pointer list class.
void deletePortMapping(const QString &protocol, const QString &remoteHost, int externalPort)
Definition: Manager.cpp:118
A template double linked list of pointers.
Definition: KviPointerList.h:55
Manager & operator=(const Manager &)
bool m_bBroadcastFailed
Definition: Manager.h:98
Definition: igdcontrolpoint.h:56
void addPortMapping(const QString &protocol, const QString &remoteHost, int externalPort, const QString &internalClient, int internalPort, const QString &description, bool enabled=true, int leaseDuration=0)
Definition: Manager.cpp:111
static Manager * m_pInstance
Definition: Manager.h:102
void slotDeviceFound(const QString &hostname, int port, const QString &rootUrl)
Definition: Manager.cpp:136
virtual ~Manager()
Definition: Manager.cpp:55
Manager()
Definition: Manager.cpp:49
Definition: Manager.h:56
QString hostname()
Definition: KviRuntimeInfo.cpp:720