From 7f2768fcae3454542ff442df6120bf90ebf91bf9 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sat, 30 Jun 2012 05:58:02 +0200 Subject: [PATCH] CHANGED: #1471 Decoupled CGroupHTML, CGroupParagraph, CViewLink from Ryzom game related code. --- code/nel/include/nel/gui/lua_manager.h | 2 + code/nel/include/nel/gui/widget_manager.h | 2 + code/nel/src/gui/lua_manager.cpp | 16 + .../client/src/interface_v3/group_html.cpp | 125 ++--- .../client/src/interface_v3/group_html.h | 18 +- .../src/interface_v3/group_paragraph.cpp | 14 +- .../client/src/interface_v3/group_paragraph.h | 3 +- .../src/interface_v3/group_quick_help.cpp | 32 +- .../src/interface_v3/interface_manager.cpp | 43 +- .../src/interface_v3/interface_manager.h | 4 - .../src/interface_v3/interface_parser.cpp | 37 ++ .../src/interface_v3/interface_parser.h | 6 + .../src/interface_v3/libwww_nel_stream.cpp | 464 +++++++++--------- .../src/interface_v3/libwww_nel_stream.h | 4 +- .../client/src/interface_v3/view_link.cpp | 6 +- .../ryzom/client/src/interface_v3/view_link.h | 5 +- code/ryzom/client/src/libwww.cpp | 29 +- 17 files changed, 407 insertions(+), 403 deletions(-) diff --git a/code/nel/include/nel/gui/lua_manager.h b/code/nel/include/nel/gui/lua_manager.h index def6ab472..1e6868f57 100644 --- a/code/nel/include/nel/gui/lua_manager.h +++ b/code/nel/include/nel/gui/lua_manager.h @@ -43,6 +43,8 @@ namespace NLGUI NLGUI::CLuaState* getLuaState() const{ return luaState; } + bool executeLuaScript( const std::string &luaScript, bool smallScript = false ); + private: CLuaManager(); diff --git a/code/nel/include/nel/gui/widget_manager.h b/code/nel/include/nel/gui/widget_manager.h index df5fd5540..19df9375b 100644 --- a/code/nel/include/nel/gui/widget_manager.h +++ b/code/nel/include/nel/gui/widget_manager.h @@ -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, std::vector< std::pair< std::string, std::string > > &templateParams, bool updateLinks = true ) = 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 ¶ms ) const = 0; }; /// Manages the GUI widgets diff --git a/code/nel/src/gui/lua_manager.cpp b/code/nel/src/gui/lua_manager.cpp index 5e9ef7761..4307db15d 100644 --- a/code/nel/src/gui/lua_manager.cpp +++ b/code/nel/src/gui/lua_manager.cpp @@ -34,6 +34,22 @@ namespace NLGUI 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; + } } diff --git a/code/ryzom/client/src/interface_v3/group_html.cpp b/code/ryzom/client/src/interface_v3/group_html.cpp index bb90cef39..b1bfdfe80 100644 --- a/code/ryzom/client/src/interface_v3/group_html.cpp +++ b/code/ryzom/client/src/interface_v3/group_html.cpp @@ -14,8 +14,6 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . -#include "stdpch.h" - //#include // LibWWW @@ -27,25 +25,21 @@ extern "C" } #include "../libwww.h" - #include "group_html.h" #include "nel/gui/group_list.h" #include "nel/gui/group_container.h" #include "view_link.h" #include "nel/gui/ctrl_scroll.h" #include "nel/gui/ctrl_button.h" -#include "dbctrl_sheet.h" #include "nel/gui/ctrl_text_button.h" #include "nel/gui/action_handler.h" #include "group_paragraph.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 "../actions.h" #include "nel/gui/dbgroup_combo_box.h" #include "nel/gui/lua_ihm.h" - -#include "../time_client.h" #include "nel/misc/i18n.h" #include "nel/misc/md5.h" #include "nel/3d/texture_file.h" @@ -62,14 +56,15 @@ using namespace NLMISC; //#define LOG_DL 1 CGroupHTML *CGroupHTML::_ConnectingLock = NULL; -extern CActionsContext ActionsContext; +CGroupHTML::SWebOptions CGroupHTML::options; + // Check if domain is on TrustedDomain bool CGroupHTML::isTrustedDomain(const string &domain) { vector::iterator it; - it = find (ClientCfg.WebIgTrustedDomains.begin(), ClientCfg.WebIgTrustedDomains.end(), domain); - return it != ClientCfg.WebIgTrustedDomains.end(); + it = find ( options.trustedDomains.begin(), options.trustedDomains.end(), domain); + return it != options.trustedDomains.end(); } void CGroupHTML::setImage(CViewBase * view, const string &file) @@ -361,8 +356,7 @@ void CGroupHTML::checkDownloads() CFile::moveFile(file.c_str(), (file+".tmp").c_str()); if (lookupLocalFile (finalUrl, file.c_str(), false)) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->executeLuaScript(it->luaScript, true); + CLuaManager::getInstance().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]) _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; + case HTML_DIV: { 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 parentId = _Paragraph->getId(); - CInterfaceManager *im = CInterfaceManager::getInstance(); - CInterfaceGroup *inst = im->createGroupInstance(templateName, parentId+":"+id, tmplParams); + CInterfaceGroup *inst = CWidgetManager::parser->createGroupInstance(templateName, parentId+":"+id, tmplParams); if (inst) { inst->setId(parentId+":"+id); @@ -1272,7 +1240,6 @@ void CGroupHTML::beginElement (uint element_number, const BOOL *present, const c paragraphChange (); } - CInterfaceManager *im = CInterfaceManager::getInstance(); typedef pair TTmplParam; vector tmplParams; 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")); if (!minWidth.empty()) 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) { @@ -1776,8 +1743,7 @@ void CGroupHTML::endElement (uint element_number) { if (addBnpDownload(_ObjectData, _ObjectAction, _ObjectScript, _ObjectMD5Sum)) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); - pIM->executeLuaScript("\nlocal __ALLREADYDL__=true\n"+_ObjectScript, true); + CLuaManager::getInstance().executeLuaScript("\nlocal __ALLREADYDL__=true\n"+_ObjectScript, true); } _ObjectScript = ""; } @@ -1811,9 +1777,8 @@ void CGroupHTML::endUnparsedElement(const char *buffer, int length) { _ParsingLua = false; // execute the embeded lua script - CInterfaceManager *pIM = CInterfaceManager::getInstance(); _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 stopBrowse (); // NB : we don't call updateRefreshButton here, because : // 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 - // this is why the call to 'updateRefreshButton' has been removed from stopBrowse + // 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 clearContext(); 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(!_BrowseTree.empty()) { - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - CGroupTree *groupTree=dynamic_cast(CWidgetManager::getInstance()->getElementFromId(_BrowseTree)); if(groupTree) { @@ -2315,7 +2278,7 @@ bool CGroupHTML::translateChar(ucchar &output, ucchar input, ucchar lastCharPara if (lastChar == 0) lastChar = getLastChar(); keep = ((lastChar != (ucchar)' ') && - (lastChar != 0)) || getPRE() || (_CurrentViewImage && (lastChar == 0)); + (lastChar != 0)) || getPRE() || (_CurrentViewImage && (lastChar == 0)); if(!getPRE()) input = ' '; } @@ -2327,8 +2290,8 @@ bool CGroupHTML::translateChar(ucchar &output, ucchar input, ucchar lastCharPara if (lastChar == 0) lastChar = getLastChar(); keep = ((lastChar != (ucchar)' ') && - (lastChar != (ucchar)'\n') && - (lastChar != 0)) || getPRE() || (_CurrentViewImage && (lastChar == 0)); + (lastChar != (ucchar)'\n') && + (lastChar != 0)) || getPRE() || (_CurrentViewImage && (lastChar == 0)); } break; 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" string param = "name=" + this->_Id + "|url=" + getLink(); - CInterfaceManager *im = CInterfaceManager::getInstance(); typedef pair TTmplParam; vector tmplParams; tmplParams.push_back(TTmplParam("id", "")); tmplParams.push_back(TTmplParam("onclick", "browse")); tmplParams.push_back(TTmplParam("onclick_param", param)); 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) { @@ -2632,8 +2594,6 @@ CInterfaceGroup *CGroupHTML::addTextArea(const std::string &templateName, const // No more text in this text view _CurrentViewLink = NULL; - CInterfaceManager *im = CInterfaceManager::getInstance(); - if (im) { // Not added ? std::vector > templateParams; @@ -2645,7 +2605,7 @@ CInterfaceGroup *CGroupHTML::addTextArea(const std::string &templateName, const templateParams.push_back (std::pair ("want_return", multiLine?"true":"false")); templateParams.push_back (std::pair ("enter_recover_focus", "false")); templateParams.push_back (std::pair ("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()); // Group created ? @@ -2679,13 +2639,11 @@ CDBGroupComboBox *CGroupHTML::addComboBox(const std::string &templateName, const } - CInterfaceManager *im = CInterfaceManager::getInstance(); - if (im) { // Not added ? std::vector > templateParams; templateParams.push_back (std::pair ("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()); // Group created ? @@ -2736,7 +2694,6 @@ CCtrlButton *CGroupHTML::addButton(CCtrlButton::EType type, const std::string &/ if(!CPath::exists(normal)) { // search in the compressed texture - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); sint32 id = rVR.getTextureIdFromName(normal); if(id == -1) @@ -2756,7 +2713,6 @@ CCtrlButton *CGroupHTML::addButton(CCtrlButton::EType type, const std::string &/ if(!CPath::exists(pushed)) { // search in the compressed texture - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); sint32 id = rVR.getTextureIdFromName(pushed); if(id == -1) @@ -3030,7 +2986,6 @@ bool CGroupHTML::lookupLocalFile (string &result, const char *url, bool isUrl) else { // Is it a texture in the big texture ? - CInterfaceManager *pIM = CInterfaceManager::getInstance(); if (CViewRenderer::getInstance()->getTextureIdFromName (result) >= 0) { return true; @@ -3115,19 +3070,19 @@ static int timer_called = 0; static int timer_callback(HTTimer * const timer , - void * const user_data , - HTEventType const event ) + void * const user_data , + HTEventType const event ) { /*---------------------------------------------------------------------------- A handy timer callback which cancels the running event loop. -----------------------------------------------------------------------------*/ - nlassert(event == HTEvent_TIMEOUT); - timer_called = 1; - HTEventList_stopLoop(); + nlassert(event == HTEvent_TIMEOUT); + timer_called = 1; + HTEventList_stopLoop(); - /* XXX - The meaning of this return value is undocumented, but close - ** inspection of libwww's source suggests that we want to return HT_OK. */ - return HT_OK; + /* XXX - The meaning of this return value is undocumented, but close + ** inspection of libwww's source suggests that we want to return HT_OK. */ + return HT_OK; } static void handleLibwwwEvents() @@ -3135,9 +3090,9 @@ static void handleLibwwwEvents() HTTimer *timer; timer_called = 0; timer = HTTimer_new(NULL, &timer_callback, NULL, - 1, YES, NO); + 1, YES, NO); if (!timer_called) - HTEventList_newLoop(); + HTEventList_newLoop(); HTTimer_delete(timer); } @@ -3147,12 +3102,14 @@ void CGroupHTML::handle () { H_AUTO(RZ_Interface_Html_handle) + const CWidgetManager::SInterfaceTimes × = CWidgetManager::getInstance()->getInterfaceTimes(); + if (_Connecting) { nlassert (_ConnectingLock == this); // Check timeout if needed - if (_TimeoutValue != 0 && _ConnectingTimeout <= TimeInSec) + if (_TimeoutValue != 0 && _ConnectingTimeout <= ( times.thisFrameMs / 1000.0f ) ) { browseError(("Connection timeout : "+_URL).c_str()); } @@ -3184,7 +3141,7 @@ void CGroupHTML::handle () nlassert (_ConnectingLock == NULL); _ConnectingLock = this; _Connecting = true; - _ConnectingTimeout = TimeInSec + _TimeoutValue; + _ConnectingTimeout = ( times.thisFrameMs / 1000.0f ) + _TimeoutValue; CButtonFreezer freezer; @@ -3238,7 +3195,7 @@ void CGroupHTML::handle () // add supported language header HTList *langs = HTList_new(); // 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); // get_document(_LibWWW->Request, _LibWWW->Anchor); @@ -3343,7 +3300,7 @@ void CGroupHTML::handle () nlassert (_ConnectingLock == NULL); _ConnectingLock = this; _Connecting = true; - _ConnectingTimeout = TimeInSec + _TimeoutValue; + _ConnectingTimeout = ( times.thisFrameMs / 1000.0f ) + _TimeoutValue; CButtonFreezer 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 ¶ms, const std::string &url) { - CInterfaceManager *pIM= CInterfaceManager::getInstance(); - // check if this action match 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; // look into this proc - uint numActions= pIM->getProcedureNumActions(procName); + uint numActions= CWidgetManager::parser->getProcedureNumActions(procName); for(uint i=0;igetProcedureAction(procName, i, procAh, procParams)) + if( CWidgetManager::parser->getProcedureAction(procName, i, procAh, procParams)) { // recurs proc if needed! if (actionLaunchUrlRecurs(procAh, procParams, url)) @@ -3633,7 +3588,6 @@ void CGroupHTML::browseRedo() // *************************************************************************** void CGroupHTML::updateUndoRedoButtons() { - CInterfaceManager *pIM= CInterfaceManager::getInstance(); CCtrlBaseButton *butUndo= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(_BrowseUndoButton)); CCtrlBaseButton *butRedo= dynamic_cast(CWidgetManager::getInstance()->getElementFromId(_BrowseRedoButton)); @@ -3647,7 +3601,6 @@ void CGroupHTML::updateUndoRedoButtons() // *************************************************************************** void CGroupHTML::updateRefreshButton() { - CInterfaceManager *pIM= CInterfaceManager::getInstance(); CCtrlBaseButton *butRefresh = dynamic_cast(CWidgetManager::getInstance()->getElementFromId(_BrowseRefreshButton)); bool enabled = !_Browsing && !_Connecting; @@ -3957,3 +3910,5 @@ ucstring CGroupHTML::decodeHTMLEntities(const ucstring &str) return result; } + + diff --git a/code/ryzom/client/src/interface_v3/group_html.h b/code/ryzom/client/src/interface_v3/group_html.h index d5c30cf1f..fa39debf7 100644 --- a/code/ryzom/client/src/interface_v3/group_html.h +++ b/code/ryzom/client/src/interface_v3/group_html.h @@ -14,9 +14,6 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . - - - #ifndef CL_GROUP_HTML_H #define CL_GROUP_HTML_H @@ -47,6 +44,7 @@ namespace NLGUI class CGroupParagraph; + // HTML group /** * 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 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 CGroupHTML(const TCtorParam ¶m); @@ -644,5 +655,4 @@ public: virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup); }; - #endif diff --git a/code/ryzom/client/src/interface_v3/group_paragraph.cpp b/code/ryzom/client/src/interface_v3/group_paragraph.cpp index f789e4738..0ad38ec64 100644 --- a/code/ryzom/client/src/interface_v3/group_paragraph.cpp +++ b/code/ryzom/client/src/interface_v3/group_paragraph.cpp @@ -15,28 +15,21 @@ // along with this program. If not, see . - -#include "stdpch.h" - #include "group_paragraph.h" #include "group_html.h" -#include "interface_manager.h" +#include "nel/gui/widget_manager.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_text_id.h" #include "nel/gui/group_container.h" - #include "nel/misc/i_xml.h" #include "nel/misc/i18n.h" - #include "nel/misc/xml_auto_ptr.h" using namespace std; using namespace NLMISC; -extern CClientChatManager ChatMngr; - NLMISC_REGISTER_OBJECT(CViewBase, CCtrlLink, std::string, "button_link"); // ---------------------------------------------------------------------------- @@ -737,7 +730,6 @@ void CGroupParagraph::checkCoords () sint parentWidth = std::min(_Parent->getMaxWReal(), _Parent->getWReal()); if (_LastW != (sint) parentWidth) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CCtrlBase *pCB = CWidgetManager::getInstance()->getCapturePointerLeft(); 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) ); if (_Over) { - CInterfaceManager *pIM = CInterfaceManager::getInstance(); CViewRenderer &rVR = *CViewRenderer::getInstance(); if (CWidgetManager::getInstance()->getModalWindow() == NULL) @@ -1229,3 +1220,4 @@ sint32 CGroupParagraph::getMinUsedW() const } return minWidth; } + diff --git a/code/ryzom/client/src/interface_v3/group_paragraph.h b/code/ryzom/client/src/interface_v3/group_paragraph.h index 1366e21a2..ce13eb6c3 100644 --- a/code/ryzom/client/src/interface_v3/group_paragraph.h +++ b/code/ryzom/client/src/interface_v3/group_paragraph.h @@ -238,7 +238,7 @@ protected: struct CElementInfo { 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; bool EltDeleteOnRemove; }; @@ -292,7 +292,6 @@ private: }; - #endif // NL_GROUP_PARAGRAPH_H /* End of group_paragraph.h */ diff --git a/code/ryzom/client/src/interface_v3/group_quick_help.cpp b/code/ryzom/client/src/interface_v3/group_quick_help.cpp index 1419a203a..d67cbeb5d 100644 --- a/code/ryzom/client/src/interface_v3/group_quick_help.cpp +++ b/code/ryzom/client/src/interface_v3/group_quick_help.cpp @@ -28,7 +28,7 @@ #include "interface_manager.h" #include "nel/gui/action_handler.h" #include "nel/misc/xml_auto_ptr.h" - +#include "../actions.h" #include "../client_cfg.h" 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) { CGroupHTML::beginElement (element_number, present, value); @@ -220,6 +222,34 @@ void CGroupQuickHelp::beginElement (uint element_number, const BOOL *present, co // Paragraph ? 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: // Get the action name if (present[MY_HTML_P_QUICK_HELP_EVENTS]) diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index a3d87f447..b0308b5db 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -21,6 +21,8 @@ // Memory #include +#include "game_share/ryzom_version.h" + #include "nel/misc/i_xml.h" #include "nel/misc/o_xml.h" #include "nel/misc/algo.h" @@ -68,6 +70,7 @@ #include "group_in_scene_bubble.h" #include "group_skills.h" #include "group_compas.h" +#include "group_html.h" // Misc #include "../input.h" @@ -404,6 +407,10 @@ CInterfaceManager::CInterfaceManager( NL3D::UDriver *driver, NL3D::UTextContext CViewRenderer::getInstance(); CViewTextID::setTextProvider( &SMTextProvider ); CViewTextFormated::setFormatter( &RyzomTextFormatter ); + CGroupHTML::options.trustedDomains = ClientCfg.WebIgTrustedDomains; + CGroupHTML::options.languageCode = ClientCfg.getHtmlLanguageCode(); + CGroupHTML::options.appName = "Ryzom"; + CGroupHTML::options.appVersion = RYZOM_VERSION; _Instance = this; 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 ¶ms) const -{ - CstItProcedureMap it= _ProcedureMap.find(procName); - if(it!=_ProcedureMap.end()) - { - const CProcedure &proc= it->second; - if(actionIndex ¶mList); // replace an action in a procedure (if possible) void setProcedureAction(const std::string &procName, uint actionIndex, const std::string &ah, const std::string ¶ms); - // 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 ¶ms) const; // Execute a anim void startAnim(const std::string &animId); void stopAnim(const std::string &animId); diff --git a/code/ryzom/client/src/interface_v3/interface_parser.cpp b/code/ryzom/client/src/interface_v3/interface_parser.cpp index 440225f03..b2ffddf3f 100644 --- a/code/ryzom/client/src/interface_v3/interface_parser.cpp +++ b/code/ryzom/client/src/interface_v3/interface_parser.cpp @@ -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 ¶ms) const +{ + CstItProcedureMap it= _ProcedureMap.find(procName); + if(it!=_ProcedureMap.end()) + { + const CProcedure &proc= it->second; + if(actionIndex. - -#include "stdpch.h" - #include extern "C" @@ -40,81 +37,80 @@ extern "C" using namespace std; using namespace NLMISC; - extern "C" { /* Final states have negative value */ typedef enum _FileState { - FS_RETRY = -4, - FS_ERROR = -3, - FS_NO_DATA = -2, - FS_GOT_DATA = -1, - FS_BEGIN = 0, - FS_PENDING, - FS_DO_CN, - FS_NEED_OPEN_FILE, - FS_NEED_BODY, - FS_PARSE_DIR, - FS_TRY_FTP + FS_RETRY = -4, + FS_ERROR = -3, + FS_NO_DATA = -2, + FS_GOT_DATA = -1, + FS_BEGIN = 0, + FS_PENDING, + FS_DO_CN, + FS_NEED_OPEN_FILE, + FS_NEED_BODY, + FS_PARSE_DIR, + FS_TRY_FTP } FileState; /* This is the context structure for the this module */ typedef struct _file_info { - FileState state; /* Current state of the connection */ - char * local; /* Local representation of file name */ - struct stat stat_info; /* Contains actual file chosen */ - HTNet * net; - HTTimer * timer; + FileState state; /* Current state of the connection */ + char * local; /* Local representation of file name */ + struct stat stat_info; /* Contains actual file chosen */ + HTNet * net; + HTTimer * timer; } file_info; struct _HTStream { - const HTStreamClass * isa; + const HTStreamClass * isa; }; struct _HTInputStream { - const HTInputStreamClass * isa; - HTChannel * ch; - HTHost * host; - char * write; /* Last byte written */ - char * read; /* Last byte read */ - int b_read; - char data [INPUT_BUFFER_SIZE]; /* buffer */ + const HTInputStreamClass * isa; + HTChannel * ch; + HTHost * host; + char * write; /* Last byte written */ + char * read; /* Last byte read */ + int b_read; + char data [INPUT_BUFFER_SIZE]; /* buffer */ }; PRIVATE int FileCleanup (HTRequest *req, int status) { - HTNet * net = HTRequest_net(req); - file_info * file = (file_info *) HTNet_context(net); - HTStream * input = HTRequest_inputStream(req); + HTNet * net = HTRequest_net(req); + file_info * file = (file_info *) HTNet_context(net); + HTStream * input = HTRequest_inputStream(req); - /* Free stream with data TO Local file system */ - if (input) + /* Free stream with data TO Local file system */ + if (input) { - if (status == HT_INTERRUPTED) - (*input->isa->abort)(input, NULL); - else - (*input->isa->_free)(input); - HTRequest_setInputStream(req, NULL); - } + if (status == HT_INTERRUPTED) + (*input->isa->abort)(input, NULL); + else + (*input->isa->_free)(input); + HTRequest_setInputStream(req, NULL); + } - /* - ** Remove if we have registered a timer function as a callback - */ - if (file->timer) + /* + ** Remove if we have registered a timer function as a callback + */ + if (file->timer) { HTTimer_delete(file->timer); file->timer = NULL; - } + } - if (file) + if (file) { HT_FREE(file->local); HT_FREE(file); - } + } 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) { - file_info *file; /* Specific access information */ - HTNet * net = HTRequest_net(request); - HTParentAnchor * anchor = HTRequest_anchor(request); + file_info *file; /* Specific access information */ + HTNet * net = HTRequest_net(request); + HTParentAnchor * anchor = HTRequest_anchor(request); - HTTRACE(PROT_TRACE, "HTLoadFile.. Looking for `%s\'\n" _ - HTAnchor_physical(anchor)); - if ((file = (file_info *) HT_CALLOC(1, sizeof(file_info))) == NULL) + HTTRACE(PROT_TRACE, "HTLoadFile.. Looking for `%s\'\n" _ + HTAnchor_physical(anchor)); + if ((file = (file_info *) HT_CALLOC(1, sizeof(file_info))) == NULL) HT_OUTOFMEM((char*)"HTLoadFILE"); - file->state = FS_BEGIN; - file->net = net; - HTNet_setContext(net, file); - HTNet_setEventCallback(net, FileEvent); - HTNet_setEventParam(net, file); /* callbacks get http* */ + file->state = FS_BEGIN; + file->net = net; + HTNet_setContext(net, file); + HTNet_setEventCallback(net, FileEvent); + 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 */) { - file_info * file = (file_info *) param; - if (timer != file->timer) + file_info * file = (file_info *) param; + if (timer != file->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 - */ - HTTimer_delete(file->timer); - file->timer = NULL; + /* + ** Delete the timer + */ + HTTimer_delete(file->timer); + file->timer = NULL; - /* - ** Now call the event again - */ - return FileEvent(INVSOC, file, HTEvent_READ); + /* + ** Now call the event again + */ + return FileEvent(INVSOC, file, HTEvent_READ); } PUBLIC int HTNeLFileOpen (HTNet * net, char * local, HTLocalMode /* mode */) { - HTRequest * request = HTNet_request(net); - HTHost * host = HTNet_host(net); - CIFile* fp = new CIFile; + HTRequest * request = HTNet_request(net); + HTHost * host = HTNet_host(net); + CIFile* fp = new CIFile; - if (!fp->open (local)) + if (!fp->open (local)) { - HTRequest_addSystemError(request, ERR_FATAL, errno, NO, (char*)"CIFile::open"); - return HT_ERROR; - } + HTRequest_addSystemError(request, ERR_FATAL, errno, NO, (char*)"CIFile::open"); + 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_getOutput(host, HTNet_transport(net), NULL, 0); - return HT_OK; + HTHost_getInput(host, HTNet_transport(net), NULL, 0); + HTHost_getOutput(host, HTNet_transport(net), NULL, 0); + return HT_OK; } PRIVATE int FileEvent (SOCKET /* soc */, void * pVoid, HTEventType type) { - file_info *file = (file_info *)pVoid; /* Specific access information */ - int status = HT_ERROR; - HTNet * net = file->net; - HTRequest * request = HTNet_request(net); - HTParentAnchor * anchor = HTRequest_anchor(request); + file_info *file = (file_info *)pVoid; /* Specific access information */ + int status = HT_ERROR; + HTNet * net = file->net; + HTRequest * request = HTNet_request(net); + HTParentAnchor * anchor = HTRequest_anchor(request); - if (type == HTEvent_CLOSE) + if (type == HTEvent_CLOSE) { /* Interrupted */ HTRequest_addError(request, ERR_FATAL, NO, HTERR_INTERRUPTED, NULL, 0, (char*)"HTLoadFile"); FileCleanup(request, HT_INTERRUPTED); return HT_OK; - } + } - /* Now jump into the machine. We know the state from the previous run */ - for(;;) + /* Now jump into the machine. We know the state from the previous run */ + for(;;) { switch (file->state) { case FS_BEGIN: - /* We only support safe (GET, HEAD, etc) methods for the moment */ - if (!HTMethod_isSafe(HTRequest_method(request))) { + /* We only support safe (GET, HEAD, etc) methods for the moment */ + if (!HTMethod_isSafe(HTRequest_method(request))) { HTRequest_addError(request, ERR_FATAL, NO, HTERR_NOT_ALLOWED, NULL, 0, (char*)"HTLoadFile"); file->state = FS_ERROR; break; - } + } - /* Check whether we have access to local disk at all */ - if (HTLib_secure()) + /* Check whether we have access to local disk at all */ + if (HTLib_secure()) { HTTRACE(PROT_TRACE, "LoadFile.... No access to local file system\n"); file->state = FS_TRY_FTP; break; - } + } /*file->local = HTWWWToLocal(HTAnchor_physical(anchor), "", - HTRequest_userProfile(request));*/ + HTRequest_userProfile(request));*/ { string tmp = HTAnchor_physical(anchor); 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()); } - if (!file->local) + if (!file->local) { file->state = FS_TRY_FTP; 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; if ((host = HTHost_new((char*)"localhost", 0)) == NULL) return HT_ERROR; HTNet_setHost(net, host); if (HTHost_addNet(host, net) == HT_PENDING) { - HTTRACE(PROT_TRACE, "HTLoadFile.. Pending...\n"); - /* move to the hack state */ - file->state = FS_PENDING; - return HT_OK; + HTTRACE(PROT_TRACE, "HTLoadFile.. Pending...\n"); + /* move to the hack state */ + file->state = FS_PENDING; + return HT_OK; } - } - file->state = FS_DO_CN; - break; + } + file->state = FS_DO_CN; + break; case FS_PENDING: - { + { HTHost * host = NULL; if ((host = HTHost_new((char*)"localhost", 0)) == NULL) return HT_ERROR; HTNet_setHost(net, host); if (HTHost_addNet(host, net) == HT_PENDING) { - HTTRACE(PROT_TRACE, "HTLoadFile.. Pending...\n"); - file->state = FS_PENDING; - return HT_OK; + HTTRACE(PROT_TRACE, "HTLoadFile.. Pending...\n"); + file->state = FS_PENDING; + return HT_OK; } - } - file->state = FS_DO_CN; - break; + } + file->state = FS_DO_CN; + break; case FS_DO_CN: - if (HTRequest_negotiation(request) && + if (HTRequest_negotiation(request) && HTMethod_isSafe(HTRequest_method(request))) { HTAnchor_setPhysical(anchor, file->local); HTTRACE(PROT_TRACE, "Load File... Found `%s\'\n" _ file->local); - } else { + } else { if (HT_STAT(file->local, &file->stat_info) == -1) { - HTTRACE(PROT_TRACE, "Load File... Not found `%s\'\n" _ file->local); - HTRequest_addError(request, ERR_FATAL, NO, HTERR_NOT_FOUND, - NULL, 0, (char*)"HTLoadFile"); - file->state = FS_ERROR; - break; + HTTRACE(PROT_TRACE, "Load File... Not found `%s\'\n" _ file->local); + HTRequest_addError(request, ERR_FATAL, NO, HTERR_NOT_FOUND, + NULL, 0, (char*)"HTLoadFile"); + file->state = FS_ERROR; + 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) - file->state = FS_PARSE_DIR; + file->state = FS_PARSE_DIR; else { - HTRequest_addError(request, ERR_INFO, NO, HTERR_NO_CONTENT, - NULL, 0, (char*)"HTLoadFile"); - file->state = FS_NO_DATA; + HTRequest_addError(request, ERR_INFO, NO, HTERR_NO_CONTENT, + NULL, 0, (char*)"HTLoadFile"); + file->state = FS_NO_DATA; } break; - } + } - { + { BOOL editable = FALSE; HTBind_getAnchorBindings(anchor); if (editable) HTAnchor_appendAllow(anchor, METHOD_PUT); @@ -306,124 +302,124 @@ PRIVATE int FileEvent (SOCKET /* soc */, void * pVoid, HTEventType type) nelFile.close(); 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 */ 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 */ if (!editable && !file->stat_info.st_size) { - HTRequest_addError(request, ERR_INFO, NO, HTERR_NO_CONTENT, - NULL, 0, (char*)"HTLoadFile"); - file->state = FS_NO_DATA; + HTRequest_addError(request, ERR_INFO, NO, HTERR_NO_CONTENT, + NULL, 0, (char*)"HTLoadFile"); + file->state = FS_NO_DATA; } else { - file->state = (HTRequest_method(request)==METHOD_GET) ? + file->state = (HTRequest_method(request)==METHOD_GET) ? FS_NEED_OPEN_FILE : FS_GOT_DATA; } - } - break; + } + break; case FS_NEED_OPEN_FILE: - status = HTNeLFileOpen(net, file->local, HT_FB_RDONLY); - if (status == HT_OK) { + status = HTNeLFileOpen(net, file->local, HT_FB_RDONLY); + if (status == HT_OK) { { - HTStream * rstream = HTStreamStack(HTAnchor_format(anchor), - HTRequest_outputFormat(request), - HTRequest_outputStream(request), - request, YES); - HTNet_setReadStream(net, rstream); - HTRequest_setOutputConnected(request, YES); + HTStream * rstream = HTStreamStack(HTAnchor_format(anchor), + HTRequest_outputFormat(request), + HTRequest_outputStream(request), + request, YES); + HTNet_setReadStream(net, rstream); + HTRequest_setOutputConnected(request, YES); } { - HTOutputStream * output = HTNet_getOutput(net, NULL, 0); - HTRequest_setInputStream(request, (HTStream *) output); + HTOutputStream * output = HTNet_getOutput(net, NULL, 0); + HTRequest_setInputStream(request, (HTStream *) output); } if (HTRequest_isSource(request) && !HTRequest_destinationsReady(request)) - return HT_OK; + return HT_OK; HTRequest_addError(request, ERR_INFO, NO, HTERR_OK, NULL, 0, (char*)"HTLoadFile"); file->state = FS_NEED_BODY; if (HTEvent_isCallbacksRegistered()) { - if (!HTRequest_preemptive(request)) { + if (!HTRequest_preemptive(request)) { if (!HTNet_preemptive(net)) { - HTTRACE(PROT_TRACE, "HTLoadFile.. Returning\n"); - HTHost_register(HTNet_host(net), net, HTEvent_READ); + HTTRACE(PROT_TRACE, "HTLoadFile.. Returning\n"); + HTHost_register(HTNet_host(net), net, HTEvent_READ); } else if (!file->timer) { - HTTRACE(PROT_TRACE, "HTLoadFile.. Returning\n"); - file->timer = + HTTRACE(PROT_TRACE, "HTLoadFile.. Returning\n"); + file->timer = HTTimer_new(NULL, ReturnEvent, file, 1, YES, NO); } return HT_OK; - } + } } - } else if (status == HT_WOULD_BLOCK || status == HT_PENDING) + } else if (status == HT_WOULD_BLOCK || status == HT_PENDING) return HT_OK; - else { + else { HTRequest_addError(request, ERR_INFO, NO, HTERR_INTERNAL, NULL, 0, (char*)"HTLoadFile"); file->state = FS_ERROR; /* Error or interrupt */ - } - break; + } + break; case FS_NEED_BODY: - status = HTHost_read(HTNet_host(net), net); - if (status == HT_WOULD_BLOCK) + status = HTHost_read(HTNet_host(net), net); + if (status == HT_WOULD_BLOCK) return HT_OK; - else if (status == HT_LOADED || status == HT_CLOSED) { + else if (status == HT_LOADED || status == HT_CLOSED) { file->state = FS_GOT_DATA; - } else { + } else { HTRequest_addError(request, ERR_INFO, NO, HTERR_FORBIDDEN, NULL, 0, (char*)"HTLoadFile"); file->state = FS_ERROR; - } - break; + } + break; case FS_TRY_FTP: - { + { char *url = HTAnchor_physical(anchor); HTAnchor *anchor; char *newname = NULL; StrAllocCopy(newname, "ftp:"); if (!strncmp(url, "file:", 5)) - StrAllocCat(newname, url+5); + StrAllocCat(newname, url+5); else - StrAllocCat(newname, url); + StrAllocCat(newname, url); anchor = HTAnchor_findAddress(newname); HTRequest_setAnchor(request, anchor); HT_FREE(newname); FileCleanup(request, HT_IGNORE); return HTLoad(request, YES); - } - break; + } + break; case FS_GOT_DATA: - FileCleanup(request, HT_LOADED); - return HT_OK; - break; + FileCleanup(request, HT_LOADED); + return HT_OK; + break; case FS_NO_DATA: - FileCleanup(request, HT_NO_DATA); - return HT_OK; - break; + FileCleanup(request, HT_NO_DATA); + return HT_OK; + break; case FS_RETRY: - FileCleanup(request, HT_RETRY); - return HT_OK; - break; + FileCleanup(request, HT_RETRY); + return HT_OK; + break; case FS_ERROR: - FileCleanup(request, HT_ERROR); - return HT_OK; - break; + FileCleanup(request, HT_ERROR); + return HT_OK; + break; 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) { - FILE * fp = HTChannel_file(me->ch); - HTNet * net = HTHost_getReadNet(me->host); - int status; + FILE * fp = HTChannel_file(me->ch); + HTNet * net = HTHost_getReadNet(me->host); + int status; - /* Read the file desriptor */ - while (fp) + /* Read the file desriptor */ + while (fp) { 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; - } - HTTRACE(PROT_TRACE, "ANSI read... File descriptor is NULL...\n"); - return HT_ERROR; + } + HTTRACE(PROT_TRACE, "ANSI read... File descriptor is NULL...\n"); + return HT_ERROR; } PRIVATE int HTNeLReader_close (HTInputStream * me) @@ -505,32 +501,32 @@ PRIVATE int HTNeLReader_close (HTInputStream * me) file->close(); } - int status = HT_OK; - HTNet * net = HTHost_getReadNet(me->host); + int status = HT_OK; + 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) - return HT_WOULD_BLOCK; + return HT_WOULD_BLOCK; net->readStream = NULL; - } - HTTRACE(STREAM_TRACE, "Socket read. FREEING....\n"); - HT_FREE(me); - return status; + } + HTTRACE(STREAM_TRACE, "Socket read. FREEING....\n"); + HT_FREE(me); + return status; } PUBLIC int HTNeLReader_consumed (HTInputStream * me, size_t bytes) { - me->write += bytes; - me->b_read -= (int)bytes; - HTHost_setRemainingRead(me->host, me->b_read); - return HT_OK; + me->write += bytes; + me->b_read -= (int)bytes; + HTHost_setRemainingRead(me->host, me->b_read); + return HT_OK; } PRIVATE int HTNeLReader_flush (HTInputStream * me) { - HTNet * net = HTHost_getReadNet(me->host); - return net && net->readStream ? (*net->readStream->isa->flush)(net->readStream) : HT_OK; + HTNet * net = HTHost_getReadNet(me->host); + return net && net->readStream ? (*net->readStream->isa->flush)(net->readStream) : HT_OK; } PRIVATE int HTNeLReader_free (HTInputStream * me) @@ -542,54 +538,56 @@ PRIVATE int HTNeLReader_free (HTInputStream * me) HTChannel_setFile (me->ch, NULL); } - HTNet * net = HTHost_getReadNet(me->host); - if (net && net->readStream) { + HTNet * net = HTHost_getReadNet(me->host); + if (net && 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 HT_OK; + } + return HT_OK; } PRIVATE int HTNeLReader_abort (HTInputStream * me, HTList * /* e */) { - HTNet * net = HTHost_getReadNet(me->host); - if (net && net->readStream) { + HTNet * net = HTHost_getReadNet(me->host); + if (net && net->readStream) { int status = (*net->readStream->isa->abort)(net->readStream, NULL); if (status != HT_IGNORE) net->readStream = NULL; - } - return HT_ERROR; + } + return HT_ERROR; } PRIVATE const HTInputStreamClass HTNeLReader = { - (char*)"SocketReader", - HTNeLReader_flush, - HTNeLReader_free, - HTNeLReader_abort, - HTNeLReader_read, - HTNeLReader_close, - HTNeLReader_consumed + (char*)"SocketReader", + HTNeLReader_flush, + HTNeLReader_free, + HTNeLReader_abort, + HTNeLReader_read, + HTNeLReader_close, + HTNeLReader_consumed }; 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); if (me == NULL) { - if ((me=(HTInputStream *) HT_CALLOC(1, sizeof(HTInputStream))) == NULL) - HT_OUTOFMEM((char*)"HTNeLReader_new"); - me->isa = &HTNeLReader; - me->ch = ch; - me->host = host; - HTTRACE(STREAM_TRACE, "Reader...... Created reader stream %p\n" _ me); + if ((me=(HTInputStream *) HT_CALLOC(1, sizeof(HTInputStream))) == NULL) + HT_OUTOFMEM((char*)"HTNeLReader_new"); + me->isa = &HTNeLReader; + me->ch = ch; + me->host = host; + HTTRACE(STREAM_TRACE, "Reader...... Created reader stream %p\n" _ me); } return me; - } - return NULL; + } + return NULL; } //PUBLIC unsigned int WWW_TraceFlag = 0; } // extern "C" + + diff --git a/code/ryzom/client/src/interface_v3/libwww_nel_stream.h b/code/ryzom/client/src/interface_v3/libwww_nel_stream.h index d213baab2..e9cb8d9ee 100644 --- a/code/ryzom/client/src/interface_v3/libwww_nel_stream.h +++ b/code/ryzom/client/src/interface_v3/libwww_nel_stream.h @@ -23,8 +23,6 @@ #include "HTProt.h" 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 diff --git a/code/ryzom/client/src/interface_v3/view_link.cpp b/code/ryzom/client/src/interface_v3/view_link.cpp index 61421133e..efe760567 100644 --- a/code/ryzom/client/src/interface_v3/view_link.cpp +++ b/code/ryzom/client/src/interface_v3/view_link.cpp @@ -14,13 +14,8 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . - - -#include "stdpch.h" - #include "nel/misc/bit_mem_stream.h" #include "nel/misc/i18n.h" - #include "view_link.h" using namespace std; @@ -62,3 +57,4 @@ bool CViewLink::getMouseOverShape(string &texName, uint8 &rot, CRGBA &col) // *************************************************************************** + diff --git a/code/ryzom/client/src/interface_v3/view_link.h b/code/ryzom/client/src/interface_v3/view_link.h index 169487a1d..dce116b82 100644 --- a/code/ryzom/client/src/interface_v3/view_link.h +++ b/code/ryzom/client/src/interface_v3/view_link.h @@ -21,6 +21,8 @@ #include "nel/gui/view_text.h" +class CGroupHTML; + /** * class implementing a link view * \author Cyril 'Hulud' Corvazier @@ -41,7 +43,7 @@ public: std::string LinkTitle; // Set the main group - void setHTMLView(class CGroupHTML *html); + void setHTMLView( CGroupHTML *html); bool getMouseOverShape(std::string &texName, uint8 &rot, NLMISC::CRGBA &col); protected: @@ -50,7 +52,6 @@ protected: CGroupHTML *HTML; }; - #endif // NL_VIEW_LINK_H /* End of view_link.h */ diff --git a/code/ryzom/client/src/libwww.cpp b/code/ryzom/client/src/libwww.cpp index a1c0ce826..b2c699cd5 100644 --- a/code/ryzom/client/src/libwww.cpp +++ b/code/ryzom/client/src/libwww.cpp @@ -15,9 +15,6 @@ // along with this program. If not, see . - -#include "stdpch.h" - // LibWWW extern "C" { @@ -27,8 +24,6 @@ extern "C" } #include "interface_v3/group_html.h" -#include "game_share/ryzom_version.h" - #include "interface_v3/libwww_nel_stream.h" 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 struct _HText { - CGroupHTML *Parent; + CGroupHTML *Parent; }; // *************************************************************************** @@ -273,7 +268,7 @@ HText * TextNew (HTRequest * request, { HText *text = new HText; text->Parent = (CGroupHTML *) HTRequest_context(request); - return text; + return text; } // *************************************************************************** @@ -281,7 +276,7 @@ HText * TextNew (HTRequest * request, BOOL TextDelete (HText * me) { delete me; - return YES; + return YES; } // *************************************************************************** @@ -437,7 +432,7 @@ int requestTerminater (HTRequest * request, HTResponse * /* response */, 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 */) { - return NULL; + return NULL; } int HTMIME_location_custom (HTRequest * request, HTResponse * response, char * token, char * value) @@ -544,7 +539,7 @@ void initLibWWW() static bool initialized = false; if (!initialized) { - //HTProfile_newNoCacheClient("Ryzom", "1.1"); + //HTProfile_newNoCacheClient("Ryzom", "1.1"); /* Need our own trace and print functions */ HTPrint_setCallback(NelPrinter); @@ -552,8 +547,8 @@ void initLibWWW() /* Initiate libwww */ - HTLib_setAppName("Ryzom"); - HTLib_setAppVersion(RYZOM_VERSION); + HTLib_setAppName( CGroupHTML::options.appName.c_str() ); + HTLib_setAppVersion( CGroupHTML::options.appVersion.c_str() ); /* Set up TCP as transport */ 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 */ 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)); // HTProtocol_add("cache", "local", 0, NO, HTLoadCache, NULL); @@ -657,8 +652,8 @@ void initLibWWW() /* Set up default event loop */ HTEventInit(); - /* Add our own request terminate handler */ - HTNet_addAfter(requestTerminater, NULL, 0, HT_ALL, HT_FILTER_LAST); + /* Add our own request terminate handler */ + HTNet_addAfter(requestTerminater, NULL, 0, HT_ALL, HT_FILTER_LAST); /* Setup cookies */ HTCookie_init(); @@ -670,7 +665,7 @@ void initLibWWW() /* Go into the event loop... */ // HTEventList_newLoop(); - // App_delete(app); + // App_delete(app); HTBind_add("htm", "text/html", NULL, "8bit", NULL, 1.0); /* HTML */ HTBind_add("html", "text/html", NULL, "8bit", NULL, 1.0); /* HTML */