mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
fix log output with ifdef
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@1818 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
874d9f45fa
commit
f56e9cfcd9
@ -123,6 +123,7 @@ std::string CUPnPLib::processUPnPErrorMessage(
|
|||||||
IXML_Document *doc) const
|
IXML_Document *doc) const
|
||||||
{
|
{
|
||||||
std::ostringstream msg;
|
std::ostringstream msg;
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
if (errorString == NULL || *errorString == 0) {
|
if (errorString == NULL || *errorString == 0) {
|
||||||
errorString = "Not available";
|
errorString = "Not available";
|
||||||
}
|
}
|
||||||
@ -151,7 +152,7 @@ std::string CUPnPLib::processUPnPErrorMessage(
|
|||||||
" (" << errorCode << ").";
|
" (" << errorCode << ").";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return msg.str();
|
return msg.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,18 +169,24 @@ void CUPnPLib::ProcessActionResponse(
|
|||||||
while (child) {
|
while (child) {
|
||||||
const DOMString childTag = Element_GetTag(child);
|
const DOMString childTag = Element_GetTag(child);
|
||||||
std::string childValue = Element_GetTextValue(child);
|
std::string childValue = Element_GetTextValue(child);
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPLib::ProcessActionResponse() \n " <<
|
std::cerr << "CUPnPLib::ProcessActionResponse() \n " <<
|
||||||
childTag << "='" <<
|
childTag << "='" <<
|
||||||
childValue << "'";
|
childValue << "'";
|
||||||
|
#endif
|
||||||
//add the variable to the wanservice property map
|
//add the variable to the wanservice property map
|
||||||
(m_ctrlPoint.m_WanService->propertyMap)[std::string(childTag)] = std::string(childValue);
|
(m_ctrlPoint.m_WanService->propertyMap)[std::string(childTag)] = std::string(childValue);
|
||||||
child = Element_GetNextSibling(child);
|
child = Element_GetNextSibling(child);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPLib::ProcessActionResponse() \n Empty response for action '" <<
|
std::cerr << "CUPnPLib::ProcessActionResponse() \n Empty response for action '" <<
|
||||||
actionName << "'.";
|
actionName << "'.";
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -358,12 +365,14 @@ m_retval (upnpLib.Element_GetFirstChildByTag(argument, "retval")),
|
|||||||
m_relatedStateVariable(upnpLib.Element_GetChildValueByTag(argument, "relatedStateVariable"))
|
m_relatedStateVariable(upnpLib.Element_GetChildValueByTag(argument, "relatedStateVariable"))
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPArgument::CUPnPArgument() \n Argument:" <<
|
std::cerr << "CUPnPArgument::CUPnPArgument() \n Argument:" <<
|
||||||
"\n name: " << m_name <<
|
"\n name: " << m_name <<
|
||||||
"\n direction: " << m_direction <<
|
"\n direction: " << m_direction <<
|
||||||
"\n retval: " << m_retval <<
|
"\n retval: " << m_retval <<
|
||||||
"\n relatedStateVariable: " << m_relatedStateVariable;
|
"\n relatedStateVariable: " << m_relatedStateVariable;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -377,9 +386,11 @@ m_UPnPControlPoint(upnpControlPoint),
|
|||||||
m_ArgumentList(upnpControlPoint, upnpLib, action, SCPDURL),
|
m_ArgumentList(upnpControlPoint, upnpLib, action, SCPDURL),
|
||||||
m_name(upnpLib.Element_GetChildValueByTag(action, "name"))
|
m_name(upnpLib.Element_GetChildValueByTag(action, "name"))
|
||||||
{
|
{
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPAction::CUPnPAction() \n Action:" <<
|
std::cerr << "CUPnPAction::CUPnPAction() \n Action:" <<
|
||||||
"\n name: " << m_name;
|
"\n name: " << m_name;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -392,9 +403,11 @@ CUPnPAllowedValue::CUPnPAllowedValue(
|
|||||||
m_UPnPControlPoint(upnpControlPoint),
|
m_UPnPControlPoint(upnpControlPoint),
|
||||||
m_allowedValue(upnpLib.Element_GetTextValue(allowedValue))
|
m_allowedValue(upnpLib.Element_GetTextValue(allowedValue))
|
||||||
{
|
{
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPAllowedValue::CUPnPAllowedValue() \n AllowedValue:" <<
|
std::cerr << "CUPnPAllowedValue::CUPnPAllowedValue() \n AllowedValue:" <<
|
||||||
"\n allowedValue: " << m_allowedValue;
|
"\n allowedValue: " << m_allowedValue;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -411,12 +424,14 @@ m_dataType (upnpLib.Element_GetChildValueByTag(stateVariable, "dataType")),
|
|||||||
m_defaultValue(upnpLib.Element_GetChildValueByTag(stateVariable, "defaultValue")),
|
m_defaultValue(upnpLib.Element_GetChildValueByTag(stateVariable, "defaultValue")),
|
||||||
m_sendEvents (upnpLib.Element_GetAttributeByTag (stateVariable, "sendEvents"))
|
m_sendEvents (upnpLib.Element_GetAttributeByTag (stateVariable, "sendEvents"))
|
||||||
{
|
{
|
||||||
std::cerr << "CUPnPStateVariable::CUPnPStateVariable() \n StateVariable:" <<
|
#ifdef UPNP_DEBUG
|
||||||
|
std::cerr << "CUPnPStateVariable::CUPnPStateVariable() \n StateVariable:" <<
|
||||||
"\n name: " << m_name <<
|
"\n name: " << m_name <<
|
||||||
"\n dataType: " << m_dataType <<
|
"\n dataType: " << m_dataType <<
|
||||||
"\n defaultValue: " << m_defaultValue <<
|
"\n defaultValue: " << m_defaultValue <<
|
||||||
"\n sendEvents: " << m_sendEvents;
|
"\n sendEvents: " << m_sendEvents;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -477,10 +492,12 @@ m_SCPD(NULL)
|
|||||||
m_SCPDURL.c_str(),
|
m_SCPDURL.c_str(),
|
||||||
scpdURL);
|
scpdURL);
|
||||||
if( errcode != UPNP_E_SUCCESS ) {
|
if( errcode != UPNP_E_SUCCESS ) {
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPService::CUPnPService() Error generating scpdURL from " <<
|
std::cerr << "CUPnPService::CUPnPService() Error generating scpdURL from " <<
|
||||||
"|" << URLBase << "|" <<
|
"|" << URLBase << "|" <<
|
||||||
m_SCPDURL << "|.";
|
m_SCPDURL << "|.";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
m_absSCPDURL = scpdURL;
|
m_absSCPDURL = scpdURL;
|
||||||
}
|
}
|
||||||
@ -493,10 +510,12 @@ m_SCPD(NULL)
|
|||||||
m_controlURL.c_str(),
|
m_controlURL.c_str(),
|
||||||
controlURL);
|
controlURL);
|
||||||
if( errcode != UPNP_E_SUCCESS ) {
|
if( errcode != UPNP_E_SUCCESS ) {
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPService::CUPnPService() Error generating controlURL from " <<
|
std::cerr << "CUPnPService::CUPnPService() Error generating controlURL from " <<
|
||||||
"|" << URLBase << "|" <<
|
"|" << URLBase << "|" <<
|
||||||
m_controlURL << "|.";
|
m_controlURL << "|.";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
m_absControlURL = controlURL;
|
m_absControlURL = controlURL;
|
||||||
}
|
}
|
||||||
@ -509,14 +528,17 @@ m_SCPD(NULL)
|
|||||||
m_eventSubURL.c_str(),
|
m_eventSubURL.c_str(),
|
||||||
eventURL);
|
eventURL);
|
||||||
if( errcode != UPNP_E_SUCCESS ) {
|
if( errcode != UPNP_E_SUCCESS ) {
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPService::CUPnPService() Error generating eventURL from " <<
|
std::cerr << "CUPnPService::CUPnPService() Error generating eventURL from " <<
|
||||||
"|" << URLBase << "|" <<
|
"|" << URLBase << "|" <<
|
||||||
m_eventSubURL << "|.";
|
m_eventSubURL << "|.";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
m_absEventSubURL = eventURL;
|
m_absEventSubURL = eventURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPService::CUPnPService() \n Service:" <<
|
std::cerr << "CUPnPService::CUPnPService() \n Service:" <<
|
||||||
"\n serviceType: " << m_serviceType <<
|
"\n serviceType: " << m_serviceType <<
|
||||||
"\n serviceId: " << m_serviceId <<
|
"\n serviceId: " << m_serviceId <<
|
||||||
@ -527,6 +549,7 @@ m_SCPD(NULL)
|
|||||||
"\n eventSubURL: " << m_eventSubURL <<
|
"\n eventSubURL: " << m_eventSubURL <<
|
||||||
"\n absEventSubURL: " << m_absEventSubURL;
|
"\n absEventSubURL: " << m_absEventSubURL;
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (m_serviceType == upnpLib.UPNP_SERVICE_WAN_IP_CONNECTION ||
|
if (m_serviceType == upnpLib.UPNP_SERVICE_WAN_IP_CONNECTION ||
|
||||||
m_serviceType == upnpLib.UPNP_SERVICE_WAN_PPP_CONNECTION) {
|
m_serviceType == upnpLib.UPNP_SERVICE_WAN_PPP_CONNECTION) {
|
||||||
@ -545,26 +568,32 @@ m_SCPD(NULL)
|
|||||||
upnpLib.m_ctrlPoint.SetWanService(this);
|
upnpLib.m_ctrlPoint.SetWanService(this);
|
||||||
// Log it
|
// Log it
|
||||||
msg.str("");
|
msg.str("");
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPService::CUPnPService() WAN Service Detected: '" <<
|
std::cerr << "CUPnPService::CUPnPService() WAN Service Detected: '" <<
|
||||||
m_serviceType << "'.";
|
m_serviceType << "'.";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
// Subscribe
|
// Subscribe
|
||||||
upnpLib.m_ctrlPoint.Subscribe(*this);
|
upnpLib.m_ctrlPoint.Subscribe(*this);
|
||||||
#if 0
|
#if 0
|
||||||
//#warning Delete this code on release.
|
//#warning Delete this code on release.
|
||||||
} else {
|
} else {
|
||||||
msg.str("");
|
msg.str("");
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "WAN service detected again: '" <<
|
std::cerr << "WAN service detected again: '" <<
|
||||||
m_serviceType <<
|
m_serviceType <<
|
||||||
"'. Will only use the first instance.";
|
"'. Will only use the first instance.";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
msg.str("");
|
msg.str("");
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPService::CUPnPService() Uninteresting service detected: '" <<
|
std::cerr << "CUPnPService::CUPnPService() Uninteresting service detected: '" <<
|
||||||
m_serviceType << "'. Ignoring.";
|
m_serviceType << "'. Ignoring.";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -578,21 +607,29 @@ bool CUPnPService::Execute(
|
|||||||
const std::string &ActionName,
|
const std::string &ActionName,
|
||||||
const std::vector<CUPnPArgumentValue> &ArgValue) const
|
const std::vector<CUPnPArgumentValue> &ArgValue) const
|
||||||
{
|
{
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPService::Execute() called." << std::endl;
|
std::cerr << "CUPnPService::Execute() called." << std::endl;
|
||||||
|
#endif
|
||||||
if (m_SCPD.get() == NULL) {
|
if (m_SCPD.get() == NULL) {
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPService::Execute() Service without SCPD Document, cannot execute action '" << ActionName <<
|
std::cerr << "CUPnPService::Execute() Service without SCPD Document, cannot execute action '" << ActionName <<
|
||||||
"' for service '" << GetServiceType() << "'.";
|
"' for service '" << GetServiceType() << "'.";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPService::Execute() Sending action " << std::endl;
|
std::cerr << "CUPnPService::Execute() Sending action " << std::endl;
|
||||||
|
#endif
|
||||||
// Check for correct action name
|
// Check for correct action name
|
||||||
ActionList::const_iterator itAction =
|
ActionList::const_iterator itAction =
|
||||||
m_SCPD->GetActionList().find(ActionName);
|
m_SCPD->GetActionList().find(ActionName);
|
||||||
if (itAction == m_SCPD->GetActionList().end()) {
|
if (itAction == m_SCPD->GetActionList().end()) {
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPService::Execute() invalid action name '" << ActionName <<
|
std::cerr << "CUPnPService::Execute() invalid action name '" << ActionName <<
|
||||||
"' for service '" << GetServiceType() << "'.";
|
"' for service '" << GetServiceType() << "'.";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::cerr << ActionName << "(";
|
std::cerr << ActionName << "(";
|
||||||
@ -603,20 +640,24 @@ bool CUPnPService::Execute(
|
|||||||
ArgumentList::const_iterator itArg =
|
ArgumentList::const_iterator itArg =
|
||||||
action.GetArgumentList().find(ArgValue[i].GetArgument());
|
action.GetArgumentList().find(ArgValue[i].GetArgument());
|
||||||
if (itArg == action.GetArgumentList().end()) {
|
if (itArg == action.GetArgumentList().end()) {
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPService::Execute() Invalid argument name '" << ArgValue[i].GetArgument() <<
|
std::cerr << "CUPnPService::Execute() Invalid argument name '" << ArgValue[i].GetArgument() <<
|
||||||
"' for action '" << action.GetName() <<
|
"' for action '" << action.GetName() <<
|
||||||
"' for service '" << GetServiceType() << "'.";
|
"' for service '" << GetServiceType() << "'.";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const CUPnPArgument &argument = *(itArg->second);
|
const CUPnPArgument &argument = *(itArg->second);
|
||||||
if (tolower(argument.GetDirection()[0]) != 'i' ||
|
if (tolower(argument.GetDirection()[0]) != 'i' ||
|
||||||
tolower(argument.GetDirection()[1]) != 'n') {
|
tolower(argument.GetDirection()[1]) != 'n') {
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPService::Execute() Invalid direction for argument '" <<
|
std::cerr << "CUPnPService::Execute() Invalid direction for argument '" <<
|
||||||
ArgValue[i].GetArgument() <<
|
ArgValue[i].GetArgument() <<
|
||||||
"' for action '" << action.GetName() <<
|
"' for action '" << action.GetName() <<
|
||||||
"' for service '" << GetServiceType() << "'.";
|
"' for service '" << GetServiceType() << "'.";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const std::string relatedStateVariableName =
|
const std::string relatedStateVariableName =
|
||||||
@ -626,23 +667,27 @@ bool CUPnPService::Execute(
|
|||||||
m_SCPD->GetServiceStateTable().
|
m_SCPD->GetServiceStateTable().
|
||||||
find(relatedStateVariableName);
|
find(relatedStateVariableName);
|
||||||
if (itSVT == m_SCPD->GetServiceStateTable().end()) {
|
if (itSVT == m_SCPD->GetServiceStateTable().end()) {
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPService::Execute() Inconsistent Service State Table, did not find '" <<
|
std::cerr << "CUPnPService::Execute() Inconsistent Service State Table, did not find '" <<
|
||||||
relatedStateVariableName <<
|
relatedStateVariableName <<
|
||||||
"' for argument '" << argument.GetName() <<
|
"' for argument '" << argument.GetName() <<
|
||||||
"' for action '" << action.GetName() <<
|
"' for action '" << action.GetName() <<
|
||||||
"' for service '" << GetServiceType() << "'.";
|
"' for service '" << GetServiceType() << "'.";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const CUPnPStateVariable &stateVariable = *(itSVT->second);
|
const CUPnPStateVariable &stateVariable = *(itSVT->second);
|
||||||
if ( !stateVariable.GetAllowedValueList().empty() &&
|
if ( !stateVariable.GetAllowedValueList().empty() &&
|
||||||
stateVariable.GetAllowedValueList().find(ArgValue[i].GetValue()) ==
|
stateVariable.GetAllowedValueList().find(ArgValue[i].GetValue()) ==
|
||||||
stateVariable.GetAllowedValueList().end()) {
|
stateVariable.GetAllowedValueList().end()) {
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPService::Execute() Value not allowed '" << ArgValue[i].GetValue() <<
|
std::cerr << "CUPnPService::Execute() Value not allowed '" << ArgValue[i].GetValue() <<
|
||||||
"' for state variable '" << relatedStateVariableName <<
|
"' for state variable '" << relatedStateVariableName <<
|
||||||
"' for argument '" << argument.GetName() <<
|
"' for argument '" << argument.GetName() <<
|
||||||
"' for action '" << action.GetName() <<
|
"' for action '" << action.GetName() <<
|
||||||
"' for service '" << GetServiceType() << "'.";
|
"' for service '" << GetServiceType() << "'.";
|
||||||
|
#endif
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -650,16 +695,22 @@ bool CUPnPService::Execute(
|
|||||||
if (firstTime) {
|
if (firstTime) {
|
||||||
firstTime = false;
|
firstTime = false;
|
||||||
} else {
|
} else {
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << ", ";
|
std::cerr << ", ";
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr <<
|
std::cerr <<
|
||||||
ArgValue[i].GetArgument() <<
|
ArgValue[i].GetArgument() <<
|
||||||
"='" <<
|
"='" <<
|
||||||
ArgValue[i].GetValue() <<
|
ArgValue[i].GetValue() <<
|
||||||
"'";
|
"'";
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << ")";
|
std::cerr << ")";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
// Everything is ok, make the action
|
// Everything is ok, make the action
|
||||||
IXML_Document *ActionDoc = NULL;
|
IXML_Document *ActionDoc = NULL;
|
||||||
if (ArgValue.size()) {
|
if (ArgValue.size()) {
|
||||||
@ -677,14 +728,18 @@ bool CUPnPService::Execute(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPService::Execute() UpnpMakeAction" << std::endl;
|
std::cerr << "CUPnPService::Execute() UpnpMakeAction" << std::endl;
|
||||||
|
#endif
|
||||||
ActionDoc = UpnpMakeAction(
|
ActionDoc = UpnpMakeAction(
|
||||||
action.GetName().c_str(),
|
action.GetName().c_str(),
|
||||||
GetServiceType().c_str(),
|
GetServiceType().c_str(),
|
||||||
0, NULL);
|
0, NULL);
|
||||||
if (!ActionDoc) {
|
if (!ActionDoc) {
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPService::Execute() Error: UpnpMakeAction returned NULL.";
|
std::cerr << "CUPnPService::Execute() Error: UpnpMakeAction returned NULL.";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -707,8 +762,10 @@ const std::string CUPnPService::GetStateVariable(
|
|||||||
std::map<std::string, std::string>::iterator it;
|
std::map<std::string, std::string>::iterator it;
|
||||||
it = propertyMap.find(stateVariableName);
|
it = propertyMap.find(stateVariableName);
|
||||||
if (it != propertyMap.end()) {
|
if (it != propertyMap.end()) {
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPService::GetStateVariable(" << stateVariableName << ") = ";
|
std::cerr << "CUPnPService::GetStateVariable(" << stateVariableName << ") = ";
|
||||||
std::cerr << (*it).second << std::endl;
|
std::cerr << (*it).second << std::endl;
|
||||||
|
#endif
|
||||||
return (*it).second;
|
return (*it).second;
|
||||||
} else {
|
} else {
|
||||||
//property map is not populated with the specified value.
|
//property map is not populated with the specified value.
|
||||||
@ -723,11 +780,15 @@ const std::string CUPnPService::GetStateVariable(
|
|||||||
&StVarVal);
|
&StVarVal);
|
||||||
if (StVarVal != NULL) {
|
if (StVarVal != NULL) {
|
||||||
std::string varValue = std::string(StVarVal);
|
std::string varValue = std::string(StVarVal);
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPService::GetStateVariable() varValue returned by UpnpGetServiceVarStatus : " << varValue << std::endl;
|
std::cerr << "CUPnPService::GetStateVariable() varValue returned by UpnpGetServiceVarStatus : " << varValue << std::endl;
|
||||||
|
#endif
|
||||||
return varValue;
|
return varValue;
|
||||||
} else {
|
} else {
|
||||||
//use event to get state variable
|
//use event to get state variable
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPService::GetStateVariable() pausing in case of an UPnP event incomming.";
|
std::cerr << "CUPnPService::GetStateVariable() pausing in case of an UPnP event incomming.";
|
||||||
|
#endif
|
||||||
time_t begin_time = time(NULL);
|
time_t begin_time = time(NULL);
|
||||||
while (true) {
|
while (true) {
|
||||||
if (time(NULL) - begin_time > 7) {
|
if (time(NULL) - begin_time > 7) {
|
||||||
@ -739,12 +800,16 @@ const std::string CUPnPService::GetStateVariable(
|
|||||||
//propertyMap should be populated by nom
|
//propertyMap should be populated by nom
|
||||||
it = propertyMap.find(stateVariableName);
|
it = propertyMap.find(stateVariableName);
|
||||||
if (it != propertyMap.end()) {
|
if (it != propertyMap.end()) {
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPService::GetStateVariable(" << stateVariableName << ") = ";
|
std::cerr << "CUPnPService::GetStateVariable(" << stateVariableName << ") = ";
|
||||||
std::cerr << (*it).second << std::endl;
|
std::cerr << (*it).second << std::endl;
|
||||||
|
#endif
|
||||||
return (*it).second;
|
return (*it).second;
|
||||||
} else {
|
} else {
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPService::GetStateVariable(" << stateVariableName << ") = ";
|
std::cerr << "CUPnPService::GetStateVariable(" << stateVariableName << ") = ";
|
||||||
std::cerr << "Empty String" << std::endl;
|
std::cerr << "Empty String" << std::endl;
|
||||||
|
#endif
|
||||||
return stdEmptyString;
|
return stdEmptyString;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -783,15 +848,18 @@ m_presentationURL (upnpLib.Element_GetChildValueByTag(device, "presentationURL"
|
|||||||
m_presentationURL.c_str(),
|
m_presentationURL.c_str(),
|
||||||
presURL);
|
presURL);
|
||||||
if (errcode != UPNP_E_SUCCESS) {
|
if (errcode != UPNP_E_SUCCESS) {
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPDevice::CUPnPDevice() Error generating presentationURL from " <<
|
std::cerr << "CUPnPDevice::CUPnPDevice() Error generating presentationURL from " <<
|
||||||
"|" << URLBase << "|" <<
|
"|" << URLBase << "|" <<
|
||||||
m_presentationURL << "|.";
|
m_presentationURL << "|.";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
m_presentationURL = presURL;
|
m_presentationURL = presURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
msg.str("");
|
msg.str("");
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPDevice::CUPnPDevice() \n Device: " <<
|
std::cerr << "CUPnPDevice::CUPnPDevice() \n Device: " <<
|
||||||
"\n friendlyName: " << m_friendlyName <<
|
"\n friendlyName: " << m_friendlyName <<
|
||||||
"\n deviceType: " << m_deviceType <<
|
"\n deviceType: " << m_deviceType <<
|
||||||
@ -806,6 +874,7 @@ m_presentationURL (upnpLib.Element_GetChildValueByTag(device, "presentationURL"
|
|||||||
"\n UPC: " << m_UPC <<
|
"\n UPC: " << m_UPC <<
|
||||||
"\n presentationURL: " << m_presentationURL
|
"\n presentationURL: " << m_presentationURL
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -824,6 +893,7 @@ m_URLBase(OriginalURLBase),
|
|||||||
m_location(location),
|
m_location(location),
|
||||||
m_expires(expires)
|
m_expires(expires)
|
||||||
{
|
{
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr <<
|
std::cerr <<
|
||||||
"CUPnPRootDevice::CUPnPRootDevice() \n Root Device: " <<
|
"CUPnPRootDevice::CUPnPRootDevice() \n Root Device: " <<
|
||||||
"\n URLBase: " << m_URLBase <<
|
"\n URLBase: " << m_URLBase <<
|
||||||
@ -831,6 +901,7 @@ m_expires(expires)
|
|||||||
"\n location: " << m_location <<
|
"\n location: " << m_location <<
|
||||||
"\n expires: " << m_expires
|
"\n expires: " << m_expires
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -848,7 +919,9 @@ m_RootDeviceListMutex(),
|
|||||||
m_IGWDeviceDetected(false),
|
m_IGWDeviceDetected(false),
|
||||||
m_WanService(NULL)
|
m_WanService(NULL)
|
||||||
{
|
{
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "UPnPControlPoint::CUPnPControlPoint() Constructor" << std::endl;
|
std::cerr << "UPnPControlPoint::CUPnPControlPoint() Constructor" << std::endl;
|
||||||
|
#endif
|
||||||
// Pointer to self
|
// Pointer to self
|
||||||
s_CtrlPoint = this;
|
s_CtrlPoint = this;
|
||||||
|
|
||||||
@ -856,27 +929,35 @@ m_WanService(NULL)
|
|||||||
int ret;
|
int ret;
|
||||||
char *ipAddress = NULL;
|
char *ipAddress = NULL;
|
||||||
unsigned short port = 0;
|
unsigned short port = 0;
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
int resLog = UpnpInitLog();
|
int resLog = UpnpInitLog();
|
||||||
ret = UpnpInit(ipAddress, udpPort);
|
|
||||||
std::cerr << "UPnPControlPoint::CUPnPControlPoint() Init log : " << resLog << std::endl;
|
std::cerr << "UPnPControlPoint::CUPnPControlPoint() Init log : " << resLog << std::endl;
|
||||||
|
#endif
|
||||||
|
ret = UpnpInit(ipAddress, udpPort);
|
||||||
#ifdef UPNP_DEBUG
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPControlPoint Constructor UpnpInit finished" << std::endl;
|
std::cerr << "CUPnPControlPoint Constructor UpnpInit finished" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
if (ret != UPNP_E_SUCCESS && ret !=UPNP_E_INIT) {
|
if (ret != UPNP_E_SUCCESS && ret !=UPNP_E_INIT) {
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "UPnPControlPoint::CUPnPControlPoint() error(UpnpInit): Error code : ";
|
std::cerr << "UPnPControlPoint::CUPnPControlPoint() error(UpnpInit): Error code : ";
|
||||||
|
#endif
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
port = UpnpGetServerPort();
|
port = UpnpGetServerPort();
|
||||||
ipAddress = UpnpGetServerIpAddress();
|
ipAddress = UpnpGetServerIpAddress();
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "UPnPControlPoint::CUPnPControlPoint() bound to " << ipAddress << ":" <<
|
std::cerr << "UPnPControlPoint::CUPnPControlPoint() bound to " << ipAddress << ":" <<
|
||||||
port << "." << std::endl;
|
port << "." << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
ret = UpnpRegisterClient(
|
ret = UpnpRegisterClient(
|
||||||
static_cast<Upnp_FunPtr>(&CUPnPControlPoint::Callback),
|
static_cast<Upnp_FunPtr>(&CUPnPControlPoint::Callback),
|
||||||
&m_UPnPClientHandle,
|
&m_UPnPClientHandle,
|
||||||
&m_UPnPClientHandle);
|
&m_UPnPClientHandle);
|
||||||
if (ret != UPNP_E_SUCCESS) {
|
if (ret != UPNP_E_SUCCESS) {
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "UPnPControlPoint::CUPnPControlPoint() error(UpnpRegisterClient): Error registering callback: ";
|
std::cerr << "UPnPControlPoint::CUPnPControlPoint() error(UpnpRegisterClient): Error registering callback: ";
|
||||||
|
#endif
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -896,7 +977,9 @@ m_WanService(NULL)
|
|||||||
//ret = UpnpSearchAsync(m_UPnPClientHandle, 3, m_upnpLib.UPNP_DEVICE_LAN.c_str(), this);
|
//ret = UpnpSearchAsync(m_UPnPClientHandle, 3, m_upnpLib.UPNP_DEVICE_LAN.c_str(), this);
|
||||||
//ret = UpnpSearchAsync(m_UPnPClientHandle, 3, m_upnpLib.UPNP_DEVICE_WAN_CONNECTION.c_str(), this);
|
//ret = UpnpSearchAsync(m_UPnPClientHandle, 3, m_upnpLib.UPNP_DEVICE_WAN_CONNECTION.c_str(), this);
|
||||||
if (ret != UPNP_E_SUCCESS) {
|
if (ret != UPNP_E_SUCCESS) {
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "UPnPControlPoint::CUPnPControlPoint() error(UpnpSearchAsync): Error sending search request: ";
|
std::cerr << "UPnPControlPoint::CUPnPControlPoint() error(UpnpSearchAsync): Error sending search request: ";
|
||||||
|
#endif
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -908,11 +991,14 @@ m_WanService(NULL)
|
|||||||
// Lock it again, so that we block. Unlocking will only happen
|
// Lock it again, so that we block. Unlocking will only happen
|
||||||
// when the UPNP_DISCOVERY_SEARCH_TIMEOUT event occurs at the
|
// when the UPNP_DISCOVERY_SEARCH_TIMEOUT event occurs at the
|
||||||
// callback.
|
// callback.
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "UPnPControlPoint::CUPnPControlPoint() blocking m_WaitForSearchTimeoutMutex." << std::endl;
|
std::cerr << "UPnPControlPoint::CUPnPControlPoint() blocking m_WaitForSearchTimeoutMutex." << std::endl;
|
||||||
|
#endif
|
||||||
//RsMutex toto(m_WaitForSearchTimeoutMutex);
|
//RsMutex toto(m_WaitForSearchTimeoutMutex);
|
||||||
m_WaitForSearchTimeoutMutex.lock();
|
m_WaitForSearchTimeoutMutex.lock();
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "UPnPControlPoint::CUPnPControlPoint() m_WaitForSearchTimeoutMutex blocking finished." << std::endl;
|
std::cerr << "UPnPControlPoint::CUPnPControlPoint() m_WaitForSearchTimeoutMutex blocking finished." << std::endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//clean the PortMappingNumberOfEntries as it is erroneus on the first event with the french neufbox
|
//clean the PortMappingNumberOfEntries as it is erroneus on the first event with the french neufbox
|
||||||
@ -920,14 +1006,20 @@ m_WanService(NULL)
|
|||||||
m_WanService->propertyMap.erase("PortMappingNumberOfEntries");
|
m_WanService->propertyMap.erase("PortMappingNumberOfEntries");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "UPnPControlPoint::CUPnPControlPoint() CUPnPControlPoint Constructor finished" << std::endl;
|
std::cerr << "UPnPControlPoint::CUPnPControlPoint() CUPnPControlPoint Constructor finished" << std::endl;
|
||||||
|
#endif
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Error processing
|
// Error processing
|
||||||
error:
|
error:
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << ret << ": " << m_upnpLib.GetUPnPErrorMessage(ret) << "." << std::endl;
|
std::cerr << ret << ": " << m_upnpLib.GetUPnPErrorMessage(ret) << "." << std::endl;
|
||||||
|
#endif
|
||||||
UpnpFinish();
|
UpnpFinish();
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "UPnPControlPoint::CUPnPControlPoint() UpnpFinish called within CUPnPControlPoint constructor." << std::endl;
|
std::cerr << "UPnPControlPoint::CUPnPControlPoint() UpnpFinish called within CUPnPControlPoint constructor." << std::endl;
|
||||||
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -947,7 +1039,9 @@ CUPnPControlPoint::~CUPnPControlPoint()
|
|||||||
// Remove all first
|
// Remove all first
|
||||||
// RemoveAll();
|
// RemoveAll();
|
||||||
UpnpUnRegisterClient(m_UPnPClientHandle);
|
UpnpUnRegisterClient(m_UPnPClientHandle);
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPControlPoint::~CUPnPControlPoint() UpnpFinish called within CUPnPControlPoint destructor." << std::endl;
|
std::cerr << "CUPnPControlPoint::~CUPnPControlPoint() UpnpFinish called within CUPnPControlPoint destructor." << std::endl;
|
||||||
|
#endif
|
||||||
UpnpFinish();
|
UpnpFinish();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -956,12 +1050,16 @@ bool CUPnPControlPoint::AddPortMappings(
|
|||||||
std::vector<CUPnPPortMapping> &upnpPortMapping)
|
std::vector<CUPnPPortMapping> &upnpPortMapping)
|
||||||
{
|
{
|
||||||
if (!WanServiceDetected()) {
|
if (!WanServiceDetected()) {
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPControlPoint::AddPortMappings() UPnP Error: "
|
std::cerr << "CUPnPControlPoint::AddPortMappings() UPnP Error: "
|
||||||
"CUPnPControlPoint::AddPortMapping: "
|
"CUPnPControlPoint::AddPortMapping: "
|
||||||
"WAN Service not detected." << std::endl;
|
"WAN Service not detected." << std::endl;
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPControlPoint::AddPortMappings() called." << std::endl;
|
std::cerr << "CUPnPControlPoint::AddPortMappings() called." << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
int n = upnpPortMapping.size();
|
int n = upnpPortMapping.size();
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
@ -996,7 +1094,9 @@ bool CUPnPControlPoint::AddPortMappings(
|
|||||||
|
|
||||||
// Not very good, must find a better test : check the new number of port entries
|
// Not very good, must find a better test : check the new number of port entries
|
||||||
//have a little break in case we just modified the variable, so we have to wait for an event
|
//have a little break in case we just modified the variable, so we have to wait for an event
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPControlPoint::AddPortMappings() GetStateVariable pausing in case of an UPnP event incomming.";
|
std::cerr << "CUPnPControlPoint::AddPortMappings() GetStateVariable pausing in case of an UPnP event incomming.";
|
||||||
|
#endif
|
||||||
time_t begin_time = time(NULL);
|
time_t begin_time = time(NULL);
|
||||||
while (true) {
|
while (true) {
|
||||||
if (time(NULL) - begin_time > 4) {
|
if (time(NULL) - begin_time > 4) {
|
||||||
@ -1008,10 +1108,14 @@ bool CUPnPControlPoint::AddPortMappings(
|
|||||||
"PortMappingNumberOfEntries"));
|
"PortMappingNumberOfEntries"));
|
||||||
int newNumberOfEntries;
|
int newNumberOfEntries;
|
||||||
NewPortMappingNumberOfEntries >> newNumberOfEntries;
|
NewPortMappingNumberOfEntries >> newNumberOfEntries;
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPControlPoint::AddPortMappings() CUPnPControlPoint::AddPortMappings() newNumberOfEntries - oldNumberOfEntries : " << (newNumberOfEntries - oldNumberOfEntries) << std::endl;
|
std::cerr << "CUPnPControlPoint::AddPortMappings() CUPnPControlPoint::AddPortMappings() newNumberOfEntries - oldNumberOfEntries : " << (newNumberOfEntries - oldNumberOfEntries) << std::endl;
|
||||||
|
#endif
|
||||||
ok = newNumberOfEntries - oldNumberOfEntries >= 1;
|
ok = newNumberOfEntries - oldNumberOfEntries >= 1;
|
||||||
|
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPControlPoint::AddPortMappings() finished. Success = " << ok << std::endl;
|
std::cerr << "CUPnPControlPoint::AddPortMappings() finished. Success = " << ok << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
@ -1019,20 +1123,28 @@ bool CUPnPControlPoint::AddPortMappings(
|
|||||||
std::string CUPnPControlPoint::getExternalAddress()
|
std::string CUPnPControlPoint::getExternalAddress()
|
||||||
{
|
{
|
||||||
if (!WanServiceDetected()) {
|
if (!WanServiceDetected()) {
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPControlPoint::getExternalAddress() UPnP Error: "
|
std::cerr << "CUPnPControlPoint::getExternalAddress() UPnP Error: "
|
||||||
"CUPnPControlPoint::AddPortMapping: "
|
"CUPnPControlPoint::AddPortMapping: "
|
||||||
"WAN Service not detected." << std::endl;
|
"WAN Service not detected." << std::endl;
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
std::string result = m_WanService->GetStateVariable("NewExternalIPAddress");
|
std::string result = m_WanService->GetStateVariable("NewExternalIPAddress");
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPControlPoint::getExternalAddress() m_WanService->GetStateVariable(NewExternalIPAddress) = " << result << std::endl;
|
std::cerr << "CUPnPControlPoint::getExternalAddress() m_WanService->GetStateVariable(NewExternalIPAddress) = " << result << std::endl;
|
||||||
|
#endif
|
||||||
if (result == "") {
|
if (result == "") {
|
||||||
PrivateGetExternalIpAdress();
|
PrivateGetExternalIpAdress();
|
||||||
result = m_WanService->GetStateVariable("NewExternalIPAddress");
|
result = m_WanService->GetStateVariable("NewExternalIPAddress");
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPControlPoint::getExternalAddress() m_WanService->GetStateVariable(NewExternalIPAddress) = " << result << std::endl;
|
std::cerr << "CUPnPControlPoint::getExternalAddress() m_WanService->GetStateVariable(NewExternalIPAddress) = " << result << std::endl;
|
||||||
|
#endif
|
||||||
if (result == "") {
|
if (result == "") {
|
||||||
result = m_WanService->GetStateVariable("ExternalIPAddress");
|
result = m_WanService->GetStateVariable("ExternalIPAddress");
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPControlPoint::getExternalAddress() m_WanService->GetStateVariable(ExternalIPAddress) = " << result << std::endl;
|
std::cerr << "CUPnPControlPoint::getExternalAddress() m_WanService->GetStateVariable(ExternalIPAddress) = " << result << std::endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -1090,11 +1202,15 @@ bool CUPnPControlPoint::PrivateAddPortMapping(
|
|||||||
bool CUPnPControlPoint::DeletePortMappings(
|
bool CUPnPControlPoint::DeletePortMappings(
|
||||||
std::vector<CUPnPPortMapping> &upnpPortMapping)
|
std::vector<CUPnPPortMapping> &upnpPortMapping)
|
||||||
{
|
{
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPControlPoint::DeletePortMappings() called." << std::endl;
|
std::cerr << "CUPnPControlPoint::DeletePortMappings() called." << std::endl;
|
||||||
|
#endif
|
||||||
if (!WanServiceDetected()) {
|
if (!WanServiceDetected()) {
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "UPnP Error: "
|
std::cerr << "UPnP Error: "
|
||||||
"CUPnPControlPoint::DeletePortMapping: "
|
"CUPnPControlPoint::DeletePortMapping: "
|
||||||
"WAN Service not detected." << std::endl;
|
"WAN Service not detected." << std::endl;
|
||||||
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1111,10 +1227,12 @@ bool CUPnPControlPoint::DeletePortMappings(
|
|||||||
if (it != m_ActivePortMappingsMap.end()) {
|
if (it != m_ActivePortMappingsMap.end()) {
|
||||||
m_ActivePortMappingsMap.erase(it);
|
m_ActivePortMappingsMap.erase(it);
|
||||||
} else {
|
} else {
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPControlPoint::DeletePortMappings() UPnP Error: "
|
std::cerr << "CUPnPControlPoint::DeletePortMappings() UPnP Error: "
|
||||||
"CUPnPControlPoint::DeletePortMapping: "
|
"CUPnPControlPoint::DeletePortMapping: "
|
||||||
"Mapping was not found in the active "
|
"Mapping was not found in the active "
|
||||||
"mapping map." << std::endl;
|
"mapping map." << std::endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete the port mapping
|
// Delete the port mapping
|
||||||
@ -1145,9 +1263,13 @@ bool CUPnPControlPoint::PrivateDeletePortMapping(
|
|||||||
bool ret = true;
|
bool ret = true;
|
||||||
for (ServiceMap::iterator it = m_ServiceMap.begin();
|
for (ServiceMap::iterator it = m_ServiceMap.begin();
|
||||||
it != m_ServiceMap.end(); ++it) {
|
it != m_ServiceMap.end(); ++it) {
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPControlPoint::PrivateDeletePortMapping() Sending a delete port mapping action." << std::endl;
|
std::cerr << "CUPnPControlPoint::PrivateDeletePortMapping() Sending a delete port mapping action." << std::endl;
|
||||||
|
#endif
|
||||||
ret &= it->second->Execute(actionName, argval);
|
ret &= it->second->Execute(actionName, argval);
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPControlPoint::PrivateDeletePortMapping() Delete port mapping action finished." << std::endl;
|
std::cerr << "CUPnPControlPoint::PrivateDeletePortMapping() Delete port mapping action finished." << std::endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@ -1183,34 +1305,42 @@ int CUPnPControlPoint::Callback(Upnp_EventType EventType, void *Event, void * /*
|
|||||||
//fprintf(stderr, "Callback: %d, Cookie: %p\n", EventType, Cookie);
|
//fprintf(stderr, "Callback: %d, Cookie: %p\n", EventType, Cookie);
|
||||||
switch (EventType) {
|
switch (EventType) {
|
||||||
case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE:
|
case UPNP_DISCOVERY_ADVERTISEMENT_ALIVE:
|
||||||
//fprintf(stderr, "Callback: UPNP_DISCOVERY_ADVERTISEMENT_ALIVE\n");
|
#ifdef UPNP_DEBUG
|
||||||
//std::cerr << "error(UPNP_DISCOVERY_ADVERTISEMENT_ALIVE): ";
|
|
||||||
std::cerr << "CUPnPControlPoint::Callback() UPNP_DISCOVERY_ADVERTISEMENT_ALIVE: ";
|
std::cerr << "CUPnPControlPoint::Callback() UPNP_DISCOVERY_ADVERTISEMENT_ALIVE: ";
|
||||||
|
#endif
|
||||||
goto upnpDiscovery;
|
goto upnpDiscovery;
|
||||||
case UPNP_DISCOVERY_SEARCH_RESULT: {
|
case UPNP_DISCOVERY_SEARCH_RESULT: {
|
||||||
//fprintf(stderr, "Callback: UPNP_DISCOVERY_SEARCH_RESULT\n");
|
#ifdef UPNP_DEBUG
|
||||||
//std::cerr << "CUPnPControlPoint::Callback() Uerror(UPNP_DISCOVERY_SEARCH_RESULT): ";
|
|
||||||
std::cerr << "UPNP_DISCOVERY_SEARCH_RESULT: ";
|
std::cerr << "UPNP_DISCOVERY_SEARCH_RESULT: ";
|
||||||
|
#endif
|
||||||
// UPnP Discovery
|
// UPnP Discovery
|
||||||
upnpDiscovery:
|
upnpDiscovery:
|
||||||
struct Upnp_Discovery *d_event = (struct Upnp_Discovery *)Event;
|
struct Upnp_Discovery *d_event = (struct Upnp_Discovery *)Event;
|
||||||
IXML_Document *doc = NULL;
|
IXML_Document *doc = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
if (d_event->ErrCode != UPNP_E_SUCCESS) {
|
if (d_event->ErrCode != UPNP_E_SUCCESS) {
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << upnpCP->m_upnpLib.GetUPnPErrorMessage(d_event->ErrCode) << ".";
|
std::cerr << upnpCP->m_upnpLib.GetUPnPErrorMessage(d_event->ErrCode) << ".";
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPControlPoint::Callback() URetrieving device description from " <<
|
std::cerr << "CUPnPControlPoint::Callback() URetrieving device description from " <<
|
||||||
d_event->Location << "." << std::endl;
|
d_event->Location << "." << std::endl;
|
||||||
|
#endif
|
||||||
// Get the XML tree device description in doc
|
// Get the XML tree device description in doc
|
||||||
ret = UpnpDownloadXmlDoc(d_event->Location, &doc);
|
ret = UpnpDownloadXmlDoc(d_event->Location, &doc);
|
||||||
if (ret != UPNP_E_SUCCESS) {
|
if (ret != UPNP_E_SUCCESS) {
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPControlPoint::Callback() UError retrieving device description from " <<
|
std::cerr << "CUPnPControlPoint::Callback() UError retrieving device description from " <<
|
||||||
d_event->Location << ": " <<
|
d_event->Location << ": " <<
|
||||||
upnpCP->m_upnpLib.GetUPnPErrorMessage(ret) << ".";
|
upnpCP->m_upnpLib.GetUPnPErrorMessage(ret) << ".";
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPControlPoint::Callback() URetrieving device description from " <<
|
std::cerr << "CUPnPControlPoint::Callback() URetrieving device description from " <<
|
||||||
d_event->Location << "." << std::endl;
|
d_event->Location << "." << std::endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (doc) {
|
if (doc) {
|
||||||
// Get the root node
|
// Get the root node
|
||||||
@ -1237,13 +1367,19 @@ upnpDiscovery:
|
|||||||
// Log it if not UPNP_DISCOVERY_ADVERTISEMENT_ALIVE,
|
// Log it if not UPNP_DISCOVERY_ADVERTISEMENT_ALIVE,
|
||||||
// we don't want to spam our logs.
|
// we don't want to spam our logs.
|
||||||
//if (EventType != UPNP_DISCOVERY_ADVERTISEMENT_ALIVE) {
|
//if (EventType != UPNP_DISCOVERY_ADVERTISEMENT_ALIVE) {
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "Internet Gateway Device Detected." << std::endl;
|
std::cerr << "Internet Gateway Device Detected." << std::endl;
|
||||||
|
#endif
|
||||||
//}
|
//}
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPControlPoint::Callback() UGetting root device desc." << std::endl;
|
std::cerr << "CUPnPControlPoint::Callback() UGetting root device desc." << std::endl;
|
||||||
|
#endif
|
||||||
// Add the root device to our list
|
// Add the root device to our list
|
||||||
upnpCP->AddRootDevice(rootDevice, urlBase,
|
upnpCP->AddRootDevice(rootDevice, urlBase,
|
||||||
d_event->Location, d_event->Expires);
|
d_event->Location, d_event->Expires);
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPControlPoint::Callback() UFinishing getting root device desc." << std::endl;
|
std::cerr << "CUPnPControlPoint::Callback() UFinishing getting root device desc." << std::endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
// Free the XML doc tree
|
// Free the XML doc tree
|
||||||
ixmlDocument_free(doc);
|
ixmlDocument_free(doc);
|
||||||
@ -1253,8 +1389,10 @@ upnpDiscovery:
|
|||||||
case UPNP_DISCOVERY_SEARCH_TIMEOUT: {
|
case UPNP_DISCOVERY_SEARCH_TIMEOUT: {
|
||||||
//fprintf(stderr, "Callback: UPNP_DISCOVERY_SEARCH_TIMEOUT\n");
|
//fprintf(stderr, "Callback: UPNP_DISCOVERY_SEARCH_TIMEOUT\n");
|
||||||
// Search timeout
|
// Search timeout
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPControlPoint::Callback() UUPNP_DISCOVERY_SEARCH_TIMEOUT : unlocking mutex." << std::endl;
|
std::cerr << "CUPnPControlPoint::Callback() UUPNP_DISCOVERY_SEARCH_TIMEOUT : unlocking mutex." << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Unlock the search timeout mutex
|
// Unlock the search timeout mutex
|
||||||
upnpCP->m_WaitForSearchTimeoutMutex.unlock();
|
upnpCP->m_WaitForSearchTimeoutMutex.unlock();
|
||||||
|
|
||||||
@ -1265,9 +1403,11 @@ upnpDiscovery:
|
|||||||
// UPnP Device Removed
|
// UPnP Device Removed
|
||||||
struct Upnp_Discovery *dab_event = (struct Upnp_Discovery *)Event;
|
struct Upnp_Discovery *dab_event = (struct Upnp_Discovery *)Event;
|
||||||
if (dab_event->ErrCode != UPNP_E_SUCCESS) {
|
if (dab_event->ErrCode != UPNP_E_SUCCESS) {
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPControlPoint::Callback() Uerror(UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE): " <<
|
std::cerr << "CUPnPControlPoint::Callback() Uerror(UPNP_DISCOVERY_ADVERTISEMENT_BYEBYE): " <<
|
||||||
upnpCP->m_upnpLib.GetUPnPErrorMessage(dab_event->ErrCode) <<
|
upnpCP->m_upnpLib.GetUPnPErrorMessage(dab_event->ErrCode) <<
|
||||||
"." << std::endl;
|
"." << std::endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
std::string devType = dab_event->DeviceType;
|
std::string devType = dab_event->DeviceType;
|
||||||
// Check for an InternetGatewayDevice and removes it from the list
|
// Check for an InternetGatewayDevice and removes it from the list
|
||||||
@ -1278,7 +1418,9 @@ upnpDiscovery:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case UPNP_EVENT_RECEIVED: {
|
case UPNP_EVENT_RECEIVED: {
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
fprintf(stderr, "Callback: UPNP_EVENT_RECEIVED\n");
|
fprintf(stderr, "Callback: UPNP_EVENT_RECEIVED\n");
|
||||||
|
#endif
|
||||||
// Event reveived
|
// Event reveived
|
||||||
struct Upnp_Event *e_event = (struct Upnp_Event *)Event;
|
struct Upnp_Event *e_event = (struct Upnp_Event *)Event;
|
||||||
const std::string Sid = e_event->Sid;
|
const std::string Sid = e_event->Sid;
|
||||||
@ -1346,17 +1488,21 @@ upnpEventSubscriptionExpired:
|
|||||||
CUPnPService &service = *(it->second);
|
CUPnPService &service = *(it->second);
|
||||||
service.SetTimeout(TimeOut);
|
service.SetTimeout(TimeOut);
|
||||||
service.SetSID(newSID);
|
service.SetSID(newSID);
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPControlPoint::Callback() Re-subscribed to EventURL '" <<
|
std::cerr << "CUPnPControlPoint::Callback() Re-subscribed to EventURL '" <<
|
||||||
es_event->PublisherUrl <<
|
es_event->PublisherUrl <<
|
||||||
"' with SID == '" <<
|
"' with SID == '" <<
|
||||||
newSID << "'." << std::endl;
|
newSID << "'." << std::endl;
|
||||||
|
#endif
|
||||||
// In principle, we should test to see if the
|
// In principle, we should test to see if the
|
||||||
// service is the same. But here we only have one
|
// service is the same. But here we only have one
|
||||||
// service, so...
|
// service, so...
|
||||||
upnpCP->RefreshPortMappings();
|
upnpCP->RefreshPortMappings();
|
||||||
} else {
|
} else {
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPControlPoint::Callback() Error: did not find service " <<
|
std::cerr << "CUPnPControlPoint::Callback() Error: did not find service " <<
|
||||||
newSID << " in the service map." << std::endl;
|
newSID << " in the service map." << std::endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1383,7 +1529,9 @@ upnpEventSubscriptionExpired:
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case UPNP_CONTROL_GET_VAR_COMPLETE: {
|
case UPNP_CONTROL_GET_VAR_COMPLETE: {
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
fprintf(stderr, "CUPnPControlPoint::Callback() Callback: UPNP_CONTROL_GET_VAR_COMPLETE\n");
|
fprintf(stderr, "CUPnPControlPoint::Callback() Callback: UPNP_CONTROL_GET_VAR_COMPLETE\n");
|
||||||
|
#endif
|
||||||
msg << "CUPnPControlPoint::Callback() error(UPNP_CONTROL_GET_VAR_COMPLETE): ";
|
msg << "CUPnPControlPoint::Callback() error(UPNP_CONTROL_GET_VAR_COMPLETE): ";
|
||||||
struct Upnp_State_Var_Complete *sv_event =
|
struct Upnp_State_Var_Complete *sv_event =
|
||||||
(struct Upnp_State_Var_Complete *)Event;
|
(struct Upnp_State_Var_Complete *)Event;
|
||||||
@ -1400,25 +1548,35 @@ upnpEventSubscriptionExpired:
|
|||||||
// ignore these cases, since this is not a device
|
// ignore these cases, since this is not a device
|
||||||
case UPNP_CONTROL_GET_VAR_REQUEST:
|
case UPNP_CONTROL_GET_VAR_REQUEST:
|
||||||
//fprintf(stderr, "Callback: UPNP_CONTROL_GET_VAR_REQUEST\n");
|
//fprintf(stderr, "Callback: UPNP_CONTROL_GET_VAR_REQUEST\n");
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPControlPoint::Callback() error(UPNP_CONTROL_GET_VAR_REQUEST): ";
|
std::cerr << "CUPnPControlPoint::Callback() error(UPNP_CONTROL_GET_VAR_REQUEST): ";
|
||||||
|
#endif
|
||||||
goto eventSubscriptionRequest;
|
goto eventSubscriptionRequest;
|
||||||
case UPNP_CONTROL_ACTION_REQUEST:
|
case UPNP_CONTROL_ACTION_REQUEST:
|
||||||
//fprintf(stderr, "Callback: UPNP_CONTROL_ACTION_REQUEST\n");
|
//fprintf(stderr, "Callback: UPNP_CONTROL_ACTION_REQUEST\n");
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPControlPoint::Callback() error(UPNP_CONTROL_ACTION_REQUEST): ";
|
std::cerr << "CUPnPControlPoint::Callback() error(UPNP_CONTROL_ACTION_REQUEST): ";
|
||||||
|
#endif
|
||||||
goto eventSubscriptionRequest;
|
goto eventSubscriptionRequest;
|
||||||
case UPNP_EVENT_SUBSCRIPTION_REQUEST:
|
case UPNP_EVENT_SUBSCRIPTION_REQUEST:
|
||||||
//fprintf(stderr, "Callback: UPNP_EVENT_SUBSCRIPTION_REQUEST\n");
|
//fprintf(stderr, "Callback: UPNP_EVENT_SUBSCRIPTION_REQUEST\n");
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPControlPoint::Callback() error(UPNP_EVENT_SUBSCRIPTION_REQUEST): ";
|
std::cerr << "CUPnPControlPoint::Callback() error(UPNP_EVENT_SUBSCRIPTION_REQUEST): ";
|
||||||
|
#endif
|
||||||
eventSubscriptionRequest:
|
eventSubscriptionRequest:
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPControlPoint::Callback() This is not a UPnP Device, this is a UPnP Control Point, event ignored." << std::endl;
|
std::cerr << "CUPnPControlPoint::Callback() This is not a UPnP Device, this is a UPnP Control Point, event ignored." << std::endl;
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// Humm, this is not good, we forgot to handle something...
|
// Humm, this is not good, we forgot to handle something...
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Callback: default... Unknown event:'%d', not good.\n",
|
"Callback: default... Unknown event:'%d', not good.\n",
|
||||||
EventType);
|
EventType);
|
||||||
std::cerr << "CUPnPControlPoint::Callback() error(UPnP::Callback): Event not handled:'" <<
|
std::cerr << "CUPnPControlPoint::Callback() error(UPnP::Callback): Event not handled:'" <<
|
||||||
EventType << "'." << std::endl;
|
EventType << "'." << std::endl;
|
||||||
|
#endif
|
||||||
// Better not throw in the callback. Who would catch it?
|
// Better not throw in the callback. Who would catch it?
|
||||||
//throw CUPnPException(msg);
|
//throw CUPnPException(msg);
|
||||||
break;
|
break;
|
||||||
@ -1433,14 +1591,18 @@ void CUPnPControlPoint::OnEventReceived(
|
|||||||
int EventKey,
|
int EventKey,
|
||||||
IXML_Document *ChangedVariablesDoc)
|
IXML_Document *ChangedVariablesDoc)
|
||||||
{
|
{
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPControlPoint::OnEventReceived() UPNP_EVENT_RECEIVED:" <<
|
std::cerr << "CUPnPControlPoint::OnEventReceived() UPNP_EVENT_RECEIVED:" <<
|
||||||
"\n SID: " << Sid <<
|
"\n SID: " << Sid <<
|
||||||
"\n Key: " << EventKey << std::endl;
|
"\n Key: " << EventKey << std::endl;
|
||||||
std::cerr << "CUPnPControlPoint::OnEventReceived() m_WanService->GetServiceId() : " << m_WanService->GetSID() << std::endl;
|
std::cerr << "CUPnPControlPoint::OnEventReceived() m_WanService->GetServiceId() : " << m_WanService->GetSID() << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (m_WanService->GetSID() == Sid) {
|
if (m_WanService->GetSID() == Sid) {
|
||||||
//let's store the properties if it is an event of the wan device
|
//let's store the properties if it is an event of the wan device
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPControlPoint::OnEventReceived() \n Property list:";
|
std::cerr << "CUPnPControlPoint::OnEventReceived() \n Property list:";
|
||||||
|
#endif
|
||||||
|
|
||||||
IXML_Element *root =
|
IXML_Element *root =
|
||||||
m_upnpLib.Element_GetRootElement(ChangedVariablesDoc);
|
m_upnpLib.Element_GetRootElement(ChangedVariablesDoc);
|
||||||
@ -1454,18 +1616,24 @@ void CUPnPControlPoint::OnEventReceived(
|
|||||||
m_upnpLib.Element_GetTag(child2);
|
m_upnpLib.Element_GetTag(child2);
|
||||||
std::string childValue =
|
std::string childValue =
|
||||||
m_upnpLib.Element_GetTextValue(child2);
|
m_upnpLib.Element_GetTextValue(child2);
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "\n " <<
|
std::cerr << "\n " <<
|
||||||
childTag << "='" <<
|
childTag << "='" <<
|
||||||
childValue << "'";
|
childValue << "'";
|
||||||
|
#endif
|
||||||
const std::string cTag(childTag);
|
const std::string cTag(childTag);
|
||||||
const std::string cValue(childValue);
|
const std::string cValue(childValue);
|
||||||
(m_WanService->propertyMap)[cTag] = cValue;
|
(m_WanService->propertyMap)[cTag] = cValue;
|
||||||
child = m_upnpLib.Element_GetNextSibling(child);
|
child = m_upnpLib.Element_GetNextSibling(child);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPControlPoint::OnEventReceived() \n Empty property list.";
|
std::cerr << "CUPnPControlPoint::OnEventReceived() \n Empty property list.";
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
// Freeing that doc segfaults. Probably should not be freed.
|
// Freeing that doc segfaults. Probably should not be freed.
|
||||||
//ixmlDocument_free(ChangedVariablesDoc);
|
//ixmlDocument_free(ChangedVariablesDoc);
|
||||||
}
|
}
|
||||||
@ -1533,9 +1701,11 @@ void CUPnPControlPoint::Subscribe(CUPnPService &service)
|
|||||||
scpdRoot, service.GetAbsSCPDURL());
|
scpdRoot, service.GetAbsSCPDURL());
|
||||||
service.SetSCPD(scpd);
|
service.SetSCPD(scpd);
|
||||||
m_ServiceMap[service.GetAbsEventSubURL()] = &service;
|
m_ServiceMap[service.GetAbsEventSubURL()] = &service;
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPControlPoint::Subscribe() Successfully retrieved SCPD Document for service " <<
|
std::cerr << "CUPnPControlPoint::Subscribe() Successfully retrieved SCPD Document for service " <<
|
||||||
service.GetServiceType() << ", absEventSubURL: " <<
|
service.GetServiceType() << ", absEventSubURL: " <<
|
||||||
service.GetAbsEventSubURL() << "." << std::endl;
|
service.GetAbsEventSubURL() << "." << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Now try to subscribe to this service. If the subscription
|
// Now try to subscribe to this service. If the subscription
|
||||||
// is not successfull, we will not be notified about events,
|
// is not successfull, we will not be notified about events,
|
||||||
@ -1545,26 +1715,34 @@ void CUPnPControlPoint::Subscribe(CUPnPService &service)
|
|||||||
service.GetTimeoutAddr(),
|
service.GetTimeoutAddr(),
|
||||||
service.GetSID());
|
service.GetSID());
|
||||||
if (errcode == UPNP_E_SUCCESS) {
|
if (errcode == UPNP_E_SUCCESS) {
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPControlPoint::Subscribe() Successfully subscribed to service " <<
|
std::cerr << "CUPnPControlPoint::Subscribe() Successfully subscribed to service " <<
|
||||||
service.GetServiceType() << ", absEventSubURL: " <<
|
service.GetServiceType() << ", absEventSubURL: " <<
|
||||||
service.GetAbsEventSubURL() << "." << std::endl;
|
service.GetAbsEventSubURL() << "." << std::endl;
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPControlPoint::Subscribe() Error subscribing to service " <<
|
std::cerr << "CUPnPControlPoint::Subscribe() Error subscribing to service " <<
|
||||||
service.GetServiceType() << ", absEventSubURL: " <<
|
service.GetServiceType() << ", absEventSubURL: " <<
|
||||||
service.GetAbsEventSubURL() << ", error: " <<
|
service.GetAbsEventSubURL() << ", error: " <<
|
||||||
m_upnpLib.GetUPnPErrorMessage(errcode) << ".";
|
m_upnpLib.GetUPnPErrorMessage(errcode) << ".";
|
||||||
|
#endif
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "CUPnPControlPoint::Subscribe() Error getting SCPD Document from " <<
|
std::cerr << "CUPnPControlPoint::Subscribe() Error getting SCPD Document from " <<
|
||||||
service.GetAbsSCPDURL() << "." << std::endl;
|
service.GetAbsSCPDURL() << "." << std::endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Error processing
|
|
||||||
error:
|
error:
|
||||||
|
1+1;
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << std::endl;
|
std::cerr << std::endl;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,8 +30,10 @@ bool upnphandler::initUPnPState()
|
|||||||
dataMtx.lock(); /* LOCK MUTEX */
|
dataMtx.lock(); /* LOCK MUTEX */
|
||||||
upnpState = RS_UPNP_S_READY;
|
upnpState = RS_UPNP_S_READY;
|
||||||
|
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "upnphandler::initUPnPState cUPnPControlPoint internal ip adress : ";
|
std::cerr << "upnphandler::initUPnPState cUPnPControlPoint internal ip adress : ";
|
||||||
std::cerr << cUPnPControlPoint->getInternalIpAddress() << std::endl;
|
std::cerr << cUPnPControlPoint->getInternalIpAddress() << std::endl;
|
||||||
|
#endif
|
||||||
|
|
||||||
//const char ipaddr = cUPnPControlPoint->getInternalIpAddress().c_str();
|
//const char ipaddr = cUPnPControlPoint->getInternalIpAddress().c_str();
|
||||||
inet_aton(cUPnPControlPoint->getInternalIpAddress(), &(upnp_iaddr.sin_addr));
|
inet_aton(cUPnPControlPoint->getInternalIpAddress(), &(upnp_iaddr.sin_addr));
|
||||||
@ -297,7 +299,10 @@ void upnphandler::enable(bool active)
|
|||||||
void upnphandler::shutdown()
|
void upnphandler::shutdown()
|
||||||
{
|
{
|
||||||
/* blocking call to shutdown upnp */
|
/* blocking call to shutdown upnp */
|
||||||
|
|
||||||
|
#ifdef UPNP_DEBUG
|
||||||
std::cerr << "upnphandler::shutdown() called." << std::endl;
|
std::cerr << "upnphandler::shutdown() called." << std::endl;
|
||||||
|
#endif
|
||||||
shutdown_upnp();
|
shutdown_upnp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user