Merge with develop

This commit is contained in:
kervala 2015-04-22 17:58:09 +02:00
parent 78eee4f222
commit cf793072d4
4 changed files with 71 additions and 11 deletions

View file

@ -192,10 +192,6 @@ namespace NLGUI
} }
} }
CURL *curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, true);
curl_easy_setopt(curl, CURLOPT_URL, finalUrl.c_str());
// use requested url for local name // use requested url for local name
string dest = localImageName(url); string dest = localImageName(url);
string tmpdest = localImageName(url)+".tmp"; string tmpdest = localImageName(url)+".tmp";
@ -209,13 +205,30 @@ namespace NLGUI
if (!NLMISC::CFile::fileExists(dest)) if (!NLMISC::CFile::fileExists(dest))
{ {
if (!MultiCurl)
{
nlwarning("Invalid MultiCurl handle, unable to download '%s'", finalUrl.c_str());
return;
}
CURL *curl = curl_easy_init();
if (!curl)
{
nlwarning("Creating cURL handle failed, unable to download '%s'", finalUrl.c_str());
return;
}
FILE *fp = fopen (tmpdest.c_str(), "wb"); FILE *fp = fopen (tmpdest.c_str(), "wb");
if (fp == NULL) if (fp == NULL)
{ {
curl_easy_cleanup(curl);
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'", tmpdest.c_str (), errno, strerror(errno));
return; return;
} }
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, true);
curl_easy_setopt(curl, CURLOPT_URL, finalUrl.c_str());
curl_easy_setopt(curl, CURLOPT_FILE, fp); curl_easy_setopt(curl, CURLOPT_FILE, fp);
curl_multi_add_handle(MultiCurl, curl); curl_multi_add_handle(MultiCurl, curl);
@ -298,19 +311,30 @@ namespace NLGUI
} }
if (action != "delete") if (action != "delete")
{ {
CURL *curl = curl_easy_init(); if (!MultiCurl)
if (!MultiCurl || !curl) {
nlwarning("Invalid MultiCurl handle, unable to download '%s'", url.c_str());
return false; return false;
}
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, true); CURL *curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); if (!curl)
{
nlwarning("Creating cURL handle failed, unable to download '%s'", url.c_str());
return false;
}
FILE *fp = fopen (tmpdest.c_str(), "wb"); FILE *fp = fopen (tmpdest.c_str(), "wb");
if (fp == NULL) if (fp == NULL)
{ {
curl_easy_cleanup(curl);
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'", tmpdest.c_str (), errno, strerror(errno));
return false; return false;
} }
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, true);
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_FILE, fp); curl_easy_setopt(curl, CURLOPT_FILE, fp);
curl_multi_add_handle(MultiCurl, curl); curl_multi_add_handle(MultiCurl, curl);
@ -392,6 +416,8 @@ namespace NLGUI
} }
else else
{ {
receiveCookies(_CurlWWW->Request, HTTPCurrentDomain, _TrustedDomain);
// redirect, get the location and try browse again // redirect, get the location and try browse again
// we cant use curl redirection because 'addHTTPGetParams()' must be called on new destination // we cant use curl redirection because 'addHTTPGetParams()' must be called on new destination
std::string location(_CurlWWW->getLocationHeader()); std::string location(_CurlWWW->getLocationHeader());
@ -417,16 +443,16 @@ namespace NLGUI
} }
else else
{ {
receiveCookies(_CurlWWW->Request, HTTPCurrentDomain, _TrustedDomain);
_RedirectsRemaining = DEFAULT_RYZOM_REDIRECT_LIMIT; _RedirectsRemaining = DEFAULT_RYZOM_REDIRECT_LIMIT;
if ( (code < 200 || code >= 300) ) if ( (code < 200 || code >= 300) )
{ {
browseError(string("Connection failed (curl code " + toString((sint32)res) + "), http code " + toString(code) + ") : " + _CurlWWW->Url).c_str()); browseError(string("Connection failed (curl code " + toString((sint32)res) + "), http code " + toString((sint32)code) + ") : " + _CurlWWW->Url).c_str());
} }
else else
{ {
receiveCookies(_CurlWWW->Request, HTTPCurrentDomain, _TrustedDomain);
char *ch; char *ch;
std::string contentType; std::string contentType;
res = curl_easy_getinfo(_CurlWWW->Request, CURLINFO_CONTENT_TYPE, &ch); res = curl_easy_getinfo(_CurlWWW->Request, CURLINFO_CONTENT_TYPE, &ch);

View file

@ -387,6 +387,9 @@ namespace NLGUI
// add all cookies for domain to curl handle // add all cookies for domain to curl handle
void sendCookies(CURL *curl, const std::string &domain, bool trusted) void sendCookies(CURL *curl, const std::string &domain, bool trusted)
{ {
// enable curl cookie engine
curl_easy_setopt(curl, CURLOPT_COOKIELIST, "");
if (domain.empty()) if (domain.empty())
return; return;

View file

@ -205,6 +205,20 @@
<value value="10" hardtext="uiNumber10"/> <value value="10" hardtext="uiNumber10"/>
</parameter> </parameter>
</action> </action>
<action name="select_shortcut_bar_2" hardtext="uiSelectShortcutBar2" contexts="game, r2ed_anim_test">
<parameter hardtext="uiShortcutBarNumber">
<value value="1" hardtext="uiNumber01"/>
<value value="2" hardtext="uiNumber02"/>
<value value="3" hardtext="uiNumber03"/>
<value value="4" hardtext="uiNumber04"/>
<value value="5" hardtext="uiNumber05"/>
<value value="6" hardtext="uiNumber06"/>
<value value="7" hardtext="uiNumber07"/>
<value value="8" hardtext="uiNumber08"/>
<value value="9" hardtext="uiNumber09"/>
<value value="10" hardtext="uiNumber10"/>
</parameter>
</action>
<action name="phrase_cancel_cast" hardtext="uiCancelCast" contexts="game, r2ed_anim_test"/> <action name="phrase_cancel_cast" hardtext="uiCancelCast" contexts="game, r2ed_anim_test"/>
</action_category> </action_category>

View file

@ -1620,6 +1620,23 @@ public:
}; };
REGISTER_ACTION_HANDLER(CHandlerPhraseSelectShortcutBar, "select_shortcut_bar"); REGISTER_ACTION_HANDLER(CHandlerPhraseSelectShortcutBar, "select_shortcut_bar");
// ***************************************************************************
class CHandlerPhraseSelectShortcutBar2 : public IActionHandler
{
public:
virtual void execute(CCtrlBase * /* pCaller */, const string &Params)
{
CInterfaceManager *pIM= CInterfaceManager::getInstance();
CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp("UI:PHRASE:SELECT_MEMORY_2", false);
if(node)
{
sint32 val;
fromString(Params, val);
node->setValue32(val);
}
}
};
REGISTER_ACTION_HANDLER(CHandlerPhraseSelectShortcutBar2, "select_shortcut_bar_2");
// *************************************************************************** // ***************************************************************************
// *************************************************************************** // ***************************************************************************