diff --git a/src/upnp.cpp b/src/upnp.cpp index 3a3d71ba4..88bef33d7 100644 --- a/src/upnp.cpp +++ b/src/upnp.cpp @@ -1,17 +1,20 @@ #include "upnp.h" +#define WAIT_TIMEOUT 5 + +// Control point registration callback int callBackCPRegister( Upnp_EventType EventType, void* Event, void* Cookie ){ switch(EventType){ case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE: case UPNP_DISCOVERY_SEARCH_RESULT: { struct Upnp_Discovery *d_event = (struct Upnp_Discovery*) Event; - IXML_Document *DescDoc=NULL; + IXML_Document *DescDoc; int ret = UpnpDownloadXmlDoc(d_event->Location, &DescDoc); if(ret != UPNP_E_SUCCESS){ // silently ignore? }else{ - ((UPnPHandler*)Cookie)->addUPnPDevice(d_event); + ((UPnPHandler*)Cookie)->addUPnPDevice(d_event, DescDoc); // TvCtrlPointAddDevice(DescDoc, d_event->Location, d_event->Expires); } if(DescDoc) ixmlDocument_free(DescDoc); @@ -54,4 +57,4 @@ void UPnPHandler::run(){ qDebug("UPnP control point successfully registered"); // Look for UPnP enabled routers (devices) ret = UpnpSearchAsync(UPnPClientHandle, WAIT_TIMEOUT, "upnp:rootdevice", this); -} \ No newline at end of file +} diff --git a/src/upnp.h b/src/upnp.h index 8e6859e35..9a2907bb1 100644 --- a/src/upnp.h +++ b/src/upnp.h @@ -26,23 +26,30 @@ #include -#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 { Q_OBJECT private: UpnpClient_Handle UPnPClientHandle; - QHash UPnPDevices; + QHash UPnPDevices; public: UPnPHandler(){} ~UPnPHandler(){} public slots: - void addUPnPDevice(struct Upnp_Discovery* device){ + void addUPnPDevice(struct Upnp_Discovery* device, IXML_Document *){ }