Added: http-equiv refresh
This commit is contained in:
parent
701c70ed6c
commit
f1532d3606
2 changed files with 66 additions and 1 deletions
|
@ -409,6 +409,10 @@ namespace NLGUI
|
||||||
double _TimeoutValue; // the timeout in seconds
|
double _TimeoutValue; // the timeout in seconds
|
||||||
double _ConnectingTimeout;
|
double _ConnectingTimeout;
|
||||||
sint _RedirectsRemaining;
|
sint _RedirectsRemaining;
|
||||||
|
// Automatic page refresh
|
||||||
|
double _LastRefreshTime;
|
||||||
|
double _NextRefreshTime;
|
||||||
|
std::string _RefreshUrl;
|
||||||
|
|
||||||
// minimal embeded lua script support
|
// minimal embeded lua script support
|
||||||
// Note : any embeded script is executed immediately after the closing
|
// Note : any embeded script is executed immediately after the closing
|
||||||
|
|
|
@ -1137,6 +1137,40 @@ namespace NLGUI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case HTML_META:
|
||||||
|
if (_ReadingHeadTag)
|
||||||
|
{
|
||||||
|
bool httpEquiv = present[HTML_META_HTTP_EQUIV] && value[HTML_META_HTTP_EQUIV];
|
||||||
|
bool httpContent = present[HTML_META_CONTENT] && value[HTML_META_CONTENT];
|
||||||
|
if (httpEquiv && httpContent)
|
||||||
|
{
|
||||||
|
// only first http-equiv="refresh" should be handled
|
||||||
|
if (_RefreshUrl.empty() && toLower(value[HTML_META_HTTP_EQUIV]) == "refresh")
|
||||||
|
{
|
||||||
|
const CWidgetManager::SInterfaceTimes × = CWidgetManager::getInstance()->getInterfaceTimes();
|
||||||
|
double timeSec = times.thisFrameMs / 1000.0f;
|
||||||
|
string content(value[HTML_META_CONTENT]);
|
||||||
|
|
||||||
|
string::size_type pos = content.find_first_of(";");
|
||||||
|
if (pos == string::npos)
|
||||||
|
{
|
||||||
|
fromString(content, _NextRefreshTime);
|
||||||
|
_RefreshUrl = _URL;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fromString(content.substr(0, pos), _NextRefreshTime);
|
||||||
|
|
||||||
|
pos = toLower(content).find("url=");
|
||||||
|
if (pos != string::npos)
|
||||||
|
_RefreshUrl = content.substr(pos + 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
_NextRefreshTime += timeSec;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
case HTML_A:
|
case HTML_A:
|
||||||
{
|
{
|
||||||
CStyleParams style;
|
CStyleParams style;
|
||||||
|
@ -2422,6 +2456,9 @@ namespace NLGUI
|
||||||
_GroupListAdaptor = NULL;
|
_GroupListAdaptor = NULL;
|
||||||
_DocumentUrl = "";
|
_DocumentUrl = "";
|
||||||
_UrlFragment.clear();
|
_UrlFragment.clear();
|
||||||
|
_RefreshUrl.clear();
|
||||||
|
_NextRefreshTime = 0.0;
|
||||||
|
_LastRefreshTime = 0.0;
|
||||||
|
|
||||||
// Register
|
// Register
|
||||||
CWidgetManager::getInstance()->registerClockMsgTarget(this);
|
CWidgetManager::getInstance()->registerClockMsgTarget(this);
|
||||||
|
@ -3413,8 +3450,15 @@ namespace NLGUI
|
||||||
// Handle now
|
// Handle now
|
||||||
handle ();
|
handle ();
|
||||||
}
|
}
|
||||||
|
if (systemEvent.getEventTypeExtended() == NLGUI::CEventDescriptorSystem::activecalledonparent)
|
||||||
|
{
|
||||||
|
if (!((NLGUI::CEventDescriptorActiveCalledOnParent &) systemEvent).getActive())
|
||||||
|
{
|
||||||
|
// stop refresh when window gets hidden
|
||||||
|
_NextRefreshTime = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return traited;
|
return traited;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4410,6 +4454,21 @@ namespace NLGUI
|
||||||
// handle curl downloads
|
// handle curl downloads
|
||||||
checkDownloads();
|
checkDownloads();
|
||||||
|
|
||||||
|
// handle refresh timer
|
||||||
|
if (_NextRefreshTime > 0 && _NextRefreshTime <= (times.thisFrameMs / 1000.0f) )
|
||||||
|
{
|
||||||
|
// there might be valid uses for 0sec refresh, but two in a row is probably a mistake
|
||||||
|
if (_NextRefreshTime - _LastRefreshTime >= 1.0)
|
||||||
|
{
|
||||||
|
_LastRefreshTime = _NextRefreshTime;
|
||||||
|
doBrowse(_RefreshUrl.c_str());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
nlwarning("Ignore second 0sec http-equiv refresh in a row (url '%s')", _URL.c_str());
|
||||||
|
|
||||||
|
_NextRefreshTime = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (_Connecting)
|
if (_Connecting)
|
||||||
{
|
{
|
||||||
// Check timeout if needed
|
// Check timeout if needed
|
||||||
|
@ -4783,6 +4842,8 @@ namespace NLGUI
|
||||||
//
|
//
|
||||||
_Browsing = true;
|
_Browsing = true;
|
||||||
_DocumentUrl = _URL;
|
_DocumentUrl = _URL;
|
||||||
|
_NextRefreshTime = 0;
|
||||||
|
_RefreshUrl.clear();
|
||||||
|
|
||||||
// clear content
|
// clear content
|
||||||
beginBuild();
|
beginBuild();
|
||||||
|
|
Loading…
Reference in a new issue