Linux multi-monitor fullscreen support
[ryzomcore.git] / ryzom / client / src / interface_v3 / group_html_cs.cpp
blob34b91f81c972afe59e1b8ef89ad2982ebeca7054
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010-2015 Winch Gate Property Limited
3 //
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>
8 //
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/>.
27 #include "stdpch.h"
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"
37 using namespace std;
38 using namespace NLMISC;
41 // ***************************************************************************
42 NLMISC_REGISTER_OBJECT(CViewBase, CGroupHTMLCS, std::string, "cs_html");
44 CGroupHTMLCS::CGroupHTMLCS(const TCtorParam &param)
45 : CGroupHTML(param)
47 Home.clear();
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);
65 uint i;
66 for (i=0; i<parameters.size(); i++)
68 if (i!=0)
69 url += "&";
70 url += parameters[i].Name;
71 url += "=";
72 url += parameters[i].Value;
76 // ***************************************************************************
78 void CGroupHTMLCS::addHTTPPostParams (SFormFields &formfields, bool /*trustedDomain*/)
80 std::vector<CParameter> parameters;
81 getParameters (parameters, false);
83 uint i;
84 for (i=0; i<parameters.size(); i++)
86 formfields.add(parameters[i].Name, parameters[i].Value);
90 // ***************************************************************************
92 string CGroupHTMLCS::home () const
94 return Home;
97 // ***************************************************************************
99 extern string getDebugInformation();
100 extern string getSystemInformation();
102 string convertToHTML (const string &s)
104 string dest;
105 uint i;
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]);
114 else
116 dest += toString ("%%%02x", (int) (unsigned char) s[i]);
119 return dest;
122 // ***************************************************************************
124 void CGroupHTMLCS::getParameters (std::vector<CParameter> &parameters, 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
133 webIgReady = true;
134 CInterfaceManager *pIM = CInterfaceManager::getInstance();
135 CLuaManager::getInstance().executeLuaScript("game:onWebIgReady()");
138 // For each line
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);
145 string dest;
146 string::size_type endOfName = line.find_first_of(":");
147 if (endOfName != string::npos)
149 CParameter param;
150 param.Name = line.substr (0, endOfName);
151 if (encodeForUrl)
152 param.Name = convertToHTML (param.Name);
153 param.Value = line.substr (endOfName+1);
154 if (encodeForUrl)
155 param.Value = convertToHTML (param.Value);
156 parameters.push_back (param);
158 startOfLine = endOfLine+1;
159 endOfLine = s.find_first_of("\n", startOfLine);
163 // ***************************************************************************