CHANGED: #1471 CGroupHTML, CGroupParagraph, CViewLink are now part of the NELGUI library and are under the NLGUI namespace.

This commit is contained in:
dfighter1985 2012-07-01 03:11:24 +02:00
parent 31c887ede8
commit bf624b79ec
35 changed files with 7193 additions and 7162 deletions

View file

@ -0,0 +1,659 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// 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/>.
#ifndef CL_GROUP_HTML_H
#define CL_GROUP_HTML_H
#define CURL_STATICLIB 1
#include <curl/curl.h>
#include "nel/misc/types_nl.h"
#include "nel/gui/interface_group.h"
#include "nel/gui/group_scrolltext.h"
#include "nel/gui/group_tree.h"
#include "nel/gui/ctrl_button.h"
#include "nel/gui/group_table.h"
typedef std::map<std::string, std::string> TStyle;
extern "C"
{
#include "WWWInit.h"
}
namespace NLGUI
{
class CCtrlButton;
class CCtrlScroll;
class CGroupList;
class CDBGroupComboBox;
class CGroupParagraph;
// HTML group
/**
* Widget to have a resizable scrolltext and its scrollbar
* \author Cyril 'Hulud' Corvazier
* \author Nevrax France
* \date 2002
*/
class CGroupHTML : public CGroupScrollText
{
public:
friend void TextAdd (struct _HText *me, const char * buf, int len);
friend void TextBeginElement (_HText *me, int element_number, const BOOL *present, const char ** value);
friend void TextEndElement (_HText *me, int element_number);
friend void TextLink (struct _HText *me, int element_number, int attribute_number, struct _HTChildAnchor *anchor, const BOOL *present, const char **value);
friend void TextBuild (HText * me, HTextStatus status);
friend void TextBeginUnparsedElement(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);
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 &param);
~CGroupHTML();
// CInterfaceGroup Interface
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
virtual void draw ();
// Events
virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc);
// Browse
virtual void browse (const char *url);
// Refresh
void refresh();
// submit form
void submitForm (uint formId, const char *submitButtonName);
// Browse error
void browseError (const char *msg);
// stop browse
void stopBrowse ();
bool isBrowsing();
void clean() { stopBrowse(); updateRefreshButton(); removeContent(); }
// Update coords
void updateCoords();
// New paragraph
void newParagraph(uint beginSpace);
// End of the paragraph
void endParagraph();
// Timeout
void setTimeout(float tm) {_TimeoutValue= std::max(0.f, tm);}
float getTimeout() const {return (float)_TimeoutValue;}
// Some constants
NLMISC::CRGBA BgColor;
NLMISC::CRGBA ErrorColor;
NLMISC::CRGBA LinkColor;
NLMISC::CRGBA TextColor;
NLMISC::CRGBA H1Color;
NLMISC::CRGBA H2Color;
NLMISC::CRGBA H3Color;
NLMISC::CRGBA H4Color;
NLMISC::CRGBA H5Color;
NLMISC::CRGBA H6Color;
bool ErrorColorGlobalColor;
bool LinkColorGlobalColor;
bool TextColorGlobalColor;
bool H1ColorGlobalColor;
bool H2ColorGlobalColor;
bool H3ColorGlobalColor;
bool H4ColorGlobalColor;
bool H5ColorGlobalColor;
bool H6ColorGlobalColor;
uint TextFontSize;
uint H1FontSize;
uint H2FontSize;
uint H3FontSize;
uint H4FontSize;
uint H5FontSize;
uint H6FontSize;
uint TDBeginSpace;
uint PBeginSpace;
uint LIBeginSpace;
uint ULBeginSpace;
uint LIIndent;
uint ULIndent;
float LineSpaceFontFactor;
std::string DefaultButtonGroup;
std::string DefaultFormTextGroup;
std::string DefaultFormTextAreaGroup;
std::string DefaultFormSelectGroup;
std::string DefaultCheckBoxBitmapNormal;
std::string DefaultCheckBoxBitmapPushed;
std::string DefaultCheckBoxBitmapOver;
std::string DefaultBackgroundBitmapView;
std::string CurrentLinkTitle;
// Browser home
std::string Home;
// Undo browse: Browse the precedent url browsed. no op if none
void browseUndo ();
// Redo browse: Browse the precedent url undoed. no op if none
void browseRedo ();
// clear undo/redo
void clearUndoRedo();
std::string getURL() const { return _URL; }
void setURL(const std::string &url);
int luaBrowse(CLuaState &ls);
int luaRefresh(CLuaState &ls);
int luaRemoveContent(CLuaState &ls);
int luaInsertText(CLuaState &ls);
int luaAddString(CLuaState &ls);
int luaAddImage(CLuaState &ls);
int luaBeginElement(CLuaState &ls);
int luaEndElement(CLuaState &ls);
int luaShowDiv(CLuaState &ls);
REFLECT_EXPORT_START(CGroupHTML, CGroupScrollText)
REFLECT_LUA_METHOD("browse", luaBrowse)
REFLECT_LUA_METHOD("refresh", luaRefresh)
REFLECT_LUA_METHOD("removeContent", luaRemoveContent)
REFLECT_LUA_METHOD("insertText", luaInsertText)
REFLECT_LUA_METHOD("addString", luaAddString)
REFLECT_LUA_METHOD("addImage", luaAddImage)
REFLECT_LUA_METHOD("beginElement", luaBeginElement)
REFLECT_LUA_METHOD("endElement", luaEndElement)
REFLECT_LUA_METHOD("showDiv", luaShowDiv)
REFLECT_STRING("url", getURL, setURL)
REFLECT_FLOAT("timeout", getTimeout, setTimeout)
REFLECT_EXPORT_END
protected :
// \name callback from libwww
// Begin of the parsing of a HTML document
virtual void beginBuild ();
// End of the parsing of a HTML document
virtual void endBuild ();
// A new text block has been parsed
virtual void addText (const char * buf, int len);
// A link has been parsed
virtual void addLink (uint element_number, uint attribute_number, HTChildAnchor *anchor, const BOOL *present, const char **value);
// A new begin HTML element has been parsed (<IMG> for exemple)
virtual void beginElement (uint element_number, const BOOL *present, const char **value);
// A new end HTML element has been parsed (</IMG> for exemple)
virtual void endElement (uint element_number);
// A new begin unparsed element has been found
virtual void beginUnparsedElement(const char *buffer, int length);
// A new end unparsed element has been found
virtual void endUnparsedElement(const char *buffer, int length);
// Add GET params to the url
virtual void addHTTPGetParams (std::string &url, bool trustedDomain);
// Add POST params to the libwww list
virtual void addHTTPPostParams (HTAssocList *formfields, bool trustedDomain);
// the current request is terminated
virtual void requestTerminated(HTRequest *request);
// Get Home URL
virtual std::string home();
// Parse style html tag
TStyle parseStyle(const std::string &str_styles);
// Handle some work at each pass
virtual void handle ();
// \name internal methods
// Add a group in the current parent group
void addGroup (CInterfaceGroup *group, uint beginSpace);
// Get the current parent group
CInterfaceGroup *getCurrentGroup();
// Update current paragraph dependent data
void paragraphChange ();
// Clear the contexts info
void clearContext();
// Translate a char
bool translateChar(ucchar &output, ucchar input, ucchar lastChar) const;
// Add a string in the current paragraph
void addString(const ucstring &str);
// Add an image in the current paragraph
void addImage(const char *image, bool globalColor, bool reloadImg=false);
// Add a text area in the current paragraph
CInterfaceGroup *addTextArea (const std::string &templateName, const char *name, uint rows, uint cols, bool multiLine, const ucstring &content);
// Add a combo box in the current paragraph
CDBGroupComboBox *addComboBox(const std::string &templateName, const char *name);
// Add a button in the current paragraph. actionHandler, actionHandlerParams and tooltip can be NULL.
CCtrlButton *addButton(CCtrlButton::EType type, const std::string &name, const std::string &normalBitmap, const std::string &pushedBitmap,
const std::string &overBitmap, bool useGlobalColor, const char *actionHandler, const char *actionHandlerParams, const char *tooltip);
// Set the background color
void setBackgroundColor (const NLMISC::CRGBA &bgcolor);
// Set the background
void setBackground (const std::string &bgtex, bool scale, bool tile);
// Force the current string to be in a single string
void flushString();
// Set the title
void setTitle (const ucstring &title);
// Lookup a url in local file system
bool lookupLocalFile (std::string &result, const char *url, bool isUrl);
// Delete page content and prepare next page
void removeContent ();
// Current URL
std::string _URL;
// Current DOMAIN
bool _TrustedDomain;
// Title prefix
ucstring _TitlePrefix;
// Title string
ucstring _TitleString;
// Need to browse next update coords..
bool _BrowseNextTime;
bool _PostNextTime;
uint _PostFormId;
std::string _PostFormSubmitButton;
// Browsing..
bool _Browsing;
bool _Connecting;
double _TimeoutValue; // the timeout in seconds
double _ConnectingTimeout;
// minimal embeded lua script support
// Note : any embeded script is executed immediately after the closing
// element has been found
// True when the <lua> element has been encountered
bool _ParsingLua;
bool _IgnoreText;
// the script to execute
std::string _LuaScript;
bool _Object;
std::string _ObjectScript;
// Someone is conecting. We got problem with libwww : 2 connection requests can deadlock the client.
static CGroupHTML *_ConnectingLock;
// LibWWW data
class CLibWWWData *_LibWWW;
// Current paragraph
std::string _DivName;
CGroupParagraph* _Paragraph;
inline CGroupParagraph *getParagraph()
{
return _Paragraph;
/*if (_Paragraph.empty())
return NULL;
return _Paragraph.back();*/
}
// PRE mode
std::vector<bool> _PRE;
inline bool getPRE() const
{
if (_PRE.empty())
return false;
return _PRE.back();
}
// UL mode
std::vector<bool> _UL;
inline bool getUL() const
{
if (_UL.empty())
return false;
return _UL.back();
}
// A mode
std::vector<bool> _A;
inline bool getA() const
{
if (_A.empty())
return false;
return _A.back();
}
// IL mode
bool _LI;
// Current text color
std::vector<NLMISC::CRGBA> _TextColor;
inline const NLMISC::CRGBA &getTextColor() const
{
if (_TextColor.empty())
return TextColor;
return _TextColor.back();
}
// Current global color flag
std::vector<bool> _GlobalColor;
inline bool getGlobalColor() const
{
if (_GlobalColor.empty())
return false;
return _GlobalColor.back();
}
// Current font size
std::vector<uint> _FontSize;
inline uint getFontSize() const
{
if (_FontSize.empty())
return TextFontSize;
return _FontSize.back();
}
// Current link
std::vector<std::string> _Link;
inline const char *getLink() const
{
if (_Link.empty())
return "";
return _Link.back().c_str();
}
std::vector<std::string> _LinkTitle;
inline const char *getLinkTitle() const
{
if (_LinkTitle.empty())
return "";
return _LinkTitle.back().c_str();
}
std::vector<std::string> _LinkClass;
inline const char *getLinkClass() const
{
if (_LinkClass.empty())
return "";
return _LinkClass.back().c_str();
}
// Divs (i.e. interface group)
std::vector<class CInterfaceGroup*> _Divs;
inline CInterfaceGroup *getDiv() const
{
if (_Divs.empty())
return NULL;
return _Divs.back();
}
// Tables
std::vector<class CGroupTable*> _Tables;
inline CGroupTable *getTable() const
{
if (_Tables.empty())
return NULL;
return _Tables.back();
}
// Cells
std::vector<class CGroupCell*> _Cells;
// TR
std::vector<bool> _TR;
inline bool getTR() const
{
if (_TR.empty())
return false;
return _TR.back();
}
// Forms
class CForm
{
public:
class CEntry
{
public:
CEntry ()
{
TextArea = NULL;
Checkbox = NULL;
ComboBox = NULL;
InitialSelection = 0;
}
// Variable name
std::string Name;
// Variable value
ucstring Value;
// Text area group
CInterfaceGroup *TextArea;
// Checkbox
CCtrlButton *Checkbox;
// Combobox group
CDBGroupComboBox *ComboBox;
// select values (for the <select> tag)
std::vector<std::string> SelectValues;
sint InitialSelection; // initial selection for the combo box
};
// The action the form has to perform
std::string Action;
// The text area associated with the form
std::vector<CEntry> Entries;
};
std::vector<CForm> _Forms;
std::vector<CInterfaceGroup *> _Groups;
// Cells parameters
class CCellParams
{
public:
CCellParams () : BgColor(0,0,0,0)
{
Align = CGroupCell::Left;
VAlign = CGroupCell::Top;
LeftMargin = 0;
NoWrap = false;
}
NLMISC::CRGBA BgColor;
std::string Style;
CGroupCell::TAlign Align;
CGroupCell::TVAlign VAlign;
sint32 LeftMargin;
bool NoWrap;
};
std::vector<CCellParams> _CellParams;
// Indentation
uint _Indent;
// Current node is a title
bool _Title;
// Current node must be localized
bool _Localize;
// Current node is a text area
bool _TextArea;
std::string _TextAreaTemplate;
ucstring _TextAreaContent;
std::string _TextAreaName;
uint _TextAreaRow;
uint _TextAreaCols;
// current mode is in select option
bool _SelectOption;
ucstring _SelectOptionStr;
// Current node is a object
std::string _ObjectType;
std::string _ObjectData;
std::string _ObjectMD5Sum;
std::string _ObjectAction;
std::string _TextAreaScript;
// Get last char
ucchar getLastChar() const;
// Current link view
class CViewLink *_CurrentViewLink;
class CViewBitmap *_CurrentViewImage;
// Current group table
class CGroupCell *_CurrentCell;
// The main group
class CGroupListAdaptor *_GroupListAdaptor;
// For auto selecting the node in a BrowseTree bound to this HTML web page
std::string _BrowseTree;
// select the tree node that has the correct url
const std::string &selectTreeNodeRecurs(CGroupTree::SNode *node, const std::string &url);
// search if the action / params match the url. look recurs into procedures
bool actionLaunchUrlRecurs(const std::string &ah, const std::string &params, const std::string &url);
// Browse undo and redo
enum {MaxUrlUndoRedo= 256};
std::string _BrowseUndoButton;
std::string _BrowseRedoButton;
std::string _BrowseRefreshButton;
// _BrowseUrl is different from _URL, in that _URL may change in handle()
std::string _AskedUrl;
std::deque<std::string> _BrowseUndo;
std::deque<std::string> _BrowseRedo;
void pushUrlUndoRedo(const std::string &url);
void doBrowse(const char *url);
void updateUndoRedoButtons();
void updateRefreshButton();
// For Killing request. Associate each CGroupHTML object with a unique ID.
uint32 _GroupHtmlUID;
static uint32 _GroupHtmlUIDPool;
typedef std::map<uint32, NLMISC::CRefPtr<CGroupHTML> > TGroupHtmlByUIDMap;
static TGroupHtmlByUIDMap _GroupHtmlByUID;
private:
// decode all HTML entities
static ucstring decodeHTMLEntities(const ucstring &str);
// ImageDownload system
enum TDataType {ImgType= 0, BnpType};
struct CDataDownload
{
CDataDownload(CURL *c, const std::string &u, FILE *f, TDataType t, CViewBase *i, const std::string &s, const std::string &m) : curl(c), url(u), luaScript(s), md5sum(m), type(t), fp(f)
{
if (t == ImgType) imgs.push_back(i);
}
CURL *curl;
std::string url;
std::string luaScript;
std::string md5sum;
TDataType type;
FILE *fp;
std::vector<CViewBase *> imgs;
};
std::vector<CDataDownload> Curls;
CURLM *MultiCurl;
int RunningCurls;
void initImageDownload();
void checkImageDownload();
void addImageDownload(const std::string &url, CViewBase *img);
std::string localImageName(const std::string &url);
bool isTrustedDomain(const std::string &domain);
void setImage(CViewBase *view, const std::string &file);
// BnpDownload system
void initBnpDownload();
void checkBnpDownload();
bool addBnpDownload(const std::string &url, const std::string &action, const std::string &script, const std::string &md5sum);
std::string localBnpName(const std::string &url);
void releaseDownloads();
void checkDownloads();
};
// adapter group that store y offset for inputs inside an html form
class CGroupHTMLInputOffset : public CInterfaceGroup
{
public:
sint32 Offset;
CGroupHTMLInputOffset(const TCtorParam &param);
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
};
}
#endif

View file

@ -0,0 +1,304 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// 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/>.
#ifndef NL_GROUP_PARAGRAPH_H
#define NL_GROUP_PARAGRAPH_H
#include "nel/misc/types_nl.h"
#include "nel/gui/group_frame.h"
#include "nel/gui/view_text.h"
#include "nel/gui/view_link.h"
#include "nel/gui/ctrl_button.h"
namespace NLGUI
{
class CCtrlLink : public CCtrlButton
{
public:
CCtrlLink (const TCtorParam &param) : CCtrlButton(param)
{}
};
// ----------------------------------------------------------------------------
class CGroupParagraph : public CInterfaceGroup
{
public:
enum EAlign
{
Bottom = 0,
Top,
Left,
Right
};
///constructor
CGroupParagraph(const TCtorParam &param);
// dtor
~CGroupParagraph();
/**
* add a child element to the group at the last position
* 'order' of the element is set to the last order + 1
* \param child : pointer to the child element
*/
void addChild (CViewBase* child, bool deleteOnRemove=true);
/**
* add a link element to the group at the last position
* \param child : pointer to the child element
*/
void addChildLink (CViewLink* child, bool deleteOnRemove=true);
/** add a child before the element at the given index.
* 'order' of the element is set to 0
* \return true if there was enough room for that child
*/
bool addChildAtIndex(CViewBase *child, uint index, bool deleteOnRemove = true);
/**
* add a text child element to the group, using the text template
* \param line : text to be added
* \param color : text color
*/
void addTextChild (const ucstring& line,const NLMISC::CRGBA &textColor, bool multiLine = true);
/**
* add a text child element to the group, using the text template
* \param line : text to be added
*/
void addTextChild (const ucstring& line, bool multiLine = true);
/// Same as adding a text child but the text will be taken from the string manager
void addTextChildID (uint32 id, bool multiLine = true);
// the same, but with id taken from the database
void addTextChildID (const std::string &dbPath, bool multiLine = true);
protected:
void delChild (CViewBase* child);
void delChild(uint index);
public:
CViewBase *getChild(uint index) const { return _Elements[index].Element; }
void deleteAllChildren();
// void removeHead();
// Get the number of children
uint getNumChildren() const { return (uint)_Elements.size(); }
// Get the number of active children
uint getNumActiveChildren() const;
/**
* set the template that will be used to add text;
* \templ : a CViewText object. Only its font size, color and shadow are required.
*/
void setTextTemplate(const CViewText& templ);
/**
* set the template that will be used to add text;
* \templ : a CViewText object. Only its font size, color and shadow are required.
*/
CViewText * getTextTemplatePtr()
{
return &_Templ;
}
/**
* parse the element and initalize it
* \paral cur : pointer to the node describing this element
* \param parentGroup : the parent group of this element
* \return true if success
*/
virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup);
//virtual uint32 getMemory();
/**
* init or reset the children element coords. Orverloaded from CInterfaceGroup because we begin with the last inserted element here
*/
virtual void updateCoords();
virtual void checkCoords();
virtual void draw();
virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc);
virtual void clearViews();
virtual void clearControls();
virtual void clearGroups();
void setSpace (sint32 s) { _Space = s; }
virtual CInterfaceElement* getElement (const std::string &id)
{ return CInterfaceGroup::getElement (id); }
sint32 getNbElement() { return (sint32)_Elements.size(); }
sint32 getSpace() { return _Space; }
void forceSizeW (sint32 newSizeW);
void forceSizeH (sint32 newSizeH);
void setMinW(sint32 minW);
void setMinH(sint32 minH);
sint32 getMinW() const {return _MinW;}
sint32 getMinH() const {return _MinH;}
// set the rank for the element at the given index (used to reinsert container after they have been turned into popups)
void setOrder(uint index, uint order) { _Elements[index].Order = order; }
uint getOrder(uint index) const { return _Elements[index].Order; }
// get element of index or -1 if not found
sint32 getElementIndex(CViewBase* child) const;
// swap 2 entries in the list (and also their orders)
// void swapChildren(uint index1, uint index2);
// deleteOnRemove flag
void setDelOnRemove(uint index, bool delOnRemove);
bool getDelOnRemove(uint index) const;
void setTopSpace(uint topSpace)
{
_TopSpace = topSpace;
setResizeFromChildHMargin(topSpace);
invalidateContent();
};
uint getTopSpace()
{
return _TopSpace;
};
void setIndent(uint indent) { _Indent = indent; }
void setFirstViewIndent(sint indent)
{
_FirstViewIndentView = indent;
invalidateContent();
}
// Set the HTML group used for links
void setBrowseGroup (CInterfaceElement *group)
{
_BrowseGroup = group;
}
/// \from CInterfaceElement
void onInvalidateContent();
sint32 getMaxUsedW() const;
sint32 getMinUsedW() const;
protected:
// Content validated
bool _ContentValidated;
// Where to add next element
EAlign _AddElt;
// Where to align the newly added element
EAlign _Align;
// Space between two elements in pixel
sint32 _Space;
// Text template
CViewText _Templ;
// Current id of the view
sint32 _IdCounter;
// Do we have a color under the element pointed by the mouse
bool _Over;
// If over is true so we have a color
NLMISC::CRGBA _OverColor;
// Current elt over the pointer
sint32 _OverElt;
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.
CViewBase *Element;
bool EltDeleteOnRemove;
};
friend struct CRemoveViewPred;
friend struct CRemoveCtrlPred;
friend struct CRemoveGroupPred;
// The list is forced to be at least this size in updateCoords().
sint32 _MinW;
sint32 _MinH;
// To conserve elements in the order they have been added
// (the element drawn are stored in _views, _contrlos or _childrengroups of cinterfacegroup
std::vector<CElementInfo> _Elements;
// Last parent width
sint32 _LastW;
// Top space
uint _TopSpace;
// Indent
uint _Indent; // Left margin
sint _FirstViewIndentView; // Additionnal left margin for the first view
// A link structure
class CLink
{
public:
CLink(CViewLink *link);
// The link view
CViewLink *Link;
// The three control button
CCtrlLink *CtrlLink[3];
};
// The links
std::vector<CLink> _Links;
// The HTML group used
CInterfaceElement *_BrowseGroup;
private:
// void setHSGroup (CViewBase *child, EAlign addElt, EAlign align);
// void setHSParent(CViewBase *view, EAlign addElt, EAlign align, uint space);
};
}
#endif // NL_GROUP_PARAGRAPH_H
/* End of group_paragraph.h */

View file

@ -27,8 +27,6 @@
#include "nel/gui/reflect.h"
#include "nel/gui/interface_common.h"
class CGroupParagraph;
namespace NLGUI
{
class CGroupList;
@ -38,6 +36,7 @@ namespace NLGUI
class CViewBase;
class CCtrlBase;
class IActionHandler;
class CGroupParagraph;
/**
* A visitor to walk a tree of interface elements and apply a teartment on them.
@ -496,7 +495,7 @@ namespace NLGUI
// Friend Class
friend class CGroupList;
friend class ::CGroupParagraph;
friend class CGroupParagraph;
// True if must modulate the global color with the view
bool _ModulateGlobalColor;

View file

@ -0,0 +1,283 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// 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/>.
#ifndef CL_LIB_WWW_H
#define CL_LIB_WWW_H
extern "C"
{
#include "WWWInit.h"
}
namespace NLGUI
{
class CCtrlBaseButton;
class CCtrlScroll;
class CGroupList;
// ***************************************************************************
// Init the libwww
void initLibWWW();
// Get an url and setup a local domain
const std::string &setCurrentDomain(const std::string &url);
extern std::string CurrentCookie;
// ***************************************************************************
// Some DTD table
// Here, modify the DTD table to change the HTML parser (add new tags for exemples)
#undef HTML_ATTR
#define HTML_ATTR(t,a) MY_HTML_##t##_##a
enum
{
HTML_ATTR(A,ACCESSKEY) = 0,
HTML_ATTR(A,CHARSET),
HTML_ATTR(A,CLASS),
HTML_ATTR(A,COORDS),
HTML_ATTR(A,DIR),
HTML_ATTR(A,HREF),
HTML_ATTR(A,HREFLANG),
HTML_ATTR(A,ID),
HTML_ATTR(A,NAME),
HTML_ATTR(A,REL),
HTML_ATTR(A,REV),
HTML_ATTR(A,SHAPE),
HTML_ATTR(A,STYLE),
HTML_ATTR(A,TABINDEX),
HTML_ATTR(A,TARGET),
HTML_ATTR(A,TYPE),
HTML_ATTR(A,TITLE),
HTML_ATTR(A,Z_ACTION_CATEGORY),
HTML_ATTR(A,Z_ACTION_PARAMS),
HTML_ATTR(A,Z_ACTION_SHORTCUT),
};
enum
{
HTML_ATTR(TABLE,ALIGN) = 0,
HTML_ATTR(TABLE,BGCOLOR),
HTML_ATTR(TABLE,BORDER),
HTML_ATTR(TABLE,CELLPADDING),
HTML_ATTR(TABLE,CELLSPACING),
HTML_ATTR(TABLE,CLASS),
HTML_ATTR(TABLE,DIR),
HTML_ATTR(TABLE,FRAME),
HTML_ATTR(TABLE,ID),
HTML_ATTR(TABLE,L_MARGIN),
HTML_ATTR(TABLE,LANG),
HTML_ATTR(TABLE,NOWRAP),
HTML_ATTR(TABLE,RULES),
HTML_ATTR(TABLE,SUMMARY),
HTML_ATTR(TABLE,STYLE),
HTML_ATTR(TABLE,TITLE),
HTML_ATTR(TABLE,VALIGN),
HTML_ATTR(TABLE,WIDTH)
};
enum
{
HTML_ATTR(TR,ALIGN) = 0,
HTML_ATTR(TR,BGCOLOR),
HTML_ATTR(TR,L_MARGIN),
HTML_ATTR(TR,NOWRAP),
HTML_ATTR(TR,VALIGN),
};
enum
{
HTML_ATTR(TD,ABBR) = 0,
HTML_ATTR(TD,ALIGN),
HTML_ATTR(TD,AXIS),
HTML_ATTR(TD,BGCOLOR),
HTML_ATTR(TD,CHAR),
HTML_ATTR(TD,CHAROFF),
HTML_ATTR(TD,CLASS),
HTML_ATTR(TD,COLSPAN),
HTML_ATTR(TD,DIR),
HTML_ATTR(TD,ID),
HTML_ATTR(TD,HEADERS),
HTML_ATTR(TD,HEIGHT),
HTML_ATTR(TD,L_MARGIN),
HTML_ATTR(TD,LANG),
HTML_ATTR(TD,NOWRAP),
HTML_ATTR(TD,ROWSPAN),
HTML_ATTR(TD,SCOPE),
HTML_ATTR(TD,STYLE),
HTML_ATTR(TD,TITLE),
HTML_ATTR(TD,VALIGN),
HTML_ATTR(TD,WIDTH),
};
enum
{
HTML_ATTR(IMG,ALIGN) = 0,
HTML_ATTR(IMG,ALT),
HTML_ATTR(IMG,BORDER),
HTML_ATTR(IMG,CLASS),
HTML_ATTR(IMG,DIR),
HTML_ATTR(IMG,GLOBAL_COLOR),
HTML_ATTR(IMG,HEIGHT),
HTML_ATTR(IMG,HSPACE),
HTML_ATTR(IMG,ID),
HTML_ATTR(IMG,ISMAP),
HTML_ATTR(IMG,LANG),
HTML_ATTR(IMG,LONGDESC),
HTML_ATTR(IMG,SRC),
HTML_ATTR(IMG,STYLE),
HTML_ATTR(IMG,TITLE),
HTML_ATTR(IMG,USEMAP),
HTML_ATTR(IMG,VSPACE),
HTML_ATTR(IMG,WIDTH),
};
enum
{
HTML_ATTR(INPUT,ACCEPT) = 0,
HTML_ATTR(INPUT,ACCESSKEY),
HTML_ATTR(INPUT,ALIGN),
HTML_ATTR(INPUT,ALT),
HTML_ATTR(INPUT,CHECKED),
HTML_ATTR(INPUT,CLASS),
HTML_ATTR(INPUT,DIR),
HTML_ATTR(INPUT,DISABLED),
HTML_ATTR(INPUT,GLOBAL_COLOR),
HTML_ATTR(INPUT,ID),
HTML_ATTR(INPUT,LANG),
HTML_ATTR(INPUT,MAXLENGTH),
HTML_ATTR(INPUT,NAME),
HTML_ATTR(INPUT,READONLY),
HTML_ATTR(INPUT,SIZE),
HTML_ATTR(INPUT,SRC),
HTML_ATTR(INPUT,STYLE),
HTML_ATTR(INPUT,TABINDEX),
HTML_ATTR(INPUT,TITLE),
HTML_ATTR(INPUT,TYPE),
HTML_ATTR(INPUT,USEMAP),
HTML_ATTR(INPUT,VALUE),
HTML_ATTR(INPUT,Z_BTN_TMPL),
HTML_ATTR(INPUT,Z_INPUT_TMPL),
HTML_ATTR(INPUT,Z_INPUT_WIDTH),
};
enum
{
HTML_ATTR(TEXTAREA,CLASS) = 0,
HTML_ATTR(TEXTAREA,COLS),
HTML_ATTR(TEXTAREA,DIR),
HTML_ATTR(TEXTAREA,DISABLED),
HTML_ATTR(TEXTAREA,ID),
HTML_ATTR(TEXTAREA,LANG),
HTML_ATTR(TEXTAREA,NAME),
HTML_ATTR(TEXTAREA,READONLY),
HTML_ATTR(TEXTAREA,ROWS),
HTML_ATTR(TEXTAREA,STYLE),
HTML_ATTR(TEXTAREA,TABINDEX),
HTML_ATTR(TEXTAREA,TITLE),
HTML_ATTR(TEXTAREA,Z_INPUT_TMPL),
};
enum
{
HTML_ATTR(P,QUICK_HELP_CONDITION) = 0,
HTML_ATTR(P,QUICK_HELP_EVENTS),
HTML_ATTR(P,QUICK_HELP_LINK),
HTML_ATTR(P,NAME),
};
enum
{
HTML_ATTR(DIV,CLASS) = 0,
HTML_ATTR(DIV,ID),
HTML_ATTR(DIV,NAME),
HTML_ATTR(DIV,STYLE),
};
#undef HTML_ATTR
// ***************************************************************************
// A smart ptr for LibWWW strings
class C3WSmartPtr
{
public:
C3WSmartPtr ()
{
_Ptr = NULL;
}
C3WSmartPtr (const char *ptr)
{
_Ptr = ptr;
}
~C3WSmartPtr ()
{
clear();
}
void operator=(const char *str)
{
clear ();
_Ptr = str;
}
operator const char *() const
{
return _Ptr;
}
void clear()
{
if (_Ptr)
{
void *ptr = (void*)_Ptr;
HT_FREE(ptr);
}
_Ptr = NULL;
}
private:
const char *_Ptr;
};
// ***************************************************************************
// Read a width HTML parameter. "100" or "100%". Returns true if percent (0 ~ 1) else false
bool getPercentage (sint32 &width, float &percent, const char *str);
// ***************************************************************************
// Parse a HTML color
NLMISC::CRGBA getColor (const char *color);
// ***************************************************************************
void _VerifyLibWWW(const char *function, bool ok, const char *file, int line);
#define VerifyLibWWW(a,b) _VerifyLibWWW(a,(b)!=FALSE,__FILE__,__LINE__)
// ***************************************************************************
// Standard request terminator
int requestTerminater (HTRequest * request, HTResponse * response, void * param, int status) ;
// ***************************************************************************
}
#endif

View file

@ -21,36 +21,41 @@
#include "nel/gui/view_text.h"
class CGroupHTML;
/**
* class implementing a link view
* \author Cyril 'Hulud' Corvazier
* \author Nicolas Vizerie
* \author Nevrax France
* \date 2003
*/
class CViewLink : public CViewText
namespace NLGUI
{
public:
// Default constructor
CViewLink (const TCtorParam &param);
class CGroupHTML;
// The URI
std::string Link;
/**
* class implementing a link view
* \author Cyril 'Hulud' Corvazier
* \author Nicolas Vizerie
* \author Nevrax France
* \date 2003
*/
class CViewLink : public CViewText
{
public:
std::string LinkTitle;
// Default constructor
CViewLink (const TCtorParam &param);
// Set the main group
void setHTMLView( CGroupHTML *html);
bool getMouseOverShape(std::string &texName, uint8 &rot, NLMISC::CRGBA &col);
// The URI
std::string Link;
protected:
std::string LinkTitle;
// The main HTML group
CGroupHTML *HTML;
};
// Set the main group
void setHTMLView( CGroupHTML *html);
bool getMouseOverShape(std::string &texName, uint8 &rot, NLMISC::CRGBA &col);
protected:
// The main HTML group
CGroupHTML *HTML;
};
}
#endif // NL_VIEW_LINK_H

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

712
code/nel/src/gui/libwww.cpp Normal file
View file

@ -0,0 +1,712 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// 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/>.
#define NOMINMAX
// LibWWW
extern "C"
{
#include "WWWLib.h" /* Global Library Include file */
#include "WWWApp.h"
#include "WWWInit.h"
}
#include "nel/gui/group_html.h"
#include "nel/gui/libwww_nel_stream.h"
using namespace NLMISC;
// The HText structure for libwww
struct _HText
{
NLGUI::CGroupHTML *Parent;
};
namespace NLGUI
{
/// the cookie value for session identification (nel cookie)
std::string CurrentCookie;
/// store all cookies we receive and resent them depending of the domain
std::map<std::string, std::map<std::string, std::string> > HTTPCookies;
std::string HTTPCurrentDomain; // The current domain that will be used to get which cookies to send
// ***************************************************************************
// Some DTD table
// Here, modify the DTD table to change the HTML parser (add new tags for examples)
#undef HTML_ATTR
#define HTML_ATTR(a,b) { (char*) #b }
HTAttr a_attr[] =
{
HTML_ATTR(A,ACCESSKEY),
HTML_ATTR(A,CHARSET),
HTML_ATTR(A,CLASS),
HTML_ATTR(A,COORDS),
HTML_ATTR(A,DIR),
HTML_ATTR(A,HREF),
HTML_ATTR(A,HREFLANG),
HTML_ATTR(A,ID),
HTML_ATTR(A,NAME),
HTML_ATTR(A,REL),
HTML_ATTR(A,REV),
HTML_ATTR(A,SHAPE),
HTML_ATTR(A,STYLE),
HTML_ATTR(A,TABINDEX),
HTML_ATTR(A,TARGET),
HTML_ATTR(A,TYPE),
HTML_ATTR(A,TITLE),
HTML_ATTR(A,Z_ACTION_CATEGORY),
HTML_ATTR(A,Z_ACTION_PARAMS),
HTML_ATTR(A,Z_ACTION_SHORTCUT),
{ 0 }
};
HTAttr table_attr[] =
{
HTML_ATTR(TABLE,ALIGN),
HTML_ATTR(TABLE,BGCOLOR),
HTML_ATTR(TABLE,BORDER),
HTML_ATTR(TABLE,CELLPADDING),
HTML_ATTR(TABLE,CELLSPACING),
HTML_ATTR(TABLE,CLASS),
HTML_ATTR(TABLE,DIR),
HTML_ATTR(TABLE,FRAME),
HTML_ATTR(TABLE,ID),
HTML_ATTR(TABLE,L_MARGIN),
HTML_ATTR(TABLE,LANG),
HTML_ATTR(TABLE,NOWRAP),
HTML_ATTR(TABLE,RULES),
HTML_ATTR(TABLE,SUMMARY),
HTML_ATTR(TABLE,STYLE),
HTML_ATTR(TABLE,TITLE),
HTML_ATTR(TABLE,VALIGN),
HTML_ATTR(TABLE,WIDTH),
{ 0 }
};
HTAttr tr_attr[] =
{
HTML_ATTR(TR,ALIGN),
HTML_ATTR(TR,BGCOLOR),
HTML_ATTR(TR,L_MARGIN),
HTML_ATTR(TR,NOWRAP),
HTML_ATTR(TR,VALIGN),
{ 0 }
};
HTAttr td_attr[] =
{
HTML_ATTR(TD,ABBR),
HTML_ATTR(TD,ALIGN),
HTML_ATTR(TD,AXIS),
HTML_ATTR(TD,BGCOLOR),
HTML_ATTR(TD,CHAR),
HTML_ATTR(TD,CHAROFF),
HTML_ATTR(TD,CLASS),
HTML_ATTR(TD,COLSPAN),
HTML_ATTR(TD,DIR),
HTML_ATTR(TD,ID),
HTML_ATTR(TD,HEADERS),
HTML_ATTR(TD,HEIGHT),
HTML_ATTR(TD,L_MARGIN),
HTML_ATTR(TD,LANG),
HTML_ATTR(TD,NOWRAP),
HTML_ATTR(TD,ROWSPAN),
HTML_ATTR(TD,SCOPE),
HTML_ATTR(TD,STYLE),
HTML_ATTR(TD,TITLE),
HTML_ATTR(TD,VALIGN),
HTML_ATTR(TD,WIDTH),
{ 0 }
};
HTAttr img_attr[] =
{
HTML_ATTR(IMG,ALIGN),
HTML_ATTR(IMG,ALT),
HTML_ATTR(IMG,BORDER),
HTML_ATTR(IMG,CLASS),
HTML_ATTR(IMG,DIR),
HTML_ATTR(IMG,GLOBAL_COLOR),
HTML_ATTR(IMG,HEIGHT),
HTML_ATTR(IMG,HSPACE),
HTML_ATTR(IMG,ID),
HTML_ATTR(IMG,ISMAP),
HTML_ATTR(IMG,LANG),
HTML_ATTR(IMG,LONGDESC),
HTML_ATTR(IMG,SRC),
HTML_ATTR(IMG,STYLE),
HTML_ATTR(IMG,TITLE),
HTML_ATTR(IMG,USEMAP),
HTML_ATTR(IMG,VSPACE),
HTML_ATTR(IMG,WIDTH),
{ 0 }
};
HTAttr input_attr[] =
{
HTML_ATTR(INPUT,ACCEPT),
HTML_ATTR(INPUT,ACCESSKEY),
HTML_ATTR(INPUT,ALIGN),
HTML_ATTR(INPUT,ALT),
HTML_ATTR(INPUT,CHECKED),
HTML_ATTR(INPUT,CLASS),
HTML_ATTR(INPUT,DIR),
HTML_ATTR(INPUT,DISABLED),
HTML_ATTR(INPUT,GLOBAL_COLOR),
HTML_ATTR(INPUT,ID),
HTML_ATTR(INPUT,LANG),
HTML_ATTR(INPUT,MAXLENGTH),
HTML_ATTR(INPUT,NAME),
HTML_ATTR(INPUT,READONLY),
HTML_ATTR(INPUT,SIZE),
HTML_ATTR(INPUT,SRC),
HTML_ATTR(INPUT,STYLE),
HTML_ATTR(INPUT,TABINDEX),
HTML_ATTR(INPUT,TITLE),
HTML_ATTR(INPUT,TYPE),
HTML_ATTR(INPUT,USEMAP),
HTML_ATTR(INPUT,VALUE),
HTML_ATTR(INPUT,Z_BTN_TMPL),
HTML_ATTR(INPUT,Z_INPUT_TMPL),
HTML_ATTR(INPUT,Z_INPUT_WIDTH),
{ 0 }
};
HTAttr textarea_attr[] =
{
HTML_ATTR(TEXTAREA,CLASS),
HTML_ATTR(TEXTAREA,COLS),
HTML_ATTR(TEXTAREA,DIR),
HTML_ATTR(TEXTAREA,DISABLED),
HTML_ATTR(TEXTAREA,ID),
HTML_ATTR(TEXTAREA,LANG),
HTML_ATTR(TEXTAREA,NAME),
HTML_ATTR(TEXTAREA,READONLY),
HTML_ATTR(TEXTAREA,ROWS),
HTML_ATTR(TEXTAREA,STYLE),
HTML_ATTR(TEXTAREA,TABINDEX),
HTML_ATTR(TEXTAREA,TITLE),
HTML_ATTR(TEXTAREA,Z_INPUT_TMPL),
{ 0 }
};
HTAttr p_attr[] =
{
HTML_ATTR(P,QUICK_HELP_CONDITION),
HTML_ATTR(P,QUICK_HELP_EVENTS),
HTML_ATTR(P,QUICK_HELP_LINK),
HTML_ATTR(P,NAME),
{ 0 }
};
HTAttr div_attr[] =
{
HTML_ATTR(DIV,CLASS),
HTML_ATTR(DIV,ID),
HTML_ATTR(DIV,NAME),
HTML_ATTR(DIV,STYLE),
{ 0 }
};
// ***************************************************************************
void _VerifyLibWWW(const char *function, bool ok, const char *file, int line)
{
if (!ok)
nlwarning("%s(%d) : LIBWWW %s returned a bad status", file, line, function);
}
#define VerifyLibWWW(a,b) _VerifyLibWWW(a,(b)!=FALSE,__FILE__,__LINE__)
// ***************************************************************************
int NelPrinter (const char * fmt, va_list pArgs)
{
char info[1024];
int ret;
ret = vsnprintf(info, sizeof(info), fmt, pArgs);
nlinfo("%s", info);
return ret;
}
// ***************************************************************************
int NelTracer (const char * fmt, va_list pArgs)
{
char err[1024];
int ret;
ret = vsnprintf(err, sizeof(err), fmt, pArgs);
nlwarning ("%s", err);
return ret;
}
// ***************************************************************************
HText * TextNew (HTRequest * request,
HTParentAnchor * /* anchor */,
HTStream * /* output_stream */)
{
HText *text = new HText;
text->Parent = (CGroupHTML *) HTRequest_context(request);
return text;
}
// ***************************************************************************
BOOL TextDelete (HText * me)
{
delete me;
return YES;
}
// ***************************************************************************
void TextBuild (HText * me, HTextStatus status)
{
// Do the work in the class
if (status == HTEXT_BEGIN)
me->Parent->beginBuild ();
else if (status == HTEXT_END)
me->Parent->endBuild ();
}
// ***************************************************************************
void TextAdd (HText * me, const char * buf, int len)
{
// Do the work in the class
me->Parent->addText (buf, len);
}
// ***************************************************************************
void TextLink (HText * me,
int element_number,
int attribute_number,
HTChildAnchor * anchor,
const BOOL * present,
const char ** value)
{
// Do the work in the class
me->Parent->addLink (element_number, attribute_number, anchor, present, value);
}
// ***************************************************************************
// Read a width HTML parameter. "100" or "100%". Returns true if percent (0 ~ 1) else false
bool getPercentage (sint32 &width, float &percent, const char *str)
{
// Percent ?
const char *percentChar;
if ((percentChar = strchr (str, '%')) != NULL)
{
std::string toto = str;
toto = toto.substr (0, percentChar - str);
fromString(toto, percent);
percent /= 100.f;
return true;
}
else
{
fromString(str, width);
return false;
}
}
// ***************************************************************************
CRGBA getColor (const char *color)
{
if (strlen (color) != 7 && strlen (color) != 9 )
return CRGBA::White;
char tmp[3] = {0,0,0};
CRGBA dst;
int value;
tmp[0] = color[1];
tmp[1] = color[2];
sscanf (tmp, "%x", &value);
dst.R = uint8(value);
tmp[0] = color[3];
tmp[1] = color[4];
sscanf (tmp, "%x", &value);
dst.G = uint8(value);
tmp[0] = color[5];
tmp[1] = color[6];
sscanf (tmp, "%x", &value);
dst.B = uint8(value);
if (strlen (color) == 9)
{
tmp[0] = color[7];
tmp[1] = color[8];
sscanf (tmp, "%x", &value);
dst.A = uint8(value);
}
else
{
// extension to html ; try to parse an additional alpha
dst.A = 255;
}
return dst;
}
// ***************************************************************************
void TextBeginElement (HText *me, int element_number, const BOOL *present, const char **value)
{
// Do the work in the class
me->Parent->beginElement (element_number, present, value);
}
// ***************************************************************************
void TextEndElement (HText *me, int element_number)
{
// Do the work in the class
me->Parent->endElement (element_number);
}
// ***************************************************************************
void TextBeginUnparsedElement(HText *me, const char *buffer, int length)
{
me->Parent->beginUnparsedElement(buffer, length);
}
// ***************************************************************************
void TextEndUnparsedElement(HText *me, const char *buffer, int length)
{
me->Parent->endUnparsedElement(buffer, length);
}
// ***************************************************************************
void TextUnparsedEntity (HText * /* HText */, const char *buffer, int length)
{
std::string str(buffer, buffer+length);
nlinfo("Unparsed entity '%s'", str.c_str());
}
// ***************************************************************************
int requestTerminater (HTRequest * request, HTResponse * /* response */,
void * param, int /* status */)
{
/*
Yoyo and Boris: we had to make the request terminate by UID and not by pointer (param is an uid).
Because this method was called at mainLoop time, but for GroupHTML created/deleted at login time !!!
=> Memory Crash.
*/
// TestYoyo
//nlinfo("** requestTerminater(): uid%d", (uint32)param);
// the parameter is actually an uint32
if (param != 0)
{
CGroupHTML::TGroupHtmlByUIDMap::iterator it= CGroupHTML::_GroupHtmlByUID.find((uint32)(size_t)param);
if(it!=CGroupHTML::_GroupHtmlByUID.end())
{
// get the pointer. NB: the refptr should not be NULL
// since object removed from map when deleted
CGroupHTML *gh = it->second;
nlassert(gh);
// callback the browser
gh->requestTerminated(request);
}
}
return HT_OK;
}
// callback called when receiving a cookie
BOOL receiveCookie (HTRequest * /* request */, HTCookie * cookie, void * /* param */)
{
if (strcmp(HTCookie_name(cookie), "ryzomId") == 0)
{
// we receive the ryzom id cookie, store it
CurrentCookie = HTCookie_value(cookie);
}
else
{
// store the id/value cookie
HTTPCookies[HTTPCurrentDomain][HTCookie_name(cookie)] = HTCookie_value(cookie);
// nlwarning("get cookie for domain %s %s=%s", HTTPCurrentDomain.c_str(), HTCookie_name(cookie), HTCookie_value(cookie));
}
return YES;
}
// callback called to add cookie to a request before sending it to the server
HTAssocList *sendCookie (HTRequest * /* request */, void * /* param */)
{
HTAssocList * alist = 0;
if (!CurrentCookie.empty())
{
if(alist == 0) alist = HTAssocList_new(); /* Is deleted by the cookie module */
HTAssocList_addObject(alist, "ryzomId", CurrentCookie.c_str());
}
if(!HTTPCookies[HTTPCurrentDomain].empty())
{
if(alist == 0) alist = HTAssocList_new();
for(std::map<std::string, std::string>::iterator it = HTTPCookies[HTTPCurrentDomain].begin(); it != HTTPCookies[HTTPCurrentDomain].end(); it++)
{
HTAssocList_addObject(alist, it->first.c_str(), it->second.c_str());
// nlwarning("set cookie for domain '%s' %s=%s", HTTPCurrentDomain.c_str(), it->first.c_str(), it->second.c_str());
}
}
return alist;
}
// ***************************************************************************
HTAnchor * TextFindAnchor (HText * /* me */, int /* index */)
{
return NULL;
}
int HTMIME_location_custom (HTRequest * request, HTResponse * response, char * token, char * value)
{
char * location = HTStrip(value);
std::string finalLocation;
//nlinfo("redirect to '%s' '%s'", value, location);
// If not absolute URI (Error) then find the base
if (!HTURL_isAbsolute(location))
{
char * base = HTAnchor_address((HTAnchor *) HTRequest_anchor(request));
location = HTParse(location, base, PARSE_ALL);
//redirection = HTAnchor_findAddress(location);
finalLocation = location;
HT_FREE(base);
HT_FREE(location);
}
else
{
finalLocation = location;
}
//nlinfo("final location '%s'", finalLocation.c_str());
CGroupHTML *gh = (CGroupHTML *) HTRequest_context(request);
gh->setURL(finalLocation);
return HT_OK;
}
// ***************************************************************************
const std::string &setCurrentDomain(const std::string &url)
{
if(url.find("http://") == 0)
{
HTTPCurrentDomain = url.substr(7, url.find('/', 7)-7);
// nlinfo("****cd: %s", HTTPCurrentDomain.c_str());
}
else
{
HTTPCurrentDomain.clear();
// nlinfo("****cd: clear the domain");
}
return HTTPCurrentDomain;
}
void initLibWWW()
{
static bool initialized = false;
if (!initialized)
{
//HTProfile_newNoCacheClient("Ryzom", "1.1");
/* Need our own trace and print functions */
HTPrint_setCallback(NelPrinter);
HTTrace_setCallback(NelTracer);
/* Initiate libwww */
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));
VerifyLibWWW("HTTransport_add", HTTransport_add("local", HT_TP_SINGLE, HTNeLReader_new, HTWriter_new));
// VerifyLibWWW("HTTransport_add", HTTransport_add("local", HT_TP_SINGLE, HTANSIReader_new, HTWriter_new));
// VerifyLibWWW("HTTransport_add", HTTransport_add("local", HT_TP_SINGLE, HTReader_new, HTWriter_new));
/* 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, HTLoadFile, NULL));
// HTProtocol_add("cache", "local", 0, NO, HTLoadCache, NULL);
HTBind_init();
// HTCacheInit(NULL, 20);
/* Setup up transfer coders */
HTFormat_addTransferCoding((char*)"chunked", HTChunkedEncoder, HTChunkedDecoder, 1.0);
/* Setup MIME stream converters */
HTFormat_addConversion("message/rfc822", "*/*", HTMIMEConvert, 1.0, 0.0, 0.0);
HTFormat_addConversion("message/x-rfc822-foot", "*/*", HTMIMEFooter, 1.0, 0.0, 0.0);
HTFormat_addConversion("message/x-rfc822-head", "*/*", HTMIMEHeader, 1.0, 0.0, 0.0);
HTFormat_addConversion("message/x-rfc822-cont", "*/*", HTMIMEContinue, 1.0, 0.0, 0.0);
HTFormat_addConversion("message/x-rfc822-partial","*/*", HTMIMEPartial, 1.0, 0.0, 0.0);
HTFormat_addConversion("multipart/*", "*/*", HTBoundary, 1.0, 0.0, 0.0);
/* Setup HTTP protocol stream */
HTFormat_addConversion("text/x-http", "*/*", HTTPStatus_new, 1.0, 0.0, 0.0);
/* Setup the HTML parser */
HTFormat_addConversion("text/html", "www/present", HTMLPresent, 1.0, 0.0, 0.0);
/* Setup black hole stream */
HTFormat_addConversion("*/*", "www/debug", HTBlackHoleConverter, 1.0, 0.0, 0.0);
HTFormat_addConversion("*/*", "www/present", HTBlackHoleConverter, 0.3, 0.0, 0.0);
/* Set max number of sockets we want open simultaneously */
HTNet_setMaxSocket(32);
/* Register our HTML parser callbacks */
VerifyLibWWW("HText_registerCDCallback", HText_registerCDCallback (TextNew, TextDelete));
VerifyLibWWW("HText_registerBuildCallback", HText_registerBuildCallback (TextBuild));
VerifyLibWWW("HText_registerTextCallback", HText_registerTextCallback(TextAdd));
VerifyLibWWW("HText_registerLinkCallback", HText_registerLinkCallback (TextLink));
VerifyLibWWW("HText_registerElementCallback", HText_registerElementCallback (TextBeginElement, TextEndElement));
VerifyLibWWW("HText_registerUnparsedElementCallback", HText_registerUnparsedElementCallback(TextBeginUnparsedElement, TextEndUnparsedElement));
VerifyLibWWW("HText_registerUnparsedEntityCallback ", HText_registerUnparsedEntityCallback (TextUnparsedEntity ));
/* Register the default set of MIME header parsers */
struct {
const char * string;
HTParserCallback * pHandler;
} fixedHandlers[] = {
{"accept", &HTMIME_accept},
{"accept-charset", &HTMIME_acceptCharset},
{"accept-encoding", &HTMIME_acceptEncoding},
{"accept-language", &HTMIME_acceptLanguage},
{"accept-ranges", &HTMIME_acceptRanges},
{"authorization", NULL},
{"cache-control", &HTMIME_cacheControl},
{"connection", &HTMIME_connection},
{"content-encoding", &HTMIME_contentEncoding},
{"content-length", &HTMIME_contentLength},
{"content-range", &HTMIME_contentRange},
{"content-transfer-encoding", &HTMIME_contentTransferEncoding},
{"content-type", &HTMIME_contentType},
{"digest-MessageDigest", &HTMIME_messageDigest},
{"keep-alive", &HTMIME_keepAlive},
{"link", &HTMIME_link},
{"location", &HTMIME_location_custom},
{"max-forwards", &HTMIME_maxForwards},
{"mime-version", NULL},
{"pragma", &HTMIME_pragma},
{"protocol", &HTMIME_protocol},
{"protocol-info", &HTMIME_protocolInfo},
{"protocol-request", &HTMIME_protocolRequest},
{"proxy-authenticate", &HTMIME_authenticate},
{"proxy-authorization", &HTMIME_proxyAuthorization},
{"public", &HTMIME_public},
{"range", &HTMIME_range},
{"referer", &HTMIME_referer},
{"retry-after", &HTMIME_retryAfter},
{"server", &HTMIME_server},
{"trailer", &HTMIME_trailer},
{"transfer-encoding", &HTMIME_transferEncoding},
{"upgrade", &HTMIME_upgrade},
{"user-agent", &HTMIME_userAgent},
{"vary", &HTMIME_vary},
{"via", &HTMIME_via},
{"warning", &HTMIME_warning},
{"www-authenticate", &HTMIME_authenticate},
{"authentication-info", &HTMIME_authenticationInfo},
{"proxy-authentication-info", &HTMIME_proxyAuthenticationInfo}
};
for (uint i = 0; i < sizeof(fixedHandlers)/sizeof(fixedHandlers[0]); i++)
HTHeader_addParser(fixedHandlers[i].string, NO, fixedHandlers[i].pHandler);
/* Set up default event loop */
HTEventInit();
/* Add our own request terminate handler */
HTNet_addAfter(requestTerminater, NULL, 0, HT_ALL, HT_FILTER_LAST);
/* Setup cookies */
HTCookie_init();
HTCookie_setCookieMode(HTCookieMode(HT_COOKIE_ACCEPT | HT_COOKIE_SEND));
HTCookie_setCallbacks(receiveCookie, NULL, sendCookie, NULL);
/* Start the first request */
/* Go into the event loop... */
// HTEventList_newLoop();
// 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 */
HTBind_caseSensitive(NO);
// Change the HTML DTD
SGML_dtd *HTML_DTD = HTML_dtd ();
HTML_DTD->tags[HTML_TABLE].attributes = table_attr;
HTML_DTD->tags[HTML_TABLE].number_of_attributes = sizeof(table_attr) / sizeof(HTAttr) - 1;
HTML_DTD->tags[HTML_TR].attributes = tr_attr;
HTML_DTD->tags[HTML_TR].number_of_attributes = sizeof(tr_attr) / sizeof(HTAttr) - 1;
HTML_DTD->tags[HTML_TD].attributes = td_attr;
HTML_DTD->tags[HTML_TD].number_of_attributes = sizeof(td_attr) / sizeof(HTAttr) - 1;
HTML_DTD->tags[HTML_IMG].attributes = img_attr;
HTML_DTD->tags[HTML_IMG].number_of_attributes = sizeof(img_attr) / sizeof(HTAttr) - 1;
HTML_DTD->tags[HTML_INPUT].attributes = input_attr;
HTML_DTD->tags[HTML_INPUT].number_of_attributes = sizeof(input_attr) / sizeof(HTAttr) - 1;
HTML_DTD->tags[HTML_TEXTAREA].attributes = textarea_attr;
HTML_DTD->tags[HTML_TEXTAREA].number_of_attributes = sizeof(textarea_attr) / sizeof(HTAttr) - 1;
HTML_DTD->tags[HTML_P].attributes = p_attr;
HTML_DTD->tags[HTML_P].number_of_attributes = sizeof(p_attr) / sizeof(HTAttr) - 1;
HTML_DTD->tags[HTML_A].attributes = a_attr;
HTML_DTD->tags[HTML_A].number_of_attributes = sizeof(a_attr) / sizeof(HTAttr) - 1;
//HTML_DTD->tags[HTML_I].attributes = a_attr;
HTML_DTD->tags[HTML_I].number_of_attributes = 0;
HTML_DTD->tags[HTML_DIV].attributes = div_attr;
HTML_DTD->tags[HTML_DIV].number_of_attributes = sizeof(div_attr) / sizeof(HTAttr) - 1;
// Set a request timeout
// HTHost_setEventTimeout (30000);
// HTHost_setActiveTimeout (30000);
// HTHost_setPersistTimeout (30000);
// Initialized
initialized = true;
}
}
// ***************************************************************************
}

View file

@ -31,7 +31,7 @@ extern "C"
#include "HTMulti.h"
#include "HTNetMan.h"
#include "HTChannl.h"
#include "libwww_nel_stream.h" /* Implemented here */
#include "nel/gui/libwww_nel_stream.h" /* Implemented here */
}
using namespace std;

View file

@ -16,45 +16,48 @@
#include "nel/misc/bit_mem_stream.h"
#include "nel/misc/i18n.h"
#include "view_link.h"
#include "nel/gui/view_link.h"
using namespace std;
using namespace NLMISC;
using namespace NL3D;
// ***************************************************************************
CViewLink::CViewLink (const TCtorParam &param)
: CViewText(param)
namespace NLGUI
{
HTML = NULL;
}
// ***************************************************************************
// ***************************************************************************
void CViewLink::setHTMLView(CGroupHTML *html)
{
HTML = html;
}
// ***************************************************************************
bool CViewLink::getMouseOverShape(string &texName, uint8 &rot, CRGBA &col)
{
if (HTML != NULL)
CViewLink::CViewLink (const TCtorParam &param)
: CViewText(param)
{
if (!LinkTitle.empty())
{
texName = LinkTitle;
rot= 0;
col = CRGBA::White;
return true;
}
HTML = NULL;
}
return false;
// ***************************************************************************
void CViewLink::setHTMLView(CGroupHTML *html)
{
HTML = html;
}
// ***************************************************************************
bool CViewLink::getMouseOverShape(string &texName, uint8 &rot, CRGBA &col)
{
if (HTML != NULL)
{
if (!LinkTitle.empty())
{
texName = LinkTitle;
rot= 0;
col = CRGBA::White;
return true;
}
}
return false;
}
// ***************************************************************************
}
// ***************************************************************************

View file

@ -31,7 +31,7 @@
#include "../net_manager.h"
#include "nel/gui/group_menu.h"
#include "../global.h"
#include "group_html.h"
#include "nel/gui/group_html.h"
//
#include "game_share/inventories.h"

View file

@ -28,7 +28,7 @@
#include "chat_window.h"
#include "people_interraction.h"
#include "nel/gui/group_editbox.h"
#include "group_html.h"
#include "nel/gui/group_html.h"
#include "inventory_manager.h"
// Client Game

File diff suppressed because it is too large Load diff

View file

@ -1,658 +0,0 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// 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/>.
#ifndef CL_GROUP_HTML_H
#define CL_GROUP_HTML_H
#define CURL_STATICLIB 1
#include <curl/curl.h>
#include "nel/misc/types_nl.h"
#include "nel/gui/interface_group.h"
#include "nel/gui/group_scrolltext.h"
#include "nel/gui/group_tree.h"
#include "nel/gui/ctrl_button.h"
#include "nel/gui/group_table.h"
typedef std::map<std::string, std::string> TStyle;
extern "C"
{
#include "WWWInit.h"
}
namespace NLGUI
{
class CCtrlButton;
class CCtrlScroll;
class CGroupList;
class CDBGroupComboBox;
}
class CGroupParagraph;
// HTML group
/**
* Widget to have a resizable scrolltext and its scrollbar
* \author Cyril 'Hulud' Corvazier
* \author Nevrax France
* \date 2002
*/
class CGroupHTML : public CGroupScrollText
{
public:
friend void TextAdd (struct _HText *me, const char * buf, int len);
friend void TextBeginElement (_HText *me, int element_number, const BOOL *present, const char ** value);
friend void TextEndElement (_HText *me, int element_number);
friend void TextLink (struct _HText *me, int element_number, int attribute_number, struct _HTChildAnchor *anchor, const BOOL *present, const char **value);
friend void TextBuild (HText * me, HTextStatus status);
friend void TextBeginUnparsedElement(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);
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 &param);
~CGroupHTML();
// CInterfaceGroup Interface
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
virtual void draw ();
// Events
virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc);
// Browse
virtual void browse (const char *url);
// Refresh
void refresh();
// submit form
void submitForm (uint formId, const char *submitButtonName);
// Browse error
void browseError (const char *msg);
// stop browse
void stopBrowse ();
bool isBrowsing();
void clean() { stopBrowse(); updateRefreshButton(); removeContent(); }
// Update coords
void updateCoords();
// New paragraph
void newParagraph(uint beginSpace);
// End of the paragraph
void endParagraph();
// Timeout
void setTimeout(float tm) {_TimeoutValue= std::max(0.f, tm);}
float getTimeout() const {return (float)_TimeoutValue;}
// Some constants
NLMISC::CRGBA BgColor;
NLMISC::CRGBA ErrorColor;
NLMISC::CRGBA LinkColor;
NLMISC::CRGBA TextColor;
NLMISC::CRGBA H1Color;
NLMISC::CRGBA H2Color;
NLMISC::CRGBA H3Color;
NLMISC::CRGBA H4Color;
NLMISC::CRGBA H5Color;
NLMISC::CRGBA H6Color;
bool ErrorColorGlobalColor;
bool LinkColorGlobalColor;
bool TextColorGlobalColor;
bool H1ColorGlobalColor;
bool H2ColorGlobalColor;
bool H3ColorGlobalColor;
bool H4ColorGlobalColor;
bool H5ColorGlobalColor;
bool H6ColorGlobalColor;
uint TextFontSize;
uint H1FontSize;
uint H2FontSize;
uint H3FontSize;
uint H4FontSize;
uint H5FontSize;
uint H6FontSize;
uint TDBeginSpace;
uint PBeginSpace;
uint LIBeginSpace;
uint ULBeginSpace;
uint LIIndent;
uint ULIndent;
float LineSpaceFontFactor;
std::string DefaultButtonGroup;
std::string DefaultFormTextGroup;
std::string DefaultFormTextAreaGroup;
std::string DefaultFormSelectGroup;
std::string DefaultCheckBoxBitmapNormal;
std::string DefaultCheckBoxBitmapPushed;
std::string DefaultCheckBoxBitmapOver;
std::string DefaultBackgroundBitmapView;
std::string CurrentLinkTitle;
// Browser home
std::string Home;
// Undo browse: Browse the precedent url browsed. no op if none
void browseUndo ();
// Redo browse: Browse the precedent url undoed. no op if none
void browseRedo ();
// clear undo/redo
void clearUndoRedo();
std::string getURL() const { return _URL; }
void setURL(const std::string &url);
int luaBrowse(CLuaState &ls);
int luaRefresh(CLuaState &ls);
int luaRemoveContent(CLuaState &ls);
int luaInsertText(CLuaState &ls);
int luaAddString(CLuaState &ls);
int luaAddImage(CLuaState &ls);
int luaBeginElement(CLuaState &ls);
int luaEndElement(CLuaState &ls);
int luaShowDiv(CLuaState &ls);
REFLECT_EXPORT_START(CGroupHTML, CGroupScrollText)
REFLECT_LUA_METHOD("browse", luaBrowse)
REFLECT_LUA_METHOD("refresh", luaRefresh)
REFLECT_LUA_METHOD("removeContent", luaRemoveContent)
REFLECT_LUA_METHOD("insertText", luaInsertText)
REFLECT_LUA_METHOD("addString", luaAddString)
REFLECT_LUA_METHOD("addImage", luaAddImage)
REFLECT_LUA_METHOD("beginElement", luaBeginElement)
REFLECT_LUA_METHOD("endElement", luaEndElement)
REFLECT_LUA_METHOD("showDiv", luaShowDiv)
REFLECT_STRING("url", getURL, setURL)
REFLECT_FLOAT("timeout", getTimeout, setTimeout)
REFLECT_EXPORT_END
protected :
// \name callback from libwww
// Begin of the parsing of a HTML document
virtual void beginBuild ();
// End of the parsing of a HTML document
virtual void endBuild ();
// A new text block has been parsed
virtual void addText (const char * buf, int len);
// A link has been parsed
virtual void addLink (uint element_number, uint attribute_number, HTChildAnchor *anchor, const BOOL *present, const char **value);
// A new begin HTML element has been parsed (<IMG> for exemple)
virtual void beginElement (uint element_number, const BOOL *present, const char **value);
// A new end HTML element has been parsed (</IMG> for exemple)
virtual void endElement (uint element_number);
// A new begin unparsed element has been found
virtual void beginUnparsedElement(const char *buffer, int length);
// A new end unparsed element has been found
virtual void endUnparsedElement(const char *buffer, int length);
// Add GET params to the url
virtual void addHTTPGetParams (std::string &url, bool trustedDomain);
// Add POST params to the libwww list
virtual void addHTTPPostParams (HTAssocList *formfields, bool trustedDomain);
// the current request is terminated
virtual void requestTerminated(HTRequest *request);
// Get Home URL
virtual std::string home();
// Parse style html tag
TStyle parseStyle(const std::string &str_styles);
// Handle some work at each pass
virtual void handle ();
// \name internal methods
// Add a group in the current parent group
void addGroup (CInterfaceGroup *group, uint beginSpace);
// Get the current parent group
CInterfaceGroup *getCurrentGroup();
// Update current paragraph dependent data
void paragraphChange ();
// Clear the contexts info
void clearContext();
// Translate a char
bool translateChar(ucchar &output, ucchar input, ucchar lastChar) const;
// Add a string in the current paragraph
void addString(const ucstring &str);
// Add an image in the current paragraph
void addImage(const char *image, bool globalColor, bool reloadImg=false);
// Add a text area in the current paragraph
CInterfaceGroup *addTextArea (const std::string &templateName, const char *name, uint rows, uint cols, bool multiLine, const ucstring &content);
// Add a combo box in the current paragraph
CDBGroupComboBox *addComboBox(const std::string &templateName, const char *name);
// Add a button in the current paragraph. actionHandler, actionHandlerParams and tooltip can be NULL.
CCtrlButton *addButton(CCtrlButton::EType type, const std::string &name, const std::string &normalBitmap, const std::string &pushedBitmap,
const std::string &overBitmap, bool useGlobalColor, const char *actionHandler, const char *actionHandlerParams, const char *tooltip);
// Set the background color
void setBackgroundColor (const NLMISC::CRGBA &bgcolor);
// Set the background
void setBackground (const std::string &bgtex, bool scale, bool tile);
// Force the current string to be in a single string
void flushString();
// Set the title
void setTitle (const ucstring &title);
// Lookup a url in local file system
bool lookupLocalFile (std::string &result, const char *url, bool isUrl);
// Delete page content and prepare next page
void removeContent ();
// Current URL
std::string _URL;
// Current DOMAIN
bool _TrustedDomain;
// Title prefix
ucstring _TitlePrefix;
// Title string
ucstring _TitleString;
// Need to browse next update coords..
bool _BrowseNextTime;
bool _PostNextTime;
uint _PostFormId;
std::string _PostFormSubmitButton;
// Browsing..
bool _Browsing;
bool _Connecting;
double _TimeoutValue; // the timeout in seconds
double _ConnectingTimeout;
// minimal embeded lua script support
// Note : any embeded script is executed immediately after the closing
// element has been found
// True when the <lua> element has been encountered
bool _ParsingLua;
bool _IgnoreText;
// the script to execute
std::string _LuaScript;
bool _Object;
std::string _ObjectScript;
// Someone is conecting. We got problem with libwww : 2 connection requests can deadlock the client.
static CGroupHTML *_ConnectingLock;
// LibWWW data
class CLibWWWData *_LibWWW;
// Current paragraph
std::string _DivName;
CGroupParagraph* _Paragraph;
inline CGroupParagraph *getParagraph()
{
return _Paragraph;
/*if (_Paragraph.empty())
return NULL;
return _Paragraph.back();*/
}
// PRE mode
std::vector<bool> _PRE;
inline bool getPRE() const
{
if (_PRE.empty())
return false;
return _PRE.back();
}
// UL mode
std::vector<bool> _UL;
inline bool getUL() const
{
if (_UL.empty())
return false;
return _UL.back();
}
// A mode
std::vector<bool> _A;
inline bool getA() const
{
if (_A.empty())
return false;
return _A.back();
}
// IL mode
bool _LI;
// Current text color
std::vector<NLMISC::CRGBA> _TextColor;
inline const NLMISC::CRGBA &getTextColor() const
{
if (_TextColor.empty())
return TextColor;
return _TextColor.back();
}
// Current global color flag
std::vector<bool> _GlobalColor;
inline bool getGlobalColor() const
{
if (_GlobalColor.empty())
return false;
return _GlobalColor.back();
}
// Current font size
std::vector<uint> _FontSize;
inline uint getFontSize() const
{
if (_FontSize.empty())
return TextFontSize;
return _FontSize.back();
}
// Current link
std::vector<std::string> _Link;
inline const char *getLink() const
{
if (_Link.empty())
return "";
return _Link.back().c_str();
}
std::vector<std::string> _LinkTitle;
inline const char *getLinkTitle() const
{
if (_LinkTitle.empty())
return "";
return _LinkTitle.back().c_str();
}
std::vector<std::string> _LinkClass;
inline const char *getLinkClass() const
{
if (_LinkClass.empty())
return "";
return _LinkClass.back().c_str();
}
// Divs (i.e. interface group)
std::vector<class CInterfaceGroup*> _Divs;
inline CInterfaceGroup *getDiv() const
{
if (_Divs.empty())
return NULL;
return _Divs.back();
}
// Tables
std::vector<class CGroupTable*> _Tables;
inline CGroupTable *getTable() const
{
if (_Tables.empty())
return NULL;
return _Tables.back();
}
// Cells
std::vector<class CGroupCell*> _Cells;
// TR
std::vector<bool> _TR;
inline bool getTR() const
{
if (_TR.empty())
return false;
return _TR.back();
}
// Forms
class CForm
{
public:
class CEntry
{
public:
CEntry ()
{
TextArea = NULL;
Checkbox = NULL;
ComboBox = NULL;
InitialSelection = 0;
}
// Variable name
std::string Name;
// Variable value
ucstring Value;
// Text area group
CInterfaceGroup *TextArea;
// Checkbox
CCtrlButton *Checkbox;
// Combobox group
CDBGroupComboBox *ComboBox;
// select values (for the <select> tag)
std::vector<std::string> SelectValues;
sint InitialSelection; // initial selection for the combo box
};
// The action the form has to perform
std::string Action;
// The text area associated with the form
std::vector<CEntry> Entries;
};
std::vector<CForm> _Forms;
std::vector<CInterfaceGroup *> _Groups;
// Cells parameters
class CCellParams
{
public:
CCellParams () : BgColor(0,0,0,0)
{
Align = CGroupCell::Left;
VAlign = CGroupCell::Top;
LeftMargin = 0;
NoWrap = false;
}
NLMISC::CRGBA BgColor;
std::string Style;
CGroupCell::TAlign Align;
CGroupCell::TVAlign VAlign;
sint32 LeftMargin;
bool NoWrap;
};
std::vector<CCellParams> _CellParams;
// Indentation
uint _Indent;
// Current node is a title
bool _Title;
// Current node must be localized
bool _Localize;
// Current node is a text area
bool _TextArea;
std::string _TextAreaTemplate;
ucstring _TextAreaContent;
std::string _TextAreaName;
uint _TextAreaRow;
uint _TextAreaCols;
// current mode is in select option
bool _SelectOption;
ucstring _SelectOptionStr;
// Current node is a object
std::string _ObjectType;
std::string _ObjectData;
std::string _ObjectMD5Sum;
std::string _ObjectAction;
std::string _TextAreaScript;
// Get last char
ucchar getLastChar() const;
// Current link view
class CViewLink *_CurrentViewLink;
class CViewBitmap *_CurrentViewImage;
// Current group table
class CGroupCell *_CurrentCell;
// The main group
class CGroupListAdaptor *_GroupListAdaptor;
// For auto selecting the node in a BrowseTree bound to this HTML web page
std::string _BrowseTree;
// select the tree node that has the correct url
const std::string &selectTreeNodeRecurs(CGroupTree::SNode *node, const std::string &url);
// search if the action / params match the url. look recurs into procedures
bool actionLaunchUrlRecurs(const std::string &ah, const std::string &params, const std::string &url);
// Browse undo and redo
enum {MaxUrlUndoRedo= 256};
std::string _BrowseUndoButton;
std::string _BrowseRedoButton;
std::string _BrowseRefreshButton;
// _BrowseUrl is different from _URL, in that _URL may change in handle()
std::string _AskedUrl;
std::deque<std::string> _BrowseUndo;
std::deque<std::string> _BrowseRedo;
void pushUrlUndoRedo(const std::string &url);
void doBrowse(const char *url);
void updateUndoRedoButtons();
void updateRefreshButton();
// For Killing request. Associate each CGroupHTML object with a unique ID.
uint32 _GroupHtmlUID;
static uint32 _GroupHtmlUIDPool;
typedef std::map<uint32, NLMISC::CRefPtr<CGroupHTML> > TGroupHtmlByUIDMap;
static TGroupHtmlByUIDMap _GroupHtmlByUID;
private:
// decode all HTML entities
static ucstring decodeHTMLEntities(const ucstring &str);
// ImageDownload system
enum TDataType {ImgType= 0, BnpType};
struct CDataDownload
{
CDataDownload(CURL *c, const std::string &u, FILE *f, TDataType t, CViewBase *i, const std::string &s, const std::string &m) : curl(c), url(u), luaScript(s), md5sum(m), type(t), fp(f)
{
if (t == ImgType) imgs.push_back(i);
}
CURL *curl;
std::string url;
std::string luaScript;
std::string md5sum;
TDataType type;
FILE *fp;
std::vector<CViewBase *> imgs;
};
std::vector<CDataDownload> Curls;
CURLM *MultiCurl;
int RunningCurls;
void initImageDownload();
void checkImageDownload();
void addImageDownload(const std::string &url, CViewBase *img);
std::string localImageName(const std::string &url);
bool isTrustedDomain(const std::string &domain);
void setImage(CViewBase *view, const std::string &file);
// BnpDownload system
void initBnpDownload();
void checkBnpDownload();
bool addBnpDownload(const std::string &url, const std::string &action, const std::string &script, const std::string &md5sum);
std::string localBnpName(const std::string &url);
void releaseDownloads();
void checkDownloads();
};
// adapter group that store y offset for inputs inside an html form
class CGroupHTMLInputOffset : public CInterfaceGroup
{
public:
sint32 Offset;
CGroupHTMLInputOffset(const TCtorParam &param);
virtual bool parse (xmlNodePtr cur, CInterfaceGroup *parentGroup);
};
#endif

View file

@ -21,7 +21,7 @@
#define CL_GROUP_HTML_CS_H
#include "nel/misc/types_nl.h"
#include "group_html.h"
#include "nel/gui/group_html.h"
/**

View file

@ -21,7 +21,7 @@
#define CL_GROUP_HTML_FORUM_H
#include "nel/misc/types_nl.h"
#include "group_html.h"
#include "nel/gui/group_html.h"
/**

View file

@ -21,7 +21,7 @@
#define CL_GROUP_HTML_MAIL_H
#include "nel/misc/types_nl.h"
#include "group_html.h"
#include "nel/gui/group_html.h"
/**

View file

@ -21,7 +21,7 @@
#define CL_GROUP_HTML_QCM_H
#include "nel/misc/types_nl.h"
#include "group_html.h"
#include "nel/gui/group_html.h"
/**

View file

@ -18,7 +18,7 @@
#define CL_GROUP_HTML_WEBIG_H
#include "nel/misc/types_nl.h"
#include "group_html.h"
#include "nel/gui/group_html.h"
/**
* Auth HTML group

View file

@ -23,7 +23,7 @@
#include "../character_cl.h"
#include "nel/gui/action_handler.h"
#include "../entities.h"
#include "group_paragraph.h" // For CCtrlLink
#include "nel/gui/group_paragraph.h" // For CCtrlLink
#include "../net_manager.h"
#include "../string_manager_client.h"
#include "../login.h"

File diff suppressed because it is too large Load diff

View file

@ -1,299 +0,0 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// 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/>.
#ifndef NL_GROUP_PARAGRAPH_H
#define NL_GROUP_PARAGRAPH_H
#include "nel/misc/types_nl.h"
#include "nel/gui/group_frame.h"
#include "nel/gui/view_text.h"
#include "view_link.h"
#include "nel/gui/ctrl_button.h"
class CCtrlLink : public CCtrlButton
{
public:
CCtrlLink (const TCtorParam &param) : CCtrlButton(param)
{}
};
// ----------------------------------------------------------------------------
class CGroupParagraph : public CInterfaceGroup
{
public:
enum EAlign
{
Bottom = 0,
Top,
Left,
Right
};
///constructor
CGroupParagraph(const TCtorParam &param);
// dtor
~CGroupParagraph();
/**
* add a child element to the group at the last position
* 'order' of the element is set to the last order + 1
* \param child : pointer to the child element
*/
void addChild (CViewBase* child, bool deleteOnRemove=true);
/**
* add a link element to the group at the last position
* \param child : pointer to the child element
*/
void addChildLink (CViewLink* child, bool deleteOnRemove=true);
/** add a child before the element at the given index.
* 'order' of the element is set to 0
* \return true if there was enough room for that child
*/
bool addChildAtIndex(CViewBase *child, uint index, bool deleteOnRemove = true);
/**
* add a text child element to the group, using the text template
* \param line : text to be added
* \param color : text color
*/
void addTextChild (const ucstring& line,const NLMISC::CRGBA &textColor, bool multiLine = true);
/**
* add a text child element to the group, using the text template
* \param line : text to be added
*/
void addTextChild (const ucstring& line, bool multiLine = true);
/// Same as adding a text child but the text will be taken from the string manager
void addTextChildID (uint32 id, bool multiLine = true);
// the same, but with id taken from the database
void addTextChildID (const std::string &dbPath, bool multiLine = true);
protected:
void delChild (CViewBase* child);
void delChild(uint index);
public:
CViewBase *getChild(uint index) const { return _Elements[index].Element; }
void deleteAllChildren();
// void removeHead();
// Get the number of children
uint getNumChildren() const { return (uint)_Elements.size(); }
// Get the number of active children
uint getNumActiveChildren() const;
/**
* set the template that will be used to add text;
* \templ : a CViewText object. Only its font size, color and shadow are required.
*/
void setTextTemplate(const CViewText& templ);
/**
* set the template that will be used to add text;
* \templ : a CViewText object. Only its font size, color and shadow are required.
*/
CViewText * getTextTemplatePtr()
{
return &_Templ;
}
/**
* parse the element and initalize it
* \paral cur : pointer to the node describing this element
* \param parentGroup : the parent group of this element
* \return true if success
*/
virtual bool parse (xmlNodePtr cur, CInterfaceGroup * parentGroup);
//virtual uint32 getMemory();
/**
* init or reset the children element coords. Orverloaded from CInterfaceGroup because we begin with the last inserted element here
*/
virtual void updateCoords();
virtual void checkCoords();
virtual void draw();
virtual bool handleEvent (const NLGUI::CEventDescriptor& eventDesc);
virtual void clearViews();
virtual void clearControls();
virtual void clearGroups();
void setSpace (sint32 s) { _Space = s; }
virtual CInterfaceElement* getElement (const std::string &id)
{ return CInterfaceGroup::getElement (id); }
sint32 getNbElement() { return (sint32)_Elements.size(); }
sint32 getSpace() { return _Space; }
void forceSizeW (sint32 newSizeW);
void forceSizeH (sint32 newSizeH);
void setMinW(sint32 minW);
void setMinH(sint32 minH);
sint32 getMinW() const {return _MinW;}
sint32 getMinH() const {return _MinH;}
// set the rank for the element at the given index (used to reinsert container after they have been turned into popups)
void setOrder(uint index, uint order) { _Elements[index].Order = order; }
uint getOrder(uint index) const { return _Elements[index].Order; }
// get element of index or -1 if not found
sint32 getElementIndex(CViewBase* child) const;
// swap 2 entries in the list (and also their orders)
// void swapChildren(uint index1, uint index2);
// deleteOnRemove flag
void setDelOnRemove(uint index, bool delOnRemove);
bool getDelOnRemove(uint index) const;
void setTopSpace(uint topSpace)
{
_TopSpace = topSpace;
setResizeFromChildHMargin(topSpace);
invalidateContent();
};
uint getTopSpace()
{
return _TopSpace;
};
void setIndent(uint indent) { _Indent = indent; }
void setFirstViewIndent(sint indent)
{
_FirstViewIndentView = indent;
invalidateContent();
}
// Set the HTML group used for links
void setBrowseGroup (CInterfaceElement *group)
{
_BrowseGroup = group;
}
/// \from CInterfaceElement
void onInvalidateContent();
sint32 getMaxUsedW() const;
sint32 getMinUsedW() const;
protected:
// Content validated
bool _ContentValidated;
// Where to add next element
EAlign _AddElt;
// Where to align the newly added element
EAlign _Align;
// Space between two elements in pixel
sint32 _Space;
// Text template
CViewText _Templ;
// Current id of the view
sint32 _IdCounter;
// Do we have a color under the element pointed by the mouse
bool _Over;
// If over is true so we have a color
NLMISC::CRGBA _OverColor;
// Current elt over the pointer
sint32 _OverElt;
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.
CViewBase *Element;
bool EltDeleteOnRemove;
};
friend struct CRemoveViewPred;
friend struct CRemoveCtrlPred;
friend struct CRemoveGroupPred;
// The list is forced to be at least this size in updateCoords().
sint32 _MinW;
sint32 _MinH;
// To conserve elements in the order they have been added
// (the element drawn are stored in _views, _contrlos or _childrengroups of cinterfacegroup
std::vector<CElementInfo> _Elements;
// Last parent width
sint32 _LastW;
// Top space
uint _TopSpace;
// Indent
uint _Indent; // Left margin
sint _FirstViewIndentView; // Additionnal left margin for the first view
// A link structure
class CLink
{
public:
CLink(CViewLink *link);
// The link view
CViewLink *Link;
// The three control button
CCtrlLink *CtrlLink[3];
};
// The links
std::vector<CLink> _Links;
// The HTML group used
CInterfaceElement *_BrowseGroup;
private:
// void setHSGroup (CViewBase *child, EAlign addElt, EAlign align);
// void setHSParent(CViewBase *view, EAlign addElt, EAlign align, uint space);
};
#endif // NL_GROUP_PARAGRAPH_H
/* End of group_paragraph.h */

View file

@ -23,8 +23,8 @@
#include "group_quick_help.h"
#include "nel/gui/group_list.h"
#include "group_paragraph.h"
#include "../libwww.h"
#include "nel/gui/group_paragraph.h"
#include "nel/gui/libwww.h"
#include "interface_manager.h"
#include "nel/gui/action_handler.h"
#include "nel/misc/xml_auto_ptr.h"

View file

@ -21,7 +21,7 @@
#define CL_GROUP_QUICK_HELP_H
#include "nel/misc/types_nl.h"
#include "group_html.h"
#include "nel/gui/group_html.h"
/**

View file

@ -26,7 +26,7 @@
#include "dbctrl_sheet.h"
#include "nel/gui/group_container.h"
#include "nel/gui/group_menu.h"
#include "group_html.h"
#include "nel/gui/group_html.h"
#include "../init_main_loop.h"
#include "inventory_manager.h"

View file

@ -70,7 +70,7 @@
#include "group_in_scene_bubble.h"
#include "group_skills.h"
#include "group_compas.h"
#include "group_html.h"
#include "nel/gui/group_html.h"
// Misc
#include "../input.h"

View file

@ -57,7 +57,7 @@
#include "nel/gui/ctrl_col_pick.h"
#include "nel/gui/ctrl_tooltip.h"
#include "nel/gui/ctrl_text_button.h"
#include "group_paragraph.h" // For CCtrlLink
#include "nel/gui/group_paragraph.h" // For CCtrlLink
// DBCtrl
#include "dbctrl_sheet.h"
// Group

View file

@ -60,7 +60,7 @@
#include "nel/misc/i18n.h"
#include "nel/misc/time_nl.h"
#include "skill_manager.h"
#include "group_html.h"
#include "nel/gui/group_html.h"
#include "../net_manager.h"
#include "../user_entity.h"
#include "sphrase_manager.h"

View file

@ -49,7 +49,7 @@
#include "nel/gui/ctrl_scroll.h"
#include "nel/gui/dbgroup_combo_box.h"
#include "nel/gui/group_tab.h"
#include "group_html.h"
#include "nel/gui/group_html.h"
#include "nel/gui/group_header.h"
#include "sphrase_manager.h"
//

View file

@ -21,8 +21,8 @@
#include "interface_manager.h"
#include "nel/gui/view_renderer.h"
#include "nel/gui/ctrl_col_pick.h"
#include "group_paragraph.h"
#include "group_html.h"
#include "nel/gui/group_paragraph.h"
#include "nel/gui/group_html.h"
#include "group_map.h"
//
#include "nel/misc/xml_auto_ptr.h"

View file

@ -1,708 +0,0 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// 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/>.
// LibWWW
extern "C"
{
#include "WWWLib.h" /* Global Library Include file */
#include "WWWApp.h"
#include "WWWInit.h"
}
#include "interface_v3/group_html.h"
#include "interface_v3/libwww_nel_stream.h"
using namespace NLMISC;
/// the cookie value for session identification (nel cookie)
std::string CurrentCookie;
/// store all cookies we receive and resent them depending of the domain
std::map<std::string, std::map<std::string, std::string> > HTTPCookies;
std::string HTTPCurrentDomain; // The current domain that will be used to get which cookies to send
// ***************************************************************************
// The HText structure for libwww
struct _HText
{
CGroupHTML *Parent;
};
// ***************************************************************************
// Some DTD table
// Here, modify the DTD table to change the HTML parser (add new tags for examples)
#undef HTML_ATTR
#define HTML_ATTR(a,b) { (char*) #b }
HTAttr a_attr[] =
{
HTML_ATTR(A,ACCESSKEY),
HTML_ATTR(A,CHARSET),
HTML_ATTR(A,CLASS),
HTML_ATTR(A,COORDS),
HTML_ATTR(A,DIR),
HTML_ATTR(A,HREF),
HTML_ATTR(A,HREFLANG),
HTML_ATTR(A,ID),
HTML_ATTR(A,NAME),
HTML_ATTR(A,REL),
HTML_ATTR(A,REV),
HTML_ATTR(A,SHAPE),
HTML_ATTR(A,STYLE),
HTML_ATTR(A,TABINDEX),
HTML_ATTR(A,TARGET),
HTML_ATTR(A,TYPE),
HTML_ATTR(A,TITLE),
HTML_ATTR(A,Z_ACTION_CATEGORY),
HTML_ATTR(A,Z_ACTION_PARAMS),
HTML_ATTR(A,Z_ACTION_SHORTCUT),
{ 0 }
};
HTAttr table_attr[] =
{
HTML_ATTR(TABLE,ALIGN),
HTML_ATTR(TABLE,BGCOLOR),
HTML_ATTR(TABLE,BORDER),
HTML_ATTR(TABLE,CELLPADDING),
HTML_ATTR(TABLE,CELLSPACING),
HTML_ATTR(TABLE,CLASS),
HTML_ATTR(TABLE,DIR),
HTML_ATTR(TABLE,FRAME),
HTML_ATTR(TABLE,ID),
HTML_ATTR(TABLE,L_MARGIN),
HTML_ATTR(TABLE,LANG),
HTML_ATTR(TABLE,NOWRAP),
HTML_ATTR(TABLE,RULES),
HTML_ATTR(TABLE,SUMMARY),
HTML_ATTR(TABLE,STYLE),
HTML_ATTR(TABLE,TITLE),
HTML_ATTR(TABLE,VALIGN),
HTML_ATTR(TABLE,WIDTH),
{ 0 }
};
HTAttr tr_attr[] =
{
HTML_ATTR(TR,ALIGN),
HTML_ATTR(TR,BGCOLOR),
HTML_ATTR(TR,L_MARGIN),
HTML_ATTR(TR,NOWRAP),
HTML_ATTR(TR,VALIGN),
{ 0 }
};
HTAttr td_attr[] =
{
HTML_ATTR(TD,ABBR),
HTML_ATTR(TD,ALIGN),
HTML_ATTR(TD,AXIS),
HTML_ATTR(TD,BGCOLOR),
HTML_ATTR(TD,CHAR),
HTML_ATTR(TD,CHAROFF),
HTML_ATTR(TD,CLASS),
HTML_ATTR(TD,COLSPAN),
HTML_ATTR(TD,DIR),
HTML_ATTR(TD,ID),
HTML_ATTR(TD,HEADERS),
HTML_ATTR(TD,HEIGHT),
HTML_ATTR(TD,L_MARGIN),
HTML_ATTR(TD,LANG),
HTML_ATTR(TD,NOWRAP),
HTML_ATTR(TD,ROWSPAN),
HTML_ATTR(TD,SCOPE),
HTML_ATTR(TD,STYLE),
HTML_ATTR(TD,TITLE),
HTML_ATTR(TD,VALIGN),
HTML_ATTR(TD,WIDTH),
{ 0 }
};
HTAttr img_attr[] =
{
HTML_ATTR(IMG,ALIGN),
HTML_ATTR(IMG,ALT),
HTML_ATTR(IMG,BORDER),
HTML_ATTR(IMG,CLASS),
HTML_ATTR(IMG,DIR),
HTML_ATTR(IMG,GLOBAL_COLOR),
HTML_ATTR(IMG,HEIGHT),
HTML_ATTR(IMG,HSPACE),
HTML_ATTR(IMG,ID),
HTML_ATTR(IMG,ISMAP),
HTML_ATTR(IMG,LANG),
HTML_ATTR(IMG,LONGDESC),
HTML_ATTR(IMG,SRC),
HTML_ATTR(IMG,STYLE),
HTML_ATTR(IMG,TITLE),
HTML_ATTR(IMG,USEMAP),
HTML_ATTR(IMG,VSPACE),
HTML_ATTR(IMG,WIDTH),
{ 0 }
};
HTAttr input_attr[] =
{
HTML_ATTR(INPUT,ACCEPT),
HTML_ATTR(INPUT,ACCESSKEY),
HTML_ATTR(INPUT,ALIGN),
HTML_ATTR(INPUT,ALT),
HTML_ATTR(INPUT,CHECKED),
HTML_ATTR(INPUT,CLASS),
HTML_ATTR(INPUT,DIR),
HTML_ATTR(INPUT,DISABLED),
HTML_ATTR(INPUT,GLOBAL_COLOR),
HTML_ATTR(INPUT,ID),
HTML_ATTR(INPUT,LANG),
HTML_ATTR(INPUT,MAXLENGTH),
HTML_ATTR(INPUT,NAME),
HTML_ATTR(INPUT,READONLY),
HTML_ATTR(INPUT,SIZE),
HTML_ATTR(INPUT,SRC),
HTML_ATTR(INPUT,STYLE),
HTML_ATTR(INPUT,TABINDEX),
HTML_ATTR(INPUT,TITLE),
HTML_ATTR(INPUT,TYPE),
HTML_ATTR(INPUT,USEMAP),
HTML_ATTR(INPUT,VALUE),
HTML_ATTR(INPUT,Z_BTN_TMPL),
HTML_ATTR(INPUT,Z_INPUT_TMPL),
HTML_ATTR(INPUT,Z_INPUT_WIDTH),
{ 0 }
};
HTAttr textarea_attr[] =
{
HTML_ATTR(TEXTAREA,CLASS),
HTML_ATTR(TEXTAREA,COLS),
HTML_ATTR(TEXTAREA,DIR),
HTML_ATTR(TEXTAREA,DISABLED),
HTML_ATTR(TEXTAREA,ID),
HTML_ATTR(TEXTAREA,LANG),
HTML_ATTR(TEXTAREA,NAME),
HTML_ATTR(TEXTAREA,READONLY),
HTML_ATTR(TEXTAREA,ROWS),
HTML_ATTR(TEXTAREA,STYLE),
HTML_ATTR(TEXTAREA,TABINDEX),
HTML_ATTR(TEXTAREA,TITLE),
HTML_ATTR(TEXTAREA,Z_INPUT_TMPL),
{ 0 }
};
HTAttr p_attr[] =
{
HTML_ATTR(P,QUICK_HELP_CONDITION),
HTML_ATTR(P,QUICK_HELP_EVENTS),
HTML_ATTR(P,QUICK_HELP_LINK),
HTML_ATTR(P,NAME),
{ 0 }
};
HTAttr div_attr[] =
{
HTML_ATTR(DIV,CLASS),
HTML_ATTR(DIV,ID),
HTML_ATTR(DIV,NAME),
HTML_ATTR(DIV,STYLE),
{ 0 }
};
// ***************************************************************************
void _VerifyLibWWW(const char *function, bool ok, const char *file, int line)
{
if (!ok)
nlwarning("%s(%d) : LIBWWW %s returned a bad status", file, line, function);
}
#define VerifyLibWWW(a,b) _VerifyLibWWW(a,(b)!=FALSE,__FILE__,__LINE__)
// ***************************************************************************
int NelPrinter (const char * fmt, va_list pArgs)
{
char info[1024];
int ret;
ret = vsnprintf(info, sizeof(info), fmt, pArgs);
nlinfo("%s", info);
return ret;
}
// ***************************************************************************
int NelTracer (const char * fmt, va_list pArgs)
{
char err[1024];
int ret;
ret = vsnprintf(err, sizeof(err), fmt, pArgs);
nlwarning ("%s", err);
return ret;
}
// ***************************************************************************
HText * TextNew (HTRequest * request,
HTParentAnchor * /* anchor */,
HTStream * /* output_stream */)
{
HText *text = new HText;
text->Parent = (CGroupHTML *) HTRequest_context(request);
return text;
}
// ***************************************************************************
BOOL TextDelete (HText * me)
{
delete me;
return YES;
}
// ***************************************************************************
void TextBuild (HText * me, HTextStatus status)
{
// Do the work in the class
if (status == HTEXT_BEGIN)
me->Parent->beginBuild ();
else if (status == HTEXT_END)
me->Parent->endBuild ();
}
// ***************************************************************************
void TextAdd (HText * me, const char * buf, int len)
{
// Do the work in the class
me->Parent->addText (buf, len);
}
// ***************************************************************************
void TextLink (HText * me,
int element_number,
int attribute_number,
HTChildAnchor * anchor,
const BOOL * present,
const char ** value)
{
// Do the work in the class
me->Parent->addLink (element_number, attribute_number, anchor, present, value);
}
// ***************************************************************************
// Read a width HTML parameter. "100" or "100%". Returns true if percent (0 ~ 1) else false
bool getPercentage (sint32 &width, float &percent, const char *str)
{
// Percent ?
const char *percentChar;
if ((percentChar = strchr (str, '%')) != NULL)
{
std::string toto = str;
toto = toto.substr (0, percentChar - str);
fromString(toto, percent);
percent /= 100.f;
return true;
}
else
{
fromString(str, width);
return false;
}
}
// ***************************************************************************
CRGBA getColor (const char *color)
{
if (strlen (color) != 7 && strlen (color) != 9 )
return CRGBA::White;
char tmp[3] = {0,0,0};
CRGBA dst;
int value;
tmp[0] = color[1];
tmp[1] = color[2];
sscanf (tmp, "%x", &value);
dst.R = uint8(value);
tmp[0] = color[3];
tmp[1] = color[4];
sscanf (tmp, "%x", &value);
dst.G = uint8(value);
tmp[0] = color[5];
tmp[1] = color[6];
sscanf (tmp, "%x", &value);
dst.B = uint8(value);
if (strlen (color) == 9)
{
tmp[0] = color[7];
tmp[1] = color[8];
sscanf (tmp, "%x", &value);
dst.A = uint8(value);
}
else
{
// extension to html ; try to parse an additional alpha
dst.A = 255;
}
return dst;
}
// ***************************************************************************
void TextBeginElement (HText *me, int element_number, const BOOL *present, const char **value)
{
// Do the work in the class
me->Parent->beginElement (element_number, present, value);
}
// ***************************************************************************
void TextEndElement (HText *me, int element_number)
{
// Do the work in the class
me->Parent->endElement (element_number);
}
// ***************************************************************************
void TextBeginUnparsedElement(HText *me, const char *buffer, int length)
{
me->Parent->beginUnparsedElement(buffer, length);
}
// ***************************************************************************
void TextEndUnparsedElement(HText *me, const char *buffer, int length)
{
me->Parent->endUnparsedElement(buffer, length);
}
// ***************************************************************************
void TextUnparsedEntity (HText * /* HText */, const char *buffer, int length)
{
std::string str(buffer, buffer+length);
nlinfo("Unparsed entity '%s'", str.c_str());
}
// ***************************************************************************
int requestTerminater (HTRequest * request, HTResponse * /* response */,
void * param, int /* status */)
{
/*
Yoyo and Boris: we had to make the request terminate by UID and not by pointer (param is an uid).
Because this method was called at mainLoop time, but for GroupHTML created/deleted at login time !!!
=> Memory Crash.
*/
// TestYoyo
//nlinfo("** requestTerminater(): uid%d", (uint32)param);
// the parameter is actually an uint32
if (param != 0)
{
CGroupHTML::TGroupHtmlByUIDMap::iterator it= CGroupHTML::_GroupHtmlByUID.find((uint32)(size_t)param);
if(it!=CGroupHTML::_GroupHtmlByUID.end())
{
// get the pointer. NB: the refptr should not be NULL
// since object removed from map when deleted
CGroupHTML *gh = it->second;
nlassert(gh);
// callback the browser
gh->requestTerminated(request);
}
}
return HT_OK;
}
// callback called when receiving a cookie
BOOL receiveCookie (HTRequest * /* request */, HTCookie * cookie, void * /* param */)
{
if (strcmp(HTCookie_name(cookie), "ryzomId") == 0)
{
// we receive the ryzom id cookie, store it
CurrentCookie = HTCookie_value(cookie);
}
else
{
// store the id/value cookie
HTTPCookies[HTTPCurrentDomain][HTCookie_name(cookie)] = HTCookie_value(cookie);
// nlwarning("get cookie for domain %s %s=%s", HTTPCurrentDomain.c_str(), HTCookie_name(cookie), HTCookie_value(cookie));
}
return YES;
}
// callback called to add cookie to a request before sending it to the server
HTAssocList *sendCookie (HTRequest * /* request */, void * /* param */)
{
HTAssocList * alist = 0;
if (!CurrentCookie.empty())
{
if(alist == 0) alist = HTAssocList_new(); /* Is deleted by the cookie module */
HTAssocList_addObject(alist, "ryzomId", CurrentCookie.c_str());
}
if(!HTTPCookies[HTTPCurrentDomain].empty())
{
if(alist == 0) alist = HTAssocList_new();
for(std::map<std::string, std::string>::iterator it = HTTPCookies[HTTPCurrentDomain].begin(); it != HTTPCookies[HTTPCurrentDomain].end(); it++)
{
HTAssocList_addObject(alist, it->first.c_str(), it->second.c_str());
// nlwarning("set cookie for domain '%s' %s=%s", HTTPCurrentDomain.c_str(), it->first.c_str(), it->second.c_str());
}
}
return alist;
}
// ***************************************************************************
HTAnchor * TextFindAnchor (HText * /* me */, int /* index */)
{
return NULL;
}
int HTMIME_location_custom (HTRequest * request, HTResponse * response, char * token, char * value)
{
char * location = HTStrip(value);
std::string finalLocation;
//nlinfo("redirect to '%s' '%s'", value, location);
// If not absolute URI (Error) then find the base
if (!HTURL_isAbsolute(location))
{
char * base = HTAnchor_address((HTAnchor *) HTRequest_anchor(request));
location = HTParse(location, base, PARSE_ALL);
//redirection = HTAnchor_findAddress(location);
finalLocation = location;
HT_FREE(base);
HT_FREE(location);
}
else
{
finalLocation = location;
}
//nlinfo("final location '%s'", finalLocation.c_str());
CGroupHTML *gh = (CGroupHTML *) HTRequest_context(request);
gh->setURL(finalLocation);
return HT_OK;
}
// ***************************************************************************
const std::string &setCurrentDomain(const std::string &url)
{
if(url.find("http://") == 0)
{
HTTPCurrentDomain = url.substr(7, url.find('/', 7)-7);
// nlinfo("****cd: %s", HTTPCurrentDomain.c_str());
}
else
{
HTTPCurrentDomain.clear();
// nlinfo("****cd: clear the domain");
}
return HTTPCurrentDomain;
}
void initLibWWW()
{
static bool initialized = false;
if (!initialized)
{
//HTProfile_newNoCacheClient("Ryzom", "1.1");
/* Need our own trace and print functions */
HTPrint_setCallback(NelPrinter);
HTTrace_setCallback(NelTracer);
/* Initiate libwww */
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));
VerifyLibWWW("HTTransport_add", HTTransport_add("local", HT_TP_SINGLE, HTNeLReader_new, HTWriter_new));
// VerifyLibWWW("HTTransport_add", HTTransport_add("local", HT_TP_SINGLE, HTANSIReader_new, HTWriter_new));
// VerifyLibWWW("HTTransport_add", HTTransport_add("local", HT_TP_SINGLE, HTReader_new, HTWriter_new));
/* 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, HTLoadFile, NULL));
// HTProtocol_add("cache", "local", 0, NO, HTLoadCache, NULL);
HTBind_init();
// HTCacheInit(NULL, 20);
/* Setup up transfer coders */
HTFormat_addTransferCoding((char*)"chunked", HTChunkedEncoder, HTChunkedDecoder, 1.0);
/* Setup MIME stream converters */
HTFormat_addConversion("message/rfc822", "*/*", HTMIMEConvert, 1.0, 0.0, 0.0);
HTFormat_addConversion("message/x-rfc822-foot", "*/*", HTMIMEFooter, 1.0, 0.0, 0.0);
HTFormat_addConversion("message/x-rfc822-head", "*/*", HTMIMEHeader, 1.0, 0.0, 0.0);
HTFormat_addConversion("message/x-rfc822-cont", "*/*", HTMIMEContinue, 1.0, 0.0, 0.0);
HTFormat_addConversion("message/x-rfc822-partial","*/*", HTMIMEPartial, 1.0, 0.0, 0.0);
HTFormat_addConversion("multipart/*", "*/*", HTBoundary, 1.0, 0.0, 0.0);
/* Setup HTTP protocol stream */
HTFormat_addConversion("text/x-http", "*/*", HTTPStatus_new, 1.0, 0.0, 0.0);
/* Setup the HTML parser */
HTFormat_addConversion("text/html", "www/present", HTMLPresent, 1.0, 0.0, 0.0);
/* Setup black hole stream */
HTFormat_addConversion("*/*", "www/debug", HTBlackHoleConverter, 1.0, 0.0, 0.0);
HTFormat_addConversion("*/*", "www/present", HTBlackHoleConverter, 0.3, 0.0, 0.0);
/* Set max number of sockets we want open simultaneously */
HTNet_setMaxSocket(32);
/* Register our HTML parser callbacks */
VerifyLibWWW("HText_registerCDCallback", HText_registerCDCallback (TextNew, TextDelete));
VerifyLibWWW("HText_registerBuildCallback", HText_registerBuildCallback (TextBuild));
VerifyLibWWW("HText_registerTextCallback", HText_registerTextCallback(TextAdd));
VerifyLibWWW("HText_registerLinkCallback", HText_registerLinkCallback (TextLink));
VerifyLibWWW("HText_registerElementCallback", HText_registerElementCallback (TextBeginElement, TextEndElement));
VerifyLibWWW("HText_registerUnparsedElementCallback", HText_registerUnparsedElementCallback(TextBeginUnparsedElement, TextEndUnparsedElement));
VerifyLibWWW("HText_registerUnparsedEntityCallback ", HText_registerUnparsedEntityCallback (TextUnparsedEntity ));
/* Register the default set of MIME header parsers */
struct {
const char * string;
HTParserCallback * pHandler;
} fixedHandlers[] = {
{"accept", &HTMIME_accept},
{"accept-charset", &HTMIME_acceptCharset},
{"accept-encoding", &HTMIME_acceptEncoding},
{"accept-language", &HTMIME_acceptLanguage},
{"accept-ranges", &HTMIME_acceptRanges},
{"authorization", NULL},
{"cache-control", &HTMIME_cacheControl},
{"connection", &HTMIME_connection},
{"content-encoding", &HTMIME_contentEncoding},
{"content-length", &HTMIME_contentLength},
{"content-range", &HTMIME_contentRange},
{"content-transfer-encoding", &HTMIME_contentTransferEncoding},
{"content-type", &HTMIME_contentType},
{"digest-MessageDigest", &HTMIME_messageDigest},
{"keep-alive", &HTMIME_keepAlive},
{"link", &HTMIME_link},
{"location", &HTMIME_location_custom},
{"max-forwards", &HTMIME_maxForwards},
{"mime-version", NULL},
{"pragma", &HTMIME_pragma},
{"protocol", &HTMIME_protocol},
{"protocol-info", &HTMIME_protocolInfo},
{"protocol-request", &HTMIME_protocolRequest},
{"proxy-authenticate", &HTMIME_authenticate},
{"proxy-authorization", &HTMIME_proxyAuthorization},
{"public", &HTMIME_public},
{"range", &HTMIME_range},
{"referer", &HTMIME_referer},
{"retry-after", &HTMIME_retryAfter},
{"server", &HTMIME_server},
{"trailer", &HTMIME_trailer},
{"transfer-encoding", &HTMIME_transferEncoding},
{"upgrade", &HTMIME_upgrade},
{"user-agent", &HTMIME_userAgent},
{"vary", &HTMIME_vary},
{"via", &HTMIME_via},
{"warning", &HTMIME_warning},
{"www-authenticate", &HTMIME_authenticate},
{"authentication-info", &HTMIME_authenticationInfo},
{"proxy-authentication-info", &HTMIME_proxyAuthenticationInfo}
};
for (uint i = 0; i < sizeof(fixedHandlers)/sizeof(fixedHandlers[0]); i++)
HTHeader_addParser(fixedHandlers[i].string, NO, fixedHandlers[i].pHandler);
/* Set up default event loop */
HTEventInit();
/* Add our own request terminate handler */
HTNet_addAfter(requestTerminater, NULL, 0, HT_ALL, HT_FILTER_LAST);
/* Setup cookies */
HTCookie_init();
HTCookie_setCookieMode(HTCookieMode(HT_COOKIE_ACCEPT | HT_COOKIE_SEND));
HTCookie_setCallbacks(receiveCookie, NULL, sendCookie, NULL);
/* Start the first request */
/* Go into the event loop... */
// HTEventList_newLoop();
// 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 */
HTBind_caseSensitive(NO);
// Change the HTML DTD
SGML_dtd *HTML_DTD = HTML_dtd ();
HTML_DTD->tags[HTML_TABLE].attributes = table_attr;
HTML_DTD->tags[HTML_TABLE].number_of_attributes = sizeof(table_attr) / sizeof(HTAttr) - 1;
HTML_DTD->tags[HTML_TR].attributes = tr_attr;
HTML_DTD->tags[HTML_TR].number_of_attributes = sizeof(tr_attr) / sizeof(HTAttr) - 1;
HTML_DTD->tags[HTML_TD].attributes = td_attr;
HTML_DTD->tags[HTML_TD].number_of_attributes = sizeof(td_attr) / sizeof(HTAttr) - 1;
HTML_DTD->tags[HTML_IMG].attributes = img_attr;
HTML_DTD->tags[HTML_IMG].number_of_attributes = sizeof(img_attr) / sizeof(HTAttr) - 1;
HTML_DTD->tags[HTML_INPUT].attributes = input_attr;
HTML_DTD->tags[HTML_INPUT].number_of_attributes = sizeof(input_attr) / sizeof(HTAttr) - 1;
HTML_DTD->tags[HTML_TEXTAREA].attributes = textarea_attr;
HTML_DTD->tags[HTML_TEXTAREA].number_of_attributes = sizeof(textarea_attr) / sizeof(HTAttr) - 1;
HTML_DTD->tags[HTML_P].attributes = p_attr;
HTML_DTD->tags[HTML_P].number_of_attributes = sizeof(p_attr) / sizeof(HTAttr) - 1;
HTML_DTD->tags[HTML_A].attributes = a_attr;
HTML_DTD->tags[HTML_A].number_of_attributes = sizeof(a_attr) / sizeof(HTAttr) - 1;
//HTML_DTD->tags[HTML_I].attributes = a_attr;
HTML_DTD->tags[HTML_I].number_of_attributes = 0;
HTML_DTD->tags[HTML_DIV].attributes = div_attr;
HTML_DTD->tags[HTML_DIV].number_of_attributes = sizeof(div_attr) / sizeof(HTAttr) - 1;
// Set a request timeout
// HTHost_setEventTimeout (30000);
// HTHost_setActiveTimeout (30000);
// HTHost_setPersistTimeout (30000);
// Initialized
initialized = true;
}
}
// ***************************************************************************

View file

@ -1,283 +0,0 @@
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
// Copyright (C) 2010 Winch Gate Property Limited
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// 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/>.
#ifndef CL_LIB_WWW_H
#define CL_LIB_WWW_H
extern "C"
{
#include "WWWInit.h"
}
namespace NLGUI
{
class CCtrlBaseButton;
class CCtrlScroll;
class CGroupList;
}
// ***************************************************************************
// Init the libwww
void initLibWWW();
// Get an url and setup a local domain
const std::string &setCurrentDomain(const std::string &url);
extern std::string CurrentCookie;
// ***************************************************************************
// Some DTD table
// Here, modify the DTD table to change the HTML parser (add new tags for exemples)
#undef HTML_ATTR
#define HTML_ATTR(t,a) MY_HTML_##t##_##a
enum
{
HTML_ATTR(A,ACCESSKEY) = 0,
HTML_ATTR(A,CHARSET),
HTML_ATTR(A,CLASS),
HTML_ATTR(A,COORDS),
HTML_ATTR(A,DIR),
HTML_ATTR(A,HREF),
HTML_ATTR(A,HREFLANG),
HTML_ATTR(A,ID),
HTML_ATTR(A,NAME),
HTML_ATTR(A,REL),
HTML_ATTR(A,REV),
HTML_ATTR(A,SHAPE),
HTML_ATTR(A,STYLE),
HTML_ATTR(A,TABINDEX),
HTML_ATTR(A,TARGET),
HTML_ATTR(A,TYPE),
HTML_ATTR(A,TITLE),
HTML_ATTR(A,Z_ACTION_CATEGORY),
HTML_ATTR(A,Z_ACTION_PARAMS),
HTML_ATTR(A,Z_ACTION_SHORTCUT),
};
enum
{
HTML_ATTR(TABLE,ALIGN) = 0,
HTML_ATTR(TABLE,BGCOLOR),
HTML_ATTR(TABLE,BORDER),
HTML_ATTR(TABLE,CELLPADDING),
HTML_ATTR(TABLE,CELLSPACING),
HTML_ATTR(TABLE,CLASS),
HTML_ATTR(TABLE,DIR),
HTML_ATTR(TABLE,FRAME),
HTML_ATTR(TABLE,ID),
HTML_ATTR(TABLE,L_MARGIN),
HTML_ATTR(TABLE,LANG),
HTML_ATTR(TABLE,NOWRAP),
HTML_ATTR(TABLE,RULES),
HTML_ATTR(TABLE,SUMMARY),
HTML_ATTR(TABLE,STYLE),
HTML_ATTR(TABLE,TITLE),
HTML_ATTR(TABLE,VALIGN),
HTML_ATTR(TABLE,WIDTH)
};
enum
{
HTML_ATTR(TR,ALIGN) = 0,
HTML_ATTR(TR,BGCOLOR),
HTML_ATTR(TR,L_MARGIN),
HTML_ATTR(TR,NOWRAP),
HTML_ATTR(TR,VALIGN),
};
enum
{
HTML_ATTR(TD,ABBR) = 0,
HTML_ATTR(TD,ALIGN),
HTML_ATTR(TD,AXIS),
HTML_ATTR(TD,BGCOLOR),
HTML_ATTR(TD,CHAR),
HTML_ATTR(TD,CHAROFF),
HTML_ATTR(TD,CLASS),
HTML_ATTR(TD,COLSPAN),
HTML_ATTR(TD,DIR),
HTML_ATTR(TD,ID),
HTML_ATTR(TD,HEADERS),
HTML_ATTR(TD,HEIGHT),
HTML_ATTR(TD,L_MARGIN),
HTML_ATTR(TD,LANG),
HTML_ATTR(TD,NOWRAP),
HTML_ATTR(TD,ROWSPAN),
HTML_ATTR(TD,SCOPE),
HTML_ATTR(TD,STYLE),
HTML_ATTR(TD,TITLE),
HTML_ATTR(TD,VALIGN),
HTML_ATTR(TD,WIDTH),
};
enum
{
HTML_ATTR(IMG,ALIGN) = 0,
HTML_ATTR(IMG,ALT),
HTML_ATTR(IMG,BORDER),
HTML_ATTR(IMG,CLASS),
HTML_ATTR(IMG,DIR),
HTML_ATTR(IMG,GLOBAL_COLOR),
HTML_ATTR(IMG,HEIGHT),
HTML_ATTR(IMG,HSPACE),
HTML_ATTR(IMG,ID),
HTML_ATTR(IMG,ISMAP),
HTML_ATTR(IMG,LANG),
HTML_ATTR(IMG,LONGDESC),
HTML_ATTR(IMG,SRC),
HTML_ATTR(IMG,STYLE),
HTML_ATTR(IMG,TITLE),
HTML_ATTR(IMG,USEMAP),
HTML_ATTR(IMG,VSPACE),
HTML_ATTR(IMG,WIDTH),
};
enum
{
HTML_ATTR(INPUT,ACCEPT) = 0,
HTML_ATTR(INPUT,ACCESSKEY),
HTML_ATTR(INPUT,ALIGN),
HTML_ATTR(INPUT,ALT),
HTML_ATTR(INPUT,CHECKED),
HTML_ATTR(INPUT,CLASS),
HTML_ATTR(INPUT,DIR),
HTML_ATTR(INPUT,DISABLED),
HTML_ATTR(INPUT,GLOBAL_COLOR),
HTML_ATTR(INPUT,ID),
HTML_ATTR(INPUT,LANG),
HTML_ATTR(INPUT,MAXLENGTH),
HTML_ATTR(INPUT,NAME),
HTML_ATTR(INPUT,READONLY),
HTML_ATTR(INPUT,SIZE),
HTML_ATTR(INPUT,SRC),
HTML_ATTR(INPUT,STYLE),
HTML_ATTR(INPUT,TABINDEX),
HTML_ATTR(INPUT,TITLE),
HTML_ATTR(INPUT,TYPE),
HTML_ATTR(INPUT,USEMAP),
HTML_ATTR(INPUT,VALUE),
HTML_ATTR(INPUT,Z_BTN_TMPL),
HTML_ATTR(INPUT,Z_INPUT_TMPL),
HTML_ATTR(INPUT,Z_INPUT_WIDTH),
};
enum
{
HTML_ATTR(TEXTAREA,CLASS) = 0,
HTML_ATTR(TEXTAREA,COLS),
HTML_ATTR(TEXTAREA,DIR),
HTML_ATTR(TEXTAREA,DISABLED),
HTML_ATTR(TEXTAREA,ID),
HTML_ATTR(TEXTAREA,LANG),
HTML_ATTR(TEXTAREA,NAME),
HTML_ATTR(TEXTAREA,READONLY),
HTML_ATTR(TEXTAREA,ROWS),
HTML_ATTR(TEXTAREA,STYLE),
HTML_ATTR(TEXTAREA,TABINDEX),
HTML_ATTR(TEXTAREA,TITLE),
HTML_ATTR(TEXTAREA,Z_INPUT_TMPL),
};
enum
{
HTML_ATTR(P,QUICK_HELP_CONDITION) = 0,
HTML_ATTR(P,QUICK_HELP_EVENTS),
HTML_ATTR(P,QUICK_HELP_LINK),
HTML_ATTR(P,NAME),
};
enum
{
HTML_ATTR(DIV,CLASS) = 0,
HTML_ATTR(DIV,ID),
HTML_ATTR(DIV,NAME),
HTML_ATTR(DIV,STYLE),
};
#undef HTML_ATTR
// ***************************************************************************
// A smart ptr for LibWWW strings
class C3WSmartPtr
{
public:
C3WSmartPtr ()
{
_Ptr = NULL;
}
C3WSmartPtr (const char *ptr)
{
_Ptr = ptr;
}
~C3WSmartPtr ()
{
clear();
}
void operator=(const char *str)
{
clear ();
_Ptr = str;
}
operator const char *() const
{
return _Ptr;
}
void clear()
{
if (_Ptr)
{
void *ptr = (void*)_Ptr;
HT_FREE(ptr);
}
_Ptr = NULL;
}
private:
const char *_Ptr;
};
// ***************************************************************************
// Read a width HTML parameter. "100" or "100%". Returns true if percent (0 ~ 1) else false
bool getPercentage (sint32 &width, float &percent, const char *str);
// ***************************************************************************
// Parse a HTML color
NLMISC::CRGBA getColor (const char *color);
// ***************************************************************************
void _VerifyLibWWW(const char *function, bool ok, const char *file, int line);
#define VerifyLibWWW(a,b) _VerifyLibWWW(a,(b)!=FALSE,__FILE__,__LINE__)
// ***************************************************************************
// Standard request terminator
int requestTerminater (HTRequest * request, HTResponse * response, void * param, int status) ;
// ***************************************************************************
#endif

View file

@ -49,7 +49,7 @@
#include "client_cfg.h"
#include "global.h"
#include "input.h"
#include "libwww.h"
#include "nel/gui/libwww.h"
#include "http_client.h"
#include "http_client_curl.h"
#include "login_progress_post_thread.h"

View file

@ -55,7 +55,7 @@
#include "main_loop.h"
#include "interface_v3/group_in_scene_bubble.h"
#include "interface_v3/inventory_manager.h"
#include "interface_v3/group_html.h"
#include "nel/gui/group_html.h"
#include "interface_v3/people_interraction.h"
#include "init_main_loop.h"
#include "view.h"