CHANGED: #1471 Decoupled CGroupHTML, CGroupParagraph, CViewLink from Ryzom game related code.

--HG--
branch : gui-refactoring
hg/feature/sse2
dfighter1985 13 years ago
parent b65e0ca0c5
commit bb698212bf

@ -43,6 +43,8 @@ namespace NLGUI
NLGUI::CLuaState* getLuaState() const{ return luaState; } NLGUI::CLuaState* getLuaState() const{ return luaState; }
bool executeLuaScript( const std::string &luaScript, bool smallScript = false );
private: private:
CLuaManager(); CLuaManager();

@ -52,6 +52,8 @@ namespace NLGUI
virtual CInterfaceGroup* createGroupInstance( const std::string &templateName, const std::string &parentID, const std::pair< std::string, std::string > *templateParams, uint numParams, bool updateLinks = true ) = 0; virtual CInterfaceGroup* createGroupInstance( const std::string &templateName, const std::string &parentID, const std::pair< std::string, std::string > *templateParams, uint numParams, bool updateLinks = true ) = 0;
virtual CInterfaceGroup* createGroupInstance( const std::string &templateName, const std::string &parentID, std::vector< std::pair< std::string, std::string > > &templateParams, bool updateLinks = true ) = 0; virtual CInterfaceGroup* createGroupInstance( const std::string &templateName, const std::string &parentID, std::vector< std::pair< std::string, std::string > > &templateParams, bool updateLinks = true ) = 0;
virtual bool parseGroupChildren( xmlNodePtr cur, CInterfaceGroup * parentGroup, bool reload ) = 0; virtual bool parseGroupChildren( xmlNodePtr cur, CInterfaceGroup * parentGroup, bool reload ) = 0;
virtual uint getProcedureNumActions( const std::string &procName ) const = 0;
virtual bool getProcedureAction( const std::string &procName, uint actionIndex, std::string &ah, std::string &params ) const = 0;
}; };
/// Manages the GUI widgets /// Manages the GUI widgets

@ -34,6 +34,22 @@ namespace NLGUI
luaState = NULL; luaState = NULL;
} }
bool CLuaManager::executeLuaScript( const std::string &luaScript, bool smallScript )
{
try
{
if( smallScript )
luaState->executeSmallScript( luaScript );
else
luaState->executeScript( luaScript );
}
catch( const ELuaError &e )
{
nlwarning( e.luaWhat().c_str() );
return false;
}
return true;
}
} }

@ -14,8 +14,6 @@
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdpch.h"
//#include <crtdbg.h> //#include <crtdbg.h>
// LibWWW // LibWWW
@ -27,25 +25,21 @@ extern "C"
} }
#include "../libwww.h" #include "../libwww.h"
#include "group_html.h" #include "group_html.h"
#include "nel/gui/group_list.h" #include "nel/gui/group_list.h"
#include "nel/gui/group_container.h" #include "nel/gui/group_container.h"
#include "view_link.h" #include "view_link.h"
#include "nel/gui/ctrl_scroll.h" #include "nel/gui/ctrl_scroll.h"
#include "nel/gui/ctrl_button.h" #include "nel/gui/ctrl_button.h"
#include "dbctrl_sheet.h"
#include "nel/gui/ctrl_text_button.h" #include "nel/gui/ctrl_text_button.h"
#include "nel/gui/action_handler.h" #include "nel/gui/action_handler.h"
#include "group_paragraph.h" #include "group_paragraph.h"
#include "nel/gui/group_editbox.h" #include "nel/gui/group_editbox.h"
#include "interface_manager.h" #include "nel/gui/widget_manager.h"
#include "nel/gui/lua_manager.h"
#include "nel/gui/view_bitmap.h" #include "nel/gui/view_bitmap.h"
#include "../actions.h"
#include "nel/gui/dbgroup_combo_box.h" #include "nel/gui/dbgroup_combo_box.h"
#include "nel/gui/lua_ihm.h" #include "nel/gui/lua_ihm.h"
#include "../time_client.h"
#include "nel/misc/i18n.h" #include "nel/misc/i18n.h"
#include "nel/misc/md5.h" #include "nel/misc/md5.h"
#include "nel/3d/texture_file.h" #include "nel/3d/texture_file.h"
@ -62,14 +56,15 @@ using namespace NLMISC;
//#define LOG_DL 1 //#define LOG_DL 1
CGroupHTML *CGroupHTML::_ConnectingLock = NULL; CGroupHTML *CGroupHTML::_ConnectingLock = NULL;
extern CActionsContext ActionsContext; CGroupHTML::SWebOptions CGroupHTML::options;
// Check if domain is on TrustedDomain // Check if domain is on TrustedDomain
bool CGroupHTML::isTrustedDomain(const string &domain) bool CGroupHTML::isTrustedDomain(const string &domain)
{ {
vector<string>::iterator it; vector<string>::iterator it;
it = find (ClientCfg.WebIgTrustedDomains.begin(), ClientCfg.WebIgTrustedDomains.end(), domain); it = find ( options.trustedDomains.begin(), options.trustedDomains.end(), domain);
return it != ClientCfg.WebIgTrustedDomains.end(); return it != options.trustedDomains.end();
} }
void CGroupHTML::setImage(CViewBase * view, const string &file) void CGroupHTML::setImage(CViewBase * view, const string &file)
@ -361,8 +356,7 @@ void CGroupHTML::checkDownloads()
CFile::moveFile(file.c_str(), (file+".tmp").c_str()); CFile::moveFile(file.c_str(), (file+".tmp").c_str());
if (lookupLocalFile (finalUrl, file.c_str(), false)) if (lookupLocalFile (finalUrl, file.c_str(), false))
{ {
CInterfaceManager *pIM = CInterfaceManager::getInstance(); CLuaManager::getInstance().executeLuaScript( it->luaScript, true );
pIM->executeLuaScript(it->luaScript, true);
} }
} }
} }
@ -899,33 +893,8 @@ void CGroupHTML::beginElement (uint element_number, const BOOL *present, const c
if (present[MY_HTML_A_CLASS] && value[MY_HTML_A_CLASS]) if (present[MY_HTML_A_CLASS] && value[MY_HTML_A_CLASS])
_LinkClass.push_back(value[MY_HTML_A_CLASS]); _LinkClass.push_back(value[MY_HTML_A_CLASS]);
// Quick help
if (_TrustedDomain && present[MY_HTML_A_Z_ACTION_SHORTCUT] && value[MY_HTML_A_Z_ACTION_SHORTCUT])
{
// Get the action category
string category;
if (present[MY_HTML_A_Z_ACTION_CATEGORY] && value[MY_HTML_A_Z_ACTION_CATEGORY])
category = value[MY_HTML_A_Z_ACTION_CATEGORY];
// Get the action params
string params;
if (present[MY_HTML_A_Z_ACTION_PARAMS] && value[MY_HTML_A_Z_ACTION_PARAMS])
params = value[MY_HTML_A_Z_ACTION_PARAMS];
// Get the action descriptor
CActionsManager *actionManager = ActionsContext.getActionsManager (category);
if (actionManager)
{
const CActionsManager::TActionComboMap &actionCombo = actionManager->getActionComboMap ();
CActionsManager::TActionComboMap::const_iterator ite = actionCombo.find (CAction::CName (value[MY_HTML_A_Z_ACTION_SHORTCUT], params.c_str()));
if (ite != actionCombo.end())
{
addString (ite->second.toUCString());
}
}
}
break; break;
case HTML_DIV: case HTML_DIV:
{ {
if (present[MY_HTML_DIV_NAME] && value[MY_HTML_DIV_NAME]) if (present[MY_HTML_DIV_NAME] && value[MY_HTML_DIV_NAME])
@ -972,8 +941,7 @@ void CGroupHTML::beginElement (uint element_number, const BOOL *present, const c
else else
parentId = _Paragraph->getId(); parentId = _Paragraph->getId();
CInterfaceManager *im = CInterfaceManager::getInstance(); CInterfaceGroup *inst = CWidgetManager::parser->createGroupInstance(templateName, parentId+":"+id, tmplParams);
CInterfaceGroup *inst = im->createGroupInstance(templateName, parentId+":"+id, tmplParams);
if (inst) if (inst)
{ {
inst->setId(parentId+":"+id); inst->setId(parentId+":"+id);
@ -1272,7 +1240,6 @@ void CGroupHTML::beginElement (uint element_number, const BOOL *present, const c
paragraphChange (); paragraphChange ();
} }
CInterfaceManager *im = CInterfaceManager::getInstance();
typedef pair<string, string> TTmplParam; typedef pair<string, string> TTmplParam;
vector<TTmplParam> tmplParams; vector<TTmplParam> tmplParams;
tmplParams.push_back(TTmplParam("id", name)); tmplParams.push_back(TTmplParam("id", name));
@ -1282,7 +1249,7 @@ void CGroupHTML::beginElement (uint element_number, const BOOL *present, const c
tmplParams.push_back(TTmplParam("active", "true")); tmplParams.push_back(TTmplParam("active", "true"));
if (!minWidth.empty()) if (!minWidth.empty())
tmplParams.push_back(TTmplParam("wmin", minWidth)); tmplParams.push_back(TTmplParam("wmin", minWidth));
CInterfaceGroup *buttonGroup = im->createGroupInstance(buttonTemplate, _Paragraph->getId(), tmplParams); CInterfaceGroup *buttonGroup = CWidgetManager::parser->createGroupInstance(buttonTemplate, _Paragraph->getId(), tmplParams);
if (buttonGroup) if (buttonGroup)
{ {
@ -1776,8 +1743,7 @@ void CGroupHTML::endElement (uint element_number)
{ {
if (addBnpDownload(_ObjectData, _ObjectAction, _ObjectScript, _ObjectMD5Sum)) if (addBnpDownload(_ObjectData, _ObjectAction, _ObjectScript, _ObjectMD5Sum))
{ {
CInterfaceManager *pIM = CInterfaceManager::getInstance(); CLuaManager::getInstance().executeLuaScript("\nlocal __ALLREADYDL__=true\n"+_ObjectScript, true);
pIM->executeLuaScript("\nlocal __ALLREADYDL__=true\n"+_ObjectScript, true);
} }
_ObjectScript = ""; _ObjectScript = "";
} }
@ -1811,9 +1777,8 @@ void CGroupHTML::endUnparsedElement(const char *buffer, int length)
{ {
_ParsingLua = false; _ParsingLua = false;
// execute the embeded lua script // execute the embeded lua script
CInterfaceManager *pIM = CInterfaceManager::getInstance();
_LuaScript = "\nlocal __CURRENT_WINDOW__=\""+this->_Id+"\" \n"+_LuaScript; _LuaScript = "\nlocal __CURRENT_WINDOW__=\""+this->_Id+"\" \n"+_LuaScript;
pIM->executeLuaScript(_LuaScript, true); CLuaManager::getInstance().executeLuaScript(_LuaScript, true);
} }
} }
} }
@ -1924,8 +1889,8 @@ CGroupHTML::~CGroupHTML()
// stop browsing // stop browsing
stopBrowse (); // NB : we don't call updateRefreshButton here, because : stopBrowse (); // NB : we don't call updateRefreshButton here, because :
// 1) it is useless, // 1) it is useless,
// 2) it crashed before when it called getElementFromId (that didn't work when a master group was being removed...). Btw it should work now // 2) it crashed before when it called getElementFromId (that didn't work when a master group was being removed...). Btw it should work now
// this is why the call to 'updateRefreshButton' has been removed from stopBrowse // this is why the call to 'updateRefreshButton' has been removed from stopBrowse
clearContext(); clearContext();
delete _LibWWW; delete _LibWWW;
@ -2219,8 +2184,6 @@ void CGroupHTML::doBrowse(const char *url)
// if a BrowseTree is bound to us, try to select the node that opens this URL (auto-locate) // if a BrowseTree is bound to us, try to select the node that opens this URL (auto-locate)
if(!_BrowseTree.empty()) if(!_BrowseTree.empty())
{ {
CInterfaceManager *pIM= CInterfaceManager::getInstance();
CGroupTree *groupTree=dynamic_cast<CGroupTree*>(CWidgetManager::getInstance()->getElementFromId(_BrowseTree)); CGroupTree *groupTree=dynamic_cast<CGroupTree*>(CWidgetManager::getInstance()->getElementFromId(_BrowseTree));
if(groupTree) if(groupTree)
{ {
@ -2315,7 +2278,7 @@ bool CGroupHTML::translateChar(ucchar &output, ucchar input, ucchar lastCharPara
if (lastChar == 0) if (lastChar == 0)
lastChar = getLastChar(); lastChar = getLastChar();
keep = ((lastChar != (ucchar)' ') && keep = ((lastChar != (ucchar)' ') &&
(lastChar != 0)) || getPRE() || (_CurrentViewImage && (lastChar == 0)); (lastChar != 0)) || getPRE() || (_CurrentViewImage && (lastChar == 0));
if(!getPRE()) if(!getPRE())
input = ' '; input = ' ';
} }
@ -2327,8 +2290,8 @@ bool CGroupHTML::translateChar(ucchar &output, ucchar input, ucchar lastCharPara
if (lastChar == 0) if (lastChar == 0)
lastChar = getLastChar(); lastChar = getLastChar();
keep = ((lastChar != (ucchar)' ') && keep = ((lastChar != (ucchar)' ') &&
(lastChar != (ucchar)'\n') && (lastChar != (ucchar)'\n') &&
(lastChar != 0)) || getPRE() || (_CurrentViewImage && (lastChar == 0)); (lastChar != 0)) || getPRE() || (_CurrentViewImage && (lastChar == 0));
} }
break; break;
case 0xd: case 0xd:
@ -2444,14 +2407,13 @@ void CGroupHTML::addString(const ucstring &str)
// Action handler parameters : "name=group_html_id|form=id_of_the_form|submit_button=button_name" // Action handler parameters : "name=group_html_id|form=id_of_the_form|submit_button=button_name"
string param = "name=" + this->_Id + "|url=" + getLink(); string param = "name=" + this->_Id + "|url=" + getLink();
CInterfaceManager *im = CInterfaceManager::getInstance();
typedef pair<string, string> TTmplParam; typedef pair<string, string> TTmplParam;
vector<TTmplParam> tmplParams; vector<TTmplParam> tmplParams;
tmplParams.push_back(TTmplParam("id", "")); tmplParams.push_back(TTmplParam("id", ""));
tmplParams.push_back(TTmplParam("onclick", "browse")); tmplParams.push_back(TTmplParam("onclick", "browse"));
tmplParams.push_back(TTmplParam("onclick_param", param)); tmplParams.push_back(TTmplParam("onclick_param", param));
tmplParams.push_back(TTmplParam("active", "true")); tmplParams.push_back(TTmplParam("active", "true"));
CInterfaceGroup *buttonGroup = im->createGroupInstance(buttonTemplate, _Paragraph->getId(), tmplParams); CInterfaceGroup *buttonGroup = CWidgetManager::parser->createGroupInstance(buttonTemplate, _Paragraph->getId(), tmplParams);
if (buttonGroup) if (buttonGroup)
{ {
@ -2632,8 +2594,6 @@ CInterfaceGroup *CGroupHTML::addTextArea(const std::string &templateName, const
// No more text in this text view // No more text in this text view
_CurrentViewLink = NULL; _CurrentViewLink = NULL;
CInterfaceManager *im = CInterfaceManager::getInstance();
if (im)
{ {
// Not added ? // Not added ?
std::vector<std::pair<std::string,std::string> > templateParams; std::vector<std::pair<std::string,std::string> > templateParams;
@ -2645,7 +2605,7 @@ CInterfaceGroup *CGroupHTML::addTextArea(const std::string &templateName, const
templateParams.push_back (std::pair<std::string,std::string> ("want_return", multiLine?"true":"false")); templateParams.push_back (std::pair<std::string,std::string> ("want_return", multiLine?"true":"false"));
templateParams.push_back (std::pair<std::string,std::string> ("enter_recover_focus", "false")); templateParams.push_back (std::pair<std::string,std::string> ("enter_recover_focus", "false"));
templateParams.push_back (std::pair<std::string,std::string> ("max_num_chars", "1024")); templateParams.push_back (std::pair<std::string,std::string> ("max_num_chars", "1024"));
CInterfaceGroup *textArea = im->createGroupInstance (templateName.c_str(), CInterfaceGroup *textArea = CWidgetManager::parser->createGroupInstance (templateName.c_str(),
getParagraph()->getId(), templateParams.empty()?NULL:&(templateParams[0]), (uint)templateParams.size()); getParagraph()->getId(), templateParams.empty()?NULL:&(templateParams[0]), (uint)templateParams.size());
// Group created ? // Group created ?
@ -2679,13 +2639,11 @@ CDBGroupComboBox *CGroupHTML::addComboBox(const std::string &templateName, const
} }
CInterfaceManager *im = CInterfaceManager::getInstance();
if (im)
{ {
// Not added ? // Not added ?
std::vector<std::pair<std::string,std::string> > templateParams; std::vector<std::pair<std::string,std::string> > templateParams;
templateParams.push_back (std::pair<std::string,std::string> ("id", name)); templateParams.push_back (std::pair<std::string,std::string> ("id", name));
CInterfaceGroup *group = im->createGroupInstance (templateName.c_str(), CInterfaceGroup *group = CWidgetManager::parser->createGroupInstance (templateName.c_str(),
getParagraph()->getId(), templateParams.empty()?NULL:&(templateParams[0]), (uint)templateParams.size()); getParagraph()->getId(), templateParams.empty()?NULL:&(templateParams[0]), (uint)templateParams.size());
// Group created ? // Group created ?
@ -2736,7 +2694,6 @@ CCtrlButton *CGroupHTML::addButton(CCtrlButton::EType type, const std::string &/
if(!CPath::exists(normal)) if(!CPath::exists(normal))
{ {
// search in the compressed texture // search in the compressed texture
CInterfaceManager *pIM = CInterfaceManager::getInstance();
CViewRenderer &rVR = *CViewRenderer::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance();
sint32 id = rVR.getTextureIdFromName(normal); sint32 id = rVR.getTextureIdFromName(normal);
if(id == -1) if(id == -1)
@ -2756,7 +2713,6 @@ CCtrlButton *CGroupHTML::addButton(CCtrlButton::EType type, const std::string &/
if(!CPath::exists(pushed)) if(!CPath::exists(pushed))
{ {
// search in the compressed texture // search in the compressed texture
CInterfaceManager *pIM = CInterfaceManager::getInstance();
CViewRenderer &rVR = *CViewRenderer::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance();
sint32 id = rVR.getTextureIdFromName(pushed); sint32 id = rVR.getTextureIdFromName(pushed);
if(id == -1) if(id == -1)
@ -3030,7 +2986,6 @@ bool CGroupHTML::lookupLocalFile (string &result, const char *url, bool isUrl)
else else
{ {
// Is it a texture in the big texture ? // Is it a texture in the big texture ?
CInterfaceManager *pIM = CInterfaceManager::getInstance();
if (CViewRenderer::getInstance()->getTextureIdFromName (result) >= 0) if (CViewRenderer::getInstance()->getTextureIdFromName (result) >= 0)
{ {
return true; return true;
@ -3115,19 +3070,19 @@ static int timer_called = 0;
static int static int
timer_callback(HTTimer * const timer , timer_callback(HTTimer * const timer ,
void * const user_data , void * const user_data ,
HTEventType const event ) HTEventType const event )
{ {
/*---------------------------------------------------------------------------- /*----------------------------------------------------------------------------
A handy timer callback which cancels the running event loop. A handy timer callback which cancels the running event loop.
-----------------------------------------------------------------------------*/ -----------------------------------------------------------------------------*/
nlassert(event == HTEvent_TIMEOUT); nlassert(event == HTEvent_TIMEOUT);
timer_called = 1; timer_called = 1;
HTEventList_stopLoop(); HTEventList_stopLoop();
/* XXX - The meaning of this return value is undocumented, but close /* XXX - The meaning of this return value is undocumented, but close
** inspection of libwww's source suggests that we want to return HT_OK. */ ** inspection of libwww's source suggests that we want to return HT_OK. */
return HT_OK; return HT_OK;
} }
static void handleLibwwwEvents() static void handleLibwwwEvents()
@ -3135,9 +3090,9 @@ static void handleLibwwwEvents()
HTTimer *timer; HTTimer *timer;
timer_called = 0; timer_called = 0;
timer = HTTimer_new(NULL, &timer_callback, NULL, timer = HTTimer_new(NULL, &timer_callback, NULL,
1, YES, NO); 1, YES, NO);
if (!timer_called) if (!timer_called)
HTEventList_newLoop(); HTEventList_newLoop();
HTTimer_delete(timer); HTTimer_delete(timer);
} }
@ -3147,12 +3102,14 @@ void CGroupHTML::handle ()
{ {
H_AUTO(RZ_Interface_Html_handle) H_AUTO(RZ_Interface_Html_handle)
const CWidgetManager::SInterfaceTimes &times = CWidgetManager::getInstance()->getInterfaceTimes();
if (_Connecting) if (_Connecting)
{ {
nlassert (_ConnectingLock == this); nlassert (_ConnectingLock == this);
// Check timeout if needed // Check timeout if needed
if (_TimeoutValue != 0 && _ConnectingTimeout <= TimeInSec) if (_TimeoutValue != 0 && _ConnectingTimeout <= ( times.thisFrameMs / 1000.0f ) )
{ {
browseError(("Connection timeout : "+_URL).c_str()); browseError(("Connection timeout : "+_URL).c_str());
} }
@ -3184,7 +3141,7 @@ void CGroupHTML::handle ()
nlassert (_ConnectingLock == NULL); nlassert (_ConnectingLock == NULL);
_ConnectingLock = this; _ConnectingLock = this;
_Connecting = true; _Connecting = true;
_ConnectingTimeout = TimeInSec + _TimeoutValue; _ConnectingTimeout = ( times.thisFrameMs / 1000.0f ) + _TimeoutValue;
CButtonFreezer freezer; CButtonFreezer freezer;
@ -3238,7 +3195,7 @@ void CGroupHTML::handle ()
// add supported language header // add supported language header
HTList *langs = HTList_new(); HTList *langs = HTList_new();
// set the language code used by the client // set the language code used by the client
HTLanguage_add(langs, ClientCfg.getHtmlLanguageCode().c_str(), 1.0); HTLanguage_add(langs, options.languageCode.c_str(), 1.0);
HTRequest_setLanguage (_LibWWW->Request, langs, 1); HTRequest_setLanguage (_LibWWW->Request, langs, 1);
// get_document(_LibWWW->Request, _LibWWW->Anchor); // get_document(_LibWWW->Request, _LibWWW->Anchor);
@ -3343,7 +3300,7 @@ void CGroupHTML::handle ()
nlassert (_ConnectingLock == NULL); nlassert (_ConnectingLock == NULL);
_ConnectingLock = this; _ConnectingLock = this;
_Connecting = true; _Connecting = true;
_ConnectingTimeout = TimeInSec + _TimeoutValue; _ConnectingTimeout = ( times.thisFrameMs / 1000.0f ) + _TimeoutValue;
CButtonFreezer freezer; CButtonFreezer freezer;
this->visit(&freezer); this->visit(&freezer);
@ -3534,8 +3491,6 @@ const std::string &CGroupHTML::selectTreeNodeRecurs(CGroupTree::SNode *node, con
// *************************************************************************** // ***************************************************************************
bool CGroupHTML::actionLaunchUrlRecurs(const std::string &ah, const std::string &params, const std::string &url) bool CGroupHTML::actionLaunchUrlRecurs(const std::string &ah, const std::string &params, const std::string &url)
{ {
CInterfaceManager *pIM= CInterfaceManager::getInstance();
// check if this action match // check if this action match
if( (ah=="launch_help" || ah=="browse") && IActionHandler::getParam (params, "url") == url) if( (ah=="launch_help" || ah=="browse") && IActionHandler::getParam (params, "url") == url)
{ {
@ -3546,11 +3501,11 @@ bool CGroupHTML::actionLaunchUrlRecurs(const std::string &ah, const std::string
{ {
const std::string &procName= params; const std::string &procName= params;
// look into this proc // look into this proc
uint numActions= pIM->getProcedureNumActions(procName); uint numActions= CWidgetManager::parser->getProcedureNumActions(procName);
for(uint i=0;i<numActions;i++) for(uint i=0;i<numActions;i++)
{ {
string procAh, procParams; string procAh, procParams;
if(pIM->getProcedureAction(procName, i, procAh, procParams)) if( CWidgetManager::parser->getProcedureAction(procName, i, procAh, procParams))
{ {
// recurs proc if needed! // recurs proc if needed!
if (actionLaunchUrlRecurs(procAh, procParams, url)) if (actionLaunchUrlRecurs(procAh, procParams, url))
@ -3633,7 +3588,6 @@ void CGroupHTML::browseRedo()
// *************************************************************************** // ***************************************************************************
void CGroupHTML::updateUndoRedoButtons() void CGroupHTML::updateUndoRedoButtons()
{ {
CInterfaceManager *pIM= CInterfaceManager::getInstance();
CCtrlBaseButton *butUndo= dynamic_cast<CCtrlBaseButton *>(CWidgetManager::getInstance()->getElementFromId(_BrowseUndoButton)); CCtrlBaseButton *butUndo= dynamic_cast<CCtrlBaseButton *>(CWidgetManager::getInstance()->getElementFromId(_BrowseUndoButton));
CCtrlBaseButton *butRedo= dynamic_cast<CCtrlBaseButton *>(CWidgetManager::getInstance()->getElementFromId(_BrowseRedoButton)); CCtrlBaseButton *butRedo= dynamic_cast<CCtrlBaseButton *>(CWidgetManager::getInstance()->getElementFromId(_BrowseRedoButton));
@ -3647,7 +3601,6 @@ void CGroupHTML::updateUndoRedoButtons()
// *************************************************************************** // ***************************************************************************
void CGroupHTML::updateRefreshButton() void CGroupHTML::updateRefreshButton()
{ {
CInterfaceManager *pIM= CInterfaceManager::getInstance();
CCtrlBaseButton *butRefresh = dynamic_cast<CCtrlBaseButton *>(CWidgetManager::getInstance()->getElementFromId(_BrowseRefreshButton)); CCtrlBaseButton *butRefresh = dynamic_cast<CCtrlBaseButton *>(CWidgetManager::getInstance()->getElementFromId(_BrowseRefreshButton));
bool enabled = !_Browsing && !_Connecting; bool enabled = !_Browsing && !_Connecting;
@ -3957,3 +3910,5 @@ ucstring CGroupHTML::decodeHTMLEntities(const ucstring &str)
return result; return result;
} }

@ -14,9 +14,6 @@
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#ifndef CL_GROUP_HTML_H #ifndef CL_GROUP_HTML_H
#define CL_GROUP_HTML_H #define CL_GROUP_HTML_H
@ -47,6 +44,7 @@ namespace NLGUI
class CGroupParagraph; class CGroupParagraph;
// HTML group // HTML group
/** /**
* Widget to have a resizable scrolltext and its scrollbar * Widget to have a resizable scrolltext and its scrollbar
@ -66,7 +64,20 @@ public:
friend void TextEndUnparsedElement(HText *me, const char *buffer, int length); friend void TextEndUnparsedElement(HText *me, const char *buffer, int length);
friend int requestTerminater (HTRequest * request, HTResponse * response, void * param, int status); friend int requestTerminater (HTRequest * request, HTResponse * response, void * param, int status);
struct SWebOptions
{
public:
std::string appName;
std::string appVersion;
std::string languageCode;
std::vector< std::string > trustedDomains;
SWebOptions()
{
}
};
static SWebOptions options;
// Constructor // Constructor
CGroupHTML(const TCtorParam &param); CGroupHTML(const TCtorParam &param);
@ -644,5 +655,4 @@ public:
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
}; };
#endif #endif

@ -15,28 +15,21 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdpch.h"
#include "group_paragraph.h" #include "group_paragraph.h"
#include "group_html.h" #include "group_html.h"
#include "interface_manager.h" #include "nel/gui/widget_manager.h"
#include "nel/gui/interface_element.h" #include "nel/gui/interface_element.h"
#include "../client_chat_manager.h" #include "nel/gui/view_pointer_base.h"
#include "nel/gui/view_bitmap.h" #include "nel/gui/view_bitmap.h"
#include "nel/gui/view_text_id.h" #include "nel/gui/view_text_id.h"
#include "nel/gui/group_container.h" #include "nel/gui/group_container.h"
#include "nel/misc/i_xml.h" #include "nel/misc/i_xml.h"
#include "nel/misc/i18n.h" #include "nel/misc/i18n.h"
#include "nel/misc/xml_auto_ptr.h" #include "nel/misc/xml_auto_ptr.h"
using namespace std; using namespace std;
using namespace NLMISC; using namespace NLMISC;
extern CClientChatManager ChatMngr;
NLMISC_REGISTER_OBJECT(CViewBase, CCtrlLink, std::string, "button_link"); NLMISC_REGISTER_OBJECT(CViewBase, CCtrlLink, std::string, "button_link");
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -737,7 +730,6 @@ void CGroupParagraph::checkCoords ()
sint parentWidth = std::min(_Parent->getMaxWReal(), _Parent->getWReal()); sint parentWidth = std::min(_Parent->getMaxWReal(), _Parent->getWReal());
if (_LastW != (sint) parentWidth) if (_LastW != (sint) parentWidth)
{ {
CInterfaceManager *pIM = CInterfaceManager::getInstance();
CCtrlBase *pCB = CWidgetManager::getInstance()->getCapturePointerLeft(); CCtrlBase *pCB = CWidgetManager::getInstance()->getCapturePointerLeft();
if (pCB != NULL) if (pCB != NULL)
{ {
@ -770,7 +762,6 @@ void CGroupParagraph::draw ()
//rVR.drawRotFlipBitmap _RenderLayer, (_XReal, _YReal, _WReal, _HReal, 0, false, rVR.getBlankTextureId(), CRGBA(0,255,0,255) ); //rVR.drawRotFlipBitmap _RenderLayer, (_XReal, _YReal, _WReal, _HReal, 0, false, rVR.getBlankTextureId(), CRGBA(0,255,0,255) );
if (_Over) if (_Over)
{ {
CInterfaceManager *pIM = CInterfaceManager::getInstance();
CViewRenderer &rVR = *CViewRenderer::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance();
if (CWidgetManager::getInstance()->getModalWindow() == NULL) if (CWidgetManager::getInstance()->getModalWindow() == NULL)
@ -1229,3 +1220,4 @@ sint32 CGroupParagraph::getMinUsedW() const
} }
return minWidth; return minWidth;
} }

@ -238,7 +238,7 @@ protected:
struct CElementInfo struct CElementInfo
{ {
uint Order; // Used to sort the window by their insertion order. uint Order; // Used to sort the window by their insertion order.
// This is used to put back a window at the right place if it was turned into a popup. // This is used to put back a window at the right place if it was turned into a popup.
CViewBase *Element; CViewBase *Element;
bool EltDeleteOnRemove; bool EltDeleteOnRemove;
}; };
@ -292,7 +292,6 @@ private:
}; };
#endif // NL_GROUP_PARAGRAPH_H #endif // NL_GROUP_PARAGRAPH_H
/* End of group_paragraph.h */ /* End of group_paragraph.h */

@ -28,7 +28,7 @@
#include "interface_manager.h" #include "interface_manager.h"
#include "nel/gui/action_handler.h" #include "nel/gui/action_handler.h"
#include "nel/misc/xml_auto_ptr.h" #include "nel/misc/xml_auto_ptr.h"
#include "../actions.h"
#include "../client_cfg.h" #include "../client_cfg.h"
using namespace std; using namespace std;
@ -213,6 +213,8 @@ void CGroupQuickHelp::setGroupTextSize (CInterfaceGroup *group, bool selected)
// *************************************************************************** // ***************************************************************************
extern CActionsContext ActionsContext;
void CGroupQuickHelp::beginElement (uint element_number, const BOOL *present, const char **value) void CGroupQuickHelp::beginElement (uint element_number, const BOOL *present, const char **value)
{ {
CGroupHTML::beginElement (element_number, present, value); CGroupHTML::beginElement (element_number, present, value);
@ -220,6 +222,34 @@ void CGroupQuickHelp::beginElement (uint element_number, const BOOL *present, co
// Paragraph ? // Paragraph ?
switch(element_number) switch(element_number)
{ {
case HTML_A:
// Quick help
if (_TrustedDomain && present[MY_HTML_A_Z_ACTION_SHORTCUT] && value[MY_HTML_A_Z_ACTION_SHORTCUT])
{
// Get the action category
string category;
if (present[MY_HTML_A_Z_ACTION_CATEGORY] && value[MY_HTML_A_Z_ACTION_CATEGORY])
category = value[MY_HTML_A_Z_ACTION_CATEGORY];
// Get the action params
string params;
if (present[MY_HTML_A_Z_ACTION_PARAMS] && value[MY_HTML_A_Z_ACTION_PARAMS])
params = value[MY_HTML_A_Z_ACTION_PARAMS];
// Get the action descriptor
CActionsManager *actionManager = ActionsContext.getActionsManager (category);
if (actionManager)
{
const CActionsManager::TActionComboMap &actionCombo = actionManager->getActionComboMap ();
CActionsManager::TActionComboMap::const_iterator ite = actionCombo.find (CAction::CName (value[MY_HTML_A_Z_ACTION_SHORTCUT], params.c_str()));
if (ite != actionCombo.end())
{
addString (ite->second.toUCString());
}
}
}
break;
case HTML_P: case HTML_P:
// Get the action name // Get the action name
if (present[MY_HTML_P_QUICK_HELP_EVENTS]) if (present[MY_HTML_P_QUICK_HELP_EVENTS])

@ -21,6 +21,8 @@
// Memory // Memory
#include <memory> #include <memory>
#include "game_share/ryzom_version.h"
#include "nel/misc/i_xml.h" #include "nel/misc/i_xml.h"
#include "nel/misc/o_xml.h" #include "nel/misc/o_xml.h"
#include "nel/misc/algo.h" #include "nel/misc/algo.h"
@ -68,6 +70,7 @@
#include "group_in_scene_bubble.h" #include "group_in_scene_bubble.h"
#include "group_skills.h" #include "group_skills.h"
#include "group_compas.h" #include "group_compas.h"
#include "group_html.h"
// Misc // Misc
#include "../input.h" #include "../input.h"
@ -404,6 +407,10 @@ CInterfaceManager::CInterfaceManager( NL3D::UDriver *driver, NL3D::UTextContext
CViewRenderer::getInstance(); CViewRenderer::getInstance();
CViewTextID::setTextProvider( &SMTextProvider ); CViewTextID::setTextProvider( &SMTextProvider );
CViewTextFormated::setFormatter( &RyzomTextFormatter ); CViewTextFormated::setFormatter( &RyzomTextFormatter );
CGroupHTML::options.trustedDomains = ClientCfg.WebIgTrustedDomains;
CGroupHTML::options.languageCode = ClientCfg.getHtmlLanguageCode();
CGroupHTML::options.appName = "Ryzom";
CGroupHTML::options.appVersion = RYZOM_VERSION;
_Instance = this; _Instance = this;
NLGUI::CDBManager::getInstance()->resizeBanks( NB_CDB_BANKS ); NLGUI::CDBManager::getInstance()->resizeBanks( NB_CDB_BANKS );
@ -3403,42 +3410,6 @@ void CInterfaceManager::setProcedureAction(const std::string &procName, uint act
} }
} }
// ------------------------------------------------------------------------------------------------
uint CInterfaceManager::getProcedureNumActions(const std::string &procName) const
{
CstItProcedureMap it= _ProcedureMap.find(procName);
if(it!=_ProcedureMap.end())
{
const CProcedure &proc= it->second;
return (uint)proc.Actions.size();
}
else
return 0;
}
// ------------------------------------------------------------------------------------------------
bool CInterfaceManager::getProcedureAction(const std::string &procName, uint actionIndex, std::string &ah, std::string &params) const
{
CstItProcedureMap it= _ProcedureMap.find(procName);
if(it!=_ProcedureMap.end())
{
const CProcedure &proc= it->second;
if(actionIndex<proc.Actions.size())
{
const CAction &action= proc.Actions[actionIndex];
// if not a variable parametrized Params
if(action.ParamBlocks.size()==1 && action.ParamBlocks[0].NumParam==-1)
{
ah= action.Action;
params= action.ParamBlocks[0].String;
return true;
}
}
}
return false;
}
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
void CInterfaceManager::startAnim (const string &animId) void CInterfaceManager::startAnim (const string &animId)
{ {

@ -271,10 +271,6 @@ public:
void runProcedure(const std::string &procName, CCtrlBase *pCaller, const std::vector<std::string> &paramList); void runProcedure(const std::string &procName, CCtrlBase *pCaller, const std::vector<std::string> &paramList);
// replace an action in a procedure (if possible) // replace an action in a procedure (if possible)
void setProcedureAction(const std::string &procName, uint actionIndex, const std::string &ah, const std::string &params); void setProcedureAction(const std::string &procName, uint actionIndex, const std::string &ah, const std::string &params);
// get info on procedure. return 0 if procedure not found
uint getProcedureNumActions(const std::string &procName) const;
// return false if procedure not found, or if bad action index. return false if has some param variable (@0...)
bool getProcedureAction(const std::string &procName, uint actionIndex, std::string &ah, std::string &params) const;
// Execute a anim // Execute a anim
void startAnim(const std::string &animId); void startAnim(const std::string &animId);
void stopAnim(const std::string &animId); void stopAnim(const std::string &animId);

@ -3432,6 +3432,43 @@ void CInterfaceParser::removeAll()
} }
// ------------------------------------------------------------------------------------------------
uint CInterfaceParser::getProcedureNumActions(const std::string &procName) const
{
CstItProcedureMap it= _ProcedureMap.find(procName);
if(it!=_ProcedureMap.end())
{
const CProcedure &proc= it->second;
return (uint)proc.Actions.size();
}
else
return 0;
}
// ------------------------------------------------------------------------------------------------
bool CInterfaceParser::getProcedureAction(const std::string &procName, uint actionIndex, std::string &ah, std::string &params) const
{
CstItProcedureMap it= _ProcedureMap.find(procName);
if(it!=_ProcedureMap.end())
{
const CProcedure &proc= it->second;
if(actionIndex<proc.Actions.size())
{
const CAction &action= proc.Actions[actionIndex];
// if not a variable parametrized Params
if(action.ParamBlocks.size()==1 && action.ParamBlocks[0].NumParam==-1)
{
ah= action.Action;
params= action.ParamBlocks[0].String;
return true;
}
}
}
return false;
}
// *************************************************************************** // ***************************************************************************
bool CInterfaceParser::parseGeneratorRootContainer(xmlNodePtr cur, xmlNodePtr &rootTreeNode) bool CInterfaceParser::parseGeneratorRootContainer(xmlNodePtr cur, xmlNodePtr &rootTreeNode)
{ {

@ -228,6 +228,12 @@ public:
void removeAll(); void removeAll();
// @} // @}
// get info on procedure. return 0 if procedure not found
uint getProcedureNumActions( const std::string &procName ) const;
// return false if procedure not found, or if bad action index. return false if has some param variable (@0...)
bool getProcedureAction( const std::string &procName, uint actionIndex, std::string &ah, std::string &params ) const;
protected: protected:
/** /**

@ -15,9 +15,6 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdpch.h"
#include <nel/misc/file.h> #include <nel/misc/file.h>
extern "C" extern "C"
@ -40,81 +37,80 @@ extern "C"
using namespace std; using namespace std;
using namespace NLMISC; using namespace NLMISC;
extern "C" extern "C"
{ {
/* Final states have negative value */ /* Final states have negative value */
typedef enum _FileState { typedef enum _FileState {
FS_RETRY = -4, FS_RETRY = -4,
FS_ERROR = -3, FS_ERROR = -3,
FS_NO_DATA = -2, FS_NO_DATA = -2,
FS_GOT_DATA = -1, FS_GOT_DATA = -1,
FS_BEGIN = 0, FS_BEGIN = 0,
FS_PENDING, FS_PENDING,
FS_DO_CN, FS_DO_CN,
FS_NEED_OPEN_FILE, FS_NEED_OPEN_FILE,
FS_NEED_BODY, FS_NEED_BODY,
FS_PARSE_DIR, FS_PARSE_DIR,
FS_TRY_FTP FS_TRY_FTP
} FileState; } FileState;
/* This is the context structure for the this module */ /* This is the context structure for the this module */
typedef struct _file_info { typedef struct _file_info {
FileState state; /* Current state of the connection */ FileState state; /* Current state of the connection */
char * local; /* Local representation of file name */ char * local; /* Local representation of file name */
struct stat stat_info; /* Contains actual file chosen */ struct stat stat_info; /* Contains actual file chosen */
HTNet * net; HTNet * net;
HTTimer * timer; HTTimer * timer;
} file_info; } file_info;
struct _HTStream { struct _HTStream {
const HTStreamClass * isa; const HTStreamClass * isa;
}; };
struct _HTInputStream { struct _HTInputStream {
const HTInputStreamClass * isa; const HTInputStreamClass * isa;
HTChannel * ch; HTChannel * ch;
HTHost * host; HTHost * host;
char * write; /* Last byte written */ char * write; /* Last byte written */
char * read; /* Last byte read */ char * read; /* Last byte read */
int b_read; int b_read;
char data [INPUT_BUFFER_SIZE]; /* buffer */ char data [INPUT_BUFFER_SIZE]; /* buffer */
}; };
PRIVATE int FileCleanup (HTRequest *req, int status) PRIVATE int FileCleanup (HTRequest *req, int status)
{ {
HTNet * net = HTRequest_net(req); HTNet * net = HTRequest_net(req);
file_info * file = (file_info *) HTNet_context(net); file_info * file = (file_info *) HTNet_context(net);
HTStream * input = HTRequest_inputStream(req); HTStream * input = HTRequest_inputStream(req);
/* Free stream with data TO Local file system */ /* Free stream with data TO Local file system */
if (input) if (input)
{ {
if (status == HT_INTERRUPTED) if (status == HT_INTERRUPTED)
(*input->isa->abort)(input, NULL); (*input->isa->abort)(input, NULL);
else else
(*input->isa->_free)(input); (*input->isa->_free)(input);
HTRequest_setInputStream(req, NULL); HTRequest_setInputStream(req, NULL);
} }
/* /*
** Remove if we have registered a timer function as a callback ** Remove if we have registered a timer function as a callback
*/ */
if (file->timer) if (file->timer)
{ {
HTTimer_delete(file->timer); HTTimer_delete(file->timer);
file->timer = NULL; file->timer = NULL;
} }
if (file) if (file)
{ {
HT_FREE(file->local); HT_FREE(file->local);
HT_FREE(file); HT_FREE(file);
} }
HTNet_delete(net, status); HTNet_delete(net, status);
return YES; return YES;
} }
@ -122,104 +118,104 @@ PRIVATE int FileEvent (SOCKET soc, void * pVoid, HTEventType type);
PUBLIC int HTLoadNeLFile (SOCKET soc, HTRequest * request) PUBLIC int HTLoadNeLFile (SOCKET soc, HTRequest * request)
{ {
file_info *file; /* Specific access information */ file_info *file; /* Specific access information */
HTNet * net = HTRequest_net(request); HTNet * net = HTRequest_net(request);
HTParentAnchor * anchor = HTRequest_anchor(request); HTParentAnchor * anchor = HTRequest_anchor(request);
HTTRACE(PROT_TRACE, "HTLoadFile.. Looking for `%s\'\n" _ HTTRACE(PROT_TRACE, "HTLoadFile.. Looking for `%s\'\n" _
HTAnchor_physical(anchor)); HTAnchor_physical(anchor));
if ((file = (file_info *) HT_CALLOC(1, sizeof(file_info))) == NULL) if ((file = (file_info *) HT_CALLOC(1, sizeof(file_info))) == NULL)
HT_OUTOFMEM((char*)"HTLoadFILE"); HT_OUTOFMEM((char*)"HTLoadFILE");
file->state = FS_BEGIN; file->state = FS_BEGIN;
file->net = net; file->net = net;
HTNet_setContext(net, file); HTNet_setContext(net, file);
HTNet_setEventCallback(net, FileEvent); HTNet_setEventCallback(net, FileEvent);
HTNet_setEventParam(net, file); /* callbacks get http* */ HTNet_setEventParam(net, file); /* callbacks get http* */
return FileEvent(soc, file, HTEvent_BEGIN); /* get it started - ops is ignored */ return FileEvent(soc, file, HTEvent_BEGIN); /* get it started - ops is ignored */
} }
PRIVATE int ReturnEvent (HTTimer * timer, void * param, HTEventType /* type */) PRIVATE int ReturnEvent (HTTimer * timer, void * param, HTEventType /* type */)
{ {
file_info * file = (file_info *) param; file_info * file = (file_info *) param;
if (timer != file->timer) if (timer != file->timer)
HTDEBUGBREAK((char*)"File timer %p not in sync\n" _ timer); HTDEBUGBREAK((char*)"File timer %p not in sync\n" _ timer);
HTTRACE(PROT_TRACE, "HTLoadFile.. Continuing %p with timer %p\n" _ file _ timer); HTTRACE(PROT_TRACE, "HTLoadFile.. Continuing %p with timer %p\n" _ file _ timer);
/* /*
** Delete the timer ** Delete the timer
*/ */
HTTimer_delete(file->timer); HTTimer_delete(file->timer);
file->timer = NULL; file->timer = NULL;
/* /*
** Now call the event again ** Now call the event again
*/ */
return FileEvent(INVSOC, file, HTEvent_READ); return FileEvent(INVSOC, file, HTEvent_READ);
} }
PUBLIC int HTNeLFileOpen (HTNet * net, char * local, HTLocalMode /* mode */) PUBLIC int HTNeLFileOpen (HTNet * net, char * local, HTLocalMode /* mode */)
{ {
HTRequest * request = HTNet_request(net); HTRequest * request = HTNet_request(net);
HTHost * host = HTNet_host(net); HTHost * host = HTNet_host(net);
CIFile* fp = new CIFile; CIFile* fp = new CIFile;
if (!fp->open (local)) if (!fp->open (local))
{ {
HTRequest_addSystemError(request, ERR_FATAL, errno, NO, (char*)"CIFile::open"); HTRequest_addSystemError(request, ERR_FATAL, errno, NO, (char*)"CIFile::open");
return HT_ERROR; return HT_ERROR;
} }
HTHost_setChannel(host, HTChannel_new(INVSOC, (FILE*)fp, YES)); HTHost_setChannel(host, HTChannel_new(INVSOC, (FILE*)fp, YES));
HTHost_getInput(host, HTNet_transport(net), NULL, 0); HTHost_getInput(host, HTNet_transport(net), NULL, 0);
HTHost_getOutput(host, HTNet_transport(net), NULL, 0); HTHost_getOutput(host, HTNet_transport(net), NULL, 0);
return HT_OK; return HT_OK;
} }
PRIVATE int FileEvent (SOCKET /* soc */, void * pVoid, HTEventType type) PRIVATE int FileEvent (SOCKET /* soc */, void * pVoid, HTEventType type)
{ {
file_info *file = (file_info *)pVoid; /* Specific access information */ file_info *file = (file_info *)pVoid; /* Specific access information */
int status = HT_ERROR; int status = HT_ERROR;
HTNet * net = file->net; HTNet * net = file->net;
HTRequest * request = HTNet_request(net); HTRequest * request = HTNet_request(net);
HTParentAnchor * anchor = HTRequest_anchor(request); HTParentAnchor * anchor = HTRequest_anchor(request);
if (type == HTEvent_CLOSE) if (type == HTEvent_CLOSE)
{ {
/* Interrupted */ /* Interrupted */
HTRequest_addError(request, ERR_FATAL, NO, HTERR_INTERRUPTED, HTRequest_addError(request, ERR_FATAL, NO, HTERR_INTERRUPTED,
NULL, 0, (char*)"HTLoadFile"); NULL, 0, (char*)"HTLoadFile");
FileCleanup(request, HT_INTERRUPTED); FileCleanup(request, HT_INTERRUPTED);
return HT_OK; return HT_OK;
} }
/* Now jump into the machine. We know the state from the previous run */ /* Now jump into the machine. We know the state from the previous run */
for(;;) for(;;)
{ {
switch (file->state) switch (file->state)
{ {
case FS_BEGIN: case FS_BEGIN:
/* We only support safe (GET, HEAD, etc) methods for the moment */ /* We only support safe (GET, HEAD, etc) methods for the moment */
if (!HTMethod_isSafe(HTRequest_method(request))) { if (!HTMethod_isSafe(HTRequest_method(request))) {
HTRequest_addError(request, ERR_FATAL, NO, HTERR_NOT_ALLOWED, HTRequest_addError(request, ERR_FATAL, NO, HTERR_NOT_ALLOWED,
NULL, 0, (char*)"HTLoadFile"); NULL, 0, (char*)"HTLoadFile");
file->state = FS_ERROR; file->state = FS_ERROR;
break; break;
} }
/* Check whether we have access to local disk at all */ /* Check whether we have access to local disk at all */
if (HTLib_secure()) if (HTLib_secure())
{ {
HTTRACE(PROT_TRACE, "LoadFile.... No access to local file system\n"); HTTRACE(PROT_TRACE, "LoadFile.... No access to local file system\n");
file->state = FS_TRY_FTP; file->state = FS_TRY_FTP;
break; break;
} }
/*file->local = HTWWWToLocal(HTAnchor_physical(anchor), "", /*file->local = HTWWWToLocal(HTAnchor_physical(anchor), "",
HTRequest_userProfile(request));*/ HTRequest_userProfile(request));*/
{ {
string tmp = HTAnchor_physical(anchor); string tmp = HTAnchor_physical(anchor);
if (strlwr(tmp).find("file:/") == 0) if (strlwr(tmp).find("file:/") == 0)
@ -229,70 +225,70 @@ PRIVATE int FileEvent (SOCKET /* soc */, void * pVoid, HTEventType type)
StrAllocCopy(file->local, tmp.c_str()); StrAllocCopy(file->local, tmp.c_str());
} }
if (!file->local) if (!file->local)
{ {
file->state = FS_TRY_FTP; file->state = FS_TRY_FTP;
break; break;
} }
/* Create a new host object and link it to the net object */ /* Create a new host object and link it to the net object */
{ {
HTHost * host = NULL; HTHost * host = NULL;
if ((host = HTHost_new((char*)"localhost", 0)) == NULL) return HT_ERROR; if ((host = HTHost_new((char*)"localhost", 0)) == NULL) return HT_ERROR;
HTNet_setHost(net, host); HTNet_setHost(net, host);
if (HTHost_addNet(host, net) == HT_PENDING) { if (HTHost_addNet(host, net) == HT_PENDING) {
HTTRACE(PROT_TRACE, "HTLoadFile.. Pending...\n"); HTTRACE(PROT_TRACE, "HTLoadFile.. Pending...\n");
/* move to the hack state */ /* move to the hack state */
file->state = FS_PENDING; file->state = FS_PENDING;
return HT_OK; return HT_OK;
} }
} }
file->state = FS_DO_CN; file->state = FS_DO_CN;
break; break;
case FS_PENDING: case FS_PENDING:
{ {
HTHost * host = NULL; HTHost * host = NULL;
if ((host = HTHost_new((char*)"localhost", 0)) == NULL) return HT_ERROR; if ((host = HTHost_new((char*)"localhost", 0)) == NULL) return HT_ERROR;
HTNet_setHost(net, host); HTNet_setHost(net, host);
if (HTHost_addNet(host, net) == HT_PENDING) { if (HTHost_addNet(host, net) == HT_PENDING) {
HTTRACE(PROT_TRACE, "HTLoadFile.. Pending...\n"); HTTRACE(PROT_TRACE, "HTLoadFile.. Pending...\n");
file->state = FS_PENDING; file->state = FS_PENDING;
return HT_OK; return HT_OK;
}
} }
} file->state = FS_DO_CN;
file->state = FS_DO_CN; break;
break;
case FS_DO_CN: case FS_DO_CN:
if (HTRequest_negotiation(request) && if (HTRequest_negotiation(request) &&
HTMethod_isSafe(HTRequest_method(request))) { HTMethod_isSafe(HTRequest_method(request))) {
HTAnchor_setPhysical(anchor, file->local); HTAnchor_setPhysical(anchor, file->local);
HTTRACE(PROT_TRACE, "Load File... Found `%s\'\n" _ file->local); HTTRACE(PROT_TRACE, "Load File... Found `%s\'\n" _ file->local);
} else { } else {
if (HT_STAT(file->local, &file->stat_info) == -1) { if (HT_STAT(file->local, &file->stat_info) == -1) {
HTTRACE(PROT_TRACE, "Load File... Not found `%s\'\n" _ file->local); HTTRACE(PROT_TRACE, "Load File... Not found `%s\'\n" _ file->local);
HTRequest_addError(request, ERR_FATAL, NO, HTERR_NOT_FOUND, HTRequest_addError(request, ERR_FATAL, NO, HTERR_NOT_FOUND,
NULL, 0, (char*)"HTLoadFile"); NULL, 0, (char*)"HTLoadFile");
file->state = FS_ERROR; file->state = FS_ERROR;
break; break;
}
} }
}
if (((file->stat_info.st_mode) & S_IFMT) == S_IFDIR) { if (((file->stat_info.st_mode) & S_IFMT) == S_IFDIR) {
if (HTRequest_method(request) == METHOD_GET) if (HTRequest_method(request) == METHOD_GET)
file->state = FS_PARSE_DIR; file->state = FS_PARSE_DIR;
else { else {
HTRequest_addError(request, ERR_INFO, NO, HTERR_NO_CONTENT, HTRequest_addError(request, ERR_INFO, NO, HTERR_NO_CONTENT,
NULL, 0, (char*)"HTLoadFile"); NULL, 0, (char*)"HTLoadFile");
file->state = FS_NO_DATA; file->state = FS_NO_DATA;
} }
break; break;
} }
{ {
BOOL editable = FALSE; BOOL editable = FALSE;
HTBind_getAnchorBindings(anchor); HTBind_getAnchorBindings(anchor);
if (editable) HTAnchor_appendAllow(anchor, METHOD_PUT); if (editable) HTAnchor_appendAllow(anchor, METHOD_PUT);
@ -306,124 +302,124 @@ PRIVATE int FileEvent (SOCKET /* soc */, void * pVoid, HTEventType type)
nelFile.close(); nelFile.close();
if (file->stat_info.st_size) if (file->stat_info.st_size)
HTAnchor_setLength(anchor, file->stat_info.st_size); HTAnchor_setLength(anchor, file->stat_info.st_size);
/* Set the file last modified time stamp */ /* Set the file last modified time stamp */
if (file->stat_info.st_mtime > 0) if (file->stat_info.st_mtime > 0)
HTAnchor_setLastModified(anchor, file->stat_info.st_mtime); HTAnchor_setLastModified(anchor, file->stat_info.st_mtime);
/* Check to see if we can edit it */ /* Check to see if we can edit it */
if (!editable && !file->stat_info.st_size) { if (!editable && !file->stat_info.st_size) {
HTRequest_addError(request, ERR_INFO, NO, HTERR_NO_CONTENT, HTRequest_addError(request, ERR_INFO, NO, HTERR_NO_CONTENT,
NULL, 0, (char*)"HTLoadFile"); NULL, 0, (char*)"HTLoadFile");
file->state = FS_NO_DATA; file->state = FS_NO_DATA;
} else { } else {
file->state = (HTRequest_method(request)==METHOD_GET) ? file->state = (HTRequest_method(request)==METHOD_GET) ?
FS_NEED_OPEN_FILE : FS_GOT_DATA; FS_NEED_OPEN_FILE : FS_GOT_DATA;
} }
} }
break; break;
case FS_NEED_OPEN_FILE: case FS_NEED_OPEN_FILE:
status = HTNeLFileOpen(net, file->local, HT_FB_RDONLY); status = HTNeLFileOpen(net, file->local, HT_FB_RDONLY);
if (status == HT_OK) { if (status == HT_OK) {
{ {
HTStream * rstream = HTStreamStack(HTAnchor_format(anchor), HTStream * rstream = HTStreamStack(HTAnchor_format(anchor),
HTRequest_outputFormat(request), HTRequest_outputFormat(request),
HTRequest_outputStream(request), HTRequest_outputStream(request),
request, YES); request, YES);
HTNet_setReadStream(net, rstream); HTNet_setReadStream(net, rstream);
HTRequest_setOutputConnected(request, YES); HTRequest_setOutputConnected(request, YES);
} }
{ {
HTOutputStream * output = HTNet_getOutput(net, NULL, 0); HTOutputStream * output = HTNet_getOutput(net, NULL, 0);
HTRequest_setInputStream(request, (HTStream *) output); HTRequest_setInputStream(request, (HTStream *) output);
} }
if (HTRequest_isSource(request) && !HTRequest_destinationsReady(request)) if (HTRequest_isSource(request) && !HTRequest_destinationsReady(request))
return HT_OK; return HT_OK;
HTRequest_addError(request, ERR_INFO, NO, HTERR_OK, NULL, 0, HTRequest_addError(request, ERR_INFO, NO, HTERR_OK, NULL, 0,
(char*)"HTLoadFile"); (char*)"HTLoadFile");
file->state = FS_NEED_BODY; file->state = FS_NEED_BODY;
if (HTEvent_isCallbacksRegistered()) { if (HTEvent_isCallbacksRegistered()) {
if (!HTRequest_preemptive(request)) { if (!HTRequest_preemptive(request)) {
if (!HTNet_preemptive(net)) { if (!HTNet_preemptive(net)) {
HTTRACE(PROT_TRACE, "HTLoadFile.. Returning\n"); HTTRACE(PROT_TRACE, "HTLoadFile.. Returning\n");
HTHost_register(HTNet_host(net), net, HTEvent_READ); HTHost_register(HTNet_host(net), net, HTEvent_READ);
} else if (!file->timer) { } else if (!file->timer) {
HTTRACE(PROT_TRACE, "HTLoadFile.. Returning\n"); HTTRACE(PROT_TRACE, "HTLoadFile.. Returning\n");
file->timer = file->timer =
HTTimer_new(NULL, ReturnEvent, file, 1, YES, NO); HTTimer_new(NULL, ReturnEvent, file, 1, YES, NO);
} }
return HT_OK; return HT_OK;
} }
} }
} else if (status == HT_WOULD_BLOCK || status == HT_PENDING) } else if (status == HT_WOULD_BLOCK || status == HT_PENDING)
return HT_OK; return HT_OK;
else { else {
HTRequest_addError(request, ERR_INFO, NO, HTERR_INTERNAL, HTRequest_addError(request, ERR_INFO, NO, HTERR_INTERNAL,
NULL, 0, (char*)"HTLoadFile"); NULL, 0, (char*)"HTLoadFile");
file->state = FS_ERROR; /* Error or interrupt */ file->state = FS_ERROR; /* Error or interrupt */
} }
break; break;
case FS_NEED_BODY: case FS_NEED_BODY:
status = HTHost_read(HTNet_host(net), net); status = HTHost_read(HTNet_host(net), net);
if (status == HT_WOULD_BLOCK) if (status == HT_WOULD_BLOCK)
return HT_OK; return HT_OK;
else if (status == HT_LOADED || status == HT_CLOSED) { else if (status == HT_LOADED || status == HT_CLOSED) {
file->state = FS_GOT_DATA; file->state = FS_GOT_DATA;
} else { } else {
HTRequest_addError(request, ERR_INFO, NO, HTERR_FORBIDDEN, HTRequest_addError(request, ERR_INFO, NO, HTERR_FORBIDDEN,
NULL, 0, (char*)"HTLoadFile"); NULL, 0, (char*)"HTLoadFile");
file->state = FS_ERROR; file->state = FS_ERROR;
} }
break; break;
case FS_TRY_FTP: case FS_TRY_FTP:
{ {
char *url = HTAnchor_physical(anchor); char *url = HTAnchor_physical(anchor);
HTAnchor *anchor; HTAnchor *anchor;
char *newname = NULL; char *newname = NULL;
StrAllocCopy(newname, "ftp:"); StrAllocCopy(newname, "ftp:");
if (!strncmp(url, "file:", 5)) if (!strncmp(url, "file:", 5))
StrAllocCat(newname, url+5); StrAllocCat(newname, url+5);
else else
StrAllocCat(newname, url); StrAllocCat(newname, url);
anchor = HTAnchor_findAddress(newname); anchor = HTAnchor_findAddress(newname);
HTRequest_setAnchor(request, anchor); HTRequest_setAnchor(request, anchor);
HT_FREE(newname); HT_FREE(newname);
FileCleanup(request, HT_IGNORE); FileCleanup(request, HT_IGNORE);
return HTLoad(request, YES); return HTLoad(request, YES);
} }
break; break;
case FS_GOT_DATA: case FS_GOT_DATA:
FileCleanup(request, HT_LOADED); FileCleanup(request, HT_LOADED);
return HT_OK; return HT_OK;
break; break;
case FS_NO_DATA: case FS_NO_DATA:
FileCleanup(request, HT_NO_DATA); FileCleanup(request, HT_NO_DATA);
return HT_OK; return HT_OK;
break; break;
case FS_RETRY: case FS_RETRY:
FileCleanup(request, HT_RETRY); FileCleanup(request, HT_RETRY);
return HT_OK; return HT_OK;
break; break;
case FS_ERROR: case FS_ERROR:
FileCleanup(request, HT_ERROR); FileCleanup(request, HT_ERROR);
return HT_OK; return HT_OK;
break; break;
default: default:
break; break;
} }
} /* End of while(1) */ } /* End of while(1) */
} }
// ************************************************************************* // *************************************************************************
@ -440,12 +436,12 @@ size_t nel_fread (void *buffer, uint size, FILE *fp)
PRIVATE int HTNeLReader_read (HTInputStream * me) PRIVATE int HTNeLReader_read (HTInputStream * me)
{ {
FILE * fp = HTChannel_file(me->ch); FILE * fp = HTChannel_file(me->ch);
HTNet * net = HTHost_getReadNet(me->host); HTNet * net = HTHost_getReadNet(me->host);
int status; int status;
/* Read the file desriptor */ /* Read the file desriptor */
while (fp) while (fp)
{ {
if ((me->b_read = (int)nel_fread(me->data, FILE_BUFFER_SIZE, fp)) == 0) if ((me->b_read = (int)nel_fread(me->data, FILE_BUFFER_SIZE, fp)) == 0)
{ {
@ -492,9 +488,9 @@ PRIVATE int HTNeLReader_read (HTInputStream * me)
} }
} }
me->write = me->data + me->b_read; me->write = me->data + me->b_read;
} }
HTTRACE(PROT_TRACE, "ANSI read... File descriptor is NULL...\n"); HTTRACE(PROT_TRACE, "ANSI read... File descriptor is NULL...\n");
return HT_ERROR; return HT_ERROR;
} }
PRIVATE int HTNeLReader_close (HTInputStream * me) PRIVATE int HTNeLReader_close (HTInputStream * me)
@ -505,32 +501,32 @@ PRIVATE int HTNeLReader_close (HTInputStream * me)
file->close(); file->close();
} }
int status = HT_OK; int status = HT_OK;
HTNet * net = HTHost_getReadNet(me->host); HTNet * net = HTHost_getReadNet(me->host);
if (net && net->readStream) { if (net && net->readStream) {
if ((status = (*net->readStream->isa->_free)(net->readStream))==HT_WOULD_BLOCK) if ((status = (*net->readStream->isa->_free)(net->readStream))==HT_WOULD_BLOCK)
return HT_WOULD_BLOCK; return HT_WOULD_BLOCK;
net->readStream = NULL; net->readStream = NULL;
} }
HTTRACE(STREAM_TRACE, "Socket read. FREEING....\n"); HTTRACE(STREAM_TRACE, "Socket read. FREEING....\n");
HT_FREE(me); HT_FREE(me);
return status; return status;
} }
PUBLIC int HTNeLReader_consumed (HTInputStream * me, size_t bytes) PUBLIC int HTNeLReader_consumed (HTInputStream * me, size_t bytes)
{ {
me->write += bytes; me->write += bytes;
me->b_read -= (int)bytes; me->b_read -= (int)bytes;
HTHost_setRemainingRead(me->host, me->b_read); HTHost_setRemainingRead(me->host, me->b_read);
return HT_OK; return HT_OK;
} }
PRIVATE int HTNeLReader_flush (HTInputStream * me) PRIVATE int HTNeLReader_flush (HTInputStream * me)
{ {
HTNet * net = HTHost_getReadNet(me->host); HTNet * net = HTHost_getReadNet(me->host);
return net && net->readStream ? (*net->readStream->isa->flush)(net->readStream) : HT_OK; return net && net->readStream ? (*net->readStream->isa->flush)(net->readStream) : HT_OK;
} }
PRIVATE int HTNeLReader_free (HTInputStream * me) PRIVATE int HTNeLReader_free (HTInputStream * me)
@ -542,54 +538,56 @@ PRIVATE int HTNeLReader_free (HTInputStream * me)
HTChannel_setFile (me->ch, NULL); HTChannel_setFile (me->ch, NULL);
} }
HTNet * net = HTHost_getReadNet(me->host); HTNet * net = HTHost_getReadNet(me->host);
if (net && net->readStream) { if (net && net->readStream) {
int status = (*net->readStream->isa->_free)(net->readStream); int status = (*net->readStream->isa->_free)(net->readStream);
if (status == HT_OK) net->readStream = NULL; if (status == HT_OK) net->readStream = NULL;
return status; return status;
} }
return HT_OK; return HT_OK;
} }
PRIVATE int HTNeLReader_abort (HTInputStream * me, HTList * /* e */) PRIVATE int HTNeLReader_abort (HTInputStream * me, HTList * /* e */)
{ {
HTNet * net = HTHost_getReadNet(me->host); HTNet * net = HTHost_getReadNet(me->host);
if (net && net->readStream) { if (net && net->readStream) {
int status = (*net->readStream->isa->abort)(net->readStream, NULL); int status = (*net->readStream->isa->abort)(net->readStream, NULL);
if (status != HT_IGNORE) net->readStream = NULL; if (status != HT_IGNORE) net->readStream = NULL;
} }
return HT_ERROR; return HT_ERROR;
} }
PRIVATE const HTInputStreamClass HTNeLReader = PRIVATE const HTInputStreamClass HTNeLReader =
{ {
(char*)"SocketReader", (char*)"SocketReader",
HTNeLReader_flush, HTNeLReader_flush,
HTNeLReader_free, HTNeLReader_free,
HTNeLReader_abort, HTNeLReader_abort,
HTNeLReader_read, HTNeLReader_read,
HTNeLReader_close, HTNeLReader_close,
HTNeLReader_consumed HTNeLReader_consumed
}; };
PUBLIC HTInputStream * HTNeLReader_new (HTHost * host, HTChannel * ch, PUBLIC HTInputStream * HTNeLReader_new (HTHost * host, HTChannel * ch,
void * /* param */, int /* mode */) void * /* param */, int /* mode */)
{ {
if (host && ch) { if (host && ch) {
HTInputStream * me = HTChannel_input(ch); HTInputStream * me = HTChannel_input(ch);
if (me == NULL) { if (me == NULL) {
if ((me=(HTInputStream *) HT_CALLOC(1, sizeof(HTInputStream))) == NULL) if ((me=(HTInputStream *) HT_CALLOC(1, sizeof(HTInputStream))) == NULL)
HT_OUTOFMEM((char*)"HTNeLReader_new"); HT_OUTOFMEM((char*)"HTNeLReader_new");
me->isa = &HTNeLReader; me->isa = &HTNeLReader;
me->ch = ch; me->ch = ch;
me->host = host; me->host = host;
HTTRACE(STREAM_TRACE, "Reader...... Created reader stream %p\n" _ me); HTTRACE(STREAM_TRACE, "Reader...... Created reader stream %p\n" _ me);
} }
return me; return me;
} }
return NULL; return NULL;
} }
//PUBLIC unsigned int WWW_TraceFlag = 0; //PUBLIC unsigned int WWW_TraceFlag = 0;
} // extern "C" } // extern "C"

@ -23,8 +23,6 @@
#include "HTProt.h" #include "HTProt.h"
extern "C" HTProtCallback HTLoadNeLFile; extern "C" HTProtCallback HTLoadNeLFile;
extern "C" PUBLIC HTInputStream * HTNeLReader_new (HTHost * host, HTChannel * ch, void * param, int mode);
extern "C" PUBLIC HTInputStream * HTNeLReader_new (HTHost * host, HTChannel * ch,
void * param, int mode);
#endif // LIBWWW_NEL_STREAM_H #endif // LIBWWW_NEL_STREAM_H

@ -14,13 +14,8 @@
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdpch.h"
#include "nel/misc/bit_mem_stream.h" #include "nel/misc/bit_mem_stream.h"
#include "nel/misc/i18n.h" #include "nel/misc/i18n.h"
#include "view_link.h" #include "view_link.h"
using namespace std; using namespace std;
@ -62,3 +57,4 @@ bool CViewLink::getMouseOverShape(string &texName, uint8 &rot, CRGBA &col)
// *************************************************************************** // ***************************************************************************

@ -21,6 +21,8 @@
#include "nel/gui/view_text.h" #include "nel/gui/view_text.h"
class CGroupHTML;
/** /**
* class implementing a link view * class implementing a link view
* \author Cyril 'Hulud' Corvazier * \author Cyril 'Hulud' Corvazier
@ -41,7 +43,7 @@ public:
std::string LinkTitle; std::string LinkTitle;
// Set the main group // Set the main group
void setHTMLView(class CGroupHTML *html); void setHTMLView( CGroupHTML *html);
bool getMouseOverShape(std::string &texName, uint8 &rot, NLMISC::CRGBA &col); bool getMouseOverShape(std::string &texName, uint8 &rot, NLMISC::CRGBA &col);
protected: protected:
@ -50,7 +52,6 @@ protected:
CGroupHTML *HTML; CGroupHTML *HTML;
}; };
#endif // NL_VIEW_LINK_H #endif // NL_VIEW_LINK_H
/* End of view_link.h */ /* End of view_link.h */

@ -15,9 +15,6 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdpch.h"
// LibWWW // LibWWW
extern "C" extern "C"
{ {
@ -27,8 +24,6 @@ extern "C"
} }
#include "interface_v3/group_html.h" #include "interface_v3/group_html.h"
#include "game_share/ryzom_version.h"
#include "interface_v3/libwww_nel_stream.h" #include "interface_v3/libwww_nel_stream.h"
using namespace NLMISC; using namespace NLMISC;
@ -45,7 +40,7 @@ std::string HTTPCurrentDomain; // The current domain that will be used to get wh
// The HText structure for libwww // The HText structure for libwww
struct _HText struct _HText
{ {
CGroupHTML *Parent; CGroupHTML *Parent;
}; };
// *************************************************************************** // ***************************************************************************
@ -273,7 +268,7 @@ HText * TextNew (HTRequest * request,
{ {
HText *text = new HText; HText *text = new HText;
text->Parent = (CGroupHTML *) HTRequest_context(request); text->Parent = (CGroupHTML *) HTRequest_context(request);
return text; return text;
} }
// *************************************************************************** // ***************************************************************************
@ -281,7 +276,7 @@ HText * TextNew (HTRequest * request,
BOOL TextDelete (HText * me) BOOL TextDelete (HText * me)
{ {
delete me; delete me;
return YES; return YES;
} }
// *************************************************************************** // ***************************************************************************
@ -437,7 +432,7 @@ int requestTerminater (HTRequest * request, HTResponse * /* response */,
gh->requestTerminated(request); gh->requestTerminated(request);
} }
} }
return HT_OK; return HT_OK;
} }
@ -486,7 +481,7 @@ HTAssocList *sendCookie (HTRequest * /* request */, void * /* param */)
HTAnchor * TextFindAnchor (HText * /* me */, int /* index */) HTAnchor * TextFindAnchor (HText * /* me */, int /* index */)
{ {
return NULL; return NULL;
} }
int HTMIME_location_custom (HTRequest * request, HTResponse * response, char * token, char * value) int HTMIME_location_custom (HTRequest * request, HTResponse * response, char * token, char * value)
@ -544,7 +539,7 @@ void initLibWWW()
static bool initialized = false; static bool initialized = false;
if (!initialized) if (!initialized)
{ {
//HTProfile_newNoCacheClient("Ryzom", "1.1"); //HTProfile_newNoCacheClient("Ryzom", "1.1");
/* Need our own trace and print functions */ /* Need our own trace and print functions */
HTPrint_setCallback(NelPrinter); HTPrint_setCallback(NelPrinter);
@ -552,8 +547,8 @@ void initLibWWW()
/* Initiate libwww */ /* Initiate libwww */
HTLib_setAppName("Ryzom"); HTLib_setAppName( CGroupHTML::options.appName.c_str() );
HTLib_setAppVersion(RYZOM_VERSION); HTLib_setAppVersion( CGroupHTML::options.appVersion.c_str() );
/* Set up TCP as transport */ /* Set up TCP as transport */
VerifyLibWWW("HTTransport_add", HTTransport_add("buffered_tcp", HT_TP_SINGLE, HTReader_new, HTBufferWriter_new)); VerifyLibWWW("HTTransport_add", HTTransport_add("buffered_tcp", HT_TP_SINGLE, HTReader_new, HTBufferWriter_new));
@ -563,7 +558,7 @@ void initLibWWW()
/* Set up HTTP as protocol */ /* Set up HTTP as protocol */
VerifyLibWWW("HTProtocol_add", HTProtocol_add("http", "buffered_tcp", 80, NO, HTLoadHTTP, NULL)); VerifyLibWWW("HTProtocol_add", HTProtocol_add("http", "buffered_tcp", 80, NO, HTLoadHTTP, NULL));
VerifyLibWWW("HTProtocol_add", HTProtocol_add("file", "local", 0, YES, HTLoadNeLFile, NULL)); VerifyLibWWW("HTProtocol_add", HTProtocol_add("file", "local", 0, YES, HTLoadNeLFile, NULL));
//VerifyLibWWW("HTProtocol_add", HTProtocol_add("file", "local", 0, YES, HTLoadFile, NULL)); //VerifyLibWWW("HTProtocol_add", HTProtocol_add("file", "local", 0, YES, HTLoadFile, NULL));
// HTProtocol_add("cache", "local", 0, NO, HTLoadCache, NULL); // HTProtocol_add("cache", "local", 0, NO, HTLoadCache, NULL);
@ -657,8 +652,8 @@ void initLibWWW()
/* Set up default event loop */ /* Set up default event loop */
HTEventInit(); HTEventInit();
/* Add our own request terminate handler */ /* Add our own request terminate handler */
HTNet_addAfter(requestTerminater, NULL, 0, HT_ALL, HT_FILTER_LAST); HTNet_addAfter(requestTerminater, NULL, 0, HT_ALL, HT_FILTER_LAST);
/* Setup cookies */ /* Setup cookies */
HTCookie_init(); HTCookie_init();
@ -670,7 +665,7 @@ void initLibWWW()
/* Go into the event loop... */ /* Go into the event loop... */
// HTEventList_newLoop(); // HTEventList_newLoop();
// App_delete(app); // App_delete(app);
HTBind_add("htm", "text/html", NULL, "8bit", NULL, 1.0); /* HTML */ HTBind_add("htm", "text/html", NULL, "8bit", NULL, 1.0); /* HTML */
HTBind_add("html", "text/html", NULL, "8bit", NULL, 1.0); /* HTML */ HTBind_add("html", "text/html", NULL, "8bit", NULL, 1.0); /* HTML */

Loading…
Cancel
Save