Commit e0ac6562 authored by Larry Sachs's avatar Larry Sachs Committed by Rick Bell

Ensure cached service proxy is still valid

Change-Id: I7c07bfc62e220cf67c395f954b3f438130aa5daf
Signed-off-by: Larry Sachs's avatarLarry Sachs <larry.j.sachs@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/21431Tested-by: default avatarjenkins-iotivity <jenkins@iotivity.org>
Reviewed-by: George Nash's avatarGeorge Nash <george.nash@intel.com>
Reviewed-by: default avatarRick Bell <richard.s.bell@intel.com>
parent e296ef92
......@@ -171,51 +171,58 @@ OCEntityHandlerResult UpnpService::processGetRequest(string uri, OCRepPayload *p
if (UPNP_SERVICE_RESOURCE == resourceType)
{
GUPnPServiceInfo *serviceInfo = GUPNP_SERVICE_INFO(m_proxy);
const char *serviceType = gupnp_service_info_get_service_type(serviceInfo);
if (OCRepPayloadSetPropString(payload, SERVICE_TYPE.c_str(), serviceType))
if (GUPNP_IS_SERVICE_INFO(serviceInfo))
{
DEBUG_PRINT(SERVICE_TYPE << ": " << serviceType);
}
else
{
ERROR_PRINT("Failed to set " + SERVICE_TYPE << " value in payload");
}
const char *serviceType = gupnp_service_info_get_service_type(serviceInfo);
if (OCRepPayloadSetPropString(payload, SERVICE_TYPE.c_str(), serviceType))
{
DEBUG_PRINT(SERVICE_TYPE << ": " << serviceType);
}
else
{
ERROR_PRINT("Failed to set " + SERVICE_TYPE << " value in payload");
}
for (auto const &kv : s_serviceInfo2AttributesMap)
{
char *c_field = kv.second(serviceInfo);
if (c_field != NULL)
for (auto const &kv : s_serviceInfo2AttributesMap)
{
if (OCRepPayloadSetPropString(payload, kv.first.c_str(), c_field))
char *c_field = kv.second(serviceInfo);
if (c_field != NULL)
{
DEBUG_PRINT(kv.first << ": " << c_field);
g_free(c_field);
if (OCRepPayloadSetPropString(payload, kv.first.c_str(), c_field))
{
DEBUG_PRINT(kv.first << ": " << c_field);
g_free(c_field);
}
else
{
ERROR_PRINT("Failed to set " << kv.first << " value in payload");
}
}
else
{
ERROR_PRINT("Failed to set " << kv.first << " value in payload");
}
if (!m_links.empty())
{
DEBUG_PRINT("Setting links for " << uri);
const OCRepPayload *links[m_links.size()];
size_t dimensions[MAX_REP_ARRAY_DEPTH] = {m_links.size(), 0, 0};
for (unsigned int i = 0; i < m_links.size(); ++i) {
DEBUG_PRINT(OC_RSRVD_LINKS << "[" << i << "]");
DEBUG_PRINT("\t" << OC_RSRVD_HREF << "=" << m_links[i].href);
DEBUG_PRINT("\t" << OC_RSRVD_REL << "=" << m_links[i].rel);
DEBUG_PRINT("\t" << OC_RSRVD_RESOURCE_TYPE << "=" << m_links[i].rt);
OCRepPayload *linkPayload = OCRepPayloadCreate();
OCRepPayloadSetPropString(linkPayload, OC_RSRVD_HREF, m_links[i].href.c_str());
OCRepPayloadSetPropString(linkPayload, OC_RSRVD_REL, m_links[i].rel.c_str());
OCRepPayloadSetPropString(linkPayload, OC_RSRVD_RESOURCE_TYPE, m_links[i].rt.c_str());
links[i] = linkPayload;
}
OCRepPayloadSetPropObjectArray(payload, OC_RSRVD_LINKS, links, dimensions);
}
}
if (!m_links.empty())
else
{
DEBUG_PRINT("Setting links for " << uri);
const OCRepPayload *links[m_links.size()];
size_t dimensions[MAX_REP_ARRAY_DEPTH] = {m_links.size(), 0, 0};
for (unsigned int i = 0; i < m_links.size(); ++i) {
DEBUG_PRINT(OC_RSRVD_LINKS << "[" << i << "]");
DEBUG_PRINT("\t" << OC_RSRVD_HREF << "=" << m_links[i].href);
DEBUG_PRINT("\t" << OC_RSRVD_REL << "=" << m_links[i].rel);
DEBUG_PRINT("\t" << OC_RSRVD_RESOURCE_TYPE << "=" << m_links[i].rt);
OCRepPayload *linkPayload = OCRepPayloadCreate();
OCRepPayloadSetPropString(linkPayload, OC_RSRVD_HREF, m_links[i].href.c_str());
OCRepPayloadSetPropString(linkPayload, OC_RSRVD_REL, m_links[i].rel.c_str());
OCRepPayloadSetPropString(linkPayload, OC_RSRVD_RESOURCE_TYPE, m_links[i].rt.c_str());
links[i] = linkPayload;
}
OCRepPayloadSetPropObjectArray(payload, OC_RSRVD_LINKS, links, dimensions);
ERROR_PRINT("GUPNP_SERVICE_INFO failed for proxy for " << m_uri);
return OC_EH_ERROR;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment