本文整理汇总了C++中PLT_DeviceDataReference::SetURLBase方法的典型用法代码示例。如果您正苦于以下问题:C++ PLT_DeviceDataReference::SetURLBase方法的具体用法?C++ PLT_DeviceDataReference::SetURLBase怎么用?C++ PLT_DeviceDataReference::SetURLBase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PLT_DeviceDataReference
的用法示例。
在下文中一共展示了PLT_DeviceDataReference::SetURLBase方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: url
/*----------------------------------------------------------------------
| PLT_DeviceData::SetDescription
+---------------------------------------------------------------------*/
NPT_Result
PLT_DeviceData::SetDescription(PLT_DeviceDataReference& root_device,
NPT_TimeInterval leasetime,
NPT_HttpUrl description_url,
const char* description,
const NPT_HttpRequestContext& context)
{
NPT_XmlParser parser;
NPT_XmlNode* tree = NULL;
NPT_Result res;
NPT_XmlElementNode* root = NULL;
NPT_String URLBase;
// create new device if none passed
if (root_device.IsNull()) {
root_device = new PLT_DeviceData(description_url, "", leasetime);
}
res = parser.Parse(description, tree);
NPT_CHECK_LABEL_SEVERE(res, cleanup);
root = tree->AsElementNode();
if (!root ||
root->GetTag() != "root" ||
!root->GetNamespace() ||
*root->GetNamespace() != "urn:schemas-upnp-org:device-1-0") {
NPT_LOG_INFO_1("root namespace is invalid: %s",
(root&&root->GetNamespace())?root->GetNamespace()->GetChars():"null");
NPT_CHECK_LABEL_SEVERE(NPT_FAILURE, cleanup);
}
// look for optional URLBase element
if (NPT_SUCCEEDED(PLT_XmlHelper::GetChildText(root, "URLBase", URLBase))) {
NPT_HttpUrl url(URLBase);
// Some devices like Connect360 try to be funny - not so
if (url.GetHost().ToLowercase() == "localhost" ||
url.GetHost().ToLowercase() == "127.0.0.1") {
url.SetHost(context.GetRemoteAddress().GetIpAddress().ToString());
}
root_device->SetURLBase(url);
} else {
// No URLBase, derive from description url
root_device->SetURLBase(description_url);
}
// at least one root device child element is required
NPT_XmlElementNode* device;
if (!(device = PLT_XmlHelper::GetChild(root, "device"))) {
NPT_CHECK_LABEL_SEVERE(NPT_FAILURE, cleanup);
}
res = SetDescriptionDevice(root_device, device, context);
cleanup:
// delete the tree
delete tree;
return res;
}