diff options
Diffstat (limited to 'linden/indra/newview/hippoGridManager.cpp')
-rw-r--r-- | linden/indra/newview/hippoGridManager.cpp | 89 |
1 files changed, 51 insertions, 38 deletions
diff --git a/linden/indra/newview/hippoGridManager.cpp b/linden/indra/newview/hippoGridManager.cpp index c9f2549..ccf63f5 100644 --- a/linden/indra/newview/hippoGridManager.cpp +++ b/linden/indra/newview/hippoGridManager.cpp | |||
@@ -23,7 +23,7 @@ | |||
23 | // ******************************************************************** | 23 | // ******************************************************************** |
24 | // Global Variables | 24 | // Global Variables |
25 | 25 | ||
26 | HippoGridManager *gHippoGridManager = 0; | 26 | HippoGridManager* gHippoGridManager = 0; |
27 | 27 | ||
28 | HippoGridInfo HippoGridInfo::FALLBACK_GRIDINFO(""); | 28 | HippoGridInfo HippoGridInfo::FALLBACK_GRIDINFO(""); |
29 | 29 | ||
@@ -39,9 +39,22 @@ HippoGridInfo HippoGridInfo::FALLBACK_GRIDINFO(""); | |||
39 | // ******************************************************************** | 39 | // ******************************************************************** |
40 | // Initialize | 40 | // Initialize |
41 | 41 | ||
42 | HippoGridInfo::HippoGridInfo(const std::string &gridNick) : | 42 | HippoGridInfo::HippoGridInfo(const std::string& gridNick) : |
43 | mPlatform(PLATFORM_OTHER), | 43 | mPlatform(PLATFORM_OPENSIM), |
44 | mGridNick(gridNick), | 44 | mGridNick(gridNick), |
45 | mGridName(LLStringUtil::null), | ||
46 | mLoginUri(LLStringUtil::null), | ||
47 | mLoginPage(LLStringUtil::null), | ||
48 | mHelperUri(LLStringUtil::null), | ||
49 | mWebSite(LLStringUtil::null), | ||
50 | mSupportUrl(LLStringUtil::null), | ||
51 | mRegisterUrl(LLStringUtil::null), | ||
52 | mPasswordUrl(LLStringUtil::null), | ||
53 | mSearchUrl(LLStringUtil::null), | ||
54 | mFirstName(LLStringUtil::null), | ||
55 | mLastName(LLStringUtil::null), | ||
56 | mAvatarPassword(LLStringUtil::null), | ||
57 | mXmlState(XML_VOID), | ||
45 | mVoiceConnector("SLVoice"), | 58 | mVoiceConnector("SLVoice"), |
46 | mRenderCompat(true), | 59 | mRenderCompat(true), |
47 | mMaxAgentGroups(-1), | 60 | mMaxAgentGroups(-1), |
@@ -167,7 +180,7 @@ void HippoGridInfo::setPlatform(Platform platform) | |||
167 | } | 180 | } |
168 | 181 | ||
169 | 182 | ||
170 | void HippoGridInfo::setPlatform(const std::string &platform) | 183 | void HippoGridInfo::setPlatform(const std::string& platform) |
171 | { | 184 | { |
172 | std::string tmp = platform; | 185 | std::string tmp = platform; |
173 | for (unsigned i=0; i<platform.size(); i++) | 186 | for (unsigned i=0; i<platform.size(); i++) |
@@ -188,64 +201,64 @@ void HippoGridInfo::setPlatform(const std::string &platform) | |||
188 | } | 201 | } |
189 | } | 202 | } |
190 | 203 | ||
191 | void HippoGridInfo::setGridName(const std::string &gridName) | 204 | void HippoGridInfo::setGridName(const std::string& gridName) |
192 | { | 205 | { |
193 | mGridName = gridName; | 206 | mGridName = gridName; |
194 | } | 207 | } |
195 | 208 | ||
196 | void HippoGridInfo::setLoginUri(const std::string &loginUri) | 209 | void HippoGridInfo::setLoginUri(const std::string& loginUri) |
197 | { | 210 | { |
198 | std::string uri = loginUri; | 211 | std::string uri = loginUri; |
199 | mLoginUri = sanitizeUri(uri); | 212 | mLoginUri = sanitizeUri(uri); |
200 | } | 213 | } |
201 | 214 | ||
202 | void HippoGridInfo::setLoginPage(const std::string &loginPage) | 215 | void HippoGridInfo::setLoginPage(const std::string& loginPage) |
203 | { | 216 | { |
204 | mLoginPage = loginPage; | 217 | mLoginPage = loginPage; |
205 | } | 218 | } |
206 | 219 | ||
207 | void HippoGridInfo::setHelperUri(const std::string &helperUri) | 220 | void HippoGridInfo::setHelperUri(const std::string& helperUri) |
208 | { | 221 | { |
209 | std::string uri = helperUri; | 222 | std::string uri = helperUri; |
210 | mHelperUri = sanitizeUri(uri); | 223 | mHelperUri = sanitizeUri(uri); |
211 | } | 224 | } |
212 | 225 | ||
213 | void HippoGridInfo::setWebSite(const std::string &website) | 226 | void HippoGridInfo::setWebSite(const std::string& website) |
214 | { | 227 | { |
215 | mWebSite = website; | 228 | mWebSite = website; |
216 | } | 229 | } |
217 | 230 | ||
218 | void HippoGridInfo::setSupportUrl(const std::string &url) | 231 | void HippoGridInfo::setSupportUrl(const std::string& url) |
219 | { | 232 | { |
220 | mSupportUrl = url; | 233 | mSupportUrl = url; |
221 | } | 234 | } |
222 | 235 | ||
223 | void HippoGridInfo::setRegisterUrl(const std::string &url) | 236 | void HippoGridInfo::setRegisterUrl(const std::string& url) |
224 | { | 237 | { |
225 | mRegisterUrl = url; | 238 | mRegisterUrl = url; |
226 | } | 239 | } |
227 | 240 | ||
228 | void HippoGridInfo::setPasswordUrl(const std::string &url) | 241 | void HippoGridInfo::setPasswordUrl(const std::string& url) |
229 | { | 242 | { |
230 | mPasswordUrl = url; | 243 | mPasswordUrl = url; |
231 | } | 244 | } |
232 | 245 | ||
233 | void HippoGridInfo::setSearchUrl(const std::string &url) | 246 | void HippoGridInfo::setSearchUrl(const std::string& url) |
234 | { | 247 | { |
235 | mSearchUrl = url; | 248 | mSearchUrl = url; |
236 | } | 249 | } |
237 | 250 | ||
238 | void HippoGridInfo::setFirstName(const std::string &firstName) | 251 | void HippoGridInfo::setFirstName(const std::string& firstName) |
239 | { | 252 | { |
240 | mFirstName = firstName; | 253 | mFirstName = firstName; |
241 | } | 254 | } |
242 | 255 | ||
243 | void HippoGridInfo::setLastName(const std::string &lastName) | 256 | void HippoGridInfo::setLastName(const std::string& lastName) |
244 | { | 257 | { |
245 | mLastName = lastName; | 258 | mLastName = lastName; |
246 | } | 259 | } |
247 | 260 | ||
248 | void HippoGridInfo::setAvatarPassword(const std::string &avatarPassword) | 261 | void HippoGridInfo::setAvatarPassword(const std::string& avatarPassword) |
249 | { | 262 | { |
250 | mAvatarPassword = avatarPassword; | 263 | mAvatarPassword = avatarPassword; |
251 | } | 264 | } |
@@ -255,12 +268,12 @@ void HippoGridInfo::setRenderCompat(bool compat) | |||
255 | mRenderCompat = compat; | 268 | mRenderCompat = compat; |
256 | } | 269 | } |
257 | 270 | ||
258 | void HippoGridInfo::setCurrencySymbol(const std::string &sym) | 271 | void HippoGridInfo::setCurrencySymbol(const std::string& sym) |
259 | { | 272 | { |
260 | mCurrencySymbol = sym.substr(0, 3); | 273 | mCurrencySymbol = sym.substr(0, 3); |
261 | } | 274 | } |
262 | 275 | ||
263 | void HippoGridInfo::setRealCurrencySymbol(const std::string &sym) | 276 | void HippoGridInfo::setRealCurrencySymbol(const std::string& sym) |
264 | { | 277 | { |
265 | mRealCurrencySymbol = sym.substr(0, 3); | 278 | mRealCurrencySymbol = sym.substr(0, 3); |
266 | } | 279 | } |
@@ -348,9 +361,9 @@ std::string HippoGridInfo::getSearchUrl(SearchType ty, bool is_web) const | |||
348 | 361 | ||
349 | 362 | ||
350 | //static | 363 | //static |
351 | void HippoGridInfo::onXmlElementStart(void *userData, const XML_Char *name, const XML_Char **atts) | 364 | void HippoGridInfo::onXmlElementStart(void* userData, const XML_Char* name, const XML_Char** atts) |
352 | { | 365 | { |
353 | HippoGridInfo *self = (HippoGridInfo*)userData; | 366 | HippoGridInfo* self = (HippoGridInfo*)userData; |
354 | if (strcasecmp(name, "gridnick") == 0) | 367 | if (strcasecmp(name, "gridnick") == 0) |
355 | self->mXmlState = XML_GRIDNICK; | 368 | self->mXmlState = XML_GRIDNICK; |
356 | else if (strcasecmp(name, "gridname") == 0) | 369 | else if (strcasecmp(name, "gridname") == 0) |
@@ -376,16 +389,16 @@ void HippoGridInfo::onXmlElementStart(void *userData, const XML_Char *name, cons | |||
376 | } | 389 | } |
377 | 390 | ||
378 | //static | 391 | //static |
379 | void HippoGridInfo::onXmlElementEnd(void *userData, const XML_Char *name) | 392 | void HippoGridInfo::onXmlElementEnd(void* userData, const XML_Char* name) |
380 | { | 393 | { |
381 | HippoGridInfo *self = (HippoGridInfo*)userData; | 394 | HippoGridInfo* self = (HippoGridInfo*)userData; |
382 | self->mXmlState = XML_VOID; | 395 | self->mXmlState = XML_VOID; |
383 | } | 396 | } |
384 | 397 | ||
385 | //static | 398 | //static |
386 | void HippoGridInfo::onXmlCharacterData(void *userData, const XML_Char *s, int len) | 399 | void HippoGridInfo::onXmlCharacterData(void* userData, const XML_Char* s, int len) |
387 | { | 400 | { |
388 | HippoGridInfo *self = (HippoGridInfo*)userData; | 401 | HippoGridInfo* self = (HippoGridInfo*)userData; |
389 | switch (self->mXmlState) | 402 | switch (self->mXmlState) |
390 | { | 403 | { |
391 | case XML_GRIDNICK: | 404 | case XML_GRIDNICK: |
@@ -507,9 +520,9 @@ void HippoGridInfo::formatFee(std::string &fee, int cost, bool showFree) const | |||
507 | // Static Helpers | 520 | // Static Helpers |
508 | 521 | ||
509 | // static | 522 | // static |
510 | const char *HippoGridInfo::getPlatformString(Platform platform) | 523 | const char* HippoGridInfo::getPlatformString(Platform platform) |
511 | { | 524 | { |
512 | static const char *platformStrings[PLATFORM_LAST] = | 525 | static const char* platformStrings[PLATFORM_LAST] = |
513 | { | 526 | { |
514 | "Other", "OpenSim", "SecondLife" | 527 | "Other", "OpenSim", "SecondLife" |
515 | }; | 528 | }; |
@@ -625,7 +638,7 @@ void HippoGridManager::discardAndReload() | |||
625 | // ******************************************************************** | 638 | // ******************************************************************** |
626 | // Public Access | 639 | // Public Access |
627 | 640 | ||
628 | HippoGridInfo* HippoGridManager::getGrid(const std::string &grid) const | 641 | HippoGridInfo* HippoGridManager::getGrid(const std::string& grid) const |
629 | { | 642 | { |
630 | std::map<std::string, HippoGridInfo*>::const_iterator it; | 643 | std::map<std::string, HippoGridInfo*>::const_iterator it; |
631 | it = mGridInfo.find(grid); | 644 | it = mGridInfo.find(grid); |
@@ -648,7 +661,7 @@ HippoGridInfo* HippoGridManager::getConnectedGrid() const | |||
648 | 661 | ||
649 | HippoGridInfo* HippoGridManager::getCurrentGrid() const | 662 | HippoGridInfo* HippoGridManager::getCurrentGrid() const |
650 | { | 663 | { |
651 | HippoGridInfo *grid = getGrid(mCurrentGrid); | 664 | HippoGridInfo* grid = getGrid(mCurrentGrid); |
652 | if (grid) | 665 | if (grid) |
653 | { | 666 | { |
654 | return grid; | 667 | return grid; |
@@ -679,10 +692,10 @@ void HippoGridManager::setCurrentGridAsConnected() | |||
679 | } | 692 | } |
680 | 693 | ||
681 | 694 | ||
682 | void HippoGridManager::addGrid(HippoGridInfo *grid) | 695 | void HippoGridManager::addGrid(HippoGridInfo* grid) |
683 | { | 696 | { |
684 | if (!grid) return; | 697 | if (!grid) return; |
685 | const std::string &nick = grid->getGridNick(); | 698 | const std::string& nick = grid->getGridNick(); |
686 | if (nick == "") | 699 | if (nick == "") |
687 | { | 700 | { |
688 | llwarns << "Ignoring to try adding grid with empty nick." << llendl; | 701 | llwarns << "Ignoring to try adding grid with empty nick." << llendl; |
@@ -699,7 +712,7 @@ void HippoGridManager::addGrid(HippoGridInfo *grid) | |||
699 | } | 712 | } |
700 | 713 | ||
701 | 714 | ||
702 | void HippoGridManager::deleteGrid(const std::string &grid) | 715 | void HippoGridManager::deleteGrid(const std::string& grid) |
703 | { | 716 | { |
704 | GridIterator it = mGridInfo.find(grid); | 717 | GridIterator it = mGridInfo.find(grid); |
705 | if (it == mGridInfo.end()) { | 718 | if (it == mGridInfo.end()) { |
@@ -710,13 +723,13 @@ void HippoGridManager::deleteGrid(const std::string &grid) | |||
710 | llinfos << "Number of grids now: " << mGridInfo.size() << llendl; | 723 | llinfos << "Number of grids now: " << mGridInfo.size() << llendl; |
711 | if (mGridInfo.empty()) llinfos << "Grid info map is empty." << llendl; | 724 | if (mGridInfo.empty()) llinfos << "Grid info map is empty." << llendl; |
712 | if (grid == mDefaultGrid) | 725 | if (grid == mDefaultGrid) |
713 | setDefaultGrid(""); // sets first grid, if map not empty | 726 | setDefaultGrid(LLStringUtil::null); // sets first grid, if map not empty |
714 | if (grid == mCurrentGrid) | 727 | if (grid == mCurrentGrid) |
715 | mCurrentGrid = mDefaultGrid; | 728 | mCurrentGrid = mDefaultGrid; |
716 | } | 729 | } |
717 | 730 | ||
718 | 731 | ||
719 | void HippoGridManager::setDefaultGrid(const std::string &grid) | 732 | void HippoGridManager::setDefaultGrid(const std::string& grid) |
720 | { | 733 | { |
721 | GridIterator it = mGridInfo.find(grid); | 734 | GridIterator it = mGridInfo.find(grid); |
722 | if (it != mGridInfo.end()) | 735 | if (it != mGridInfo.end()) |
@@ -738,7 +751,7 @@ void HippoGridManager::setDefaultGrid(const std::string &grid) | |||
738 | } | 751 | } |
739 | 752 | ||
740 | 753 | ||
741 | void HippoGridManager::setCurrentGrid(const std::string &grid) | 754 | void HippoGridManager::setCurrentGrid(const std::string& grid) |
742 | { | 755 | { |
743 | GridIterator it = mGridInfo.find(grid); | 756 | GridIterator it = mGridInfo.find(grid); |
744 | if (it != mGridInfo.end()) | 757 | if (it != mGridInfo.end()) |
@@ -774,7 +787,7 @@ void HippoGridManager::loadFromFile() | |||
774 | } | 787 | } |
775 | 788 | ||
776 | 789 | ||
777 | void HippoGridManager::parseUrl(const char *url, bool mergeIfNewer) | 790 | void HippoGridManager::parseUrl(const char* url, bool mergeIfNewer) |
778 | { | 791 | { |
779 | llinfos << "Loading grid info from '" << url << "'." << llendl; | 792 | llinfos << "Loading grid info from '" << url << "'." << llendl; |
780 | 793 | ||
@@ -796,7 +809,7 @@ void HippoGridManager::parseUrl(const char *url, bool mergeIfNewer) | |||
796 | parseData(gridInfo, mergeIfNewer); | 809 | parseData(gridInfo, mergeIfNewer); |
797 | } | 810 | } |
798 | 811 | ||
799 | void HippoGridManager::parseFile(const std::string &fileName, bool mergeIfNewer) | 812 | void HippoGridManager::parseFile(const std::string& fileName, bool mergeIfNewer) |
800 | { | 813 | { |
801 | llifstream infile; | 814 | llifstream infile; |
802 | infile.open(fileName.c_str()); | 815 | infile.open(fileName.c_str()); |
@@ -853,7 +866,7 @@ void HippoGridManager::parseData(LLSD &gridInfo, bool mergeIfNewer) | |||
853 | else if (gridMap.has("gridnick") && gridMap.has("loginuri")) | 866 | else if (gridMap.has("gridnick") && gridMap.has("loginuri")) |
854 | { | 867 | { |
855 | std::string gridnick = gridMap["gridnick"]; | 868 | std::string gridnick = gridMap["gridnick"]; |
856 | HippoGridInfo *grid; | 869 | HippoGridInfo* grid; |
857 | GridIterator it = mGridInfo.find(gridnick); | 870 | GridIterator it = mGridInfo.find(gridnick); |
858 | bool newGrid = (it == mGridInfo.end()); | 871 | bool newGrid = (it == mGridInfo.end()); |
859 | if (newGrid) | 872 | if (newGrid) |
@@ -900,7 +913,7 @@ void HippoGridManager::saveFile() | |||
900 | GridIterator it, end = mGridInfo.end(); | 913 | GridIterator it, end = mGridInfo.end(); |
901 | for (it = mGridInfo.begin(); it != end; ++it, i++) | 914 | for (it = mGridInfo.begin(); it != end; ++it, i++) |
902 | { | 915 | { |
903 | HippoGridInfo *grid = it->second; | 916 | HippoGridInfo* grid = it->second; |
904 | gridInfo[i]["gridnick"] = grid->getGridNick(); | 917 | gridInfo[i]["gridnick"] = grid->getGridNick(); |
905 | gridInfo[i]["platform"] = HippoGridInfo::getPlatformString(grid->getPlatform()); | 918 | gridInfo[i]["platform"] = HippoGridInfo::getPlatformString(grid->getPlatform()); |
906 | gridInfo[i]["gridname"] = grid->getGridName(); | 919 | gridInfo[i]["gridname"] = grid->getGridName(); |