aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJacek Antonelli2009-09-10 02:31:50 -0500
committerJacek Antonelli2009-09-10 02:35:58 -0500
commitf57eabefa1291f4e047aa03416c9c544413b9f0e (patch)
tree25f1d75d05a8b00f3c2b7207731a9cfafdad9732
parentMerged 'armin/grid-manager5' into login-manager (diff)
downloadmeta-impy-f57eabefa1291f4e047aa03416c9c544413b9f0e.zip
meta-impy-f57eabefa1291f4e047aa03416c9c544413b9f0e.tar.gz
meta-impy-f57eabefa1291f4e047aa03416c9c544413b9f0e.tar.bz2
meta-impy-f57eabefa1291f4e047aa03416c9c544413b9f0e.tar.xz
Fixed line endings on hippo and grid manager files.
-rw-r--r--linden/indra/newview/app_settings/default_grids.xml102
-rw-r--r--linden/indra/newview/hippoGridManager.cpp1194
-rw-r--r--linden/indra/newview/hippoGridManager.h342
-rw-r--r--linden/indra/newview/hippoLimits.cpp108
-rw-r--r--linden/indra/newview/hippoLimits.h66
-rw-r--r--linden/indra/newview/hippoRestRequest.cpp108
-rw-r--r--linden/indra/newview/hippoRestRequest.h32
-rw-r--r--linden/indra/newview/hippoUpdate.cpp184
-rw-r--r--linden/indra/newview/hippoUpdate.h24
9 files changed, 1080 insertions, 1080 deletions
diff --git a/linden/indra/newview/app_settings/default_grids.xml b/linden/indra/newview/app_settings/default_grids.xml
index f4feb0c..dabcb0b 100644
--- a/linden/indra/newview/app_settings/default_grids.xml
+++ b/linden/indra/newview/app_settings/default_grids.xml
@@ -1,51 +1,51 @@
1<llsd> 1<llsd>
2 <array> 2 <array>
3 3
4 <!-- 4 <!--
5 This file contains fallback settings only. 5 This file contains fallback settings only.
6 The actual list of grids is loaded from a web server. 6 The actual list of grids is loaded from a web server.
7 --> 7 -->
8 8
9 <map> 9 <map>
10 <key>default_grids_version</key><string>0</string> 10 <key>default_grids_version</key><string>0</string>
11 </map> 11 </map>
12 12
13 <!-- OSGrid --> 13 <!-- OSGrid -->
14 <map> 14 <map>
15 <key>gridnick</key><string>osgrid</string> 15 <key>gridnick</key><string>osgrid</string>
16 <key>gridname</key><string>OSGrid</string> 16 <key>gridname</key><string>OSGrid</string>
17 <key>platform</key><string>OpenSim</string> 17 <key>platform</key><string>OpenSim</string>
18 <key>loginuri</key><string>http://osgrid.org:8002/</string> 18 <key>loginuri</key><string>http://osgrid.org:8002/</string>
19 <key>loginpage</key><string>http://osgrid.org/loginscreen.php</string> 19 <key>loginpage</key><string>http://osgrid.org/loginscreen.php</string>
20 <key>helperuri</key><string>http://osgrid.org/</string> 20 <key>helperuri</key><string>http://osgrid.org/</string>
21 <key>website</key><string>http://osgrid.org/</string> 21 <key>website</key><string>http://osgrid.org/</string>
22 <key>support</key><string>http://osgrid.org/</string> 22 <key>support</key><string>http://osgrid.org/</string>
23 <key>register</key><string>http://osgrid.org/index.php?page=create</string> 23 <key>register</key><string>http://osgrid.org/index.php?page=create</string>
24 <key>password</key><string>http://osgrid.org/index.php?page=change</string> 24 <key>password</key><string>http://osgrid.org/index.php?page=change</string>
25 </map> 25 </map>
26 26
27 <!-- Second Life --> 27 <!-- Second Life -->
28 <map> 28 <map>
29 <key>gridnick</key><string>secondlife</string> 29 <key>gridnick</key><string>secondlife</string>
30 <key>gridname</key><string>Second Life</string> 30 <key>gridname</key><string>Second Life</string>
31 <key>platform</key><string>SecondLife</string> 31 <key>platform</key><string>SecondLife</string>
32 <key>loginuri</key><string>https://login.agni.lindenlab.com/cgi-bin/login.cgi</string> 32 <key>loginuri</key><string>https://login.agni.lindenlab.com/cgi-bin/login.cgi</string>
33 <key>loginpage</key><string>http://secondlife.com/app/login/</string> 33 <key>loginpage</key><string>http://secondlife.com/app/login/</string>
34 <key>helperuri</key><string>https://secondlife.com/helpers/</string> 34 <key>helperuri</key><string>https://secondlife.com/helpers/</string>
35 <key>website</key><string>http://secondlife.com/</string> 35 <key>website</key><string>http://secondlife.com/</string>
36 <key>support</key><string>http://secondlife.com/support/</string> 36 <key>support</key><string>http://secondlife.com/support/</string>
37 <key>register</key><string>http://secondlife.com/registration/</string> 37 <key>register</key><string>http://secondlife.com/registration/</string>
38 <key>password</key><string>http://secondlife.com/account/request.php</string> 38 <key>password</key><string>http://secondlife.com/account/request.php</string>
39 </map> 39 </map>
40 40
41 <!-- Local Host --> 41 <!-- Local Host -->
42 <map> 42 <map>
43 <key>gridnick</key><string>local</string> 43 <key>gridnick</key><string>local</string>
44 <key>gridname</key><string>Local Host</string> 44 <key>gridname</key><string>Local Host</string>
45 <key>platform</key><string>OpenSim</string> 45 <key>platform</key><string>OpenSim</string>
46 <key>loginuri</key><string>http://127.0.0.1:9000/</string> 46 <key>loginuri</key><string>http://127.0.0.1:9000/</string>
47 <key>helperuri</key><string>http://127.0.0.1:9000/</string> 47 <key>helperuri</key><string>http://127.0.0.1:9000/</string>
48 </map> 48 </map>
49 49
50 </array> 50 </array>
51</llsd> 51</llsd>
diff --git a/linden/indra/newview/hippoGridManager.cpp b/linden/indra/newview/hippoGridManager.cpp
index 8415adb..19ed2c4 100644
--- a/linden/indra/newview/hippoGridManager.cpp
+++ b/linden/indra/newview/hippoGridManager.cpp
@@ -1,597 +1,597 @@
1 1
2 2
3#include "hippoGridManager.h" 3#include "hippoGridManager.h"
4 4
5#include <cctype> 5#include <cctype>
6 6
7#include <stdtypes.h> 7#include <stdtypes.h>
8#include <lldir.h> 8#include <lldir.h>
9#include <lleconomy.h> 9#include <lleconomy.h>
10#include <llerror.h> 10#include <llerror.h>
11#include <llfile.h> 11#include <llfile.h>
12#include <llhttpclient.h> 12#include <llhttpclient.h>
13#include <llsdserialize.h> 13#include <llsdserialize.h>
14#include "llviewercontrol.h" 14#include "llviewercontrol.h"
15#include "llweb.h" 15#include "llweb.h"
16 16
17#include "hippoRestRequest.h" 17#include "hippoRestRequest.h"
18 18
19 19
20// ******************************************************************** 20// ********************************************************************
21// Global Variables 21// Global Variables
22 22
23HippoGridManager *gHippoGridManager = 0; 23HippoGridManager *gHippoGridManager = 0;
24 24
25HippoGridInfo HippoGridInfo::FALLBACK_GRIDINFO(""); 25HippoGridInfo HippoGridInfo::FALLBACK_GRIDINFO("");
26 26
27 27
28 28
29// ******************************************************************** 29// ********************************************************************
30// ******************************************************************** 30// ********************************************************************
31// HippoGridInfo 31// HippoGridInfo
32// ******************************************************************** 32// ********************************************************************
33// ******************************************************************** 33// ********************************************************************
34 34
35 35
36// ******************************************************************** 36// ********************************************************************
37// Initialize 37// Initialize
38 38
39HippoGridInfo::HippoGridInfo(const std::string &gridNick) : 39HippoGridInfo::HippoGridInfo(const std::string &gridNick) :
40 mPlatform(PLATFORM_OTHER), 40 mPlatform(PLATFORM_OTHER),
41 mGridNick(gridNick), 41 mGridNick(gridNick),
42 mRenderCompat(true), 42 mRenderCompat(true),
43 mCurrencySymbol("OS$"), 43 mCurrencySymbol("OS$"),
44 mRealCurrencySymbol("US$"), 44 mRealCurrencySymbol("US$"),
45 mDirectoryFee(30) 45 mDirectoryFee(30)
46{ 46{
47 cleanUpGridNick(mGridNick); 47 cleanUpGridNick(mGridNick);
48} 48}
49 49
50 50
51void HippoGridInfo::setPlatform(Platform platform) 51void HippoGridInfo::setPlatform(Platform platform)
52{ 52{
53 mPlatform = platform; 53 mPlatform = platform;
54 mCurrencySymbol = (mPlatform == PLATFORM_SECONDLIFE)? "L$": "OS$"; 54 mCurrencySymbol = (mPlatform == PLATFORM_SECONDLIFE)? "L$": "OS$";
55} 55}
56 56
57 57
58void HippoGridInfo::setPlatform(const std::string &platform) 58void HippoGridInfo::setPlatform(const std::string &platform)
59{ 59{
60 std::string tmp = platform; 60 std::string tmp = platform;
61 for (unsigned i=0; i<platform.size(); i++) 61 for (unsigned i=0; i<platform.size(); i++)
62 tmp[i] = tolower(tmp[i]); 62 tmp[i] = tolower(tmp[i]);
63 63
64 if (tmp == "opensim") { 64 if (tmp == "opensim") {
65 setPlatform(PLATFORM_OPENSIM); 65 setPlatform(PLATFORM_OPENSIM);
66 } else if (tmp == "secondlife") { 66 } else if (tmp == "secondlife") {
67 setPlatform(PLATFORM_SECONDLIFE); 67 setPlatform(PLATFORM_SECONDLIFE);
68 } else { 68 } else {
69 setPlatform(PLATFORM_OTHER); 69 setPlatform(PLATFORM_OTHER);
70 llwarns << "Unknown platform '" << platform << "'." << llendl; 70 llwarns << "Unknown platform '" << platform << "'." << llendl;
71 } 71 }
72} 72}
73 73
74 74
75// ******************************************************************** 75// ********************************************************************
76// Grid Info 76// Grid Info
77 77
78std::string HippoGridInfo::getSearchUrl(SearchType ty) const 78std::string HippoGridInfo::getSearchUrl(SearchType ty) const
79{ 79{
80 if ((mPlatform == PLATFORM_SECONDLIFE) || mSearchUrl.empty()) { 80 if ((mPlatform == PLATFORM_SECONDLIFE) || mSearchUrl.empty()) {
81 // Second Life defaults 81 // Second Life defaults
82 if (ty == SEARCH_ALL_EMPTY) { 82 if (ty == SEARCH_ALL_EMPTY) {
83 return gSavedSettings.getString("SearchURLDefault"); 83 return gSavedSettings.getString("SearchURLDefault");
84 } else if (ty == SEARCH_ALL_QUERY) { 84 } else if (ty == SEARCH_ALL_QUERY) {
85 return gSavedSettings.getString("SearchURLQuery"); 85 return gSavedSettings.getString("SearchURLQuery");
86 } else if (ty == SEARCH_ALL_TEMPLATE) { 86 } else if (ty == SEARCH_ALL_TEMPLATE) {
87 return gSavedSettings.getString("SearchURLSuffix2"); 87 return gSavedSettings.getString("SearchURLSuffix2");
88 } else { 88 } else {
89 llinfos << "Illegal search URL type " << ty << llendl; 89 llinfos << "Illegal search URL type " << ty << llendl;
90 return ""; 90 return "";
91 } 91 }
92 } else { 92 } else {
93 // OpenSim and other 93 // OpenSim and other
94 if (ty == SEARCH_ALL_EMPTY) { 94 if (ty == SEARCH_ALL_EMPTY) {
95 return (mSearchUrl + "panel=All&"); 95 return (mSearchUrl + "panel=All&");
96 } else if (ty == SEARCH_ALL_QUERY) { 96 } else if (ty == SEARCH_ALL_QUERY) {
97 return (mSearchUrl + "q=[QUERY]&s=[COLLECTION]&"); 97 return (mSearchUrl + "q=[QUERY]&s=[COLLECTION]&");
98 } else if (ty == SEARCH_ALL_TEMPLATE) { 98 } else if (ty == SEARCH_ALL_TEMPLATE) {
99 return "lang=[LANG]&m=[MATURE]&t=[TEEN]&region=[REGION]&x=[X]&y=[Y]&z=[Z]&session=[SESSION]"; 99 return "lang=[LANG]&m=[MATURE]&t=[TEEN]&region=[REGION]&x=[X]&y=[Y]&z=[Z]&session=[SESSION]";
100 } else { 100 } else {
101 llinfos << "Illegal search URL type " << ty << llendl; 101 llinfos << "Illegal search URL type " << ty << llendl;
102 return ""; 102 return "";
103 } 103 }
104 } 104 }
105} 105}
106 106
107 107
108//static 108//static
109void HippoGridInfo::onXmlElementStart(void *userData, const XML_Char *name, const XML_Char **atts) 109void HippoGridInfo::onXmlElementStart(void *userData, const XML_Char *name, const XML_Char **atts)
110{ 110{
111 HippoGridInfo *self = (HippoGridInfo*)userData; 111 HippoGridInfo *self = (HippoGridInfo*)userData;
112 if (strcasecmp(name, "gridnick") == 0) 112 if (strcasecmp(name, "gridnick") == 0)
113 self->mXmlState = XML_GRIDNICK; 113 self->mXmlState = XML_GRIDNICK;
114 else if (strcasecmp(name, "gridname") == 0) 114 else if (strcasecmp(name, "gridname") == 0)
115 self->mXmlState = XML_GRIDNAME; 115 self->mXmlState = XML_GRIDNAME;
116 else if (strcasecmp(name, "platform") == 0) 116 else if (strcasecmp(name, "platform") == 0)
117 self->mXmlState = XML_PLATFORM; 117 self->mXmlState = XML_PLATFORM;
118 else if ((strcasecmp(name, "login") == 0) || (strcasecmp(name, "loginuri") == 0)) 118 else if ((strcasecmp(name, "login") == 0) || (strcasecmp(name, "loginuri") == 0))
119 self->mXmlState = XML_LOGINURI; 119 self->mXmlState = XML_LOGINURI;
120 else if ((strcasecmp(name, "welcome") == 0) || (strcasecmp(name, "loginpage") == 0)) 120 else if ((strcasecmp(name, "welcome") == 0) || (strcasecmp(name, "loginpage") == 0))
121 self->mXmlState = XML_LOGINPAGE; 121 self->mXmlState = XML_LOGINPAGE;
122 else if ((strcasecmp(name, "economy") == 0) || (strcasecmp(name, "helperuri") == 0)) 122 else if ((strcasecmp(name, "economy") == 0) || (strcasecmp(name, "helperuri") == 0))
123 self->mXmlState = XML_HELPERURI; 123 self->mXmlState = XML_HELPERURI;
124 else if ((strcasecmp(name, "about") == 0) || (strcasecmp(name, "website") == 0)) 124 else if ((strcasecmp(name, "about") == 0) || (strcasecmp(name, "website") == 0))
125 self->mXmlState = XML_WEBSITE; 125 self->mXmlState = XML_WEBSITE;
126 else if ((strcasecmp(name, "help") == 0) || (strcasecmp(name, "support") == 0)) 126 else if ((strcasecmp(name, "help") == 0) || (strcasecmp(name, "support") == 0))
127 self->mXmlState = XML_SUPPORT; 127 self->mXmlState = XML_SUPPORT;
128 else if ((strcasecmp(name, "register") == 0) || (strcasecmp(name, "account") == 0)) 128 else if ((strcasecmp(name, "register") == 0) || (strcasecmp(name, "account") == 0))
129 self->mXmlState = XML_REGISTER; 129 self->mXmlState = XML_REGISTER;
130 else if (strcasecmp(name, "password") == 0) 130 else if (strcasecmp(name, "password") == 0)
131 self->mXmlState = XML_PASSWORD; 131 self->mXmlState = XML_PASSWORD;
132 //else if (strcasecmp(name, "search") == 0) 132 //else if (strcasecmp(name, "search") == 0)
133 //self->mXmlState = XML_SEARCH; 133 //self->mXmlState = XML_SEARCH;
134} 134}
135 135
136//static 136//static
137void HippoGridInfo::onXmlElementEnd(void *userData, const XML_Char *name) 137void HippoGridInfo::onXmlElementEnd(void *userData, const XML_Char *name)
138{ 138{
139 HippoGridInfo *self = (HippoGridInfo*)userData; 139 HippoGridInfo *self = (HippoGridInfo*)userData;
140 self->mXmlState = XML_VOID; 140 self->mXmlState = XML_VOID;
141} 141}
142 142
143//static 143//static
144void HippoGridInfo::onXmlCharacterData(void *userData, const XML_Char *s, int len) 144void HippoGridInfo::onXmlCharacterData(void *userData, const XML_Char *s, int len)
145{ 145{
146 HippoGridInfo *self = (HippoGridInfo*)userData; 146 HippoGridInfo *self = (HippoGridInfo*)userData;
147 switch (self->mXmlState) { 147 switch (self->mXmlState) {
148 148
149 case XML_GRIDNICK: 149 case XML_GRIDNICK:
150 if (self->mGridNick == "") self->mGridNick.assign(s, len); 150 if (self->mGridNick == "") self->mGridNick.assign(s, len);
151 cleanUpGridNick(self->mGridNick); 151 cleanUpGridNick(self->mGridNick);
152 break; 152 break;
153 153
154 case XML_PLATFORM: { 154 case XML_PLATFORM: {
155 std::string platform(s, len); 155 std::string platform(s, len);
156 self->setPlatform(platform); 156 self->setPlatform(platform);
157 break; 157 break;
158 } 158 }
159 159
160 case XML_LOGINURI: 160 case XML_LOGINURI:
161 self->mLoginUri.assign(s, len); 161 self->mLoginUri.assign(s, len);
162 cleanUpUri(self->mLoginUri); 162 cleanUpUri(self->mLoginUri);
163 break; 163 break;
164 164
165 case XML_HELPERURI: 165 case XML_HELPERURI:
166 self->mHelperUri.assign(s, len); 166 self->mHelperUri.assign(s, len);
167 cleanUpUri(self->mHelperUri); 167 cleanUpUri(self->mHelperUri);
168 break; 168 break;
169 169
170 case XML_SEARCH: 170 case XML_SEARCH:
171 //self->mSearchUrl.assign(s, len); 171 //self->mSearchUrl.assign(s, len);
172 //cleanUpQueryUrl(mSearchUrl); 172 //cleanUpQueryUrl(mSearchUrl);
173 break; 173 break;
174 174
175 case XML_GRIDNAME: self->mGridName.assign(s, len); break; 175 case XML_GRIDNAME: self->mGridName.assign(s, len); break;
176 case XML_LOGINPAGE: self->mLoginPage.assign(s, len); break; 176 case XML_LOGINPAGE: self->mLoginPage.assign(s, len); break;
177 case XML_WEBSITE: self->mWebSite.assign(s, len); break; 177 case XML_WEBSITE: self->mWebSite.assign(s, len); break;
178 case XML_SUPPORT: self->mSupportUrl.assign(s, len); break; 178 case XML_SUPPORT: self->mSupportUrl.assign(s, len); break;
179 case XML_REGISTER: self->mRegisterUrl.assign(s, len); break; 179 case XML_REGISTER: self->mRegisterUrl.assign(s, len); break;
180 case XML_PASSWORD: self->mPasswordUrl.assign(s, len); break; 180 case XML_PASSWORD: self->mPasswordUrl.assign(s, len); break;
181 181
182 case XML_VOID: break; 182 case XML_VOID: break;
183 } 183 }
184} 184}
185 185
186 186
187bool HippoGridInfo::retrieveGridInfo() 187bool HippoGridInfo::retrieveGridInfo()
188{ 188{
189 if (mLoginUri == "") return false; 189 if (mLoginUri == "") return false;
190 190
191 std::string reply; 191 std::string reply;
192 int result = HippoRestRequest::getBlocking(mLoginUri + "get_grid_info", &reply); 192 int result = HippoRestRequest::getBlocking(mLoginUri + "get_grid_info", &reply);
193 if (result != 200) return false; 193 if (result != 200) return false;
194 194
195 llinfos << "Received: " << reply << llendl; 195 llinfos << "Received: " << reply << llendl;
196 196
197 bool success = true; 197 bool success = true;
198 XML_Parser parser = XML_ParserCreate(0); 198 XML_Parser parser = XML_ParserCreate(0);
199 XML_SetUserData(parser, this); 199 XML_SetUserData(parser, this);
200 XML_SetElementHandler(parser, onXmlElementStart, onXmlElementEnd); 200 XML_SetElementHandler(parser, onXmlElementStart, onXmlElementEnd);
201 XML_SetCharacterDataHandler(parser, onXmlCharacterData); 201 XML_SetCharacterDataHandler(parser, onXmlCharacterData);
202 mXmlState = XML_VOID; 202 mXmlState = XML_VOID;
203 if (!XML_Parse(parser, reply.data(), reply.size(), TRUE)) { 203 if (!XML_Parse(parser, reply.data(), reply.size(), TRUE)) {
204 llwarns << "XML Parse Error: " << XML_ErrorString(XML_GetErrorCode(parser)) << llendl; 204 llwarns << "XML Parse Error: " << XML_ErrorString(XML_GetErrorCode(parser)) << llendl;
205 success = false; 205 success = false;
206 } 206 }
207 XML_ParserFree(parser); 207 XML_ParserFree(parser);
208 208
209 return success; 209 return success;
210} 210}
211 211
212 212
213std::string HippoGridInfo::getUploadFee() const 213std::string HippoGridInfo::getUploadFee() const
214{ 214{
215 std::string fee; 215 std::string fee;
216 formatFee(fee, LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(), true); 216 formatFee(fee, LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(), true);
217 return fee; 217 return fee;
218} 218}
219 219
220std::string HippoGridInfo::getGroupCreationFee() const 220std::string HippoGridInfo::getGroupCreationFee() const
221{ 221{
222 std::string fee; 222 std::string fee;
223 formatFee(fee, LLGlobalEconomy::Singleton::getInstance()->getPriceGroupCreate(), false); 223 formatFee(fee, LLGlobalEconomy::Singleton::getInstance()->getPriceGroupCreate(), false);
224 return fee; 224 return fee;
225} 225}
226 226
227std::string HippoGridInfo::getDirectoryFee() const 227std::string HippoGridInfo::getDirectoryFee() const
228{ 228{
229 std::string fee; 229 std::string fee;
230 formatFee(fee, mDirectoryFee, true); 230 formatFee(fee, mDirectoryFee, true);
231 if (fee != "free") fee += "/week"; 231 if (fee != "free") fee += "/week";
232 return fee; 232 return fee;
233} 233}
234 234
235void HippoGridInfo::formatFee(std::string &fee, int cost, bool showFree) const 235void HippoGridInfo::formatFee(std::string &fee, int cost, bool showFree) const
236{ 236{
237 if (showFree && (cost == 0)) { 237 if (showFree && (cost == 0)) {
238 fee = "free"; 238 fee = "free";
239 } else { 239 } else {
240 fee = llformat("%s%d", getCurrencySymbol().c_str(), cost); 240 fee = llformat("%s%d", getCurrencySymbol().c_str(), cost);
241 } 241 }
242} 242}
243 243
244 244
245// ******************************************************************** 245// ********************************************************************
246// Static Helpers 246// Static Helpers
247 247
248// static 248// static
249const char *HippoGridInfo::getPlatformString(Platform platform) 249const char *HippoGridInfo::getPlatformString(Platform platform)
250{ 250{
251 static const char *platformStrings[PLATFORM_LAST] = { 251 static const char *platformStrings[PLATFORM_LAST] = {
252 "Other", "OpenSim", "SecondLife" 252 "Other", "OpenSim", "SecondLife"
253 }; 253 };
254 254
255 if ((platform < PLATFORM_OTHER) || (platform >= PLATFORM_LAST)) 255 if ((platform < PLATFORM_OTHER) || (platform >= PLATFORM_LAST))
256 platform = PLATFORM_OTHER; 256 platform = PLATFORM_OTHER;
257 return platformStrings[platform]; 257 return platformStrings[platform];
258} 258}
259 259
260 260
261// static 261// static
262void HippoGridInfo::cleanUpGridNick(std::string &gridnick) 262void HippoGridInfo::cleanUpGridNick(std::string &gridnick)
263{ 263{
264 std::string tmp; 264 std::string tmp;
265 int size = gridnick.size(); 265 int size = gridnick.size();
266 for (int i=0; i<size; i++) { 266 for (int i=0; i<size; i++) {
267 char c = gridnick[i]; 267 char c = gridnick[i];
268 if ((c == '_') || isalnum(c)) { 268 if ((c == '_') || isalnum(c)) {
269 tmp += tolower(c); 269 tmp += tolower(c);
270 } else if (isspace(c)) { 270 } else if (isspace(c)) {
271 tmp += "_"; 271 tmp += "_";
272 } 272 }
273 } 273 }
274 gridnick = tmp; 274 gridnick = tmp;
275} 275}
276 276
277// static 277// static
278void HippoGridInfo::cleanUpUri(std::string &uri) 278void HippoGridInfo::cleanUpUri(std::string &uri)
279{ 279{
280 std::string::size_type n = uri.rfind('/'); 280 std::string::size_type n = uri.rfind('/');
281 if ((n == std::string::npos) || (n < 10)) 281 if ((n == std::string::npos) || (n < 10))
282 uri += '/'; 282 uri += '/';
283} 283}
284 284
285 285
286void HippoGridInfo::initFallback() 286void HippoGridInfo::initFallback()
287{ 287{
288 FALLBACK_GRIDINFO.mGridNick = "secondlife"; 288 FALLBACK_GRIDINFO.mGridNick = "secondlife";
289 FALLBACK_GRIDINFO.setPlatform(PLATFORM_SECONDLIFE); 289 FALLBACK_GRIDINFO.setPlatform(PLATFORM_SECONDLIFE);
290 FALLBACK_GRIDINFO.setGridName("Second Life"); 290 FALLBACK_GRIDINFO.setGridName("Second Life");
291 FALLBACK_GRIDINFO.setLoginUri("https://login.agni.lindenlab.com/cgi-bin/login.cgi"); 291 FALLBACK_GRIDINFO.setLoginUri("https://login.agni.lindenlab.com/cgi-bin/login.cgi");
292 FALLBACK_GRIDINFO.setLoginPage("http://secondlife.com/app/login/"); 292 FALLBACK_GRIDINFO.setLoginPage("http://secondlife.com/app/login/");
293 FALLBACK_GRIDINFO.setHelperUri("https://secondlife.com/helpers/"); 293 FALLBACK_GRIDINFO.setHelperUri("https://secondlife.com/helpers/");
294 FALLBACK_GRIDINFO.setWebSite("http://secondlife.com/"); 294 FALLBACK_GRIDINFO.setWebSite("http://secondlife.com/");
295} 295}
296 296
297 297
298 298
299// ******************************************************************** 299// ********************************************************************
300// ******************************************************************** 300// ********************************************************************
301// HippoGridManager 301// HippoGridManager
302// ******************************************************************** 302// ********************************************************************
303// ******************************************************************** 303// ********************************************************************
304 304
305 305
306// ******************************************************************** 306// ********************************************************************
307// Initialize 307// Initialize
308 308
309HippoGridManager::HippoGridManager() : 309HippoGridManager::HippoGridManager() :
310 mConnectedGrid(0), 310 mConnectedGrid(0),
311 mDefaultGridsVersion(0) 311 mDefaultGridsVersion(0)
312{ 312{
313} 313}
314 314
315HippoGridManager::~HippoGridManager() 315HippoGridManager::~HippoGridManager()
316{ 316{
317 cleanup(); 317 cleanup();
318} 318}
319 319
320 320
321void HippoGridManager::cleanup() 321void HippoGridManager::cleanup()
322{ 322{
323 std::map<std::string, HippoGridInfo*>::iterator it, end = mGridInfo.end(); 323 std::map<std::string, HippoGridInfo*>::iterator it, end = mGridInfo.end();
324 for (it=mGridInfo.begin(); it != end; ++it) { 324 for (it=mGridInfo.begin(); it != end; ++it) {
325 delete it->second; 325 delete it->second;
326 } 326 }
327 mGridInfo.clear(); 327 mGridInfo.clear();
328} 328}
329 329
330 330
331void HippoGridManager::init() 331void HippoGridManager::init()
332{ 332{
333 HippoGridInfo::initFallback(); 333 HippoGridInfo::initFallback();
334 loadFromFile(); 334 loadFromFile();
335 335
336 // !!!### gSavedSettings.getControl("CmdLineLoginURI"); 336 // !!!### gSavedSettings.getControl("CmdLineLoginURI");
337 // !!!### gSavedSettings.getString("CmdLineLoginPage"); 337 // !!!### gSavedSettings.getString("CmdLineLoginPage");
338 // !!!### gSavedSettings.getString("CmdLineHelperURI"); 338 // !!!### gSavedSettings.getString("CmdLineHelperURI");
339 // !!!### LLString::compareInsensitive(gGridInfo[grid_index].mLabel, grid_name.c_str())) 339 // !!!### LLString::compareInsensitive(gGridInfo[grid_index].mLabel, grid_name.c_str()))
340} 340}
341 341
342 342
343void HippoGridManager::discardAndReload() 343void HippoGridManager::discardAndReload()
344{ 344{
345 cleanup(); 345 cleanup();
346 loadFromFile(); 346 loadFromFile();
347} 347}
348 348
349 349
350// ******************************************************************** 350// ********************************************************************
351// Public Access 351// Public Access
352 352
353HippoGridInfo *HippoGridManager::getGrid(const std::string &grid) const 353HippoGridInfo *HippoGridManager::getGrid(const std::string &grid) const
354{ 354{
355 std::map<std::string, HippoGridInfo*>::const_iterator it; 355 std::map<std::string, HippoGridInfo*>::const_iterator it;
356 it = mGridInfo.find(grid); 356 it = mGridInfo.find(grid);
357 if (it != mGridInfo.end()) { 357 if (it != mGridInfo.end()) {
358 return it->second; 358 return it->second;
359 } else { 359 } else {
360 return 0; 360 return 0;
361 } 361 }
362} 362}
363 363
364 364
365HippoGridInfo *HippoGridManager::getCurrentGrid() const 365HippoGridInfo *HippoGridManager::getCurrentGrid() const
366{ 366{
367 HippoGridInfo *grid = getGrid(mCurrentGrid); 367 HippoGridInfo *grid = getGrid(mCurrentGrid);
368 if (grid) { 368 if (grid) {
369 return grid; 369 return grid;
370 } else { 370 } else {
371 return &HippoGridInfo::FALLBACK_GRIDINFO; 371 return &HippoGridInfo::FALLBACK_GRIDINFO;
372 } 372 }
373} 373}
374 374
375 375
376void HippoGridManager::addGrid(HippoGridInfo *grid) 376void HippoGridManager::addGrid(HippoGridInfo *grid)
377{ 377{
378 if (!grid) return; 378 if (!grid) return;
379 const std::string &nick = grid->getGridNick(); 379 const std::string &nick = grid->getGridNick();
380 if (nick == "") { 380 if (nick == "") {
381 llwarns << "Ignoring to try adding grid with empty nick." << llendl; 381 llwarns << "Ignoring to try adding grid with empty nick." << llendl;
382 delete grid; 382 delete grid;
383 return; 383 return;
384 } 384 }
385 if (mGridInfo.find(nick) != mGridInfo.end()) { 385 if (mGridInfo.find(nick) != mGridInfo.end()) {
386 llwarns << "Ignoring to try adding existing grid " << nick << '.' << llendl; 386 llwarns << "Ignoring to try adding existing grid " << nick << '.' << llendl;
387 delete grid; 387 delete grid;
388 return; 388 return;
389 } 389 }
390 mGridInfo[nick] = grid; 390 mGridInfo[nick] = grid;
391} 391}
392 392
393 393
394void HippoGridManager::deleteGrid(const std::string &grid) 394void HippoGridManager::deleteGrid(const std::string &grid)
395{ 395{
396 GridIterator it = mGridInfo.find(grid); 396 GridIterator it = mGridInfo.find(grid);
397 if (it == mGridInfo.end()) { 397 if (it == mGridInfo.end()) {
398 llwarns << "Trying to delete non-existing grid " << grid << '.' << llendl; 398 llwarns << "Trying to delete non-existing grid " << grid << '.' << llendl;
399 return; 399 return;
400 } 400 }
401 mGridInfo.erase(it); 401 mGridInfo.erase(it);
402 llinfos << "Number of grids now: " << mGridInfo.size() << llendl; 402 llinfos << "Number of grids now: " << mGridInfo.size() << llendl;
403 if (mGridInfo.empty()) llinfos << "Grid info map is empty." << llendl; 403 if (mGridInfo.empty()) llinfos << "Grid info map is empty." << llendl;
404 if (grid == mDefaultGrid) 404 if (grid == mDefaultGrid)
405 setDefaultGrid(""); // sets first grid, if map not empty 405 setDefaultGrid(""); // sets first grid, if map not empty
406 if (grid == mCurrentGrid) 406 if (grid == mCurrentGrid)
407 mCurrentGrid = mDefaultGrid; 407 mCurrentGrid = mDefaultGrid;
408} 408}
409 409
410 410
411void HippoGridManager::setDefaultGrid(const std::string &grid) 411void HippoGridManager::setDefaultGrid(const std::string &grid)
412{ 412{
413 GridIterator it = mGridInfo.find(grid); 413 GridIterator it = mGridInfo.find(grid);
414 if (it != mGridInfo.end()) { 414 if (it != mGridInfo.end()) {
415 mDefaultGrid = grid; 415 mDefaultGrid = grid;
416 } else if (mGridInfo.find("secondlife") != mGridInfo.end()) { 416 } else if (mGridInfo.find("secondlife") != mGridInfo.end()) {
417 mDefaultGrid = "secondlife"; 417 mDefaultGrid = "secondlife";
418 } else if (!mGridInfo.empty()) { 418 } else if (!mGridInfo.empty()) {
419 mDefaultGrid = mGridInfo.begin()->first; 419 mDefaultGrid = mGridInfo.begin()->first;
420 } else { 420 } else {
421 mDefaultGrid = ""; 421 mDefaultGrid = "";
422 } 422 }
423} 423}
424 424
425 425
426void HippoGridManager::setCurrentGrid(const std::string &grid) 426void HippoGridManager::setCurrentGrid(const std::string &grid)
427{ 427{
428 GridIterator it = mGridInfo.find(grid); 428 GridIterator it = mGridInfo.find(grid);
429 if (it != mGridInfo.end()) { 429 if (it != mGridInfo.end()) {
430 mCurrentGrid = grid; 430 mCurrentGrid = grid;
431 } else if (!mGridInfo.empty()) { 431 } else if (!mGridInfo.empty()) {
432 llwarns << "Unknown grid '" << grid << "'. Setting to default grid." << llendl; 432 llwarns << "Unknown grid '" << grid << "'. Setting to default grid." << llendl;
433 mCurrentGrid = mDefaultGrid; 433 mCurrentGrid = mDefaultGrid;
434 } 434 }
435} 435}
436 436
437 437
438// ******************************************************************** 438// ********************************************************************
439// Persistent Store 439// Persistent Store
440 440
441void HippoGridManager::loadFromFile() 441void HippoGridManager::loadFromFile()
442{ 442{
443 mDefaultGridsVersion = 0; 443 mDefaultGridsVersion = 0;
444 // load user grid info 444 // load user grid info
445 parseFile(gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "grid_info.xml"), false); 445 parseFile(gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "grid_info.xml"), false);
446 // merge default grid info, if newer. Force load, if list of grids is empty. 446 // merge default grid info, if newer. Force load, if list of grids is empty.
447 parseFile(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "default_grids.xml"), !mGridInfo.empty()); 447 parseFile(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "default_grids.xml"), !mGridInfo.empty());
448 // merge grid info from web site, if newer. Force load, if list of grids is empty. 448 // merge grid info from web site, if newer. Force load, if list of grids is empty.
449 if (gSavedSettings.getBOOL("CheckForGridUpdates")) 449 if (gSavedSettings.getBOOL("CheckForGridUpdates"))
450 parseUrl("http://opensim-viewer.sourceforge.net/db/grids.php", !mGridInfo.empty()); 450 parseUrl("http://opensim-viewer.sourceforge.net/db/grids.php", !mGridInfo.empty());
451 451
452 setDefaultGrid(gSavedSettings.getString("DefaultGrid")); 452 setDefaultGrid(gSavedSettings.getString("DefaultGrid"));
453 setCurrentGrid(gSavedSettings.getString("CmdLineGridChoice")); 453 setCurrentGrid(gSavedSettings.getString("CmdLineGridChoice"));
454} 454}
455 455
456 456
457void HippoGridManager::parseUrl(const char *url, bool mergeIfNewer) 457void HippoGridManager::parseUrl(const char *url, bool mergeIfNewer)
458{ 458{
459 llinfos << "Loading grid info from '" << url << "'." << llendl; 459 llinfos << "Loading grid info from '" << url << "'." << llendl;
460 460
461 // query update server 461 // query update server
462 std::string escaped_url = LLWeb::escapeURL(url); 462 std::string escaped_url = LLWeb::escapeURL(url);
463 LLSD response = LLHTTPClient::blockingGet(url); 463 LLSD response = LLHTTPClient::blockingGet(url);
464 464
465 // check response, return on error 465 // check response, return on error
466 S32 status = response["status"].asInteger(); 466 S32 status = response["status"].asInteger();
467 if ((status != 200) || !response["body"].isArray()) { 467 if ((status != 200) || !response["body"].isArray()) {
468 llinfos << "GridInfo Update failed (" << status << "): " 468 llinfos << "GridInfo Update failed (" << status << "): "
469 << (response["body"].isString()? response["body"].asString(): "<unknown error>") 469 << (response["body"].isString()? response["body"].asString(): "<unknown error>")
470 << llendl; 470 << llendl;
471 return; 471 return;
472 } 472 }
473 473
474 LLSD gridInfo = response["body"]; 474 LLSD gridInfo = response["body"];
475 parseData(gridInfo, mergeIfNewer); 475 parseData(gridInfo, mergeIfNewer);
476} 476}
477 477
478void HippoGridManager::parseFile(const std::string &fileName, bool mergeIfNewer) 478void HippoGridManager::parseFile(const std::string &fileName, bool mergeIfNewer)
479{ 479{
480 llifstream infile; 480 llifstream infile;
481 infile.open(fileName.c_str()); 481 infile.open(fileName.c_str());
482 if(!infile.is_open()) { 482 if(!infile.is_open()) {
483 llwarns << "Cannot find grid info file " << fileName << " to load." << llendl; 483 llwarns << "Cannot find grid info file " << fileName << " to load." << llendl;
484 return; 484 return;
485 } 485 }
486 486
487 LLSD gridInfo; 487 LLSD gridInfo;
488 if (LLSDSerialize::fromXML(gridInfo, infile) <= 0) { 488 if (LLSDSerialize::fromXML(gridInfo, infile) <= 0) {
489 llwarns << "Unable to parse grid info file " << fileName << '.' << llendl; 489 llwarns << "Unable to parse grid info file " << fileName << '.' << llendl;
490 return; 490 return;
491 } 491 }
492 492
493 llinfos << "Loading grid info file " << fileName << '.' << llendl; 493 llinfos << "Loading grid info file " << fileName << '.' << llendl;
494 parseData(gridInfo, mergeIfNewer); 494 parseData(gridInfo, mergeIfNewer);
495} 495}
496 496
497 497
498void HippoGridManager::parseData(LLSD &gridInfo, bool mergeIfNewer) 498void HippoGridManager::parseData(LLSD &gridInfo, bool mergeIfNewer)
499{ 499{
500 if (mergeIfNewer) { 500 if (mergeIfNewer) {
501 LLSD::array_const_iterator it, end = gridInfo.endArray(); 501 LLSD::array_const_iterator it, end = gridInfo.endArray();
502 for (it = gridInfo.beginArray(); it != end; ++it) { 502 for (it = gridInfo.beginArray(); it != end; ++it) {
503 LLSD gridMap = *it; 503 LLSD gridMap = *it;
504 if (gridMap.has("default_grids_version")) { 504 if (gridMap.has("default_grids_version")) {
505 int version = gridMap["default_grids_version"]; 505 int version = gridMap["default_grids_version"];
506 if (version <= mDefaultGridsVersion) return; 506 if (version <= mDefaultGridsVersion) return;
507 else break; 507 else break;
508 } 508 }
509 } 509 }
510 if (it == end) { 510 if (it == end) {
511 llwarns << "Grid data has no version number." << llendl; 511 llwarns << "Grid data has no version number." << llendl;
512 return; 512 return;
513 } 513 }
514 } 514 }
515 515
516 llinfos << "Loading grid data." << llendl; 516 llinfos << "Loading grid data." << llendl;
517 517
518 LLSD::array_const_iterator it, end = gridInfo.endArray(); 518 LLSD::array_const_iterator it, end = gridInfo.endArray();
519 for (it = gridInfo.beginArray(); it != end; ++it) { 519 for (it = gridInfo.beginArray(); it != end; ++it) {
520 LLSD gridMap = *it; 520 LLSD gridMap = *it;
521 if (gridMap.has("default_grids_version")) { 521 if (gridMap.has("default_grids_version")) {
522 mDefaultGridsVersion = gridMap["default_grids_version"]; 522 mDefaultGridsVersion = gridMap["default_grids_version"];
523 } else if (gridMap.has("gridnick") && gridMap.has("loginuri")) { 523 } else if (gridMap.has("gridnick") && gridMap.has("loginuri")) {
524 std::string gridnick = gridMap["gridnick"]; 524 std::string gridnick = gridMap["gridnick"];
525 HippoGridInfo *grid; 525 HippoGridInfo *grid;
526 GridIterator it = mGridInfo.find(gridnick); 526 GridIterator it = mGridInfo.find(gridnick);
527 bool newGrid = (it == mGridInfo.end()); 527 bool newGrid = (it == mGridInfo.end());
528 if (newGrid) { 528 if (newGrid) {
529 // create new grid info 529 // create new grid info
530 grid = new HippoGridInfo(gridnick); 530 grid = new HippoGridInfo(gridnick);
531 } else { 531 } else {
532 // update existing grid info 532 // update existing grid info
533 grid = it->second; 533 grid = it->second;
534 } 534 }
535 grid->setLoginUri(gridMap["loginuri"]); 535 grid->setLoginUri(gridMap["loginuri"]);
536 if (gridMap.has("platform")) grid->setPlatform(gridMap["platform"]); 536 if (gridMap.has("platform")) grid->setPlatform(gridMap["platform"]);
537 if (gridMap.has("gridname")) grid->setGridName(gridMap["gridname"]); 537 if (gridMap.has("gridname")) grid->setGridName(gridMap["gridname"]);
538 if (gridMap.has("loginpage")) grid->setLoginPage(gridMap["loginpage"]); 538 if (gridMap.has("loginpage")) grid->setLoginPage(gridMap["loginpage"]);
539 if (gridMap.has("helperuri")) grid->setHelperUri(gridMap["helperuri"]); 539 if (gridMap.has("helperuri")) grid->setHelperUri(gridMap["helperuri"]);
540 if (gridMap.has("website")) grid->setWebSite(gridMap["website"]); 540 if (gridMap.has("website")) grid->setWebSite(gridMap["website"]);
541 if (gridMap.has("support")) grid->setSupportUrl(gridMap["support"]); 541 if (gridMap.has("support")) grid->setSupportUrl(gridMap["support"]);
542 if (gridMap.has("register")) grid->setRegisterUrl(gridMap["register"]); 542 if (gridMap.has("register")) grid->setRegisterUrl(gridMap["register"]);
543 if (gridMap.has("password")) grid->setPasswordUrl(gridMap["password"]); 543 if (gridMap.has("password")) grid->setPasswordUrl(gridMap["password"]);
544 //if (gridMap.has("search")) grid->setSearchUrl(gridMap["search"]); 544 //if (gridMap.has("search")) grid->setSearchUrl(gridMap["search"]);
545 if (gridMap.has("render_compat")) grid->setRenderCompat(gridMap["render_compat"]); 545 if (gridMap.has("render_compat")) grid->setRenderCompat(gridMap["render_compat"]);
546 if (gridMap.has("firstname")) grid->setFirstName(gridMap["firstname"]); 546 if (gridMap.has("firstname")) grid->setFirstName(gridMap["firstname"]);
547 if (gridMap.has("lastname")) grid->setLastName(gridMap["lastname"]); 547 if (gridMap.has("lastname")) grid->setLastName(gridMap["lastname"]);
548 if (gridMap.has("avatarpassword")) grid->setAvatarPassword(gridMap["avatarpassword"]); 548 if (gridMap.has("avatarpassword")) grid->setAvatarPassword(gridMap["avatarpassword"]);
549 if (newGrid) addGrid(grid); 549 if (newGrid) addGrid(grid);
550 } 550 }
551 } 551 }
552} 552}
553 553
554 554
555void HippoGridManager::saveFile() 555void HippoGridManager::saveFile()
556{ 556{
557 // save default grid to client settings 557 // save default grid to client settings
558 gSavedSettings.setString("DefaultGrid", mDefaultGrid); 558 gSavedSettings.setString("DefaultGrid", mDefaultGrid);
559 559
560 // build LLSD 560 // build LLSD
561 LLSD gridInfo; 561 LLSD gridInfo;
562 gridInfo[0]["default_grids_version"] = mDefaultGridsVersion; 562 gridInfo[0]["default_grids_version"] = mDefaultGridsVersion;
563 563
564 // add grids 564 // add grids
565 S32 i = 1; 565 S32 i = 1;
566 GridIterator it, end = mGridInfo.end(); 566 GridIterator it, end = mGridInfo.end();
567 for (it = mGridInfo.begin(); it != end; ++it, i++) { 567 for (it = mGridInfo.begin(); it != end; ++it, i++) {
568 HippoGridInfo *grid = it->second; 568 HippoGridInfo *grid = it->second;
569 gridInfo[i]["gridnick"] = grid->getGridNick(); 569 gridInfo[i]["gridnick"] = grid->getGridNick();
570 gridInfo[i]["platform"] = HippoGridInfo::getPlatformString(grid->getPlatform()); 570 gridInfo[i]["platform"] = HippoGridInfo::getPlatformString(grid->getPlatform());
571 gridInfo[i]["gridname"] = grid->getGridName(); 571 gridInfo[i]["gridname"] = grid->getGridName();
572 gridInfo[i]["loginuri"] = grid->getLoginUri(); 572 gridInfo[i]["loginuri"] = grid->getLoginUri();
573 gridInfo[i]["loginpage"] = grid->getLoginPage(); 573 gridInfo[i]["loginpage"] = grid->getLoginPage();
574 gridInfo[i]["helperuri"] = grid->getHelperUri(); 574 gridInfo[i]["helperuri"] = grid->getHelperUri();
575 gridInfo[i]["website"] = grid->getWebSite(); 575 gridInfo[i]["website"] = grid->getWebSite();
576 gridInfo[i]["support"] = grid->getSupportUrl(); 576 gridInfo[i]["support"] = grid->getSupportUrl();
577 gridInfo[i]["register"] = grid->getRegisterUrl(); 577 gridInfo[i]["register"] = grid->getRegisterUrl();
578 gridInfo[i]["firstname"] = grid->getFirstName(); 578 gridInfo[i]["firstname"] = grid->getFirstName();
579 gridInfo[i]["lastname"] = grid->getLastName(); 579 gridInfo[i]["lastname"] = grid->getLastName();
580 gridInfo[i]["avatarpassword"] = grid->getAvatarPassword(); 580 gridInfo[i]["avatarpassword"] = grid->getAvatarPassword();
581 581
582 //gridInfo[i]["search"] = grid->getSearchUrl(); 582 //gridInfo[i]["search"] = grid->getSearchUrl();
583 gridInfo[i]["render_compat"] = grid->isRenderCompat(); 583 gridInfo[i]["render_compat"] = grid->isRenderCompat();
584 } 584 }
585 585
586 // write client grid info file 586 // write client grid info file
587 std::string fileName = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "grid_info.xml"); 587 std::string fileName = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "grid_info.xml");
588 llofstream file; 588 llofstream file;
589 file.open(fileName.c_str()); 589 file.open(fileName.c_str());
590 if (file.is_open()) { 590 if (file.is_open()) {
591 LLSDSerialize::toPrettyXML(gridInfo, file); 591 LLSDSerialize::toPrettyXML(gridInfo, file);
592 file.close(); 592 file.close();
593 llinfos << "Saved grids to " << fileName << llendl; 593 llinfos << "Saved grids to " << fileName << llendl;
594 } else { 594 } else {
595 llerrs << "Unable to open grid info file: " << fileName << llendl; 595 llerrs << "Unable to open grid info file: " << fileName << llendl;
596 } 596 }
597} 597}
diff --git a/linden/indra/newview/hippoGridManager.h b/linden/indra/newview/hippoGridManager.h
index 933a944..f6ee497 100644
--- a/linden/indra/newview/hippoGridManager.h
+++ b/linden/indra/newview/hippoGridManager.h
@@ -1,171 +1,171 @@
1#ifndef __HIPPO_GRID_MANAGER_H__ 1#ifndef __HIPPO_GRID_MANAGER_H__
2#define __HIPPO_GRID_MANAGER_H__ 2#define __HIPPO_GRID_MANAGER_H__
3 3
4 4
5#include <map> 5#include <map>
6#include <string> 6#include <string>
7 7
8#ifndef XML_STATIC 8#ifndef XML_STATIC
9#define XML_STATIC 9#define XML_STATIC
10#endif 10#endif
11#include <expat/expat.h> 11#include <expat/expat.h>
12 12
13 13
14class LLSD; 14class LLSD;
15 15
16 16
17class HippoGridInfo 17class HippoGridInfo
18{ 18{
19public: 19public:
20 enum Platform { 20 enum Platform {
21 PLATFORM_OTHER = 0, 21 PLATFORM_OTHER = 0,
22 PLATFORM_OPENSIM, 22 PLATFORM_OPENSIM,
23 PLATFORM_SECONDLIFE, 23 PLATFORM_SECONDLIFE,
24 PLATFORM_LAST 24 PLATFORM_LAST
25 }; 25 };
26 enum SearchType { 26 enum SearchType {
27 SEARCH_ALL_EMPTY, 27 SEARCH_ALL_EMPTY,
28 SEARCH_ALL_QUERY, 28 SEARCH_ALL_QUERY,
29 SEARCH_ALL_TEMPLATE 29 SEARCH_ALL_TEMPLATE
30 }; 30 };
31 31
32 explicit HippoGridInfo(const std::string &gridNick); 32 explicit HippoGridInfo(const std::string &gridNick);
33 33
34 Platform getPlatform() const { return mPlatform; } 34 Platform getPlatform() const { return mPlatform; }
35 const std::string &getGridNick() const { return mGridNick; } 35 const std::string &getGridNick() const { return mGridNick; }
36 const std::string &getGridName() const { return mGridName; } 36 const std::string &getGridName() const { return mGridName; }
37 const std::string &getLoginUri() const { return mLoginUri; } 37 const std::string &getLoginUri() const { return mLoginUri; }
38 const std::string &getLoginPage() const { return mLoginPage; } 38 const std::string &getLoginPage() const { return mLoginPage; }
39 const std::string &getHelperUri() const { return mHelperUri; } 39 const std::string &getHelperUri() const { return mHelperUri; }
40 const std::string &getWebSite() const { return mWebSite; } 40 const std::string &getWebSite() const { return mWebSite; }
41 const std::string &getSupportUrl() const { return mSupportUrl; } 41 const std::string &getSupportUrl() const { return mSupportUrl; }
42 const std::string &getRegisterUrl() const { return mRegisterUrl; } 42 const std::string &getRegisterUrl() const { return mRegisterUrl; }
43 const std::string &getPasswordUrl() const { return mPasswordUrl; } 43 const std::string &getPasswordUrl() const { return mPasswordUrl; }
44 const std::string &getSearchUrl() const { return mSearchUrl; } 44 const std::string &getSearchUrl() const { return mSearchUrl; }
45 const std::string &getFirstName() const { return mFirstName; } 45 const std::string &getFirstName() const { return mFirstName; }
46 const std::string &getLastName() const { return mLastName; } 46 const std::string &getLastName() const { return mLastName; }
47 const std::string &getAvatarPassword() const { return mAvatarPassword; } 47 const std::string &getAvatarPassword() const { return mAvatarPassword; }
48 std::string getSearchUrl(SearchType ty) const; 48 std::string getSearchUrl(SearchType ty) const;
49 bool isRenderCompat() const { return mRenderCompat; } 49 bool isRenderCompat() const { return mRenderCompat; }
50 50
51 const std::string &getCurrencySymbol() const { return mCurrencySymbol; } 51 const std::string &getCurrencySymbol() const { return mCurrencySymbol; }
52 const std::string &getRealCurrencySymbol() const { return mRealCurrencySymbol; } 52 const std::string &getRealCurrencySymbol() const { return mRealCurrencySymbol; }
53 std::string getUploadFee() const; 53 std::string getUploadFee() const;
54 std::string getGroupCreationFee() const; 54 std::string getGroupCreationFee() const;
55 std::string getDirectoryFee() const; 55 std::string getDirectoryFee() const;
56 56
57 bool isOpenSimulator() const { return (mPlatform == PLATFORM_OPENSIM ); } 57 bool isOpenSimulator() const { return (mPlatform == PLATFORM_OPENSIM ); }
58 bool isSecondLife() const { return (mPlatform == PLATFORM_SECONDLIFE); } 58 bool isSecondLife() const { return (mPlatform == PLATFORM_SECONDLIFE); }
59 59
60 void setPlatform (const std::string &platform); 60 void setPlatform (const std::string &platform);
61 void setPlatform (Platform platform); 61 void setPlatform (Platform platform);
62 void setGridName (const std::string &gridName) { mGridName = gridName; } 62 void setGridName (const std::string &gridName) { mGridName = gridName; }
63 void setLoginUri (const std::string &loginUri) { mLoginUri = loginUri; cleanUpUri(mLoginUri); } 63 void setLoginUri (const std::string &loginUri) { mLoginUri = loginUri; cleanUpUri(mLoginUri); }
64 void setLoginPage(const std::string &loginPage) { mLoginPage = loginPage; } 64 void setLoginPage(const std::string &loginPage) { mLoginPage = loginPage; }
65 void setHelperUri(const std::string &helperUri) { mHelperUri = helperUri; cleanUpUri(mHelperUri); } 65 void setHelperUri(const std::string &helperUri) { mHelperUri = helperUri; cleanUpUri(mHelperUri); }
66 void setWebSite (const std::string &website) { mWebSite = website; } 66 void setWebSite (const std::string &website) { mWebSite = website; }
67 void setSupportUrl(const std::string &url) { mSupportUrl = url; } 67 void setSupportUrl(const std::string &url) { mSupportUrl = url; }
68 void setRegisterUrl(const std::string &url) { mRegisterUrl = url; } 68 void setRegisterUrl(const std::string &url) { mRegisterUrl = url; }
69 void setPasswordUrl(const std::string &url) { mPasswordUrl = url; } 69 void setPasswordUrl(const std::string &url) { mPasswordUrl = url; }
70 void setSearchUrl(const std::string &url) { mSearchUrl = url; } 70 void setSearchUrl(const std::string &url) { mSearchUrl = url; }
71 void setRenderCompat(bool compat) { mRenderCompat = compat; } 71 void setRenderCompat(bool compat) { mRenderCompat = compat; }
72 void setFirstName(const std::string &firstName) { mFirstName = firstName; } //aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 72 void setFirstName(const std::string &firstName) { mFirstName = firstName; } //aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
73 void setLastName(const std::string &lastName) { mLastName = lastName; } 73 void setLastName(const std::string &lastName) { mLastName = lastName; }
74 void setAvatarPassword(const std::string &avatarPassword) { mAvatarPassword = avatarPassword; } 74 void setAvatarPassword(const std::string &avatarPassword) { mAvatarPassword = avatarPassword; }
75 75
76 void setCurrencySymbol(const std::string &sym) { mCurrencySymbol = sym.substr(0, 3); } 76 void setCurrencySymbol(const std::string &sym) { mCurrencySymbol = sym.substr(0, 3); }
77 void setRealCurrencySymbol(const std::string &sym) { mRealCurrencySymbol = sym.substr(0, 3); } 77 void setRealCurrencySymbol(const std::string &sym) { mRealCurrencySymbol = sym.substr(0, 3); }
78 void setDirectoryFee(int fee) { mDirectoryFee = fee; } 78 void setDirectoryFee(int fee) { mDirectoryFee = fee; }
79 79
80 bool retrieveGridInfo(); 80 bool retrieveGridInfo();
81 81
82 static const char *getPlatformString(Platform platform); 82 static const char *getPlatformString(Platform platform);
83 static void cleanUpGridNick(std::string &gridnick); 83 static void cleanUpGridNick(std::string &gridnick);
84 84
85 static HippoGridInfo FALLBACK_GRIDINFO; 85 static HippoGridInfo FALLBACK_GRIDINFO;
86 static void initFallback(); 86 static void initFallback();
87 87
88private: 88private:
89 Platform mPlatform; 89 Platform mPlatform;
90 std::string mGridNick; 90 std::string mGridNick;
91 std::string mGridName; 91 std::string mGridName;
92 std::string mLoginUri; 92 std::string mLoginUri;
93 std::string mLoginPage; 93 std::string mLoginPage;
94 std::string mHelperUri; 94 std::string mHelperUri;
95 std::string mWebSite; 95 std::string mWebSite;
96 std::string mSupportUrl; 96 std::string mSupportUrl;
97 std::string mRegisterUrl; 97 std::string mRegisterUrl;
98 std::string mPasswordUrl; 98 std::string mPasswordUrl;
99 std::string mSearchUrl; 99 std::string mSearchUrl;
100 std::string mFirstName; 100 std::string mFirstName;
101 std::string mLastName; 101 std::string mLastName;
102 std::string mAvatarPassword; 102 std::string mAvatarPassword;
103 bool mRenderCompat; 103 bool mRenderCompat;
104 104
105 std::string mCurrencySymbol; 105 std::string mCurrencySymbol;
106 std::string mRealCurrencySymbol; 106 std::string mRealCurrencySymbol;
107 int mDirectoryFee; 107 int mDirectoryFee;
108 108
109 // for parsing grid info XML 109 // for parsing grid info XML
110 enum XmlState { 110 enum XmlState {
111 XML_VOID, XML_GRIDNICK, XML_PLATFORM, XML_GRIDNAME, 111 XML_VOID, XML_GRIDNICK, XML_PLATFORM, XML_GRIDNAME,
112 XML_LOGINURI, XML_LOGINPAGE, XML_HELPERURI, 112 XML_LOGINURI, XML_LOGINPAGE, XML_HELPERURI,
113 XML_WEBSITE, XML_SUPPORT, XML_REGISTER, XML_PASSWORD, XML_SEARCH 113 XML_WEBSITE, XML_SUPPORT, XML_REGISTER, XML_PASSWORD, XML_SEARCH
114 }; 114 };
115 XmlState mXmlState; 115 XmlState mXmlState;
116 116
117 static void cleanUpUri(std::string &uri); 117 static void cleanUpUri(std::string &uri);
118 void formatFee(std::string &fee, int cost, bool showFree) const; 118 void formatFee(std::string &fee, int cost, bool showFree) const;
119 119
120 static void onXmlElementStart(void *userData, const XML_Char *name, const XML_Char **atts); 120 static void onXmlElementStart(void *userData, const XML_Char *name, const XML_Char **atts);
121 static void onXmlElementEnd(void *userData, const XML_Char *name); 121 static void onXmlElementEnd(void *userData, const XML_Char *name);
122 static void onXmlCharacterData(void *userData, const XML_Char *s, int len); 122 static void onXmlCharacterData(void *userData, const XML_Char *s, int len);
123}; 123};
124 124
125 125
126class HippoGridManager 126class HippoGridManager
127{ 127{
128public: 128public:
129 HippoGridManager(); 129 HippoGridManager();
130 ~HippoGridManager(); 130 ~HippoGridManager();
131 131
132 void init(); 132 void init();
133 void saveFile(); 133 void saveFile();
134 void discardAndReload(); 134 void discardAndReload();
135 135
136 HippoGridInfo *getGrid(const std::string &grid) const; 136 HippoGridInfo *getGrid(const std::string &grid) const;
137 HippoGridInfo *getConnectedGrid() const { return (mConnectedGrid)? mConnectedGrid: getCurrentGrid(); } 137 HippoGridInfo *getConnectedGrid() const { return (mConnectedGrid)? mConnectedGrid: getCurrentGrid(); }
138 HippoGridInfo *getCurrentGrid() const; 138 HippoGridInfo *getCurrentGrid() const;
139 const std::string &getDefaultGridNick() const { return mDefaultGrid; } 139 const std::string &getDefaultGridNick() const { return mDefaultGrid; }
140 const std::string &getCurrentGridNick() const { return mCurrentGrid; } 140 const std::string &getCurrentGridNick() const { return mCurrentGrid; }
141 141
142 void setDefaultGrid(const std::string &grid); 142 void setDefaultGrid(const std::string &grid);
143 void setCurrentGrid(const std::string &grid); 143 void setCurrentGrid(const std::string &grid);
144 void setCurrentGridAsConnected() { mConnectedGrid = getCurrentGrid(); } 144 void setCurrentGridAsConnected() { mConnectedGrid = getCurrentGrid(); }
145 145
146 void addGrid(HippoGridInfo *grid); 146 void addGrid(HippoGridInfo *grid);
147 void deleteGrid(const std::string &grid); 147 void deleteGrid(const std::string &grid);
148 148
149 typedef std::map<std::string, HippoGridInfo*>::iterator GridIterator; 149 typedef std::map<std::string, HippoGridInfo*>::iterator GridIterator;
150 GridIterator beginGrid() { return mGridInfo.begin(); } 150 GridIterator beginGrid() { return mGridInfo.begin(); }
151 GridIterator endGrid() { return mGridInfo.end(); } 151 GridIterator endGrid() { return mGridInfo.end(); }
152 152
153private: 153private:
154 std::map<std::string, HippoGridInfo*> mGridInfo; 154 std::map<std::string, HippoGridInfo*> mGridInfo;
155 std::string mDefaultGrid; 155 std::string mDefaultGrid;
156 std::string mCurrentGrid; 156 std::string mCurrentGrid;
157 HippoGridInfo *mConnectedGrid; 157 HippoGridInfo *mConnectedGrid;
158 int mDefaultGridsVersion; 158 int mDefaultGridsVersion;
159 159
160 void cleanup(); 160 void cleanup();
161 void loadFromFile(); 161 void loadFromFile();
162 void parseFile(const std::string &fileName, bool mergeIfNewer); 162 void parseFile(const std::string &fileName, bool mergeIfNewer);
163 void parseUrl(const char *url, bool mergeIfNewer); 163 void parseUrl(const char *url, bool mergeIfNewer);
164 void parseData(LLSD &gridInfo, bool mergeIfNewer); 164 void parseData(LLSD &gridInfo, bool mergeIfNewer);
165}; 165};
166 166
167 167
168extern HippoGridManager *gHippoGridManager; 168extern HippoGridManager *gHippoGridManager;
169 169
170 170
171#endif 171#endif
diff --git a/linden/indra/newview/hippoLimits.cpp b/linden/indra/newview/hippoLimits.cpp
index 63a5899..d5deb9f 100644
--- a/linden/indra/newview/hippoLimits.cpp
+++ b/linden/indra/newview/hippoLimits.cpp
@@ -1,54 +1,54 @@
1 1
2 2
3#include "hippoLimits.h" 3#include "hippoLimits.h"
4 4
5#include "hippoGridManager.h" 5#include "hippoGridManager.h"
6 6
7#include <llerror.h> 7#include <llerror.h>
8 8
9 9
10HippoLimits *gHippoLimits = 0; 10HippoLimits *gHippoLimits = 0;
11 11
12 12
13HippoLimits::HippoLimits() 13HippoLimits::HippoLimits()
14{ 14{
15 setLimits(); 15 setLimits();
16} 16}
17 17
18 18
19void HippoLimits::setLimits() 19void HippoLimits::setLimits()
20{ 20{
21 if (gHippoGridManager->getConnectedGrid()->getPlatform() == HippoGridInfo::PLATFORM_SECONDLIFE) { 21 if (gHippoGridManager->getConnectedGrid()->getPlatform() == HippoGridInfo::PLATFORM_SECONDLIFE) {
22 setSecondLifeLimits(); 22 setSecondLifeLimits();
23 } else { 23 } else {
24 setOpenSimLimits(); 24 setOpenSimLimits();
25 } 25 }
26} 26}
27 27
28 28
29void HippoLimits::setOpenSimLimits() 29void HippoLimits::setOpenSimLimits()
30{ 30{
31 mMaxAgentGroups = 100; 31 mMaxAgentGroups = 100;
32 mMaxPrimScale = 256.0f; 32 mMaxPrimScale = 256.0f;
33 mMaxHeight = 10000.0f; 33 mMaxHeight = 10000.0f;
34 if (gHippoGridManager->getConnectedGrid()->isRenderCompat()) { 34 if (gHippoGridManager->getConnectedGrid()->isRenderCompat()) {
35 llinfos << "Using rendering compatible OpenSim limits." << llendl; 35 llinfos << "Using rendering compatible OpenSim limits." << llendl;
36 mMinHoleSize = 0.05f; 36 mMinHoleSize = 0.05f;
37 mMaxHollow = 0.95f; 37 mMaxHollow = 0.95f;
38 } else { 38 } else {
39 llinfos << "Using Hippo OpenSim limits." << llendl; 39 llinfos << "Using Hippo OpenSim limits." << llendl;
40 mMinHoleSize = 0.01f; 40 mMinHoleSize = 0.01f;
41 mMaxHollow = 0.99f; 41 mMaxHollow = 0.99f;
42 } 42 }
43} 43}
44 44
45void HippoLimits::setSecondLifeLimits() 45void HippoLimits::setSecondLifeLimits()
46{ 46{
47 llinfos << "Using Second Life limits." << llendl; 47 llinfos << "Using Second Life limits." << llendl;
48 mMaxAgentGroups = 25; 48 mMaxAgentGroups = 25;
49 mMaxPrimScale = 10.0f; 49 mMaxPrimScale = 10.0f;
50 mMaxHeight = 4096.0f; 50 mMaxHeight = 4096.0f;
51 mMinHoleSize = 0.05f; 51 mMinHoleSize = 0.05f;
52 mMaxHollow = 0.95f; 52 mMaxHollow = 0.95f;
53} 53}
54 54
diff --git a/linden/indra/newview/hippoLimits.h b/linden/indra/newview/hippoLimits.h
index 333a979..900480b 100644
--- a/linden/indra/newview/hippoLimits.h
+++ b/linden/indra/newview/hippoLimits.h
@@ -1,33 +1,33 @@
1#ifndef __HIPPO_LIMITS_H__ 1#ifndef __HIPPO_LIMITS_H__
2#define __HIPPO_LIMITS_H__ 2#define __HIPPO_LIMITS_H__
3 3
4 4
5class HippoLimits 5class HippoLimits
6{ 6{
7public: 7public:
8 HippoLimits(); 8 HippoLimits();
9 9
10 int getMaxAgentGroups() const { return mMaxAgentGroups; } 10 int getMaxAgentGroups() const { return mMaxAgentGroups; }
11 float getMaxHeight() const { return mMaxHeight; } 11 float getMaxHeight() const { return mMaxHeight; }
12 float getMinHoleSize() const { return mMinHoleSize; } 12 float getMinHoleSize() const { return mMinHoleSize; }
13 float getMaxHollow() const { return mMaxHollow; } 13 float getMaxHollow() const { return mMaxHollow; }
14 float getMaxPrimScale() const { return mMaxPrimScale; } 14 float getMaxPrimScale() const { return mMaxPrimScale; }
15 15
16 void setLimits(); 16 void setLimits();
17 17
18private: 18private:
19 int mMaxAgentGroups; 19 int mMaxAgentGroups;
20 float mMaxHeight; 20 float mMaxHeight;
21 float mMinHoleSize; 21 float mMinHoleSize;
22 float mMaxHollow; 22 float mMaxHollow;
23 float mMaxPrimScale; 23 float mMaxPrimScale;
24 24
25 void setOpenSimLimits(); 25 void setOpenSimLimits();
26 void setSecondLifeLimits(); 26 void setSecondLifeLimits();
27}; 27};
28 28
29 29
30extern HippoLimits *gHippoLimits; 30extern HippoLimits *gHippoLimits;
31 31
32 32
33#endif 33#endif
diff --git a/linden/indra/newview/hippoRestRequest.cpp b/linden/indra/newview/hippoRestRequest.cpp
index ab8a557..cf518de 100644
--- a/linden/indra/newview/hippoRestRequest.cpp
+++ b/linden/indra/newview/hippoRestRequest.cpp
@@ -1,54 +1,54 @@
1 1
2 2
3#include "hippoRestRequest.h" 3#include "hippoRestRequest.h"
4 4
5#ifndef CURL_STATICLIB 5#ifndef CURL_STATICLIB
6#define CURL_STATICLIB 1 6#define CURL_STATICLIB 1
7#endif 7#endif
8#include <curl/curl.h> 8#include <curl/curl.h>
9 9
10#include <stdtypes.h> 10#include <stdtypes.h>
11#include <llerror.h> 11#include <llerror.h>
12 12
13 13
14static size_t curlWrite(void *ptr, size_t size, size_t nmemb, void *userData) 14static size_t curlWrite(void *ptr, size_t size, size_t nmemb, void *userData)
15{ 15{
16 std::string *result = (std::string*)userData; 16 std::string *result = (std::string*)userData;
17 size_t bytes = (size * nmemb); 17 size_t bytes = (size * nmemb);
18 result->append((char*)ptr, bytes); 18 result->append((char*)ptr, bytes);
19 return nmemb; 19 return nmemb;
20} 20}
21 21
22 22
23//static 23//static
24int HippoRestRequest::getBlocking(const std::string &url, std::string *result) 24int HippoRestRequest::getBlocking(const std::string &url, std::string *result)
25{ 25{
26 llinfos << "Requesting: " << url << llendl; 26 llinfos << "Requesting: " << url << llendl;
27 27
28 char curlErrorBuffer[CURL_ERROR_SIZE]; 28 char curlErrorBuffer[CURL_ERROR_SIZE];
29 CURL* curlp = curl_easy_init(); 29 CURL* curlp = curl_easy_init();
30 30
31 curl_easy_setopt(curlp, CURLOPT_NOSIGNAL, 1); // don't use SIGALRM for timeouts 31 curl_easy_setopt(curlp, CURLOPT_NOSIGNAL, 1); // don't use SIGALRM for timeouts
32 curl_easy_setopt(curlp, CURLOPT_TIMEOUT, 5); // seconds 32 curl_easy_setopt(curlp, CURLOPT_TIMEOUT, 5); // seconds
33 33
34 curl_easy_setopt(curlp, CURLOPT_WRITEFUNCTION, curlWrite); 34 curl_easy_setopt(curlp, CURLOPT_WRITEFUNCTION, curlWrite);
35 curl_easy_setopt(curlp, CURLOPT_WRITEDATA, result); 35 curl_easy_setopt(curlp, CURLOPT_WRITEDATA, result);
36 curl_easy_setopt(curlp, CURLOPT_URL, url.c_str()); 36 curl_easy_setopt(curlp, CURLOPT_URL, url.c_str());
37 curl_easy_setopt(curlp, CURLOPT_ERRORBUFFER, curlErrorBuffer); 37 curl_easy_setopt(curlp, CURLOPT_ERRORBUFFER, curlErrorBuffer);
38 curl_easy_setopt(curlp, CURLOPT_FAILONERROR, 1); 38 curl_easy_setopt(curlp, CURLOPT_FAILONERROR, 1);
39 39
40 *result = ""; 40 *result = "";
41 S32 curlSuccess = curl_easy_perform(curlp); 41 S32 curlSuccess = curl_easy_perform(curlp);
42 S32 httpStatus = 499; 42 S32 httpStatus = 499;
43 curl_easy_getinfo(curlp, CURLINFO_RESPONSE_CODE, &httpStatus); 43 curl_easy_getinfo(curlp, CURLINFO_RESPONSE_CODE, &httpStatus);
44 44
45 if (curlSuccess != 0) { 45 if (curlSuccess != 0) {
46 llwarns << "CURL ERROR (HTTP Status " << httpStatus << "): " << curlErrorBuffer << llendl; 46 llwarns << "CURL ERROR (HTTP Status " << httpStatus << "): " << curlErrorBuffer << llendl;
47 } else if (httpStatus != 200) { 47 } else if (httpStatus != 200) {
48 llwarns << "HTTP Error " << httpStatus << ", but no Curl error." << llendl; 48 llwarns << "HTTP Error " << httpStatus << ", but no Curl error." << llendl;
49 } 49 }
50 50
51 curl_easy_cleanup(curlp); 51 curl_easy_cleanup(curlp);
52 return httpStatus; 52 return httpStatus;
53} 53}
54 54
diff --git a/linden/indra/newview/hippoRestRequest.h b/linden/indra/newview/hippoRestRequest.h
index e43233c..1dcb4a0 100644
--- a/linden/indra/newview/hippoRestRequest.h
+++ b/linden/indra/newview/hippoRestRequest.h
@@ -1,16 +1,16 @@
1#ifndef __HIPPO_REST_REQTUEST_H__ 1#ifndef __HIPPO_REST_REQTUEST_H__
2#define __HIPPO_REST_REQTUEST_H__ 2#define __HIPPO_REST_REQTUEST_H__
3 3
4 4
5#include <string> 5#include <string>
6 6
7 7
8class HippoRestRequest 8class HippoRestRequest
9{ 9{
10 public: 10 public:
11 static int getBlocking(const std::string &url, std::string *result); 11 static int getBlocking(const std::string &url, std::string *result);
12 12
13}; 13};
14 14
15 15
16#endif 16#endif
diff --git a/linden/indra/newview/hippoUpdate.cpp b/linden/indra/newview/hippoUpdate.cpp
index 7a33487..872ca30 100644
--- a/linden/indra/newview/hippoUpdate.cpp
+++ b/linden/indra/newview/hippoUpdate.cpp
@@ -1,92 +1,92 @@
1 1
2#include "hippoUpdate.h" 2#include "hippoUpdate.h"
3 3
4#include <cstdio> 4#include <cstdio>
5#include <list> 5#include <list>
6#include <vector> 6#include <vector>
7 7
8#include <stdtypes.h> 8#include <stdtypes.h>
9#include <llhttpclient.h> 9#include <llhttpclient.h>
10#include <llmemory.h> 10#include <llmemory.h>
11#include <llversionviewer.h> 11#include <llversionviewer.h>
12#include "llviewercontrol.h" 12#include "llviewercontrol.h"
13#include "llviewernetwork.h" 13#include "llviewernetwork.h"
14#include "llweb.h" 14#include "llweb.h"
15#include <llwindow.h> 15#include <llwindow.h>
16 16
17 17
18std::string gHippoChannel; 18std::string gHippoChannel;
19 19
20 20
21// static 21// static
22bool HippoUpdate::checkUpdate() 22bool HippoUpdate::checkUpdate()
23{ 23{
24 llinfos << "Hippo Update Check..." << llendl; 24 llinfos << "Hippo Update Check..." << llendl;
25 25
26 // get channel name 26 // get channel name
27 gHippoChannel = gSavedSettings.getString("ChannelName"); 27 gHippoChannel = gSavedSettings.getString("ChannelName");
28 28
29 // get mac address 29 // get mac address
30 char macAddress[18]; 30 char macAddress[18];
31 sprintf(macAddress, "%02x:%02x:%02x:%02x:%02x:%02x", 31 sprintf(macAddress, "%02x:%02x:%02x:%02x:%02x:%02x",
32 gMACAddress[0], gMACAddress[1], gMACAddress[2], gMACAddress[3], gMACAddress[4], gMACAddress[5]); 32 gMACAddress[0], gMACAddress[1], gMACAddress[2], gMACAddress[3], gMACAddress[4], gMACAddress[5]);
33 33
34 // build URL for update check 34 // build URL for update check
35 char url[1000]; 35 char url[1000];
36 snprintf(url, 1000, 36 snprintf(url, 1000,
37/* "http://update.mjm.game-host.org/os/viewer.php?" 37/* "http://update.mjm.game-host.org/os/viewer.php?"
38 "product=%s&channel=%s&" 38 "product=%s&channel=%s&"
39 "version_major=%d&version_minor=%d&version_patch=%d&version_base=%s&" 39 "version_major=%d&version_minor=%d&version_patch=%d&version_base=%s&"
40 "platform=%s&mac=%s", 40 "platform=%s&mac=%s",
41 LL_PRODUCT, LL_CHANNEL_CSTR, 41 LL_PRODUCT, LL_CHANNEL_CSTR,
42 LL_VERSION_MAJOR, LL_VERSION_MINOR, LL_VERSION_PATCH, LL_VERSION_BASE, 42 LL_VERSION_MAJOR, LL_VERSION_MINOR, LL_VERSION_PATCH, LL_VERSION_BASE,
43 LL_PLATFORM*/"", macAddress); 43 LL_PLATFORM*/"", macAddress);
44 44
45 // query update server 45 // query update server
46 std::string escaped_url = LLWeb::escapeURL(url); 46 std::string escaped_url = LLWeb::escapeURL(url);
47 LLSD response = LLHTTPClient::blockingGet(escaped_url.c_str()); 47 LLSD response = LLHTTPClient::blockingGet(escaped_url.c_str());
48 48
49 // check response, return on error 49 // check response, return on error
50 S32 status = response["status"].asInteger(); 50 S32 status = response["status"].asInteger();
51 if ((status != 200) || !response["body"].isMap()) { 51 if ((status != 200) || !response["body"].isMap()) {
52 llinfos << "Hippo Update failed (" << status << "): " 52 llinfos << "Hippo Update failed (" << status << "): "
53 << (response["body"].isString()? response["body"].asString(): "<unknown error>") 53 << (response["body"].isString()? response["body"].asString(): "<unknown error>")
54 << llendl; 54 << llendl;
55 return true; 55 return true;
56 } 56 }
57 57
58 // get data from response 58 // get data from response
59 LLSD data = response["body"]; 59 LLSD data = response["body"];
60 std::string webpage = (data.has("webpage") && data["webpage"].isString())? data["webpage"].asString(): ""; 60 std::string webpage = (data.has("webpage") && data["webpage"].isString())? data["webpage"].asString(): "";
61 std::string message = (data.has("message") && data["message"].isString())? data["message"].asString(): ""; 61 std::string message = (data.has("message") && data["message"].isString())? data["message"].asString(): "";
62 std::string yourVersion = (data.has("yourVersion") && data["yourVersion"].isString())? data["yourVersion"].asString(): ""; 62 std::string yourVersion = (data.has("yourVersion") && data["yourVersion"].isString())? data["yourVersion"].asString(): "";
63 std::string curVersion = (data.has("curVersion") && data["curVersion"].isString())? data["curVersion"].asString(): ""; 63 std::string curVersion = (data.has("curVersion") && data["curVersion"].isString())? data["curVersion"].asString(): "";
64 bool update = (data.has("update") && data["update"].isBoolean())? data["update"].asBoolean(): false; 64 bool update = (data.has("update") && data["update"].isBoolean())? data["update"].asBoolean(): false;
65 bool mandatory = (data.has("mandatory") && data["mandatory"].isBoolean())? data["mandatory"].asBoolean(): false; 65 bool mandatory = (data.has("mandatory") && data["mandatory"].isBoolean())? data["mandatory"].asBoolean(): false;
66 66
67 // log and return, if no update available 67 // log and return, if no update available
68 llinfos << "Your version is " << yourVersion << ", current version is " << curVersion << '.' << llendl; 68 llinfos << "Your version is " << yourVersion << ", current version is " << curVersion << '.' << llendl;
69 if (!update) return true; 69 if (!update) return true;
70 llinfos << "Update is " << (mandatory? "mandatory.": "optional.") << llendl; 70 llinfos << "Update is " << (mandatory? "mandatory.": "optional.") << llendl;
71 71
72 // show update dialog 72 // show update dialog
73 char msg[1000]; 73 char msg[1000];
74 snprintf(msg, 1000, 74 snprintf(msg, 1000,
75 "There is a new viewer version available.\n" 75 "There is a new viewer version available.\n"
76 "\n" 76 "\n"
77 "Your version: %s\n" 77 "Your version: %s\n"
78 "Current version: %s\n" 78 "Current version: %s\n"
79 "%s\n" 79 "%s\n"
80 "Do you want to visit the web site?", 80 "Do you want to visit the web site?",
81 yourVersion.c_str(), curVersion.c_str(), 81 yourVersion.c_str(), curVersion.c_str(),
82 mandatory? "\nThis is a mandatory update.\n": ""); 82 mandatory? "\nThis is a mandatory update.\n": "");
83 S32 button = OSMessageBox(msg, "Hippo OpenSim Viewer Update", OSMB_YESNO); 83 S32 button = OSMessageBox(msg, "Hippo OpenSim Viewer Update", OSMB_YESNO);
84 if (button == OSBTN_YES) { 84 if (button == OSBTN_YES) {
85 llinfos << "Taking user to " << webpage << llendl; 85 llinfos << "Taking user to " << webpage << llendl;
86 LLWeb::loadURLExternal(webpage); 86 LLWeb::loadURLExternal(webpage);
87 // exit the viewer 87 // exit the viewer
88 return false; 88 return false;
89 } 89 }
90 90
91 return !mandatory; 91 return !mandatory;
92} 92}
diff --git a/linden/indra/newview/hippoUpdate.h b/linden/indra/newview/hippoUpdate.h
index 632b2ef..559c8b3 100644
--- a/linden/indra/newview/hippoUpdate.h
+++ b/linden/indra/newview/hippoUpdate.h
@@ -1,12 +1,12 @@
1#ifndef __HIPPO_UPDATE_H__ 1#ifndef __HIPPO_UPDATE_H__
2#define __HIPPO_UPDATE_H__ 2#define __HIPPO_UPDATE_H__
3 3
4 4
5class HippoUpdate 5class HippoUpdate
6{ 6{
7 public: 7 public:
8 static bool checkUpdate(); 8 static bool checkUpdate();
9}; 9};
10 10
11 11
12#endif 12#endif