|
|
@ -524,18 +524,19 @@ namespace NLGUI
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string tmpdest = download.dest + ".tmp";
|
|
|
|
// use browser Id so that two browsers would not use same temp file
|
|
|
|
|
|
|
|
download.tmpdest = localImageName(_Id + download.dest) + ".tmp";
|
|
|
|
|
|
|
|
|
|
|
|
// erase the tmp file if exists
|
|
|
|
// erase the tmp file if exists
|
|
|
|
if (CFile::fileExists(tmpdest))
|
|
|
|
if (CFile::fileExists(download.tmpdest))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CFile::deleteFile(tmpdest);
|
|
|
|
CFile::deleteFile(download.tmpdest);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FILE *fp = nlfopen (tmpdest, "wb");
|
|
|
|
FILE *fp = nlfopen (download.tmpdest, "wb");
|
|
|
|
if (fp == NULL)
|
|
|
|
if (fp == NULL)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
nlwarning("Can't open file '%s' for writing: code=%d '%s'", tmpdest.c_str (), errno, strerror(errno));
|
|
|
|
nlwarning("Can't open file '%s' for writing: code=%d '%s'", download.tmpdest.c_str (), errno, strerror(errno));
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -543,7 +544,7 @@ namespace NLGUI
|
|
|
|
if (!curl)
|
|
|
|
if (!curl)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
fclose(fp);
|
|
|
|
fclose(fp);
|
|
|
|
CFile::deleteFile(tmpdest);
|
|
|
|
CFile::deleteFile(download.tmpdest);
|
|
|
|
|
|
|
|
|
|
|
|
nlwarning("Creating cURL handle failed, unable to download '%s'", download.url.c_str());
|
|
|
|
nlwarning("Creating cURL handle failed, unable to download '%s'", download.url.c_str());
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
@ -607,28 +608,19 @@ namespace NLGUI
|
|
|
|
|
|
|
|
|
|
|
|
void CGroupHTML::finishCurlDownload(const CDataDownload &download)
|
|
|
|
void CGroupHTML::finishCurlDownload(const CDataDownload &download)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::string tmpfile = download.dest + ".tmp";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (download.type == ImgType)
|
|
|
|
if (download.type == ImgType)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// there is race condition if two browser instances are downloading same file
|
|
|
|
if (CFile::fileExists(download.tmpdest) && CFile::getFileSize(download.tmpdest) > 0)
|
|
|
|
// second instance deletes first tmpfile and creates new file for itself.
|
|
|
|
|
|
|
|
if (CFile::getFileSize(tmpfile) > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// verify that image is not corrupted
|
|
|
|
// verify that image is not corrupted
|
|
|
|
uint32 w, h;
|
|
|
|
uint32 w, h;
|
|
|
|
CBitmap::loadSize(tmpfile, w, h);
|
|
|
|
CBitmap::loadSize(download.tmpdest, w, h);
|
|
|
|
if (w != 0 && h != 0)
|
|
|
|
if (w != 0 && h != 0)
|
|
|
|
{
|
|
|
|
|
|
|
|
// if not tmpfile, then img is already in cache
|
|
|
|
|
|
|
|
if (CFile::fileExists(tmpfile))
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (CFile::fileExists(download.dest))
|
|
|
|
if (CFile::fileExists(download.dest))
|
|
|
|
{
|
|
|
|
|
|
|
|
CFile::deleteFile(download.dest);
|
|
|
|
CFile::deleteFile(download.dest);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// to reload image on page, the easiest seems to be changing texture
|
|
|
|
// to reload image on page, the easiest seems to be changing texture
|
|
|
|
// to temp file temporarily. that forces driver to reload texture from disk
|
|
|
|
// to temp file temporarily. that forces driver to reload texture from disk
|
|
|
@ -636,25 +628,37 @@ namespace NLGUI
|
|
|
|
// cache was updated, first set texture as temp file
|
|
|
|
// cache was updated, first set texture as temp file
|
|
|
|
for(uint i = 0; i < download.imgs.size(); i++)
|
|
|
|
for(uint i = 0; i < download.imgs.size(); i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
setImage(download.imgs[i].Image, tmpfile, download.imgs[i].Type);
|
|
|
|
setImage(download.imgs[i].Image, download.tmpdest, download.imgs[i].Type);
|
|
|
|
setImageSize(download.imgs[i].Image, download.imgs[i].Style);
|
|
|
|
setImageSize(download.imgs[i].Image, download.imgs[i].Style);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CFile::moveFile(download.dest, tmpfile);
|
|
|
|
CFile::moveFile(download.dest, download.tmpdest);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch(const NLMISC::Exception &e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// exception message has .tmp file name, so keep it for further analysis
|
|
|
|
|
|
|
|
nlwarning("Invalid image (%s) from url (%s): %s", download.tmpdest.c_str(), download.url.c_str(), e.what());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (CFile::fileExists(download.dest) && CFile::getFileSize(download.dest) > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// verify that image is not corrupted
|
|
|
|
|
|
|
|
uint32 w, h;
|
|
|
|
|
|
|
|
CBitmap::loadSize(download.dest, w, h);
|
|
|
|
|
|
|
|
if (w != 0 && h != 0)
|
|
|
|
for(uint i = 0; i < download.imgs.size(); i++)
|
|
|
|
for(uint i = 0; i < download.imgs.size(); i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
setImage(download.imgs[i].Image, download.dest, download.imgs[i].Type);
|
|
|
|
setImage(download.imgs[i].Image, download.dest, download.imgs[i].Type);
|
|
|
|
setImageSize(download.imgs[i].Image, download.imgs[i].Style);
|
|
|
|
setImageSize(download.imgs[i].Image, download.imgs[i].Style);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(const NLMISC::Exception &e)
|
|
|
|
catch(const NLMISC::Exception &e)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// exception message has .tmp file name, so keep it for further analysis
|
|
|
|
nlwarning("Invalid image (%s) from url (%s): %s", download.dest.c_str(), download.url.c_str(), e.what());
|
|
|
|
nlwarning("Invalid image (%s): %s", download.url.c_str(), e.what());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -663,13 +667,13 @@ namespace NLGUI
|
|
|
|
|
|
|
|
|
|
|
|
if (download.type == StylesheetType)
|
|
|
|
if (download.type == StylesheetType)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (CFile::fileExists(tmpfile))
|
|
|
|
if (CFile::fileExists(download.tmpdest))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (CFile::fileExists(download.dest))
|
|
|
|
if (CFile::fileExists(download.dest))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CFile::deleteFile(download.dest);
|
|
|
|
CFile::deleteFile(download.dest);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
CFile::moveFile(download.dest, tmpfile);
|
|
|
|
CFile::moveFile(download.dest, download.tmpdest);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cssDownloadFinished(download.url, download.dest);
|
|
|
|
cssDownloadFinished(download.url, download.dest);
|
|
|
|
|
|
|
|
|
|
|
@ -680,20 +684,20 @@ namespace NLGUI
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bool verified = false;
|
|
|
|
bool verified = false;
|
|
|
|
// no tmpfile if file was already in cache
|
|
|
|
// no tmpfile if file was already in cache
|
|
|
|
if (CFile::fileExists(tmpfile))
|
|
|
|
if (CFile::fileExists(download.tmpdest))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
verified = download.md5sum.empty() || (download.md5sum != getMD5(tmpfile).toString());
|
|
|
|
verified = download.md5sum.empty() || (download.md5sum != getMD5(download.tmpdest).toString());
|
|
|
|
if (verified)
|
|
|
|
if (verified)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (CFile::fileExists(download.dest))
|
|
|
|
if (CFile::fileExists(download.dest))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CFile::deleteFile(download.dest);
|
|
|
|
CFile::deleteFile(download.dest);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
CFile::moveFile(download.dest, tmpfile);
|
|
|
|
CFile::moveFile(download.dest, download.tmpdest);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CFile::deleteFile(tmpfile);
|
|
|
|
CFile::deleteFile(download.tmpdest);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (CFile::fileExists(download.dest))
|
|
|
|
else if (CFile::fileExists(download.dest))
|
|
|
@ -745,7 +749,7 @@ namespace NLGUI
|
|
|
|
if (type != OverImage)
|
|
|
|
if (type != OverImage)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::string temp = dest;
|
|
|
|
std::string temp = dest;
|
|
|
|
if (!CFile::fileExists(temp))
|
|
|
|
if (!CFile::fileExists(temp) || CFile::getFileSize(temp) == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
temp = placeholder;
|
|
|
|
temp = placeholder;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -857,21 +861,16 @@ namespace NLGUI
|
|
|
|
CFile::createDirectory( pathName );
|
|
|
|
CFile::createDirectory( pathName );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CGroupHTML::addStylesheetDownload(std::vector<std::string> links)
|
|
|
|
void CGroupHTML::addStylesheetDownload(const std::vector<CHtmlParser::StyleLink> links)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for(uint i = 0; i < links.size(); ++i)
|
|
|
|
for(uint i = 0; i < links.size(); ++i)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::string url = getAbsoluteUrl(links[i]);
|
|
|
|
_StylesheetQueue.push_back(links[i]);
|
|
|
|
std::string local = localImageName(url);
|
|
|
|
std::string url = getAbsoluteUrl(links[i].Url);
|
|
|
|
|
|
|
|
_StylesheetQueue.back().Url = url;
|
|
|
|
|
|
|
|
|
|
|
|
// insert only if url not already downloading
|
|
|
|
|
|
|
|
std::vector<std::string>::const_iterator it = std::find(_StylesheetQueue.begin(), _StylesheetQueue.end(), url);
|
|
|
|
|
|
|
|
if (it == _StylesheetQueue.end())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_StylesheetQueue.push_back(url);
|
|
|
|
|
|
|
|
// push to the front of the queue
|
|
|
|
// push to the front of the queue
|
|
|
|
Curls.push_front(CDataDownload(url, local, StylesheetType, NULL, "", ""));
|
|
|
|
Curls.push_front(CDataDownload(url, localImageName(url), StylesheetType, NULL, "", ""));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pumpCurlQueue();
|
|
|
|
pumpCurlQueue();
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -971,9 +970,9 @@ namespace NLGUI
|
|
|
|
{
|
|
|
|
{
|
|
|
|
fclose(it->fp);
|
|
|
|
fclose(it->fp);
|
|
|
|
|
|
|
|
|
|
|
|
if (CFile::fileExists(it->dest + ".tmp"))
|
|
|
|
if (CFile::fileExists(it->tmpdest))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CFile::deleteFile(it->dest + ".tmp");
|
|
|
|
CFile::deleteFile(it->tmpdest);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -2549,6 +2548,17 @@ namespace NLGUI
|
|
|
|
newParagraph->setResizeFromChildH(true);
|
|
|
|
newParagraph->setResizeFromChildH(true);
|
|
|
|
|
|
|
|
|
|
|
|
newParagraph->setMarginLeft(getIndent());
|
|
|
|
newParagraph->setMarginLeft(getIndent());
|
|
|
|
|
|
|
|
if (!_Style.Current.TextAlign.empty())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (_Style.Current.TextAlign == "left")
|
|
|
|
|
|
|
|
newParagraph->setTextAlign(CGroupParagraph::AlignLeft);
|
|
|
|
|
|
|
|
else if (_Style.Current.TextAlign == "center")
|
|
|
|
|
|
|
|
newParagraph->setTextAlign(CGroupParagraph::AlignCenter);
|
|
|
|
|
|
|
|
else if (_Style.Current.TextAlign == "right")
|
|
|
|
|
|
|
|
newParagraph->setTextAlign(CGroupParagraph::AlignRight);
|
|
|
|
|
|
|
|
else if (_Style.Current.TextAlign == "justify")
|
|
|
|
|
|
|
|
newParagraph->setTextAlign(CGroupParagraph::AlignJustify);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Add to the group
|
|
|
|
// Add to the group
|
|
|
|
addHtmlGroup (newParagraph, beginSpace);
|
|
|
|
addHtmlGroup (newParagraph, beginSpace);
|
|
|
@ -2642,6 +2652,17 @@ namespace NLGUI
|
|
|
|
invalidateCoords();
|
|
|
|
invalidateCoords();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CGroupHTML::browseErrorHtml(const std::string &html)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
releaseDownloads();
|
|
|
|
|
|
|
|
removeContent();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
renderHtmlString(html);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
updateRefreshButton();
|
|
|
|
|
|
|
|
invalidateCoords();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
|
|
|
|
bool CGroupHTML::isBrowsing()
|
|
|
|
bool CGroupHTML::isBrowsing()
|
|
|
@ -3964,11 +3985,22 @@ namespace NLGUI
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!success)
|
|
|
|
if (!success)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
CUrlParser uri(_CurlWWW->Url);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// potentially unwanted chars
|
|
|
|
|
|
|
|
std::string url = _CurlWWW->Url;
|
|
|
|
|
|
|
|
url = strFindReplaceAll(url, string("<"), string("%3C"));
|
|
|
|
|
|
|
|
url = strFindReplaceAll(url, string(">"), string("%3E"));
|
|
|
|
|
|
|
|
url = strFindReplaceAll(url, string("\""), string("%22"));
|
|
|
|
|
|
|
|
url = strFindReplaceAll(url, string("'"), string("%27"));
|
|
|
|
|
|
|
|
|
|
|
|
std::string err;
|
|
|
|
std::string err;
|
|
|
|
err = "Connection failed with cURL error: ";
|
|
|
|
err = "<html><head><title>cURL error</title></head><body>";
|
|
|
|
|
|
|
|
err += "<h1>Connection failed with cURL error</h1>";
|
|
|
|
err += error;
|
|
|
|
err += error;
|
|
|
|
err += "\nURL '" + _CurlWWW->Url + "'";
|
|
|
|
err += "<hr>(" + uri.scheme + "://" + uri.host + ") <a href=\"" + url + "\">reload</a>";
|
|
|
|
browseError(err.c_str());
|
|
|
|
err += "</body></html>";
|
|
|
|
|
|
|
|
browseErrorHtml(err);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -4080,10 +4112,9 @@ namespace NLGUI
|
|
|
|
obj.LastModified = data.data->getLastModified();
|
|
|
|
obj.LastModified = data.data->getLastModified();
|
|
|
|
|
|
|
|
|
|
|
|
CHttpCache::getInstance()->store(data.dest, obj);
|
|
|
|
CHttpCache::getInstance()->store(data.dest, obj);
|
|
|
|
std::string tmpfile = data.dest + ".tmp";
|
|
|
|
if (code == 304 && CFile::fileExists(data.tmpdest))
|
|
|
|
if (code == 304 && CFile::fileExists(tmpfile))
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CFile::deleteFile(tmpfile);
|
|
|
|
CFile::deleteFile(data.tmpdest);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ((code >= 301 && code <= 303) || code == 307 || code == 308)
|
|
|
|
else if ((code >= 301 && code <= 303) || code == 307 || code == 308)
|
|
|
@ -4111,10 +4142,9 @@ namespace NLGUI
|
|
|
|
|
|
|
|
|
|
|
|
LOG_DL("Redirect '%s'", location.c_str());
|
|
|
|
LOG_DL("Redirect '%s'", location.c_str());
|
|
|
|
// no finished callback called, so cleanup old temp
|
|
|
|
// no finished callback called, so cleanup old temp
|
|
|
|
std::string tmpfile = data.dest + ".tmp";
|
|
|
|
if (CFile::fileExists(data.tmpdest))
|
|
|
|
if (CFile::fileExists(tmpfile))
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CFile::deleteFile(tmpfile);
|
|
|
|
CFile::deleteFile(data.tmpdest);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -4187,19 +4217,28 @@ namespace NLGUI
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
void CGroupHTML::cssDownloadFinished(const std::string &url, const std::string &local)
|
|
|
|
void CGroupHTML::cssDownloadFinished(const std::string &url, const std::string &local)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// remove file from download queue
|
|
|
|
for(std::vector<CHtmlParser::StyleLink>::iterator it = _StylesheetQueue.begin();
|
|
|
|
std::vector<std::string>::iterator it = std::find(_StylesheetQueue.begin(), _StylesheetQueue.end(), url);
|
|
|
|
it != _StylesheetQueue.end(); ++it)
|
|
|
|
if (it != _StylesheetQueue.end())
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_StylesheetQueue.erase(it);
|
|
|
|
if (it->Url == url)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!CFile::fileExists(local))
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
// read downloaded file into HtmlStyles
|
|
|
|
|
|
|
|
if (CFile::fileExists(local) && it->Index < _HtmlStyles.size())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
CIFile in;
|
|
|
|
|
|
|
|
if (in.open(local))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!in.readAll(_HtmlStyles[it->Index]))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
nlwarning("Failed to read downloaded css file(%s), url(%s)", local.c_str(), url.c_str());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
parseStylesheetFile(local);
|
|
|
|
_StylesheetQueue.erase(it);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CGroupHTML::renderDocument()
|
|
|
|
void CGroupHTML::renderDocument()
|
|
|
@ -4217,6 +4256,16 @@ namespace NLGUI
|
|
|
|
beginBuild();
|
|
|
|
beginBuild();
|
|
|
|
removeContent();
|
|
|
|
removeContent();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// process all <style> and <link rel=stylesheet> elements
|
|
|
|
|
|
|
|
for(uint i = 0; i < _HtmlStyles.size(); ++i)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!_HtmlStyles[i].empty())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_Style.parseStylesheet(_HtmlStyles[i]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
_HtmlStyles.clear();
|
|
|
|
|
|
|
|
|
|
|
|
std::list<CHtmlElement>::iterator it = _HtmlDOM.Children.begin();
|
|
|
|
std::list<CHtmlElement>::iterator it = _HtmlDOM.Children.begin();
|
|
|
|
while(it != _HtmlDOM.Children.end())
|
|
|
|
while(it != _HtmlDOM.Children.end())
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -4826,9 +4875,6 @@ namespace NLGUI
|
|
|
|
// ***************************************************************************
|
|
|
|
// ***************************************************************************
|
|
|
|
bool CGroupHTML::parseHtml(const std::string &htmlString)
|
|
|
|
bool CGroupHTML::parseHtml(const std::string &htmlString)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::vector<std::string> links;
|
|
|
|
|
|
|
|
std::string styleString;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CHtmlElement *parsedDOM;
|
|
|
|
CHtmlElement *parsedDOM;
|
|
|
|
if (_CurrentHTMLElement == NULL)
|
|
|
|
if (_CurrentHTMLElement == NULL)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -4841,16 +4887,28 @@ namespace NLGUI
|
|
|
|
parsedDOM = _CurrentHTMLElement;
|
|
|
|
parsedDOM = _CurrentHTMLElement;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<CHtmlParser::StyleLink> links;
|
|
|
|
|
|
|
|
|
|
|
|
CHtmlParser parser;
|
|
|
|
CHtmlParser parser;
|
|
|
|
parser.getDOM(htmlString, *parsedDOM, styleString, links);
|
|
|
|
parser.getDOM(htmlString, *parsedDOM, _HtmlStyles, links);
|
|
|
|
|
|
|
|
|
|
|
|
if (!styleString.empty())
|
|
|
|
// <link> elements inserted from lua::parseHtml are ignored
|
|
|
|
|
|
|
|
if (_CurrentHTMLElement == NULL && !links.empty())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_Style.parseStylesheet(styleString);
|
|
|
|
addStylesheetDownload(links);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!links.empty())
|
|
|
|
else if (_CurrentHTMLElement != NULL)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
addStylesheetDownload(links);
|
|
|
|
// Called from active element (lua)
|
|
|
|
|
|
|
|
// <style> order is not preserved as document is already being rendered
|
|
|
|
|
|
|
|
for(uint i = 0; i < _HtmlStyles.size(); ++i)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!_HtmlStyles[i].empty())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_Style.parseStylesheet(_HtmlStyles[i]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
_HtmlStyles.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// this should rarely fail as first element should be <html>
|
|
|
|
// this should rarely fail as first element should be <html>
|
|
|
@ -4861,7 +4919,7 @@ namespace NLGUI
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (it->Type == CHtmlElement::ELEMENT_NODE && it->Value == "html")
|
|
|
|
if (it->Type == CHtmlElement::ELEMENT_NODE && it->Value == "html")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// more newly parsed childs from <body> into siblings
|
|
|
|
// move newly parsed childs from <body> into siblings
|
|
|
|
if (_CurrentHTMLElement) {
|
|
|
|
if (_CurrentHTMLElement) {
|
|
|
|
std::list<CHtmlElement>::iterator it2 = it->Children.begin();
|
|
|
|
std::list<CHtmlElement>::iterator it2 = it->Children.begin();
|
|
|
|
while(it2 != it->Children.end())
|
|
|
|
while(it2 != it->Children.end())
|
|
|
@ -5358,6 +5416,11 @@ namespace NLGUI
|
|
|
|
cellParams.Align = CGroupCell::Center;
|
|
|
|
cellParams.Align = CGroupCell::Center;
|
|
|
|
else if (align == "right")
|
|
|
|
else if (align == "right")
|
|
|
|
cellParams.Align = CGroupCell::Right;
|
|
|
|
cellParams.Align = CGroupCell::Right;
|
|
|
|
|
|
|
|
else if (align != "justify")
|
|
|
|
|
|
|
|
align.clear();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// copy td align (can be empty) attribute back into css
|
|
|
|
|
|
|
|
_Style.Current.TextAlign = align;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -5503,7 +5566,7 @@ namespace NLGUI
|
|
|
|
string suri = elm.getAttribute("href");
|
|
|
|
string suri = elm.getAttribute("href");
|
|
|
|
if(suri.find("ah:") == 0)
|
|
|
|
if(suri.find("ah:") == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (_TrustedDomain)
|
|
|
|
if (_TrustedDomain || suri.find("ah:script:") == 0)
|
|
|
|
_Link.back() = suri;
|
|
|
|
_Link.back() = suri;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -6360,11 +6423,13 @@ namespace NLGUI
|
|
|
|
|
|
|
|
|
|
|
|
void CGroupHTML::htmlOBJECTend(const CHtmlElement &elm)
|
|
|
|
void CGroupHTML::htmlOBJECTend(const CHtmlElement &elm)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!_TrustedDomain)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (_ObjectType=="application/ryzom-data")
|
|
|
|
if (_ObjectType=="application/ryzom-data")
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!_TrustedDomain)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if (!_ObjectData.empty())
|
|
|
|
if (!_ObjectData.empty())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (addBnpDownload(_ObjectData, _ObjectAction, _ObjectScript, _ObjectMD5Sum))
|
|
|
|
if (addBnpDownload(_ObjectData, _ObjectAction, _ObjectScript, _ObjectMD5Sum))
|
|
|
@ -6374,6 +6439,20 @@ namespace NLGUI
|
|
|
|
_ObjectScript.clear();
|
|
|
|
_ObjectScript.clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (_ObjectType=="application/ryzom-tutorial")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
while(strFindReplace(_ObjectScript, "[", "〈"));
|
|
|
|
|
|
|
|
while(strFindReplace(_ObjectScript, "]", "〉"));
|
|
|
|
|
|
|
|
CLuaManager::getInstance().executeLuaScript("\ngame:executeTutorial([["+_ObjectScript+"]])\n", true);
|
|
|
|
|
|
|
|
_ObjectScript.clear();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (_ObjectType=="application/ryzom-script")
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
while(strFindReplace(_ObjectScript, "[", "〈"));
|
|
|
|
|
|
|
|
while(strFindReplace(_ObjectScript, "]", "〉"));
|
|
|
|
|
|
|
|
CLuaManager::getInstance().executeLuaScript("\ngame:executeRyzomScript([["+_ObjectScript+"]])\n", true);
|
|
|
|
|
|
|
|
_ObjectScript.clear();
|
|
|
|
|
|
|
|
}
|
|
|
|
_Object = false;
|
|
|
|
_Object = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -6767,6 +6846,9 @@ namespace NLGUI
|
|
|
|
// setting ModulateGlobalColor must be after addImageDownload
|
|
|
|
// setting ModulateGlobalColor must be after addImageDownload
|
|
|
|
if (_Style.checkStyle("-ryzom-modulate-bgcolor", "true"))
|
|
|
|
if (_Style.checkStyle("-ryzom-modulate-bgcolor", "true"))
|
|
|
|
table->setModulateGlobalColor(true);
|
|
|
|
table->setModulateGlobalColor(true);
|
|
|
|
|
|
|
|
else if (_Style.checkStyle("-ryzom-modulate-bgcolor", "false"))
|
|
|
|
|
|
|
|
table->setModulateGlobalColor(false);
|
|
|
|
|
|
|
|
|
|
|
|
table->setMarginLeft(getIndent());
|
|
|
|
table->setMarginLeft(getIndent());
|
|
|
|
addHtmlGroup (table, 0);
|
|
|
|
addHtmlGroup (table, 0);
|
|
|
|
|
|
|
|
|
|
|
|