Merge with develop

--HG--
branch : compatibility-develop
This commit is contained in:
Nimetu 2017-05-14 01:27:20 +03:00
commit fcbdbd17b7
3 changed files with 212 additions and 10 deletions

View file

@ -821,7 +821,7 @@ namespace NLGUI
{ {
public: public:
CDataDownload(const std::string &u, const std::string &d, TDataType t, CViewBase *i, const std::string &s, const std::string &m, const CStyleParams &style = CStyleParams()) CDataDownload(const std::string &u, const std::string &d, TDataType t, CViewBase *i, const std::string &s, const std::string &m, const CStyleParams &style = CStyleParams())
: data(NULL), fp(NULL), url(u), dest(d), type(t), luaScript(s), md5sum(m) : data(NULL), fp(NULL), url(u), dest(d), type(t), luaScript(s), md5sum(m), redirects(0)
{ {
if (t == ImgType) imgs.push_back(CDataImageDownload(i, style)); if (t == ImgType) imgs.push_back(CDataImageDownload(i, style));
} }
@ -833,6 +833,7 @@ namespace NLGUI
std::string luaScript; std::string luaScript;
std::string md5sum; std::string md5sum;
TDataType type; TDataType type;
uint32 redirects;
FILE *fp; FILE *fp;
std::vector<CDataImageDownload> imgs; std::vector<CDataImageDownload> imgs;
}; };

View file

@ -651,17 +651,52 @@ namespace NLGUI
string tmpfile = it->dest + ".tmp"; string tmpfile = it->dest + ".tmp";
if(res != CURLE_OK || r < 200 || r >= 300 || (!it->md5sum.empty() && (it->md5sum != getMD5(tmpfile).toString()))) if(res != CURLE_OK || r < 200 || r >= 300 || (!it->md5sum.empty() && (it->md5sum != getMD5(tmpfile).toString())))
{ {
NLMISC::CFile::deleteFile(tmpfile.c_str()); if (it->redirects < DEFAULT_RYZOM_REDIRECT_LIMIT && ((r >= 301 && r <= 303) || r == 307 || r == 308))
// 304 Not Modified
if (res == CURLE_OK && r == 304)
{ {
CHttpCacheObject obj; std::string location(it->data->getLocationHeader());
obj.Expires = it->data->getExpires(); if (!location.empty())
obj.Etag = it->data->getEtag(); {
obj.LastModified = it->data->getLastModified(); CUrlParser uri(location);
if (!uri.isAbsolute())
{
uri.inherit(it->url);
location = uri.toString();
}
CHttpCache::getInstance()->store(it->dest, obj); it->url = location;
it->fp = NULL;
// release CCurlWWWData
delete it->data;
it->data = NULL;
it->redirects++;
#ifdef LOG_DL
nlwarning("Redirect '%s'", location.c_str());
#endif
// keep the request in queue
continue;
}
else
nlwarning("Redirected to empty url '%s'", it->url.c_str());
}
else
{
if (it->redirects >= DEFAULT_RYZOM_REDIRECT_LIMIT)
nlwarning("Redirect limit reached for '%s'", it->url.c_str());
NLMISC::CFile::deleteFile(tmpfile.c_str());
// 304 Not Modified
if (res == CURLE_OK && r == 304)
{
CHttpCacheObject obj;
obj.Expires = it->data->getExpires();
obj.Etag = it->data->getEtag();
obj.LastModified = it->data->getLastModified();
CHttpCache::getInstance()->store(it->dest, obj);
}
} }
} }
else else

View file

@ -1294,4 +1294,170 @@
</group> </group>
</group> </group>
<tree node="web_transactions" /> <tree node="web_transactions" />
<group type="container"
id="web_lua_action"
w="480"
h="400"
title=""
global_color="false"
open_button="false"
force_open_out="true"
header_color="UI:SAVE:WIN:COLORS:COM"
resizer="true"
pop_min_w="220"
pop_min_h="96"
pop_max_w="2000"
pop_max_h="1600"
title_bar_open="false"
lockable="true"
openable="false"
opened="true"
movable="true"
active="true">
<group id="header_closed"
x="0"
y="0"
h="12"
posref="TL TL"></group>
<group id="header_opened"
x="0"
y="0"
w="480"
h="16"
posref="TL TL">
<!-- must be frozen by default cause no undo/redo at start -->
<ctrl style="text_button_header"
button_type="push_button"
id="browse_redo"
posref="MR MR"
x="-16"
y="0"
hardtext="uiBrowseRedoButton"
tooltip="uittBrowseRedo"
onclick_l="browse_redo"
params_l="name=ui:interface:web_lua_action:content:html"
frozen="true" />
<ctrl style="text_button_header"
button_type="push_button"
id="browse_undo"
posparent="browse_redo"
posref="ML MR"
x="-4"
y="0"
hardtext="uiBrowseUndoButton"
tooltip="uittBrowseUndo"
onclick_l="browse_undo"
params_l="name=ui:interface:web_lua_action:content:html"
frozen="true" />
<ctrl style="text_button_header"
button_type="push_button"
id="browse_refresh"
posparent="browse_undo"
posref="ML MR"
x="-4"
y="0"
hardtext="uiBrowseRefresh"
tooltip="uittBrowseRefresh"
onclick_l="browse_refresh"
params_l="name=ui:interface:web_lua_action:content:html" />
<ctrl style="text_button_header"
button_type="push_button"
id="browse_home"
posparent="browse_refresh"
posref="ML MR"
x="-4"
y="0"
hardtext="uiBrowseHome"
tooltip="uittBrowseHome"
onclick_l="browse_home"
params_l="name=ui:interface:web_lua_action:content:html" />
</group>
<group id="content"
x="0"
y="0"
w="0"
h="0"
posref="TL TL">
<group type="webig_html"
id="html"
posref="TL TL"
url=""
home="http://app.ryzom.com/"
sizeref="wh"
x="0"
y="0"
w="0"
h="0"
background_color="0 0 0 255"
error_color="255 240 48 255"
link_color="240 155 100 255"
text_color="210 210 210 255"
h1_color="255 255 255 255"
h2_color="255 255 255 255"
h3_color="255 255 255 255"
h4_color="255 255 255 255"
h5_color="255 255 255 255"
h6_color="255 255 255 255"
text_font_size="10"
h1_font_size="20"
h2_font_size="18"
h3_font_size="16"
h4_font_size="14"
h5_font_size="12"
h6_font_size="12"
paragraph_begin_space="12"
multi_line_space_factor="0.25"
td_begin_space="0"
li_begin_space="4"
ul_begin_space="12"
li_indent="-10"
ul_indent="30"
checkbox_bitmap_normal="w_slot_on.tga"
checkbox_bitmap_pushed="w_opacity_on.tga"
checkbox_bitmap_over=""
background_bitmap_view="black2"
browse_next_time="false"
form_text_area_group="edit_box_widget_multiline"
browse_refresh="ui:interface:web_lua_action:header_opened:browse_refresh"
browse_undo="ui:interface:web_lua_action:header_opened:browse_undo"
browse_redo="ui:interface:web_lua_action:header_opened:browse_redo">
<group id="black"
posref="BR BR"
sizeref="hw"
w="-10"
h="-12"
inherit_gc_alpha="true" />
<instance template="inner_thin_border"
posparent="black"
inherit_gc_alpha="true" />
<view type="bitmap"
id="black2"
posparent="black"
posref="MM MM"
sizeref="wh"
w="-2"
h="-2"
inherit_gc_alpha="true"
scale="true"
texture="blank.tga"
global_color="false" />
<group type="list"
id="text_list"
fontsize="9"
posref="TL TL"
posparent="black"
x="2"
y="-2"
space="0"
sizeref="hw"
w="-4"
h="-4"
maxelements="2000" />
<ctrl style="skin_scroll"
id="scroll_bar" />
</group>
</group>
</group>
<tree node="web_lua_action" />
</interface_config> </interface_config>