mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-14 16:57:55 +00:00
- some fixes in new UPnP (still unfinished)
This commit is contained in:
parent
78916bba41
commit
0dc4bdd646
@ -1,17 +1,20 @@
|
|||||||
#include "upnp.h"
|
#include "upnp.h"
|
||||||
|
|
||||||
|
#define WAIT_TIMEOUT 5
|
||||||
|
|
||||||
|
// Control point registration callback
|
||||||
int callBackCPRegister( Upnp_EventType EventType, void* Event, void* Cookie ){
|
int callBackCPRegister( Upnp_EventType EventType, void* Event, void* Cookie ){
|
||||||
switch(EventType){
|
switch(EventType){
|
||||||
case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE:
|
case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE:
|
||||||
case UPNP_DISCOVERY_SEARCH_RESULT:
|
case UPNP_DISCOVERY_SEARCH_RESULT:
|
||||||
{
|
{
|
||||||
struct Upnp_Discovery *d_event = (struct Upnp_Discovery*) Event;
|
struct Upnp_Discovery *d_event = (struct Upnp_Discovery*) Event;
|
||||||
IXML_Document *DescDoc=NULL;
|
IXML_Document *DescDoc;
|
||||||
int ret = UpnpDownloadXmlDoc(d_event->Location, &DescDoc);
|
int ret = UpnpDownloadXmlDoc(d_event->Location, &DescDoc);
|
||||||
if(ret != UPNP_E_SUCCESS){
|
if(ret != UPNP_E_SUCCESS){
|
||||||
// silently ignore?
|
// silently ignore?
|
||||||
}else{
|
}else{
|
||||||
((UPnPHandler*)Cookie)->addUPnPDevice(d_event);
|
((UPnPHandler*)Cookie)->addUPnPDevice(d_event, DescDoc);
|
||||||
// TvCtrlPointAddDevice(DescDoc, d_event->Location, d_event->Expires);
|
// TvCtrlPointAddDevice(DescDoc, d_event->Location, d_event->Expires);
|
||||||
}
|
}
|
||||||
if(DescDoc) ixmlDocument_free(DescDoc);
|
if(DescDoc) ixmlDocument_free(DescDoc);
|
||||||
@ -54,4 +57,4 @@ void UPnPHandler::run(){
|
|||||||
qDebug("UPnP control point successfully registered");
|
qDebug("UPnP control point successfully registered");
|
||||||
// Look for UPnP enabled routers (devices)
|
// Look for UPnP enabled routers (devices)
|
||||||
ret = UpnpSearchAsync(UPnPClientHandle, WAIT_TIMEOUT, "upnp:rootdevice", this);
|
ret = UpnpSearchAsync(UPnPClientHandle, WAIT_TIMEOUT, "upnp:rootdevice", this);
|
||||||
}
|
}
|
||||||
|
15
src/upnp.h
15
src/upnp.h
@ -26,23 +26,30 @@
|
|||||||
|
|
||||||
#include <upnp/upnp.h>
|
#include <upnp/upnp.h>
|
||||||
|
|
||||||
#define WAIT_TIMEOUT 5
|
class UPnPDevice{
|
||||||
|
private:
|
||||||
|
struct Upnp_Discovery* device;
|
||||||
|
IXML_Document *doc;
|
||||||
|
|
||||||
// Control point registration callback
|
public:
|
||||||
|
UPnPDevice(struct Upnp_Discovery* device, IXML_Document* doc): device(device), doc(doc){}
|
||||||
|
IXML_Document* getDoc(){ return doc; }
|
||||||
|
struct Upnp_Discovery* getDevice(){ return device;}
|
||||||
|
};
|
||||||
|
|
||||||
class UPnPHandler : public QThread {
|
class UPnPHandler : public QThread {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UpnpClient_Handle UPnPClientHandle;
|
UpnpClient_Handle UPnPClientHandle;
|
||||||
QHash<QString,struct Upnp_Discovery*> UPnPDevices;
|
QHash<QString, UPnPDevice> UPnPDevices;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UPnPHandler(){}
|
UPnPHandler(){}
|
||||||
~UPnPHandler(){}
|
~UPnPHandler(){}
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void addUPnPDevice(struct Upnp_Discovery* device){
|
void addUPnPDevice(struct Upnp_Discovery* device, IXML_Document *){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user