libktorrent  2.2.0
upnpmcastsocket.h
1 /***************************************************************************
2  * Copyright (C) 2005-2007 by Joris Guisson *
3  * joris.guisson@gmail.com *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19  ***************************************************************************/
20 
21 #ifndef KTUPNPMCASTSOCKET_H
22 #define KTUPNPMCASTSOCKET_H
23 
24 #include <QSet>
25 #include <QUdpSocket>
26 #include <util/ptrmap.h>
27 #include <util/constants.h>
28 #include <ktorrent_export.h>
29 #include "upnprouter.h"
30 
31 using bt::Uint32;
32 
33 namespace bt
34 {
35  class UPnPRouter;
36 
43  class KTORRENT_EXPORT UPnPMCastSocket : public QUdpSocket
44  {
45  Q_OBJECT
46  public:
47  UPnPMCastSocket(bool verbose = false);
48  ~UPnPMCastSocket() override;
49 
51  Uint32 getNumDevicesDiscovered() const;
52 
54  UPnPRouter* findDevice(const QString & name);
55 
57  void saveRouters(const QString & file);
58 
60  void loadRouters(const QString & file);
61 
63  void setVerbose(bool v);
64 
65  public Q_SLOTS:
70  void discover();
71 
72  private Q_SLOTS:
73  void onReadyRead();
74  void error(QAbstractSocket::SocketError err);
75  void onXmlFileDownloaded(UPnPRouter* r,bool success);
76 
77  Q_SIGNALS:
82  void discovered(bt::UPnPRouter* router);
83 
84  private:
85  class UPnPMCastSocketPrivate;
86  UPnPMCastSocketPrivate* d;
87  };
88 }
89 
90 #endif
bt::UPnPMCastSocket::discovered
void discovered(bt::UPnPRouter *router)
bt::UPnPMCastSocket::findDevice
UPnPRouter * findDevice(const QString &name)
Find a router using it's server name.
bt::UPnPMCastSocket::saveRouters
void saveRouters(const QString &file)
Save all routers to a file (for convenience at startup)
bt::UPnPRouter
Definition: upnprouter.h:97
bt::UPnPMCastSocket::setVerbose
void setVerbose(bool v)
Set verbose mode.
bt::UPnPMCastSocket::loadRouters
void loadRouters(const QString &file)
Load all routers from a file.
bt::UPnPMCastSocket::getNumDevicesDiscovered
Uint32 getNumDevicesDiscovered() const
Get the number of routers discovered.
bt::UPnPMCastSocket::discover
void discover()
bt::UPnPMCastSocket
Definition: upnpmcastsocket.h:44