From 04ecbc551412915dfcb75684e908f63ab4503879 Mon Sep 17 00:00:00 2001 From: joss17 Date: Fri, 30 Oct 2009 00:36:14 +0000 Subject: [PATCH] add new method for external upnp address git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1752 b45a01b8-16f6-495d-af2f-9b41ad6348cc --- libretroshare/src/upnp/UPnPBase.cpp | 35 ++++++++++++++++++++--------- libretroshare/src/upnp/UPnPBase.h | 5 +++-- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/libretroshare/src/upnp/UPnPBase.cpp b/libretroshare/src/upnp/UPnPBase.cpp index 5b79435e2..cb5895c1a 100644 --- a/libretroshare/src/upnp/UPnPBase.cpp +++ b/libretroshare/src/upnp/UPnPBase.cpp @@ -170,6 +170,8 @@ void CUPnPLib::ProcessActionResponse( std::cerr << "\n " << childTag << "='" << childValue << "'"; + //add the variable to the wanservice property map + (m_ctrlPoint.m_WanService->propertyMap)[std::string(childTag)] = std::string(childValue); child = Element_GetNextSibling(child); } } else { @@ -1021,8 +1023,12 @@ std::string CUPnPControlPoint::getExternalAddress() "WAN Service not detected." << std::endl; return false; } - - return m_WanService->GetStateVariable("ExternalIPAddress"); + PrivateGetExternalIpAdress(); + std::string result = m_WanService->GetStateVariable("NewExternalIPAddress"); + if (result == "") { + result = m_WanService->GetStateVariable("ExternalIPAddress"); + } + return result; } void CUPnPControlPoint::RefreshPortMappings() @@ -1137,6 +1143,22 @@ bool CUPnPControlPoint::PrivateDeletePortMapping( return ret; } +bool CUPnPControlPoint::PrivateGetExternalIpAdress() +{ + // Start building the action + std::string actionName("GetExternalIPAddress"); + std::vector argval(0); + + // Execute + bool ret = true; + for (ServiceMap::iterator it = m_ServiceMap.begin(); + it != m_ServiceMap.end(); ++it) { + ret &= it->second->Execute(actionName, argval); + } + + return ret; +} + // This function is static int CUPnPControlPoint::Callback(Upnp_EventType EventType, void *Event, void * /*Cookie*/) @@ -1362,15 +1384,6 @@ upnpEventSubscriptionExpired: } else { //add the variable to the wanservice property map (upnpCP->m_WanService->propertyMap)[std::string(sv_event->StateVarName)] = std::string(sv_event->CurrentVal); -#if 0 - // Warning: The use of UpnpGetServiceVarStatus and - // UpnpGetServiceVarStatusAsync is deprecated by the - // UPnP forum. - TvCtrlPointHandleGetVar( - sv_event->CtrlUrl, - sv_event->StateVarName, - sv_event->CurrentVal ); -#endif } break; } diff --git a/libretroshare/src/upnp/UPnPBase.h b/libretroshare/src/upnp/UPnPBase.h index 620766936..2ad342c21 100644 --- a/libretroshare/src/upnp/UPnPBase.h +++ b/libretroshare/src/upnp/UPnPBase.h @@ -569,10 +569,10 @@ private: PortMappingMap m_ActivePortMappingsMap; RsMutex m_RootDeviceListMutex; bool m_IGWDeviceDetected; - CUPnPService *m_WanService; RsMutex m_WaitForSearchTimeoutMutex; public: + CUPnPService *m_WanService; RsMutex m_getStateVariableMutex; std::string m_getStateVariableLastResult; static CUPnPControlPoint *s_CtrlPoint; @@ -586,7 +586,7 @@ public: std::vector &upnpPortMapping); bool DeletePortMappings( std::vector &upnpPortMapping); - + UpnpClient_Handle GetUPnPClientHandle() const { return m_UPnPClientHandle; } @@ -622,6 +622,7 @@ private: CUPnPPortMapping &upnpPortMapping); bool PrivateDeletePortMapping( CUPnPPortMapping &upnpPortMapping); + bool PrivateGetExternalIpAdress(); }; // File_checked_for_headers