diff options
author | McCabe Maxsted | 2011-04-15 21:07:29 -0700 |
---|---|---|
committer | McCabe Maxsted | 2011-04-15 21:07:29 -0700 |
commit | f7df6f323e4746abae0a0858cb7ef56bedbb94ca (patch) | |
tree | 7a4a9e3be1ca658c0d72c78f413946249a38ad21 /linden/indra/newview/hippogridmanager.cpp | |
parent | test commit - slviewer-0-v12500-DeadObjectsFixes_v2.patch (diff) | |
download | meta-impy-f7df6f323e4746abae0a0858cb7ef56bedbb94ca.zip meta-impy-f7df6f323e4746abae0a0858cb7ef56bedbb94ca.tar.gz meta-impy-f7df6f323e4746abae0a0858cb7ef56bedbb94ca.tar.bz2 meta-impy-f7df6f323e4746abae0a0858cb7ef56bedbb94ca.tar.xz |
Updated the grid manager to save names and passwords along with grid info. This commit includes the following:
* Fixed missing GPL headers from hippo grid manager
* Fixed grids named <required> or "" being saved in the list
* Fixed grid manager list only showing grid nicks, not grid names
* Fixed grid names not settable in the grid manager
* Grid manager now remembers avatar names and passwords
* Usernames can now be set in the grid manager for SL (needs work)
* Fixed grid manager being stuck in an updating state
* Some general code cleanup
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/hippogridmanager.cpp | 387 |
1 files changed, 131 insertions, 256 deletions
diff --git a/linden/indra/newview/hippogridmanager.cpp b/linden/indra/newview/hippogridmanager.cpp index 6bf6e63..8277361 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 | ||
@@ -43,14 +72,14 @@ HippoGridInfo::HippoGridInfo(const std::string& gridNick) : | |||
43 | mPlatform(PLATFORM_OPENSIM), | 72 | mPlatform(PLATFORM_OPENSIM), |
44 | mGridNick(gridNick), | 73 | mGridNick(gridNick), |
45 | mGridName(LLStringUtil::null), | 74 | mGridName(LLStringUtil::null), |
46 | mLoginUri(LLStringUtil::null), | 75 | mLoginURI(LLStringUtil::null), |
47 | mLoginPage(LLStringUtil::null), | 76 | mLoginPage(LLStringUtil::null), |
48 | mHelperUri(LLStringUtil::null), | 77 | mHelperURI(LLStringUtil::null), |
49 | mWebSite(LLStringUtil::null), | 78 | mWebSite(LLStringUtil::null), |
50 | mSupportUrl(LLStringUtil::null), | 79 | mSupportURL(LLStringUtil::null), |
51 | mRegisterUrl(LLStringUtil::null), | 80 | mRegisterURL(LLStringUtil::null), |
52 | mPasswordUrl(LLStringUtil::null), | 81 | mPasswordURL(LLStringUtil::null), |
53 | mSearchUrl(LLStringUtil::null), | 82 | mSearchURL(LLStringUtil::null), |
54 | mFirstName(LLStringUtil::null), | 83 | mFirstName(LLStringUtil::null), |
55 | mLastName(LLStringUtil::null), | 84 | mLastName(LLStringUtil::null), |
56 | mAvatarPassword(LLStringUtil::null), | 85 | mAvatarPassword(LLStringUtil::null), |
@@ -60,133 +89,24 @@ HippoGridInfo::HippoGridInfo(const std::string& gridNick) : | |||
60 | mMaxAgentGroups(-1), | 89 | mMaxAgentGroups(-1), |
61 | mCurrencySymbol("OS$"), | 90 | mCurrencySymbol("OS$"), |
62 | mRealCurrencySymbol("US$"), | 91 | mRealCurrencySymbol("US$"), |
63 | mDirectoryFee(30) | 92 | mDirectoryFee(30), |
93 | mUsername(LLStringUtil::null), | ||
94 | mUsernameCompat(false) | ||
64 | { | 95 | { |
65 | std::string nick = gridNick; | 96 | std::string nick = gridNick; |
66 | mGridNick = sanitizeGridNick( nick ); | 97 | mGridNick = sanitizeGridNick(nick); |
67 | } | 98 | } |
68 | 99 | ||
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 | } | ||
157 | |||
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) | 100 | void HippoGridInfo::setPlatform(Platform platform) |
181 | { | 101 | { |
182 | mPlatform = platform; | 102 | mPlatform = platform; |
183 | if (mPlatform == PLATFORM_SECONDLIFE) | 103 | if (mPlatform == PLATFORM_SECONDLIFE) |
184 | { | 104 | { |
185 | mCurrencySymbol = "L$"; | 105 | mCurrencySymbol = "L$"; |
106 | mUsernameCompat = true; | ||
186 | } | 107 | } |
187 | } | 108 | } |
188 | 109 | ||
189 | |||
190 | void HippoGridInfo::setPlatform(const std::string& platform) | 110 | void HippoGridInfo::setPlatform(const std::string& platform) |
191 | { | 111 | { |
192 | std::string tmp = platform; | 112 | std::string tmp = platform; |
@@ -208,96 +128,25 @@ void HippoGridInfo::setPlatform(const std::string& platform) | |||
208 | } | 128 | } |
209 | } | 129 | } |
210 | 130 | ||
211 | void HippoGridInfo::setGridName(const std::string& gridName) | 131 | void HippoGridInfo::setLoginURI(const std::string& loginURI) |
212 | { | 132 | { |
213 | mGridName = gridName; | 133 | std::string uri = loginURI; |
134 | mLoginURI = sanitizeURI(uri); | ||
214 | } | 135 | } |
215 | 136 | ||
216 | void HippoGridInfo::setLoginUri(const std::string& loginUri) | 137 | void HippoGridInfo::setHelperURI(const std::string& helperURI) |
217 | { | 138 | { |
218 | std::string uri = loginUri; | 139 | std::string uri = helperURI; |
219 | mLoginUri = sanitizeUri(uri); | 140 | mHelperURI = sanitizeURI(uri); |
220 | } | 141 | } |
221 | 142 | ||
222 | void HippoGridInfo::setLoginPage(const std::string& loginPage) | ||
223 | { | ||
224 | mLoginPage = loginPage; | ||
225 | } | ||
226 | |||
227 | void HippoGridInfo::setHelperUri(const std::string& helperUri) | ||
228 | { | ||
229 | std::string uri = helperUri; | ||
230 | mHelperUri = sanitizeUri(uri); | ||
231 | } | ||
232 | |||
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 | 143 | ||
295 | // ******************************************************************** | 144 | // ******************************************************************** |
296 | // Grid Info | 145 | // Grid Info |
297 | 146 | ||
298 | std::string HippoGridInfo::getSearchUrl(SearchType ty, bool is_web) const | 147 | std::string HippoGridInfo::getSearchURL(SearchType ty, bool is_web) const |
299 | { | 148 | { |
300 | // Don't worry about whether or not mSearchUrl is empty here anymore -- MC | 149 | // Don't worry about whether or not mSearchURL is empty here anymore -- MC |
301 | if (is_web) | 150 | if (is_web) |
302 | { | 151 | { |
303 | if (mPlatform == PLATFORM_SECONDLIFE) | 152 | if (mPlatform == PLATFORM_SECONDLIFE) |
@@ -321,16 +170,16 @@ std::string HippoGridInfo::getSearchUrl(SearchType ty, bool is_web) const | |||
321 | return ""; | 170 | return ""; |
322 | } | 171 | } |
323 | } | 172 | } |
324 | else if (!mSearchUrl.empty()) | 173 | else if (!mSearchURL.empty()) |
325 | { | 174 | { |
326 | // Search url sent to us in the login response | 175 | // Search url sent to us in the login response |
327 | if (ty == SEARCH_ALL_EMPTY) | 176 | if (ty == SEARCH_ALL_EMPTY) |
328 | { | 177 | { |
329 | return (mSearchUrl); | 178 | return (mSearchURL); |
330 | } | 179 | } |
331 | else if (ty == SEARCH_ALL_QUERY) | 180 | else if (ty == SEARCH_ALL_QUERY) |
332 | { | 181 | { |
333 | return (mSearchUrl + "q=[QUERY]&s=[COLLECTION]&"); | 182 | return (mSearchURL + "q=[QUERY]&s=[COLLECTION]&"); |
334 | } | 183 | } |
335 | else if (ty == SEARCH_ALL_TEMPLATE) | 184 | else if (ty == SEARCH_ALL_TEMPLATE) |
336 | { | 185 | { |
@@ -369,11 +218,11 @@ std::string HippoGridInfo::getSearchUrl(SearchType ty, bool is_web) const | |||
369 | // Use the old search all | 218 | // Use the old search all |
370 | if (ty == SEARCH_ALL_EMPTY) | 219 | if (ty == SEARCH_ALL_EMPTY) |
371 | { | 220 | { |
372 | return (mSearchUrl + "panel=All&"); | 221 | return (mSearchURL + "panel=All&"); |
373 | } | 222 | } |
374 | else if (ty == SEARCH_ALL_QUERY) | 223 | else if (ty == SEARCH_ALL_QUERY) |
375 | { | 224 | { |
376 | return (mSearchUrl + "q=[QUERY]&s=[COLLECTION]&"); | 225 | return (mSearchURL + "q=[QUERY]&s=[COLLECTION]&"); |
377 | } | 226 | } |
378 | else if (ty == SEARCH_ALL_TEMPLATE) | 227 | else if (ty == SEARCH_ALL_TEMPLATE) |
379 | { | 228 | { |
@@ -424,7 +273,7 @@ void HippoGridInfo::onXmlElementEnd(void* userData, const XML_Char* name) | |||
424 | } | 273 | } |
425 | 274 | ||
426 | //static | 275 | //static |
427 | void HippoGridInfo::onXmlCharacterData(void* userData, const XML_Char* s, int len) | 276 | void HippoGridInfo::onXmlCharacterData(void* userData, const XML_Char* s, S32 len) |
428 | { | 277 | { |
429 | HippoGridInfo* self = (HippoGridInfo*)userData; | 278 | HippoGridInfo* self = (HippoGridInfo*)userData; |
430 | switch (self->mXmlState) | 279 | switch (self->mXmlState) |
@@ -446,30 +295,30 @@ void HippoGridInfo::onXmlCharacterData(void* userData, const XML_Char* s, int le | |||
446 | case XML_LOGINURI: | 295 | case XML_LOGINURI: |
447 | { | 296 | { |
448 | std::string loginuri(s, len); | 297 | std::string loginuri(s, len); |
449 | self->mLoginUri = sanitizeUri( loginuri ); | 298 | self->mLoginURI = sanitizeURI( loginuri ); |
450 | break; | 299 | break; |
451 | } | 300 | } |
452 | 301 | ||
453 | case XML_HELPERURI: | 302 | case XML_HELPERURI: |
454 | { | 303 | { |
455 | std::string helperuri(s, len); | 304 | std::string helperuri(s, len); |
456 | self->mHelperUri = sanitizeUri( helperuri ); | 305 | self->mHelperURI = sanitizeURI( helperuri ); |
457 | break; | 306 | break; |
458 | } | 307 | } |
459 | 308 | ||
460 | case XML_SEARCH: | 309 | case XML_SEARCH: |
461 | { | 310 | { |
462 | self->mSearchUrl.assign(s, len); | 311 | self->mSearchURL.assign(s, len); |
463 | //sanitizeQueryUrl(mSearchUrl); | 312 | //sanitizeQueryURL(mSearchURL); |
464 | break; | 313 | break; |
465 | } | 314 | } |
466 | 315 | ||
467 | case XML_GRIDNAME: self->mGridName.assign(s, len); break; | 316 | case XML_GRIDNAME: self->mGridName.assign(s, len); break; |
468 | case XML_LOGINPAGE: self->mLoginPage.assign(s, len); break; | 317 | case XML_LOGINPAGE: self->mLoginPage.assign(s, len); break; |
469 | case XML_WEBSITE: self->mWebSite.assign(s, len); break; | 318 | case XML_WEBSITE: self->mWebSite.assign(s, len); break; |
470 | case XML_SUPPORT: self->mSupportUrl.assign(s, len); break; | 319 | case XML_SUPPORT: self->mSupportURL.assign(s, len); break; |
471 | case XML_REGISTER: self->mRegisterUrl.assign(s, len); break; | 320 | case XML_REGISTER: self->mRegisterURL.assign(s, len); break; |
472 | case XML_PASSWORD: self->mPasswordUrl.assign(s, len); break; | 321 | case XML_PASSWORD: self->mPasswordURL.assign(s, len); break; |
473 | 322 | ||
474 | case XML_VOID: break; | 323 | case XML_VOID: break; |
475 | } | 324 | } |
@@ -478,16 +327,16 @@ void HippoGridInfo::onXmlCharacterData(void* userData, const XML_Char* s, int le | |||
478 | 327 | ||
479 | bool HippoGridInfo::retrieveGridInfo() | 328 | bool HippoGridInfo::retrieveGridInfo() |
480 | { | 329 | { |
481 | if (mLoginUri == "") return false; | 330 | if (mLoginURI == "") return false; |
482 | 331 | ||
483 | // If last character in uri is not "/" | 332 | // If last character in uri is not "/" |
484 | std::string uri = mLoginUri; | 333 | std::string uri = mLoginURI; |
485 | if (uri.compare(uri.length()-1, 1, "/") != 0) | 334 | if (uri.compare(uri.length()-1, 1, "/") != 0) |
486 | { | 335 | { |
487 | uri += '/'; | 336 | uri += '/'; |
488 | } | 337 | } |
489 | std::string reply; | 338 | std::string reply; |
490 | int result = HippoRestRequest::getBlocking(uri + "get_grid_info", &reply); | 339 | S32 result = HippoRestRequest::getBlocking(uri + "get_grid_info", &reply); |
491 | if (result != 200) return false; | 340 | if (result != 200) return false; |
492 | 341 | ||
493 | llinfos << "Received: " << reply << llendl; | 342 | llinfos << "Received: " << reply << llendl; |
@@ -508,6 +357,14 @@ bool HippoGridInfo::retrieveGridInfo() | |||
508 | return success; | 357 | return success; |
509 | } | 358 | } |
510 | 359 | ||
360 | const std::string& HippoGridInfo::getGridName() const | ||
361 | { | ||
362 | if (mGridName.empty()) | ||
363 | { | ||
364 | return mGridNick; | ||
365 | } | ||
366 | return mGridName; | ||
367 | } | ||
511 | 368 | ||
512 | std::string HippoGridInfo::getUploadFee() const | 369 | std::string HippoGridInfo::getUploadFee() const |
513 | { | 370 | { |
@@ -531,7 +388,7 @@ std::string HippoGridInfo::getDirectoryFee() const | |||
531 | return fee; | 388 | return fee; |
532 | } | 389 | } |
533 | 390 | ||
534 | void HippoGridInfo::formatFee(std::string &fee, int cost, bool showFree) const | 391 | void HippoGridInfo::formatFee(std::string &fee, S32 cost, bool showFree) const |
535 | { | 392 | { |
536 | if (showFree && (cost == 0)) | 393 | if (showFree && (cost == 0)) |
537 | { | 394 | { |
@@ -556,7 +413,9 @@ const char* HippoGridInfo::getPlatformString(Platform platform) | |||
556 | }; | 413 | }; |
557 | 414 | ||
558 | if ((platform < PLATFORM_OTHER) || (platform >= PLATFORM_LAST)) | 415 | if ((platform < PLATFORM_OTHER) || (platform >= PLATFORM_LAST)) |
416 | { | ||
559 | platform = PLATFORM_OTHER; | 417 | platform = PLATFORM_OTHER; |
418 | } | ||
560 | return platformStrings[platform]; | 419 | return platformStrings[platform]; |
561 | } | 420 | } |
562 | 421 | ||
@@ -565,8 +424,8 @@ const char* HippoGridInfo::getPlatformString(Platform platform) | |||
565 | std::string HippoGridInfo::sanitizeGridNick(std::string &gridnick) | 424 | std::string HippoGridInfo::sanitizeGridNick(std::string &gridnick) |
566 | { | 425 | { |
567 | std::string tmp; | 426 | std::string tmp; |
568 | int size = gridnick.size(); | 427 | S32 size = gridnick.size(); |
569 | for (int i=0; i<size; i++) | 428 | for (S32 i=0; i<size; i++) |
570 | { | 429 | { |
571 | char c = gridnick[i]; | 430 | char c = gridnick[i]; |
572 | if ((c == '_') || isalnum(c)) | 431 | if ((c == '_') || isalnum(c)) |
@@ -582,8 +441,10 @@ std::string HippoGridInfo::sanitizeGridNick(std::string &gridnick) | |||
582 | } | 441 | } |
583 | 442 | ||
584 | // static | 443 | // static |
585 | std::string HippoGridInfo::sanitizeUri(std::string &uri) | 444 | std::string HippoGridInfo::sanitizeURI(std::string &uri) |
586 | { | 445 | { |
446 | // Why don't we do this anymore? -- MC | ||
447 | |||
587 | // if (uri.empty()) { | 448 | // if (uri.empty()) { |
588 | // return ""; | 449 | // return ""; |
589 | // } | 450 | // } |
@@ -603,8 +464,8 @@ void HippoGridInfo::initFallback() | |||
603 | FALLBACK_GRIDINFO.mGridNick = "localhost"; | 464 | FALLBACK_GRIDINFO.mGridNick = "localhost"; |
604 | FALLBACK_GRIDINFO.setPlatform(PLATFORM_OPENSIM); | 465 | FALLBACK_GRIDINFO.setPlatform(PLATFORM_OPENSIM); |
605 | FALLBACK_GRIDINFO.setGridName("Local Host"); | 466 | FALLBACK_GRIDINFO.setGridName("Local Host"); |
606 | FALLBACK_GRIDINFO.setLoginUri("http://127.0.0.1:9000/"); | 467 | FALLBACK_GRIDINFO.setLoginURI("http://127.0.0.1:9000/"); |
607 | FALLBACK_GRIDINFO.setHelperUri("http://127.0.0.1:9000/"); | 468 | FALLBACK_GRIDINFO.setHelperURI("http://127.0.0.1:9000/"); |
608 | } | 469 | } |
609 | 470 | ||
610 | 471 | ||
@@ -683,7 +544,7 @@ HippoGridInfo* HippoGridManager::getGrid(const std::string& grid) const | |||
683 | 544 | ||
684 | HippoGridInfo* HippoGridManager::getConnectedGrid() const | 545 | HippoGridInfo* HippoGridManager::getConnectedGrid() const |
685 | { | 546 | { |
686 | return (mConnectedGrid)? mConnectedGrid: getCurrentGrid(); | 547 | return (mConnectedGrid) ? mConnectedGrid : getCurrentGrid(); |
687 | } | 548 | } |
688 | 549 | ||
689 | 550 | ||
@@ -700,11 +561,6 @@ HippoGridInfo* HippoGridManager::getCurrentGrid() const | |||
700 | } | 561 | } |
701 | } | 562 | } |
702 | 563 | ||
703 | const std::string& HippoGridManager::getDefaultGridNick() const | ||
704 | { | ||
705 | return mDefaultGrid; | ||
706 | } | ||
707 | |||
708 | const std::string& HippoGridManager::getCurrentGridNick() const | 564 | const std::string& HippoGridManager::getCurrentGridNick() const |
709 | { | 565 | { |
710 | if (mCurrentGrid.empty()) | 566 | if (mCurrentGrid.empty()) |
@@ -714,12 +570,6 @@ const std::string& HippoGridManager::getCurrentGridNick() const | |||
714 | return mCurrentGrid; | 570 | return mCurrentGrid; |
715 | } | 571 | } |
716 | 572 | ||
717 | void HippoGridManager::setCurrentGridAsConnected() | ||
718 | { | ||
719 | mConnectedGrid = getCurrentGrid(); | ||
720 | } | ||
721 | |||
722 | |||
723 | void HippoGridManager::addGrid(HippoGridInfo* grid) | 573 | void HippoGridManager::addGrid(HippoGridInfo* grid) |
724 | { | 574 | { |
725 | if (!grid) return; | 575 | if (!grid) return; |
@@ -743,17 +593,25 @@ void HippoGridManager::addGrid(HippoGridInfo* grid) | |||
743 | void HippoGridManager::deleteGrid(const std::string& grid) | 593 | void HippoGridManager::deleteGrid(const std::string& grid) |
744 | { | 594 | { |
745 | GridIterator it = mGridInfo.find(grid); | 595 | GridIterator it = mGridInfo.find(grid); |
746 | if (it == mGridInfo.end()) { | 596 | if (it == mGridInfo.end()) |
597 | { | ||
747 | llwarns << "Trying to delete non-existing grid " << grid << '.' << llendl; | 598 | llwarns << "Trying to delete non-existing grid " << grid << '.' << llendl; |
748 | return; | 599 | return; |
749 | } | 600 | } |
601 | |||
750 | mGridInfo.erase(it); | 602 | mGridInfo.erase(it); |
603 | |||
751 | llinfos << "Number of grids now: " << mGridInfo.size() << llendl; | 604 | llinfos << "Number of grids now: " << mGridInfo.size() << llendl; |
605 | |||
752 | if (mGridInfo.empty()) llinfos << "Grid info map is empty." << llendl; | 606 | if (mGridInfo.empty()) llinfos << "Grid info map is empty." << llendl; |
753 | if (grid == mDefaultGrid) | 607 | if (grid == mDefaultGrid) |
608 | { | ||
754 | setDefaultGrid(LLStringUtil::null); // sets first grid, if map not empty | 609 | setDefaultGrid(LLStringUtil::null); // sets first grid, if map not empty |
610 | } | ||
755 | if (grid == mCurrentGrid) | 611 | if (grid == mCurrentGrid) |
612 | { | ||
756 | mCurrentGrid = mDefaultGrid; | 613 | mCurrentGrid = mDefaultGrid; |
614 | } | ||
757 | } | 615 | } |
758 | 616 | ||
759 | 617 | ||
@@ -793,6 +651,18 @@ void HippoGridManager::setCurrentGrid(const std::string& grid) | |||
793 | } | 651 | } |
794 | } | 652 | } |
795 | 653 | ||
654 | bool HippoGridManager::hasGridNick(const std::string& grid_nick) | ||
655 | { | ||
656 | for (GridIterator it = beginGrid(); it != endGrid(); ++it) | ||
657 | { | ||
658 | if (grid_nick == it->second->getGridNick()) | ||
659 | { | ||
660 | return true; | ||
661 | } | ||
662 | } | ||
663 | return false; | ||
664 | } | ||
665 | |||
796 | 666 | ||
797 | // ******************************************************************** | 667 | // ******************************************************************** |
798 | // Persistent Store | 668 | // Persistent Store |
@@ -810,7 +680,7 @@ void HippoGridManager::loadFromFile() | |||
810 | std::string update_list = gSavedSettings.getString("GridUpdateList"); | 680 | std::string update_list = gSavedSettings.getString("GridUpdateList"); |
811 | if (!update_list.empty()) | 681 | if (!update_list.empty()) |
812 | { | 682 | { |
813 | parseUrl(update_list, !mGridInfo.empty()); | 683 | parseURL(update_list, !mGridInfo.empty()); |
814 | } | 684 | } |
815 | else | 685 | else |
816 | { | 686 | { |
@@ -825,7 +695,7 @@ void HippoGridManager::loadFromFile() | |||
825 | } | 695 | } |
826 | 696 | ||
827 | 697 | ||
828 | void HippoGridManager::parseUrl(const std::string url, bool mergeIfNewer) | 698 | void HippoGridManager::parseURL(const std::string url, bool mergeIfNewer) |
829 | { | 699 | { |
830 | llinfos << "Loading grid info from '" << url << "'." << llendl; | 700 | llinfos << "Loading grid info from '" << url << "'." << llendl; |
831 | 701 | ||
@@ -879,7 +749,7 @@ void HippoGridManager::parseData(LLSD &gridInfo, bool mergeIfNewer) | |||
879 | LLSD gridMap = *it; | 749 | LLSD gridMap = *it; |
880 | if (gridMap.has("default_grids_version")) | 750 | if (gridMap.has("default_grids_version")) |
881 | { | 751 | { |
882 | int version = gridMap["default_grids_version"]; | 752 | S32 version = gridMap["default_grids_version"]; |
883 | if (version <= mDefaultGridsVersion) return; | 753 | if (version <= mDefaultGridsVersion) return; |
884 | else break; | 754 | else break; |
885 | } | 755 | } |
@@ -917,20 +787,22 @@ void HippoGridManager::parseData(LLSD &gridInfo, bool mergeIfNewer) | |||
917 | // update existing grid info | 787 | // update existing grid info |
918 | grid = it->second; | 788 | grid = it->second; |
919 | } | 789 | } |
920 | grid->setLoginUri(gridMap["loginuri"]); | 790 | grid->setLoginURI(gridMap["loginuri"]); |
921 | if (gridMap.has("platform")) grid->setPlatform(gridMap["platform"]); | 791 | if (gridMap.has("platform")) grid->setPlatform(gridMap["platform"]); |
922 | if (gridMap.has("gridname")) grid->setGridName(gridMap["gridname"]); | 792 | if (gridMap.has("gridname")) grid->setGridName(gridMap["gridname"]); |
923 | if (gridMap.has("loginpage")) grid->setLoginPage(gridMap["loginpage"]); | 793 | if (gridMap.has("loginpage")) grid->setLoginPage(gridMap["loginpage"]); |
924 | if (gridMap.has("helperuri")) grid->setHelperUri(gridMap["helperuri"]); | 794 | if (gridMap.has("helperuri")) grid->setHelperURI(gridMap["helperuri"]); |
925 | if (gridMap.has("website")) grid->setWebSite(gridMap["website"]); | 795 | if (gridMap.has("website")) grid->setWebSite(gridMap["website"]); |
926 | if (gridMap.has("support")) grid->setSupportUrl(gridMap["support"]); | 796 | if (gridMap.has("support")) grid->setSupportURL(gridMap["support"]); |
927 | if (gridMap.has("register")) grid->setRegisterUrl(gridMap["register"]); | 797 | if (gridMap.has("register")) grid->setRegisterURL(gridMap["register"]); |
928 | if (gridMap.has("password")) grid->setPasswordUrl(gridMap["password"]); | 798 | if (gridMap.has("password")) grid->setPasswordURL(gridMap["password"]); |
929 | if (gridMap.has("search")) grid->setSearchUrl(gridMap["search"]); | 799 | if (gridMap.has("search")) grid->setSearchURL(gridMap["search"]); |
930 | if (gridMap.has("render_compat")) grid->setRenderCompat(gridMap["render_compat"]); | 800 | if (gridMap.has("render_compat")) grid->setRenderCompat(gridMap["render_compat"]); |
931 | // if (gridMap.has("firstname")) grid->setFirstName(gridMap["firstname"]); | 801 | if (gridMap.has("firstname")) grid->setFirstName(gridMap["firstname"]); |
932 | // if (gridMap.has("lastname")) grid->setLastName(gridMap["lastname"]); | 802 | if (gridMap.has("lastname")) grid->setLastName(gridMap["lastname"]); |
933 | // if (gridMap.has("avatarpassword")) grid->setAvatarPassword(gridMap["avatarpassword"]); | 803 | if (gridMap.has("avatarpassword")) grid->setAvatarPassword(gridMap["avatarpassword"]); |
804 | if (gridMap.has("username")) grid->setUsername(gridMap["username"]); | ||
805 | if (gridMap.has("username_compat")) grid->setUsernameCompat(gridMap["username_compat"]); | ||
934 | if (newGrid) addGrid(grid); | 806 | if (newGrid) addGrid(grid); |
935 | } | 807 | } |
936 | } | 808 | } |
@@ -955,19 +827,22 @@ void HippoGridManager::saveFile() | |||
955 | gridInfo[i]["gridnick"] = grid->getGridNick(); | 827 | gridInfo[i]["gridnick"] = grid->getGridNick(); |
956 | gridInfo[i]["platform"] = HippoGridInfo::getPlatformString(grid->getPlatform()); | 828 | gridInfo[i]["platform"] = HippoGridInfo::getPlatformString(grid->getPlatform()); |
957 | gridInfo[i]["gridname"] = grid->getGridName(); | 829 | gridInfo[i]["gridname"] = grid->getGridName(); |
958 | gridInfo[i]["loginuri"] = grid->getLoginUri(); | 830 | gridInfo[i]["loginuri"] = grid->getLoginURI(); |
959 | gridInfo[i]["loginpage"] = grid->getLoginPage(); | 831 | gridInfo[i]["loginpage"] = grid->getLoginPage(); |
960 | gridInfo[i]["helperuri"] = grid->getHelperUri(); | 832 | gridInfo[i]["helperuri"] = grid->getHelperURI(); |
961 | gridInfo[i]["website"] = grid->getWebSite(); | 833 | gridInfo[i]["website"] = grid->getWebSite(); |
962 | gridInfo[i]["support"] = grid->getSupportUrl(); | 834 | gridInfo[i]["support"] = grid->getSupportURL(); |
963 | gridInfo[i]["register"] = grid->getRegisterUrl(); | 835 | gridInfo[i]["register"] = grid->getRegisterURL(); |
964 | gridInfo[i]["password"] = grid->getPasswordUrl(); | 836 | gridInfo[i]["password"] = grid->getPasswordURL(); |
965 | // gridInfo[i]["firstname"] = grid->getFirstName(); | 837 | gridInfo[i]["firstname"] = grid->getFirstName(); |
966 | // gridInfo[i]["lastname"] = grid->getLastName(); | 838 | gridInfo[i]["lastname"] = grid->getLastName(); |
967 | // gridInfo[i]["avatarpassword"] = grid->getAvatarPassword(); | 839 | gridInfo[i]["avatarpassword"] = grid->getAvatarPassword(); |
968 | 840 | ||
969 | gridInfo[i]["search"] = grid->getSearchUrl(); | 841 | gridInfo[i]["search"] = grid->getSearchURL(); |
970 | gridInfo[i]["render_compat"] = grid->isRenderCompat(); | 842 | gridInfo[i]["render_compat"] = grid->isRenderCompat(); |
843 | |||
844 | gridInfo[i]["username"] = grid->getUsername(); | ||
845 | gridInfo[i]["username_compat"] = grid->isUsernameCompat(); | ||
971 | } | 846 | } |
972 | 847 | ||
973 | // write client grid info file | 848 | // write client grid info file |