1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2012 Matt RAYKOWSKI (sfb) <matt.raykowski@gmail.com>
6 // Copyright (C) 2013 Laszlo KIS-ADAM (dfighter) <dfighter1985@gmail.com>
7 // Copyright (C) 2019 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
9 // This program is free software: you can redistribute it and/or modify
10 // it under the terms of the GNU Affero General Public License as
11 // published by the Free Software Foundation, either version 3 of the
12 // License, or (at your option) any later version.
14 // This program is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 // GNU Affero General Public License for more details.
19 // You should have received a copy of the GNU Affero General Public License
20 // along with this program. If not, see <http://www.gnu.org/licenses/>.
29 #include "group_html_cs.h"
30 #include "nel/misc/xml_auto_ptr.h"
31 #include "../client_cfg.h"
32 #include "interface_manager.h"
34 // used for login cookie to be sent to the web server
35 #include "../net_manager.h"
38 using namespace NLMISC
;
41 // ***************************************************************************
42 NLMISC_REGISTER_OBJECT(CViewBase
, CGroupHTMLCS
, std::string
, "cs_html");
44 CGroupHTMLCS::CGroupHTMLCS(const TCtorParam
¶m
)
50 // ***************************************************************************
52 CGroupHTMLCS::~CGroupHTMLCS()
56 // ***************************************************************************
58 void CGroupHTMLCS::addHTTPGetParams (string
&url
, bool /*trustedDomain*/)
60 url
+= ((url
.find('?') != string::npos
) ? "&" : "?");
62 std::vector
<CParameter
> parameters
;
63 getParameters (parameters
, true);
66 for (i
=0; i
<parameters
.size(); i
++)
70 url
+= parameters
[i
].Name
;
72 url
+= parameters
[i
].Value
;
76 // ***************************************************************************
78 void CGroupHTMLCS::addHTTPPostParams (SFormFields
&formfields
, bool /*trustedDomain*/)
80 std::vector
<CParameter
> parameters
;
81 getParameters (parameters
, false);
84 for (i
=0; i
<parameters
.size(); i
++)
86 formfields
.add(parameters
[i
].Name
, parameters
[i
].Value
);
90 // ***************************************************************************
92 string
CGroupHTMLCS::home () const
97 // ***************************************************************************
99 extern string
getDebugInformation();
100 extern string
getSystemInformation();
102 string
convertToHTML (const string
&s
)
106 for (i
=0; i
<s
.size(); i
++)
108 if ( ((s
[i
] >= 'a') && (s
[i
] <= 'z')) ||
109 ((s
[i
] >= 'A') && (s
[i
] <= 'Z')) ||
110 ((s
[i
] >= '0') && (s
[i
] <= '9')))
112 dest
.push_back (s
[i
]);
116 dest
+= toString ("%%%02x", (int) (unsigned char) s
[i
]);
122 // ***************************************************************************
124 void CGroupHTMLCS::getParameters (std::vector
<CParameter
> ¶meters
, bool encodeForUrl
)
126 string s
= getDebugInformation();
127 s
+= getSystemInformation();
129 static bool webIgReady
= false;
131 if (!webIgReady
) // Webig is ready when getParameters of CGroupHTMLCS is called
134 CInterfaceManager
*pIM
= CInterfaceManager::getInstance();
135 CLuaManager::getInstance().executeLuaScript("game:onWebIgReady()");
139 string::size_type startOfLine
= 0;
140 string::size_type endOfLine
;
141 endOfLine
= s
.find_first_of("\n");
142 while (endOfLine
!= string::npos
)
144 string line
= s
.substr (startOfLine
, endOfLine
-startOfLine
);
146 string::size_type endOfName
= line
.find_first_of(":");
147 if (endOfName
!= string::npos
)
150 param
.Name
= line
.substr (0, endOfName
);
152 param
.Name
= convertToHTML (param
.Name
);
153 param
.Value
= line
.substr (endOfName
+1);
155 param
.Value
= convertToHTML (param
.Value
);
156 parameters
.push_back (param
);
158 startOfLine
= endOfLine
+1;
159 endOfLine
= s
.find_first_of("\n", startOfLine
);
163 // ***************************************************************************