diff options
Diffstat (limited to 'linden/indra/newview/hippogridmanager.cpp')
-rw-r--r-- | linden/indra/newview/hippogridmanager.cpp | 479 |
1 files changed, 222 insertions, 257 deletions
diff --git a/linden/indra/newview/hippogridmanager.cpp b/linden/indra/newview/hippogridmanager.cpp index c08709d..6f28d87 100644 --- a/linden/indra/newview/hippogridmanager.cpp +++ b/linden/indra/newview/hippogridmanager.cpp | |||
@@ -1,4 +1,33 @@ | |||
1 | // Ported to Imprudence from the Hippo OpenSim Viewer by Jacek Antonelli | 1 | /** |
2 | * @file hippogridmanager.cpp | ||
3 | * @brief stores grid information | ||
4 | * | ||
5 | * $LicenseInfo:firstyear=2011&license=viewergpl$ | ||
6 | * | ||
7 | * Copyright (c) 2011 | ||
8 | * Ported to Imprudence from the Hippo OpenSim Viewer by Jacek Antonelli | ||
9 | * | ||
10 | * Imprudence Viewer Source Code | ||
11 | * The source code in this file ("Source Code") is provided to you | ||
12 | * under the terms of the GNU General Public License, version 2.0 | ||
13 | * ("GPL"). Terms of the GPL can be found in doc/GPL-license.txt in | ||
14 | * this distribution, or online at | ||
15 | * http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
16 | * | ||
17 | * There are special exceptions to the terms and conditions of the GPL as | ||
18 | * it is applied to this Source Code. View the full text of the exception | ||
19 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
20 | * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
21 | * | ||
22 | * By copying, modifying or distributing this software, you acknowledge | ||
23 | * that you have read and understood your obligations described above, | ||
24 | * and agree to abide by those obligations. | ||
25 | * | ||
26 | * ALL SOURCE CODE IS PROVIDED "AS IS." THE AUTHOR MAKES NO | ||
27 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
28 | * COMPLETENESS OR PERFORMANCE. | ||
29 | * $/LicenseInfo$ | ||
30 | */ | ||
2 | 31 | ||
3 | #include "llviewerprecompiledheaders.h" | 32 | #include "llviewerprecompiledheaders.h" |
4 | 33 | ||
@@ -12,10 +41,14 @@ | |||
12 | #include <llerror.h> | 41 | #include <llerror.h> |
13 | #include <llfile.h> | 42 | #include <llfile.h> |
14 | #include <llhttpclient.h> | 43 | #include <llhttpclient.h> |
44 | #include "llmd5.h" | ||
15 | #include <llsdserialize.h> | 45 | #include <llsdserialize.h> |
46 | |||
16 | #include "lltrans.h" | 47 | #include "lltrans.h" |
17 | #include "llviewercontrol.h" | 48 | #include "llviewercontrol.h" |
49 | #include "llviewernetwork.h" // gMacAddress | ||
18 | #include "llweb.h" | 50 | #include "llweb.h" |
51 | #include "llxorcipher.h" // saved password, MAC address | ||
19 | 52 | ||
20 | #include "hipporestrequest.h" | 53 | #include "hipporestrequest.h" |
21 | 54 | ||
@@ -43,150 +76,41 @@ HippoGridInfo::HippoGridInfo(const std::string& gridNick) : | |||
43 | mPlatform(PLATFORM_OPENSIM), | 76 | mPlatform(PLATFORM_OPENSIM), |
44 | mGridNick(gridNick), | 77 | mGridNick(gridNick), |
45 | mGridName(LLStringUtil::null), | 78 | mGridName(LLStringUtil::null), |
46 | mLoginUri(LLStringUtil::null), | 79 | mLoginURI(LLStringUtil::null), |
47 | mLoginPage(LLStringUtil::null), | 80 | mLoginPage(LLStringUtil::null), |
48 | mHelperUri(LLStringUtil::null), | 81 | mHelperURI(LLStringUtil::null), |
49 | mWebSite(LLStringUtil::null), | 82 | mWebSite(LLStringUtil::null), |
50 | mSupportUrl(LLStringUtil::null), | 83 | mSupportURL(LLStringUtil::null), |
51 | mRegisterUrl(LLStringUtil::null), | 84 | mRegisterURL(LLStringUtil::null), |
52 | mPasswordUrl(LLStringUtil::null), | 85 | mPasswordURL(LLStringUtil::null), |
53 | mSearchUrl(LLStringUtil::null), | 86 | mSearchURL(LLStringUtil::null), |
54 | mFirstName(LLStringUtil::null), | 87 | mFirstName(LLStringUtil::null), |
55 | mLastName(LLStringUtil::null), | 88 | mLastName(LLStringUtil::null), |
56 | mAvatarPassword(LLStringUtil::null), | 89 | mPasswordAvatar(LLStringUtil::null), |
57 | mXmlState(XML_VOID), | 90 | mXmlState(XML_VOID), |
58 | mVoiceConnector("SLVoice"), | 91 | mVoiceConnector("SLVoice"), |
59 | mRenderCompat(true), | 92 | mRenderCompat(true), |
60 | mMaxAgentGroups(-1), | 93 | mMaxAgentGroups(-1), |
61 | mCurrencySymbol("OS$"), | 94 | mCurrencySymbol("OS$"), |
62 | mRealCurrencySymbol("US$"), | 95 | mRealCurrencySymbol("US$"), |
63 | mDirectoryFee(30) | 96 | mDirectoryFee(30), |
97 | mUsername(LLStringUtil::null), | ||
98 | mUsernameCompat(false) | ||
64 | { | 99 | { |
65 | std::string nick = gridNick; | 100 | std::string nick = gridNick; |
66 | mGridNick = sanitizeGridNick( nick ); | 101 | mGridNick = sanitizeGridNick(nick); |
67 | } | ||
68 | |||
69 | |||
70 | // ******************************************************************** | ||
71 | // Getters | ||
72 | |||
73 | HippoGridInfo::Platform HippoGridInfo::getPlatform() | ||
74 | { | ||
75 | return mPlatform; | ||
76 | } | ||
77 | |||
78 | bool HippoGridInfo::isOpenSimulator() const | ||
79 | { | ||
80 | return (mPlatform == HippoGridInfo::PLATFORM_OPENSIM); | ||
81 | } | ||
82 | |||
83 | bool HippoGridInfo::isSecondLife() const | ||
84 | { | ||
85 | return (mPlatform == HippoGridInfo::PLATFORM_SECONDLIFE); | ||
86 | } | ||
87 | |||
88 | const std::string& HippoGridInfo::getGridNick() const | ||
89 | { | ||
90 | return mGridNick; | ||
91 | } | ||
92 | |||
93 | const std::string& HippoGridInfo::getGridName() const | ||
94 | { | ||
95 | return mGridName; | ||
96 | } | ||
97 | |||
98 | const std::string& HippoGridInfo::getLoginUri() const | ||
99 | { | ||
100 | return mLoginUri; | ||
101 | } | ||
102 | |||
103 | const std::string& HippoGridInfo::getLoginPage() const | ||
104 | { | ||
105 | return mLoginPage; | ||
106 | } | ||
107 | |||
108 | const std::string& HippoGridInfo::getHelperUri() const | ||
109 | { | ||
110 | return mHelperUri; | ||
111 | } | ||
112 | |||
113 | const std::string& HippoGridInfo::getWebSite() const | ||
114 | { | ||
115 | return mWebSite; | ||
116 | } | ||
117 | |||
118 | const std::string& HippoGridInfo::getSupportUrl() const | ||
119 | { | ||
120 | return mSupportUrl; | ||
121 | } | ||
122 | |||
123 | const std::string& HippoGridInfo::getRegisterUrl() const | ||
124 | { | ||
125 | return mRegisterUrl; | ||
126 | } | ||
127 | |||
128 | const std::string& HippoGridInfo::getPasswordUrl() const | ||
129 | { | ||
130 | return mPasswordUrl; | ||
131 | } | ||
132 | |||
133 | const std::string& HippoGridInfo::getSearchUrl() const | ||
134 | { | ||
135 | return mSearchUrl; | ||
136 | } | ||
137 | |||
138 | const std::string& HippoGridInfo::getFirstName() const | ||
139 | { | ||
140 | return mFirstName; | ||
141 | } | ||
142 | |||
143 | const std::string& HippoGridInfo::getLastName() const | ||
144 | { | ||
145 | return mLastName; | ||
146 | } | ||
147 | |||
148 | const std::string& HippoGridInfo::getAvatarPassword() const | ||
149 | { | ||
150 | return mAvatarPassword; | ||
151 | } | ||
152 | |||
153 | bool HippoGridInfo::isRenderCompat() const | ||
154 | { | ||
155 | return mRenderCompat; | ||
156 | } | 102 | } |
157 | 103 | ||
158 | const std::string& HippoGridInfo::getCurrencySymbol() const | ||
159 | { | ||
160 | return mCurrencySymbol; | ||
161 | } | ||
162 | |||
163 | const std::string& HippoGridInfo::getRealCurrencySymbol() const | ||
164 | { | ||
165 | return mRealCurrencySymbol; | ||
166 | } | ||
167 | |||
168 | bool HippoGridInfo::isUsernameCompat() const | ||
169 | { | ||
170 | // currently only SecondLife grids support username-style logins | ||
171 | // but Aurora is working on implementing it -- MC | ||
172 | return (mPlatform == HippoGridInfo::PLATFORM_SECONDLIFE); | ||
173 | } | ||
174 | |||
175 | |||
176 | |||
177 | // ******************************************************************** | ||
178 | // Setters | ||
179 | |||
180 | void HippoGridInfo::setPlatform(Platform platform) | 104 | void HippoGridInfo::setPlatform(Platform platform) |
181 | { | 105 | { |
182 | mPlatform = platform; | 106 | mPlatform = platform; |
183 | if (mPlatform == PLATFORM_SECONDLIFE) | 107 | if (mPlatform == PLATFORM_SECONDLIFE) |
184 | { | 108 | { |
185 | mCurrencySymbol = "L$"; | 109 | mCurrencySymbol = "L$"; |
110 | mUsernameCompat = true; | ||
186 | } | 111 | } |
187 | } | 112 | } |
188 | 113 | ||
189 | |||
190 | void HippoGridInfo::setPlatform(const std::string& platform) | 114 | void HippoGridInfo::setPlatform(const std::string& platform) |
191 | { | 115 | { |
192 | std::string tmp = platform; | 116 | std::string tmp = platform; |
@@ -208,96 +132,25 @@ void HippoGridInfo::setPlatform(const std::string& platform) | |||
208 | } | 132 | } |
209 | } | 133 | } |
210 | 134 | ||
211 | void HippoGridInfo::setGridName(const std::string& gridName) | 135 | void HippoGridInfo::setLoginURI(const std::string& loginURI) |
212 | { | ||
213 | mGridName = gridName; | ||
214 | } | ||
215 | |||
216 | void HippoGridInfo::setLoginUri(const std::string& loginUri) | ||
217 | { | ||
218 | std::string uri = loginUri; | ||
219 | mLoginUri = sanitizeUri(uri); | ||
220 | } | ||
221 | |||
222 | void HippoGridInfo::setLoginPage(const std::string& loginPage) | ||
223 | { | 136 | { |
224 | mLoginPage = loginPage; | 137 | std::string uri = loginURI; |
138 | mLoginURI = sanitizeURI(uri); | ||
225 | } | 139 | } |
226 | 140 | ||
227 | void HippoGridInfo::setHelperUri(const std::string& helperUri) | 141 | void HippoGridInfo::setHelperURI(const std::string& helperURI) |
228 | { | 142 | { |
229 | std::string uri = helperUri; | 143 | std::string uri = helperURI; |
230 | mHelperUri = sanitizeUri(uri); | 144 | mHelperURI = sanitizeURI(uri); |
231 | } | 145 | } |
232 | 146 | ||
233 | void HippoGridInfo::setWebSite(const std::string& website) | ||
234 | { | ||
235 | mWebSite = website; | ||
236 | } | ||
237 | |||
238 | void HippoGridInfo::setSupportUrl(const std::string& url) | ||
239 | { | ||
240 | mSupportUrl = url; | ||
241 | } | ||
242 | |||
243 | void HippoGridInfo::setRegisterUrl(const std::string& url) | ||
244 | { | ||
245 | mRegisterUrl = url; | ||
246 | } | ||
247 | |||
248 | void HippoGridInfo::setPasswordUrl(const std::string& url) | ||
249 | { | ||
250 | mPasswordUrl = url; | ||
251 | } | ||
252 | |||
253 | void HippoGridInfo::setSearchUrl(const std::string& url) | ||
254 | { | ||
255 | mSearchUrl = url; | ||
256 | } | ||
257 | |||
258 | void HippoGridInfo::setFirstName(const std::string& firstName) | ||
259 | { | ||
260 | mFirstName = firstName; | ||
261 | } | ||
262 | |||
263 | void HippoGridInfo::setLastName(const std::string& lastName) | ||
264 | { | ||
265 | mLastName = lastName; | ||
266 | } | ||
267 | |||
268 | void HippoGridInfo::setAvatarPassword(const std::string& avatarPassword) | ||
269 | { | ||
270 | mAvatarPassword = avatarPassword; | ||
271 | } | ||
272 | |||
273 | void HippoGridInfo::setRenderCompat(bool compat) | ||
274 | { | ||
275 | mRenderCompat = compat; | ||
276 | } | ||
277 | |||
278 | void HippoGridInfo::setCurrencySymbol(const std::string& sym) | ||
279 | { | ||
280 | mCurrencySymbol = sym.substr(0, 3); | ||
281 | } | ||
282 | |||
283 | void HippoGridInfo::setRealCurrencySymbol(const std::string& sym) | ||
284 | { | ||
285 | mRealCurrencySymbol = sym.substr(0, 3); | ||
286 | } | ||
287 | |||
288 | void HippoGridInfo::setDirectoryFee(int fee) | ||
289 | { | ||
290 | mDirectoryFee = fee; | ||
291 | } | ||
292 | |||
293 | |||
294 | 147 | ||
295 | // ******************************************************************** | 148 | // ******************************************************************** |
296 | // Grid Info | 149 | // Grid Info |
297 | 150 | ||
298 | std::string HippoGridInfo::getSearchUrl(SearchType ty, bool is_web) const | 151 | std::string HippoGridInfo::getSearchURL(SearchType ty, bool is_web) const |
299 | { | 152 | { |
300 | // Don't worry about whether or not mSearchUrl is empty here anymore -- MC | 153 | // Don't worry about whether or not mSearchURL is empty here anymore -- MC |
301 | if (is_web) | 154 | if (is_web) |
302 | { | 155 | { |
303 | if (mPlatform == PLATFORM_SECONDLIFE) | 156 | if (mPlatform == PLATFORM_SECONDLIFE) |
@@ -321,16 +174,16 @@ std::string HippoGridInfo::getSearchUrl(SearchType ty, bool is_web) const | |||
321 | return ""; | 174 | return ""; |
322 | } | 175 | } |
323 | } | 176 | } |
324 | else if (!mSearchUrl.empty()) | 177 | else if (!mSearchURL.empty()) |
325 | { | 178 | { |
326 | // Search url sent to us in the login response | 179 | // Search url sent to us in the login response |
327 | if (ty == SEARCH_ALL_EMPTY) | 180 | if (ty == SEARCH_ALL_EMPTY) |
328 | { | 181 | { |
329 | return (mSearchUrl); | 182 | return (mSearchURL); |
330 | } | 183 | } |
331 | else if (ty == SEARCH_ALL_QUERY) | 184 | else if (ty == SEARCH_ALL_QUERY) |
332 | { | 185 | { |
333 | return (mSearchUrl + "q=[QUERY]&s=[COLLECTION]&"); | 186 | return (mSearchURL + "q=[QUERY]&s=[COLLECTION]&"); |
334 | } | 187 | } |
335 | else if (ty == SEARCH_ALL_TEMPLATE) | 188 | else if (ty == SEARCH_ALL_TEMPLATE) |
336 | { | 189 | { |
@@ -369,11 +222,11 @@ std::string HippoGridInfo::getSearchUrl(SearchType ty, bool is_web) const | |||
369 | // Use the old search all | 222 | // Use the old search all |
370 | if (ty == SEARCH_ALL_EMPTY) | 223 | if (ty == SEARCH_ALL_EMPTY) |
371 | { | 224 | { |
372 | return (mSearchUrl + "panel=All&"); | 225 | return (mSearchURL + "panel=All&"); |
373 | } | 226 | } |
374 | else if (ty == SEARCH_ALL_QUERY) | 227 | else if (ty == SEARCH_ALL_QUERY) |
375 | { | 228 | { |
376 | return (mSearchUrl + "q=[QUERY]&s=[COLLECTION]&"); | 229 | return (mSearchURL + "q=[QUERY]&s=[COLLECTION]&"); |
377 | } | 230 | } |
378 | else if (ty == SEARCH_ALL_TEMPLATE) | 231 | else if (ty == SEARCH_ALL_TEMPLATE) |
379 | { | 232 | { |
@@ -424,7 +277,7 @@ void HippoGridInfo::onXmlElementEnd(void* userData, const XML_Char* name) | |||
424 | } | 277 | } |
425 | 278 | ||
426 | //static | 279 | //static |
427 | void HippoGridInfo::onXmlCharacterData(void* userData, const XML_Char* s, int len) | 280 | void HippoGridInfo::onXmlCharacterData(void* userData, const XML_Char* s, S32 len) |
428 | { | 281 | { |
429 | HippoGridInfo* self = (HippoGridInfo*)userData; | 282 | HippoGridInfo* self = (HippoGridInfo*)userData; |
430 | switch (self->mXmlState) | 283 | switch (self->mXmlState) |
@@ -446,30 +299,30 @@ void HippoGridInfo::onXmlCharacterData(void* userData, const XML_Char* s, int le | |||
446 | case XML_LOGINURI: | 299 | case XML_LOGINURI: |
447 | { | 300 | { |
448 | std::string loginuri(s, len); | 301 | std::string loginuri(s, len); |
449 | self->mLoginUri = sanitizeUri( loginuri ); | 302 | self->mLoginURI = sanitizeURI( loginuri ); |
450 | break; | 303 | break; |
451 | } | 304 | } |
452 | 305 | ||
453 | case XML_HELPERURI: | 306 | case XML_HELPERURI: |
454 | { | 307 | { |
455 | std::string helperuri(s, len); | 308 | std::string helperuri(s, len); |
456 | self->mHelperUri = sanitizeUri( helperuri ); | 309 | self->mHelperURI = sanitizeURI( helperuri ); |
457 | break; | 310 | break; |
458 | } | 311 | } |
459 | 312 | ||
460 | case XML_SEARCH: | 313 | case XML_SEARCH: |
461 | { | 314 | { |
462 | self->mSearchUrl.assign(s, len); | 315 | self->mSearchURL.assign(s, len); |
463 | //sanitizeQueryUrl(mSearchUrl); | 316 | //sanitizeQueryURL(mSearchURL); |
464 | break; | 317 | break; |
465 | } | 318 | } |
466 | 319 | ||
467 | case XML_GRIDNAME: self->mGridName.assign(s, len); break; | 320 | case XML_GRIDNAME: self->mGridName.assign(s, len); break; |
468 | case XML_LOGINPAGE: self->mLoginPage.assign(s, len); break; | 321 | case XML_LOGINPAGE: self->mLoginPage.assign(s, len); break; |
469 | case XML_WEBSITE: self->mWebSite.assign(s, len); break; | 322 | case XML_WEBSITE: self->mWebSite.assign(s, len); break; |
470 | case XML_SUPPORT: self->mSupportUrl.assign(s, len); break; | 323 | case XML_SUPPORT: self->mSupportURL.assign(s, len); break; |
471 | case XML_REGISTER: self->mRegisterUrl.assign(s, len); break; | 324 | case XML_REGISTER: self->mRegisterURL.assign(s, len); break; |
472 | case XML_PASSWORD: self->mPasswordUrl.assign(s, len); break; | 325 | case XML_PASSWORD: self->mPasswordURL.assign(s, len); break; |
473 | 326 | ||
474 | case XML_VOID: break; | 327 | case XML_VOID: break; |
475 | } | 328 | } |
@@ -478,16 +331,16 @@ void HippoGridInfo::onXmlCharacterData(void* userData, const XML_Char* s, int le | |||
478 | 331 | ||
479 | bool HippoGridInfo::retrieveGridInfo() | 332 | bool HippoGridInfo::retrieveGridInfo() |
480 | { | 333 | { |
481 | if (mLoginUri == "") return false; | 334 | if (mLoginURI == "") return false; |
482 | 335 | ||
483 | // If last character in uri is not "/" | 336 | // If last character in uri is not "/" |
484 | std::string uri = mLoginUri; | 337 | std::string uri = mLoginURI; |
485 | if (uri.compare(uri.length()-1, 1, "/") != 0) | 338 | if (uri.compare(uri.length()-1, 1, "/") != 0) |
486 | { | 339 | { |
487 | uri += '/'; | 340 | uri += '/'; |
488 | } | 341 | } |
489 | std::string reply; | 342 | std::string reply; |
490 | int result = HippoRestRequest::getBlocking(uri + "get_grid_info", &reply); | 343 | S32 result = HippoRestRequest::getBlocking(uri + "get_grid_info", &reply); |
491 | if (result != 200) return false; | 344 | if (result != 200) return false; |
492 | 345 | ||
493 | llinfos << "Received: " << reply << llendl; | 346 | llinfos << "Received: " << reply << llendl; |
@@ -508,6 +361,14 @@ bool HippoGridInfo::retrieveGridInfo() | |||
508 | return success; | 361 | return success; |
509 | } | 362 | } |
510 | 363 | ||
364 | const std::string& HippoGridInfo::getGridName() const | ||
365 | { | ||
366 | if (mGridName.empty()) | ||
367 | { | ||
368 | return mGridNick; | ||
369 | } | ||
370 | return mGridName; | ||
371 | } | ||
511 | 372 | ||
512 | std::string HippoGridInfo::getUploadFee() const | 373 | std::string HippoGridInfo::getUploadFee() const |
513 | { | 374 | { |
@@ -531,7 +392,7 @@ std::string HippoGridInfo::getDirectoryFee() const | |||
531 | return fee; | 392 | return fee; |
532 | } | 393 | } |
533 | 394 | ||
534 | void HippoGridInfo::formatFee(std::string &fee, int cost, bool showFree) const | 395 | void HippoGridInfo::formatFee(std::string &fee, S32 cost, bool showFree) const |
535 | { | 396 | { |
536 | if (showFree && (cost == 0)) | 397 | if (showFree && (cost == 0)) |
537 | { | 398 | { |
@@ -544,6 +405,92 @@ void HippoGridInfo::formatFee(std::string &fee, int cost, bool showFree) const | |||
544 | } | 405 | } |
545 | 406 | ||
546 | 407 | ||
408 | void HippoGridInfo::setPassword(const std::string& unhashed_password) | ||
409 | { | ||
410 | if (unhashed_password.empty()) | ||
411 | { | ||
412 | mPasswordAvatar = ""; | ||
413 | return; | ||
414 | } | ||
415 | |||
416 | if (unhashed_password == mPasswordAvatar) | ||
417 | { | ||
418 | return; | ||
419 | } | ||
420 | |||
421 | std::string hashed_password(""); | ||
422 | |||
423 | // Max "actual" password length is 16 characters. | ||
424 | // Hex digests are always 32 characters. | ||
425 | if (unhashed_password.length() == 32) | ||
426 | { | ||
427 | hashed_password = unhashed_password; | ||
428 | } | ||
429 | else | ||
430 | { | ||
431 | // this is a user-entered plaintext password | ||
432 | LLMD5 pass((unsigned char *)unhashed_password.c_str()); | ||
433 | char munged_password[MD5HEX_STR_SIZE]; | ||
434 | pass.hex_digest(munged_password); | ||
435 | hashed_password = munged_password; | ||
436 | } | ||
437 | |||
438 | // need to fix the bug in this | ||
439 | /* | ||
440 | |||
441 | // Encipher with MAC address | ||
442 | const S32 HASHED_LENGTH = 32; | ||
443 | U8 buffer[HASHED_LENGTH+1]; | ||
444 | |||
445 | LLStringUtil::copy((char*)buffer, hashed_password.c_str(), HASHED_LENGTH+1); | ||
446 | |||
447 | LLXORCipher cipher(gMACAddress, 6); | ||
448 | cipher.encrypt(buffer, HASHED_LENGTH); | ||
449 | |||
450 | mPasswordAvatar.assign((char*)buffer); | ||
451 | */ | ||
452 | mPasswordAvatar.assign(hashed_password); | ||
453 | } | ||
454 | |||
455 | |||
456 | std::string HippoGridInfo::getPassword() const | ||
457 | { | ||
458 | // need to fix the bug in this | ||
459 | /* | ||
460 | if (mPasswordAvatar.empty() || mPasswordAvatar.length() == 32) | ||
461 | { | ||
462 | return mPasswordAvatar; | ||
463 | } | ||
464 | |||
465 | std::string hashed_password(""); | ||
466 | |||
467 | // UUID is 16 bytes, written into ASCII is 32 characters | ||
468 | // without trailing \0 | ||
469 | const S32 HASHED_LENGTH = 32; | ||
470 | U8 buffer[HASHED_LENGTH+1]; | ||
471 | |||
472 | LLStringUtil::copy((char*)buffer, mPasswordAvatar.c_str(), HASHED_LENGTH+1); | ||
473 | |||
474 | // Decipher with MAC address | ||
475 | LLXORCipher cipher(gMACAddress, 6); | ||
476 | cipher.decrypt(buffer, HASHED_LENGTH); | ||
477 | |||
478 | buffer[HASHED_LENGTH] = '\0'; | ||
479 | |||
480 | // Check to see if the mac address generated a bad hashed | ||
481 | // password. It should be a hex-string or else the mac adress has | ||
482 | // changed. This is a security feature to make sure that if you | ||
483 | // get someone's grid_info.xml file, you cannot hack their account. | ||
484 | if (is_hex_string(buffer, HASHED_LENGTH)) | ||
485 | { | ||
486 | hashed_password.assign((char*)buffer); | ||
487 | } | ||
488 | |||
489 | return hashed_password; | ||
490 | */ | ||
491 | return mPasswordAvatar; | ||
492 | } | ||
493 | |||
547 | // ******************************************************************** | 494 | // ******************************************************************** |
548 | // Static Helpers | 495 | // Static Helpers |
549 | 496 | ||
@@ -556,7 +503,9 @@ const char* HippoGridInfo::getPlatformString(Platform platform) | |||
556 | }; | 503 | }; |
557 | 504 | ||
558 | if ((platform < PLATFORM_OTHER) || (platform >= PLATFORM_LAST)) | 505 | if ((platform < PLATFORM_OTHER) || (platform >= PLATFORM_LAST)) |
506 | { | ||
559 | platform = PLATFORM_OTHER; | 507 | platform = PLATFORM_OTHER; |
508 | } | ||
560 | return platformStrings[platform]; | 509 | return platformStrings[platform]; |
561 | } | 510 | } |
562 | 511 | ||
@@ -565,8 +514,8 @@ const char* HippoGridInfo::getPlatformString(Platform platform) | |||
565 | std::string HippoGridInfo::sanitizeGridNick(std::string &gridnick) | 514 | std::string HippoGridInfo::sanitizeGridNick(std::string &gridnick) |
566 | { | 515 | { |
567 | std::string tmp; | 516 | std::string tmp; |
568 | int size = gridnick.size(); | 517 | S32 size = gridnick.size(); |
569 | for (int i=0; i<size; i++) | 518 | for (S32 i=0; i<size; i++) |
570 | { | 519 | { |
571 | char c = gridnick[i]; | 520 | char c = gridnick[i]; |
572 | if ((c == '_') || isalnum(c)) | 521 | if ((c == '_') || isalnum(c)) |
@@ -582,8 +531,10 @@ std::string HippoGridInfo::sanitizeGridNick(std::string &gridnick) | |||
582 | } | 531 | } |
583 | 532 | ||
584 | // static | 533 | // static |
585 | std::string HippoGridInfo::sanitizeUri(std::string &uri) | 534 | std::string HippoGridInfo::sanitizeURI(std::string &uri) |
586 | { | 535 | { |
536 | // Why don't we do this anymore? -- MC | ||
537 | |||
587 | // if (uri.empty()) { | 538 | // if (uri.empty()) { |
588 | // return ""; | 539 | // return ""; |
589 | // } | 540 | // } |
@@ -603,8 +554,8 @@ void HippoGridInfo::initFallback() | |||
603 | FALLBACK_GRIDINFO.mGridNick = "localhost"; | 554 | FALLBACK_GRIDINFO.mGridNick = "localhost"; |
604 | FALLBACK_GRIDINFO.setPlatform(PLATFORM_OPENSIM); | 555 | FALLBACK_GRIDINFO.setPlatform(PLATFORM_OPENSIM); |
605 | FALLBACK_GRIDINFO.setGridName("Local Host"); | 556 | FALLBACK_GRIDINFO.setGridName("Local Host"); |
606 | FALLBACK_GRIDINFO.setLoginUri("http://127.0.0.1:9000/"); | 557 | FALLBACK_GRIDINFO.setLoginURI("http://127.0.0.1:9000/"); |
607 | FALLBACK_GRIDINFO.setHelperUri("http://127.0.0.1:9000/"); | 558 | FALLBACK_GRIDINFO.setHelperURI("http://127.0.0.1:9000/"); |
608 | } | 559 | } |
609 | 560 | ||
610 | 561 | ||
@@ -683,7 +634,7 @@ HippoGridInfo* HippoGridManager::getGrid(const std::string& grid) const | |||
683 | 634 | ||
684 | HippoGridInfo* HippoGridManager::getConnectedGrid() const | 635 | HippoGridInfo* HippoGridManager::getConnectedGrid() const |
685 | { | 636 | { |
686 | return (mConnectedGrid)? mConnectedGrid: getCurrentGrid(); | 637 | return (mConnectedGrid) ? mConnectedGrid : getCurrentGrid(); |
687 | } | 638 | } |
688 | 639 | ||
689 | 640 | ||
@@ -700,11 +651,6 @@ HippoGridInfo* HippoGridManager::getCurrentGrid() const | |||
700 | } | 651 | } |
701 | } | 652 | } |
702 | 653 | ||
703 | const std::string& HippoGridManager::getDefaultGridNick() const | ||
704 | { | ||
705 | return mDefaultGrid; | ||
706 | } | ||
707 | |||
708 | const std::string& HippoGridManager::getCurrentGridNick() const | 654 | const std::string& HippoGridManager::getCurrentGridNick() const |
709 | { | 655 | { |
710 | if (mCurrentGrid.empty()) | 656 | if (mCurrentGrid.empty()) |
@@ -714,12 +660,6 @@ const std::string& HippoGridManager::getCurrentGridNick() const | |||
714 | return mCurrentGrid; | 660 | return mCurrentGrid; |
715 | } | 661 | } |
716 | 662 | ||
717 | void HippoGridManager::setCurrentGridAsConnected() | ||
718 | { | ||
719 | mConnectedGrid = getCurrentGrid(); | ||
720 | } | ||
721 | |||
722 | |||
723 | void HippoGridManager::addGrid(HippoGridInfo* grid) | 663 | void HippoGridManager::addGrid(HippoGridInfo* grid) |
724 | { | 664 | { |
725 | if (!grid) return; | 665 | if (!grid) return; |
@@ -743,17 +683,25 @@ void HippoGridManager::addGrid(HippoGridInfo* grid) | |||
743 | void HippoGridManager::deleteGrid(const std::string& grid) | 683 | void HippoGridManager::deleteGrid(const std::string& grid) |
744 | { | 684 | { |
745 | GridIterator it = mGridInfo.find(grid); | 685 | GridIterator it = mGridInfo.find(grid); |
746 | if (it == mGridInfo.end()) { | 686 | if (it == mGridInfo.end()) |
687 | { | ||
747 | llwarns << "Trying to delete non-existing grid " << grid << '.' << llendl; | 688 | llwarns << "Trying to delete non-existing grid " << grid << '.' << llendl; |
748 | return; | 689 | return; |
749 | } | 690 | } |
691 | |||
750 | mGridInfo.erase(it); | 692 | mGridInfo.erase(it); |
693 | |||
751 | llinfos << "Number of grids now: " << mGridInfo.size() << llendl; | 694 | llinfos << "Number of grids now: " << mGridInfo.size() << llendl; |
695 | |||
752 | if (mGridInfo.empty()) llinfos << "Grid info map is empty." << llendl; | 696 | if (mGridInfo.empty()) llinfos << "Grid info map is empty." << llendl; |
753 | if (grid == mDefaultGrid) | 697 | if (grid == mDefaultGrid) |
698 | { | ||
754 | setDefaultGrid(LLStringUtil::null); // sets first grid, if map not empty | 699 | setDefaultGrid(LLStringUtil::null); // sets first grid, if map not empty |
700 | } | ||
755 | if (grid == mCurrentGrid) | 701 | if (grid == mCurrentGrid) |
702 | { | ||
756 | mCurrentGrid = mDefaultGrid; | 703 | mCurrentGrid = mDefaultGrid; |
704 | } | ||
757 | } | 705 | } |
758 | 706 | ||
759 | 707 | ||
@@ -796,6 +744,18 @@ void HippoGridManager::setCurrentGrid(const std::string& grid) | |||
796 | } | 744 | } |
797 | } | 745 | } |
798 | 746 | ||
747 | bool HippoGridManager::hasGridNick(const std::string& grid_nick) | ||
748 | { | ||
749 | for (GridIterator it = beginGrid(); it != endGrid(); ++it) | ||
750 | { | ||
751 | if (grid_nick == it->second->getGridNick()) | ||
752 | { | ||
753 | return true; | ||
754 | } | ||
755 | } | ||
756 | return false; | ||
757 | } | ||
758 | |||
799 | 759 | ||
800 | // ******************************************************************** | 760 | // ******************************************************************** |
801 | // Persistent Store | 761 | // Persistent Store |
@@ -813,7 +773,7 @@ void HippoGridManager::loadFromFile() | |||
813 | std::string update_list = gSavedSettings.getString("GridUpdateList"); | 773 | std::string update_list = gSavedSettings.getString("GridUpdateList"); |
814 | if (!update_list.empty()) | 774 | if (!update_list.empty()) |
815 | { | 775 | { |
816 | parseUrl(update_list, !mGridInfo.empty()); | 776 | parseURL(update_list, !mGridInfo.empty()); |
817 | } | 777 | } |
818 | else | 778 | else |
819 | { | 779 | { |
@@ -828,7 +788,7 @@ void HippoGridManager::loadFromFile() | |||
828 | } | 788 | } |
829 | 789 | ||
830 | 790 | ||
831 | void HippoGridManager::parseUrl(const std::string url, bool mergeIfNewer) | 791 | void HippoGridManager::parseURL(const std::string url, bool mergeIfNewer) |
832 | { | 792 | { |
833 | llinfos << "Loading grid info from '" << url << "'." << llendl; | 793 | llinfos << "Loading grid info from '" << url << "'." << llendl; |
834 | 794 | ||
@@ -882,7 +842,7 @@ void HippoGridManager::parseData(LLSD &gridInfo, bool mergeIfNewer) | |||
882 | LLSD gridMap = *it; | 842 | LLSD gridMap = *it; |
883 | if (gridMap.has("default_grids_version")) | 843 | if (gridMap.has("default_grids_version")) |
884 | { | 844 | { |
885 | int version = gridMap["default_grids_version"]; | 845 | S32 version = gridMap["default_grids_version"]; |
886 | if (version <= mDefaultGridsVersion) return; | 846 | if (version <= mDefaultGridsVersion) return; |
887 | else break; | 847 | else break; |
888 | } | 848 | } |
@@ -920,20 +880,22 @@ void HippoGridManager::parseData(LLSD &gridInfo, bool mergeIfNewer) | |||
920 | // update existing grid info | 880 | // update existing grid info |
921 | grid = it->second; | 881 | grid = it->second; |
922 | } | 882 | } |
923 | grid->setLoginUri(gridMap["loginuri"]); | 883 | grid->setLoginURI(gridMap["loginuri"]); |
924 | if (gridMap.has("platform")) grid->setPlatform(gridMap["platform"]); | 884 | if (gridMap.has("platform")) grid->setPlatform(gridMap["platform"]); |
925 | if (gridMap.has("gridname")) grid->setGridName(gridMap["gridname"]); | 885 | if (gridMap.has("gridname")) grid->setGridName(gridMap["gridname"]); |
926 | if (gridMap.has("loginpage")) grid->setLoginPage(gridMap["loginpage"]); | 886 | if (gridMap.has("loginpage")) grid->setLoginPage(gridMap["loginpage"]); |
927 | if (gridMap.has("helperuri")) grid->setHelperUri(gridMap["helperuri"]); | 887 | if (gridMap.has("helperuri")) grid->setHelperURI(gridMap["helperuri"]); |
928 | if (gridMap.has("website")) grid->setWebSite(gridMap["website"]); | 888 | if (gridMap.has("website")) grid->setWebSite(gridMap["website"]); |
929 | if (gridMap.has("support")) grid->setSupportUrl(gridMap["support"]); | 889 | if (gridMap.has("support")) grid->setSupportURL(gridMap["support"]); |
930 | if (gridMap.has("register")) grid->setRegisterUrl(gridMap["register"]); | 890 | if (gridMap.has("register")) grid->setRegisterURL(gridMap["register"]); |
931 | if (gridMap.has("password")) grid->setPasswordUrl(gridMap["password"]); | 891 | if (gridMap.has("password")) grid->setPasswordURL(gridMap["password"]); |
932 | if (gridMap.has("search")) grid->setSearchUrl(gridMap["search"]); | 892 | if (gridMap.has("search")) grid->setSearchURL(gridMap["search"]); |
933 | if (gridMap.has("render_compat")) grid->setRenderCompat(gridMap["render_compat"]); | 893 | if (gridMap.has("render_compat")) grid->setRenderCompat(gridMap["render_compat"]); |
934 | // if (gridMap.has("firstname")) grid->setFirstName(gridMap["firstname"]); | 894 | if (gridMap.has("firstname")) grid->setFirstName(gridMap["firstname"]); |
935 | // if (gridMap.has("lastname")) grid->setLastName(gridMap["lastname"]); | 895 | if (gridMap.has("lastname")) grid->setLastName(gridMap["lastname"]); |
936 | // if (gridMap.has("avatarpassword")) grid->setAvatarPassword(gridMap["avatarpassword"]); | 896 | if (gridMap.has("avatarpassword")) grid->setPassword(gridMap["avatarpassword"]); |
897 | if (gridMap.has("username")) grid->setUsername(gridMap["username"]); | ||
898 | if (gridMap.has("username_compat")) grid->setUsernameCompat(gridMap["username_compat"]); | ||
937 | if (newGrid) addGrid(grid); | 899 | if (newGrid) addGrid(grid); |
938 | } | 900 | } |
939 | } | 901 | } |
@@ -958,19 +920,22 @@ void HippoGridManager::saveFile() | |||
958 | gridInfo[i]["gridnick"] = grid->getGridNick(); | 920 | gridInfo[i]["gridnick"] = grid->getGridNick(); |
959 | gridInfo[i]["platform"] = HippoGridInfo::getPlatformString(grid->getPlatform()); | 921 | gridInfo[i]["platform"] = HippoGridInfo::getPlatformString(grid->getPlatform()); |
960 | gridInfo[i]["gridname"] = grid->getGridName(); | 922 | gridInfo[i]["gridname"] = grid->getGridName(); |
961 | gridInfo[i]["loginuri"] = grid->getLoginUri(); | 923 | gridInfo[i]["loginuri"] = grid->getLoginURI(); |
962 | gridInfo[i]["loginpage"] = grid->getLoginPage(); | 924 | gridInfo[i]["loginpage"] = grid->getLoginPage(); |
963 | gridInfo[i]["helperuri"] = grid->getHelperUri(); | 925 | gridInfo[i]["helperuri"] = grid->getHelperURI(); |
964 | gridInfo[i]["website"] = grid->getWebSite(); | 926 | gridInfo[i]["website"] = grid->getWebSite(); |
965 | gridInfo[i]["support"] = grid->getSupportUrl(); | 927 | gridInfo[i]["support"] = grid->getSupportURL(); |
966 | gridInfo[i]["register"] = grid->getRegisterUrl(); | 928 | gridInfo[i]["register"] = grid->getRegisterURL(); |
967 | gridInfo[i]["password"] = grid->getPasswordUrl(); | 929 | gridInfo[i]["password"] = grid->getPasswordURL(); |
968 | // gridInfo[i]["firstname"] = grid->getFirstName(); | 930 | gridInfo[i]["firstname"] = grid->getFirstName(); |
969 | // gridInfo[i]["lastname"] = grid->getLastName(); | 931 | gridInfo[i]["lastname"] = grid->getLastName(); |
970 | // gridInfo[i]["avatarpassword"] = grid->getAvatarPassword(); | 932 | gridInfo[i]["avatarpassword"] = grid->getPassword(); |
971 | 933 | ||
972 | gridInfo[i]["search"] = grid->getSearchUrl(); | 934 | gridInfo[i]["search"] = grid->getSearchURL(); |
973 | gridInfo[i]["render_compat"] = grid->isRenderCompat(); | 935 | gridInfo[i]["render_compat"] = grid->isRenderCompat(); |
936 | |||
937 | gridInfo[i]["username"] = grid->getUsername(); | ||
938 | gridInfo[i]["username_compat"] = grid->isUsernameCompat(); | ||
974 | } | 939 | } |
975 | 940 | ||
976 | // write client grid info file | 941 | // write client grid info file |