Skip to content
Snippets Groups Projects
Commit 10b2aaa1 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

upnp: cleanup

Change-Id: I85c88cfd1f2d5712fc271ad33da9f4b1b424bcfb
parent 7a8d39f1
Branches
Tags v3.1.10
No related merge requests found
...@@ -686,8 +686,8 @@ PUPnP::actionIsIgdConnected(const UPnPIGD& igd) ...@@ -686,8 +686,8 @@ PUPnP::actionIsIgdConnected(const UPnPIGD& igd)
return false; return false;
// Action and response pointers. // Action and response pointers.
std::unique_ptr<IXML_Document, decltype(ixmlDocument_free)&> action(nullptr, ixmlDocument_free); // Action pointer. XMLDocument action(nullptr, ixmlDocument_free); // Action pointer.
std::unique_ptr<IXML_Document, decltype(ixmlDocument_free)&> response(nullptr, ixmlDocument_free); // Response pointer. XMLDocument response(nullptr, ixmlDocument_free); // Response pointer.
IXML_Document* action_container_ptr = nullptr; IXML_Document* action_container_ptr = nullptr;
IXML_Document* response_container_ptr = nullptr; IXML_Document* response_container_ptr = nullptr;
...@@ -730,19 +730,19 @@ PUPnP::actionGetExternalIP(const UPnPIGD& igd) ...@@ -730,19 +730,19 @@ PUPnP::actionGetExternalIP(const UPnPIGD& igd)
// Action and response pointers. // Action and response pointers.
std::unique_ptr<IXML_Document, decltype(ixmlDocument_free)&> action(nullptr, ixmlDocument_free); // Action pointer. std::unique_ptr<IXML_Document, decltype(ixmlDocument_free)&> action(nullptr, ixmlDocument_free); // Action pointer.
std::unique_ptr<IXML_Document, decltype(ixmlDocument_free)&> response(nullptr, ixmlDocument_free); // Response pointer. std::unique_ptr<IXML_Document, decltype(ixmlDocument_free)&> response(nullptr, ixmlDocument_free); // Response pointer.
IXML_Document* action_container_ptr = nullptr;
IXML_Document* response_container_ptr = nullptr;
// Set action name. // Set action name.
std::string action_name { "GetExternalIPAddress" }; static constexpr const char* action_name { "GetExternalIPAddress" };
action_container_ptr = UpnpMakeAction(action_name.c_str(), igd.getServiceType().c_str(), 0, nullptr); IXML_Document* action_container_ptr = nullptr;
action_container_ptr = UpnpMakeAction(action_name, igd.getServiceType().c_str(), 0, nullptr);
if (not action_container_ptr) { if (not action_container_ptr) {
JAMI_WARN("PUPnP: Failed to make GetExternalIPAddress action"); JAMI_WARN("PUPnP: Failed to make GetExternalIPAddress action");
return {}; return {};
} }
action.reset(action_container_ptr); action.reset(action_container_ptr);
IXML_Document* response_container_ptr = nullptr;
int upnp_err = UpnpSendAction(ctrlptHandle_, igd.getControlURL().c_str(), igd.getServiceType().c_str(), nullptr, action.get(), &response_container_ptr); int upnp_err = UpnpSendAction(ctrlptHandle_, igd.getControlURL().c_str(), igd.getServiceType().c_str(), nullptr, action.get(), &response_container_ptr);
if (upnp_err != UPNP_E_SUCCESS) { if (upnp_err != UPNP_E_SUCCESS) {
JAMI_WARN("PUPnP: Failed to send GetExternalIPAddress action -> %s", UpnpGetErrorMessage(upnp_err)); JAMI_WARN("PUPnP: Failed to send GetExternalIPAddress action -> %s", UpnpGetErrorMessage(upnp_err));
...@@ -765,7 +765,7 @@ PUPnP::actionDeletePortMappingsByDesc(const UPnPIGD& igd, const std::string& des ...@@ -765,7 +765,7 @@ PUPnP::actionDeletePortMappingsByDesc(const UPnPIGD& igd, const std::string& des
return; return;
// Set action name. // Set action name.
std::string action_name { "GetGenericPortMappingEntry" }; static constexpr const char* action_name { "GetGenericPortMappingEntry" };
int entry_idx = 0; int entry_idx = 0;
bool done = false; bool done = false;
...@@ -777,7 +777,7 @@ PUPnP::actionDeletePortMappingsByDesc(const UPnPIGD& igd, const std::string& des ...@@ -777,7 +777,7 @@ PUPnP::actionDeletePortMappingsByDesc(const UPnPIGD& igd, const std::string& des
IXML_Document* action_container_ptr = nullptr; IXML_Document* action_container_ptr = nullptr;
IXML_Document* response_container_ptr = nullptr; IXML_Document* response_container_ptr = nullptr;
UpnpAddToAction(&action_container_ptr, action_name.c_str(), igd.getServiceType().c_str(), "NewPortMappingIndex", std::to_string(entry_idx).c_str()); UpnpAddToAction(&action_container_ptr, action_name, igd.getServiceType().c_str(), "NewPortMappingIndex", std::to_string(entry_idx).c_str());
action.reset(action_container_ptr); action.reset(action_container_ptr);
int upnp_err = UpnpSendAction(ctrlptHandle_, igd.getControlURL().c_str(), igd.getServiceType().c_str(), nullptr, action.get(), &response_container_ptr); int upnp_err = UpnpSendAction(ctrlptHandle_, igd.getControlURL().c_str(), igd.getServiceType().c_str(), nullptr, action.get(), &response_container_ptr);
...@@ -799,7 +799,6 @@ PUPnP::actionDeletePortMappingsByDesc(const UPnPIGD& igd, const std::string& des ...@@ -799,7 +799,6 @@ PUPnP::actionDeletePortMappingsByDesc(const UPnPIGD& igd, const std::string& des
errorCode.c_str(), errorDescription.c_str()); errorCode.c_str(), errorDescription.c_str());
} }
done = true; done = true;
} else { } else {
// Parse the rest of the response. // Parse the rest of the response.
std::string desc_actual = getFirstDocItem(response.get(), "NewPortMappingDescription"); std::string desc_actual = getFirstDocItem(response.get(), "NewPortMappingDescription");
...@@ -881,8 +880,8 @@ PUPnP::actionAddPortMapping(const UPnPIGD& igd, const Mapping& mapping, UPnPProt ...@@ -881,8 +880,8 @@ PUPnP::actionAddPortMapping(const UPnPIGD& igd, const Mapping& mapping, UPnPProt
error_code = UPnPProtocol::UpnpError::ERROR_OK; error_code = UPnPProtocol::UpnpError::ERROR_OK;
// Action and response pointers. // Action and response pointers.
std::unique_ptr<IXML_Document, decltype(ixmlDocument_free)&> action(nullptr, ixmlDocument_free); // Action pointer. XMLDocument action(nullptr, ixmlDocument_free); // Action pointer.
std::unique_ptr<IXML_Document, decltype(ixmlDocument_free)&> response(nullptr, ixmlDocument_free); // Response pointer. XMLDocument response(nullptr, ixmlDocument_free); // Response pointer.
IXML_Document* action_container_ptr = nullptr; IXML_Document* action_container_ptr = nullptr;
IXML_Document* response_container_ptr = nullptr; IXML_Document* response_container_ptr = nullptr;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment