From f57eabefa1291f4e047aa03416c9c544413b9f0e Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Thu, 10 Sep 2009 02:31:50 -0500 Subject: Fixed line endings on hippo and grid manager files. --- .../indra/newview/app_settings/default_grids.xml | 102 +- linden/indra/newview/hippoGridManager.cpp | 1194 ++++++++++---------- linden/indra/newview/hippoGridManager.h | 342 +++--- linden/indra/newview/hippoLimits.cpp | 108 +- linden/indra/newview/hippoLimits.h | 66 +- linden/indra/newview/hippoRestRequest.cpp | 108 +- linden/indra/newview/hippoRestRequest.h | 32 +- linden/indra/newview/hippoUpdate.cpp | 184 +-- linden/indra/newview/hippoUpdate.h | 24 +- 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 @@ - - - - - - - default_grids_version0 - - - - - gridnickosgrid - gridnameOSGrid - platformOpenSim - loginurihttp://osgrid.org:8002/ - loginpagehttp://osgrid.org/loginscreen.php - helperurihttp://osgrid.org/ - websitehttp://osgrid.org/ - supporthttp://osgrid.org/ - registerhttp://osgrid.org/index.php?page=create - passwordhttp://osgrid.org/index.php?page=change - - - - - gridnicksecondlife - gridnameSecond Life - platformSecondLife - loginurihttps://login.agni.lindenlab.com/cgi-bin/login.cgi - loginpagehttp://secondlife.com/app/login/ - helperurihttps://secondlife.com/helpers/ - websitehttp://secondlife.com/ - supporthttp://secondlife.com/support/ - registerhttp://secondlife.com/registration/ - passwordhttp://secondlife.com/account/request.php - - - - - gridnicklocal - gridnameLocal Host - platformOpenSim - loginurihttp://127.0.0.1:9000/ - helperurihttp://127.0.0.1:9000/ - - - - + + + + + + + default_grids_version0 + + + + + gridnickosgrid + gridnameOSGrid + platformOpenSim + loginurihttp://osgrid.org:8002/ + loginpagehttp://osgrid.org/loginscreen.php + helperurihttp://osgrid.org/ + websitehttp://osgrid.org/ + supporthttp://osgrid.org/ + registerhttp://osgrid.org/index.php?page=create + passwordhttp://osgrid.org/index.php?page=change + + + + + gridnicksecondlife + gridnameSecond Life + platformSecondLife + loginurihttps://login.agni.lindenlab.com/cgi-bin/login.cgi + loginpagehttp://secondlife.com/app/login/ + helperurihttps://secondlife.com/helpers/ + websitehttp://secondlife.com/ + supporthttp://secondlife.com/support/ + registerhttp://secondlife.com/registration/ + passwordhttp://secondlife.com/account/request.php + + + + + gridnicklocal + gridnameLocal Host + platformOpenSim + loginurihttp://127.0.0.1:9000/ + helperurihttp://127.0.0.1:9000/ + + + + 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 @@ - - -#include "hippoGridManager.h" - -#include - -#include -#include -#include -#include -#include -#include -#include -#include "llviewercontrol.h" -#include "llweb.h" - -#include "hippoRestRequest.h" - - -// ******************************************************************** -// Global Variables - -HippoGridManager *gHippoGridManager = 0; - -HippoGridInfo HippoGridInfo::FALLBACK_GRIDINFO(""); - - - -// ******************************************************************** -// ******************************************************************** -// HippoGridInfo -// ******************************************************************** -// ******************************************************************** - - -// ******************************************************************** -// Initialize - -HippoGridInfo::HippoGridInfo(const std::string &gridNick) : - mPlatform(PLATFORM_OTHER), - mGridNick(gridNick), - mRenderCompat(true), - mCurrencySymbol("OS$"), - mRealCurrencySymbol("US$"), - mDirectoryFee(30) -{ - cleanUpGridNick(mGridNick); -} - - -void HippoGridInfo::setPlatform(Platform platform) -{ - mPlatform = platform; - mCurrencySymbol = (mPlatform == PLATFORM_SECONDLIFE)? "L$": "OS$"; -} - - -void HippoGridInfo::setPlatform(const std::string &platform) -{ - std::string tmp = platform; - for (unsigned i=0; imXmlState = XML_GRIDNICK; - else if (strcasecmp(name, "gridname") == 0) - self->mXmlState = XML_GRIDNAME; - else if (strcasecmp(name, "platform") == 0) - self->mXmlState = XML_PLATFORM; - else if ((strcasecmp(name, "login") == 0) || (strcasecmp(name, "loginuri") == 0)) - self->mXmlState = XML_LOGINURI; - else if ((strcasecmp(name, "welcome") == 0) || (strcasecmp(name, "loginpage") == 0)) - self->mXmlState = XML_LOGINPAGE; - else if ((strcasecmp(name, "economy") == 0) || (strcasecmp(name, "helperuri") == 0)) - self->mXmlState = XML_HELPERURI; - else if ((strcasecmp(name, "about") == 0) || (strcasecmp(name, "website") == 0)) - self->mXmlState = XML_WEBSITE; - else if ((strcasecmp(name, "help") == 0) || (strcasecmp(name, "support") == 0)) - self->mXmlState = XML_SUPPORT; - else if ((strcasecmp(name, "register") == 0) || (strcasecmp(name, "account") == 0)) - self->mXmlState = XML_REGISTER; - else if (strcasecmp(name, "password") == 0) - self->mXmlState = XML_PASSWORD; - //else if (strcasecmp(name, "search") == 0) - //self->mXmlState = XML_SEARCH; -} - -//static -void HippoGridInfo::onXmlElementEnd(void *userData, const XML_Char *name) -{ - HippoGridInfo *self = (HippoGridInfo*)userData; - self->mXmlState = XML_VOID; -} - -//static -void HippoGridInfo::onXmlCharacterData(void *userData, const XML_Char *s, int len) -{ - HippoGridInfo *self = (HippoGridInfo*)userData; - switch (self->mXmlState) { - - case XML_GRIDNICK: - if (self->mGridNick == "") self->mGridNick.assign(s, len); - cleanUpGridNick(self->mGridNick); - break; - - case XML_PLATFORM: { - std::string platform(s, len); - self->setPlatform(platform); - break; - } - - case XML_LOGINURI: - self->mLoginUri.assign(s, len); - cleanUpUri(self->mLoginUri); - break; - - case XML_HELPERURI: - self->mHelperUri.assign(s, len); - cleanUpUri(self->mHelperUri); - break; - - case XML_SEARCH: - //self->mSearchUrl.assign(s, len); - //cleanUpQueryUrl(mSearchUrl); - break; - - case XML_GRIDNAME: self->mGridName.assign(s, len); break; - case XML_LOGINPAGE: self->mLoginPage.assign(s, len); break; - case XML_WEBSITE: self->mWebSite.assign(s, len); break; - case XML_SUPPORT: self->mSupportUrl.assign(s, len); break; - case XML_REGISTER: self->mRegisterUrl.assign(s, len); break; - case XML_PASSWORD: self->mPasswordUrl.assign(s, len); break; - - case XML_VOID: break; - } -} - - -bool HippoGridInfo::retrieveGridInfo() -{ - if (mLoginUri == "") return false; - - std::string reply; - int result = HippoRestRequest::getBlocking(mLoginUri + "get_grid_info", &reply); - if (result != 200) return false; - - llinfos << "Received: " << reply << llendl; - - bool success = true; - XML_Parser parser = XML_ParserCreate(0); - XML_SetUserData(parser, this); - XML_SetElementHandler(parser, onXmlElementStart, onXmlElementEnd); - XML_SetCharacterDataHandler(parser, onXmlCharacterData); - mXmlState = XML_VOID; - if (!XML_Parse(parser, reply.data(), reply.size(), TRUE)) { - llwarns << "XML Parse Error: " << XML_ErrorString(XML_GetErrorCode(parser)) << llendl; - success = false; - } - XML_ParserFree(parser); - - return success; -} - - -std::string HippoGridInfo::getUploadFee() const -{ - std::string fee; - formatFee(fee, LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(), true); - return fee; -} - -std::string HippoGridInfo::getGroupCreationFee() const -{ - std::string fee; - formatFee(fee, LLGlobalEconomy::Singleton::getInstance()->getPriceGroupCreate(), false); - return fee; -} - -std::string HippoGridInfo::getDirectoryFee() const -{ - std::string fee; - formatFee(fee, mDirectoryFee, true); - if (fee != "free") fee += "/week"; - return fee; -} - -void HippoGridInfo::formatFee(std::string &fee, int cost, bool showFree) const -{ - if (showFree && (cost == 0)) { - fee = "free"; - } else { - fee = llformat("%s%d", getCurrencySymbol().c_str(), cost); - } -} - - -// ******************************************************************** -// Static Helpers - -// static -const char *HippoGridInfo::getPlatformString(Platform platform) -{ - static const char *platformStrings[PLATFORM_LAST] = { - "Other", "OpenSim", "SecondLife" - }; - - if ((platform < PLATFORM_OTHER) || (platform >= PLATFORM_LAST)) - platform = PLATFORM_OTHER; - return platformStrings[platform]; -} - - -// static -void HippoGridInfo::cleanUpGridNick(std::string &gridnick) -{ - std::string tmp; - int size = gridnick.size(); - for (int i=0; i::iterator it, end = mGridInfo.end(); - for (it=mGridInfo.begin(); it != end; ++it) { - delete it->second; - } - mGridInfo.clear(); -} - - -void HippoGridManager::init() -{ - HippoGridInfo::initFallback(); - loadFromFile(); - - // !!!### gSavedSettings.getControl("CmdLineLoginURI"); - // !!!### gSavedSettings.getString("CmdLineLoginPage"); - // !!!### gSavedSettings.getString("CmdLineHelperURI"); - // !!!### LLString::compareInsensitive(gGridInfo[grid_index].mLabel, grid_name.c_str())) -} - - -void HippoGridManager::discardAndReload() -{ - cleanup(); - loadFromFile(); -} - - -// ******************************************************************** -// Public Access - -HippoGridInfo *HippoGridManager::getGrid(const std::string &grid) const -{ - std::map::const_iterator it; - it = mGridInfo.find(grid); - if (it != mGridInfo.end()) { - return it->second; - } else { - return 0; - } -} - - -HippoGridInfo *HippoGridManager::getCurrentGrid() const -{ - HippoGridInfo *grid = getGrid(mCurrentGrid); - if (grid) { - return grid; - } else { - return &HippoGridInfo::FALLBACK_GRIDINFO; - } -} - - -void HippoGridManager::addGrid(HippoGridInfo *grid) -{ - if (!grid) return; - const std::string &nick = grid->getGridNick(); - if (nick == "") { - llwarns << "Ignoring to try adding grid with empty nick." << llendl; - delete grid; - return; - } - if (mGridInfo.find(nick) != mGridInfo.end()) { - llwarns << "Ignoring to try adding existing grid " << nick << '.' << llendl; - delete grid; - return; - } - mGridInfo[nick] = grid; -} - - -void HippoGridManager::deleteGrid(const std::string &grid) -{ - GridIterator it = mGridInfo.find(grid); - if (it == mGridInfo.end()) { - llwarns << "Trying to delete non-existing grid " << grid << '.' << llendl; - return; - } - mGridInfo.erase(it); - llinfos << "Number of grids now: " << mGridInfo.size() << llendl; - if (mGridInfo.empty()) llinfos << "Grid info map is empty." << llendl; - if (grid == mDefaultGrid) - setDefaultGrid(""); // sets first grid, if map not empty - if (grid == mCurrentGrid) - mCurrentGrid = mDefaultGrid; -} - - -void HippoGridManager::setDefaultGrid(const std::string &grid) -{ - GridIterator it = mGridInfo.find(grid); - if (it != mGridInfo.end()) { - mDefaultGrid = grid; - } else if (mGridInfo.find("secondlife") != mGridInfo.end()) { - mDefaultGrid = "secondlife"; - } else if (!mGridInfo.empty()) { - mDefaultGrid = mGridInfo.begin()->first; - } else { - mDefaultGrid = ""; - } -} - - -void HippoGridManager::setCurrentGrid(const std::string &grid) -{ - GridIterator it = mGridInfo.find(grid); - if (it != mGridInfo.end()) { - mCurrentGrid = grid; - } else if (!mGridInfo.empty()) { - llwarns << "Unknown grid '" << grid << "'. Setting to default grid." << llendl; - mCurrentGrid = mDefaultGrid; - } -} - - -// ******************************************************************** -// Persistent Store - -void HippoGridManager::loadFromFile() -{ - mDefaultGridsVersion = 0; - // load user grid info - parseFile(gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "grid_info.xml"), false); - // merge default grid info, if newer. Force load, if list of grids is empty. - parseFile(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "default_grids.xml"), !mGridInfo.empty()); - // merge grid info from web site, if newer. Force load, if list of grids is empty. - if (gSavedSettings.getBOOL("CheckForGridUpdates")) - parseUrl("http://opensim-viewer.sourceforge.net/db/grids.php", !mGridInfo.empty()); - - setDefaultGrid(gSavedSettings.getString("DefaultGrid")); - setCurrentGrid(gSavedSettings.getString("CmdLineGridChoice")); -} - - -void HippoGridManager::parseUrl(const char *url, bool mergeIfNewer) -{ - llinfos << "Loading grid info from '" << url << "'." << llendl; - - // query update server - std::string escaped_url = LLWeb::escapeURL(url); - LLSD response = LLHTTPClient::blockingGet(url); - - // check response, return on error - S32 status = response["status"].asInteger(); - if ((status != 200) || !response["body"].isArray()) { - llinfos << "GridInfo Update failed (" << status << "): " - << (response["body"].isString()? response["body"].asString(): "") - << llendl; - return; - } - - LLSD gridInfo = response["body"]; - parseData(gridInfo, mergeIfNewer); -} - -void HippoGridManager::parseFile(const std::string &fileName, bool mergeIfNewer) -{ - llifstream infile; - infile.open(fileName.c_str()); - if(!infile.is_open()) { - llwarns << "Cannot find grid info file " << fileName << " to load." << llendl; - return; - } - - LLSD gridInfo; - if (LLSDSerialize::fromXML(gridInfo, infile) <= 0) { - llwarns << "Unable to parse grid info file " << fileName << '.' << llendl; - return; - } - - llinfos << "Loading grid info file " << fileName << '.' << llendl; - parseData(gridInfo, mergeIfNewer); -} - - -void HippoGridManager::parseData(LLSD &gridInfo, bool mergeIfNewer) -{ - if (mergeIfNewer) { - LLSD::array_const_iterator it, end = gridInfo.endArray(); - for (it = gridInfo.beginArray(); it != end; ++it) { - LLSD gridMap = *it; - if (gridMap.has("default_grids_version")) { - int version = gridMap["default_grids_version"]; - if (version <= mDefaultGridsVersion) return; - else break; - } - } - if (it == end) { - llwarns << "Grid data has no version number." << llendl; - return; - } - } - - llinfos << "Loading grid data." << llendl; - - LLSD::array_const_iterator it, end = gridInfo.endArray(); - for (it = gridInfo.beginArray(); it != end; ++it) { - LLSD gridMap = *it; - if (gridMap.has("default_grids_version")) { - mDefaultGridsVersion = gridMap["default_grids_version"]; - } else if (gridMap.has("gridnick") && gridMap.has("loginuri")) { - std::string gridnick = gridMap["gridnick"]; - HippoGridInfo *grid; - GridIterator it = mGridInfo.find(gridnick); - bool newGrid = (it == mGridInfo.end()); - if (newGrid) { - // create new grid info - grid = new HippoGridInfo(gridnick); - } else { - // update existing grid info - grid = it->second; - } - grid->setLoginUri(gridMap["loginuri"]); - if (gridMap.has("platform")) grid->setPlatform(gridMap["platform"]); - if (gridMap.has("gridname")) grid->setGridName(gridMap["gridname"]); - if (gridMap.has("loginpage")) grid->setLoginPage(gridMap["loginpage"]); - if (gridMap.has("helperuri")) grid->setHelperUri(gridMap["helperuri"]); - if (gridMap.has("website")) grid->setWebSite(gridMap["website"]); - if (gridMap.has("support")) grid->setSupportUrl(gridMap["support"]); - if (gridMap.has("register")) grid->setRegisterUrl(gridMap["register"]); - if (gridMap.has("password")) grid->setPasswordUrl(gridMap["password"]); - //if (gridMap.has("search")) grid->setSearchUrl(gridMap["search"]); - if (gridMap.has("render_compat")) grid->setRenderCompat(gridMap["render_compat"]); - if (gridMap.has("firstname")) grid->setFirstName(gridMap["firstname"]); - if (gridMap.has("lastname")) grid->setLastName(gridMap["lastname"]); - if (gridMap.has("avatarpassword")) grid->setAvatarPassword(gridMap["avatarpassword"]); - if (newGrid) addGrid(grid); - } - } -} - - -void HippoGridManager::saveFile() -{ - // save default grid to client settings - gSavedSettings.setString("DefaultGrid", mDefaultGrid); - - // build LLSD - LLSD gridInfo; - gridInfo[0]["default_grids_version"] = mDefaultGridsVersion; - - // add grids - S32 i = 1; - GridIterator it, end = mGridInfo.end(); - for (it = mGridInfo.begin(); it != end; ++it, i++) { - HippoGridInfo *grid = it->second; - gridInfo[i]["gridnick"] = grid->getGridNick(); - gridInfo[i]["platform"] = HippoGridInfo::getPlatformString(grid->getPlatform()); - gridInfo[i]["gridname"] = grid->getGridName(); - gridInfo[i]["loginuri"] = grid->getLoginUri(); - gridInfo[i]["loginpage"] = grid->getLoginPage(); - gridInfo[i]["helperuri"] = grid->getHelperUri(); - gridInfo[i]["website"] = grid->getWebSite(); - gridInfo[i]["support"] = grid->getSupportUrl(); - gridInfo[i]["register"] = grid->getRegisterUrl(); - gridInfo[i]["firstname"] = grid->getFirstName(); - gridInfo[i]["lastname"] = grid->getLastName(); - gridInfo[i]["avatarpassword"] = grid->getAvatarPassword(); - - //gridInfo[i]["search"] = grid->getSearchUrl(); - gridInfo[i]["render_compat"] = grid->isRenderCompat(); - } - - // write client grid info file - std::string fileName = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "grid_info.xml"); - llofstream file; - file.open(fileName.c_str()); - if (file.is_open()) { - LLSDSerialize::toPrettyXML(gridInfo, file); - file.close(); - llinfos << "Saved grids to " << fileName << llendl; - } else { - llerrs << "Unable to open grid info file: " << fileName << llendl; - } -} + + +#include "hippoGridManager.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include "llviewercontrol.h" +#include "llweb.h" + +#include "hippoRestRequest.h" + + +// ******************************************************************** +// Global Variables + +HippoGridManager *gHippoGridManager = 0; + +HippoGridInfo HippoGridInfo::FALLBACK_GRIDINFO(""); + + + +// ******************************************************************** +// ******************************************************************** +// HippoGridInfo +// ******************************************************************** +// ******************************************************************** + + +// ******************************************************************** +// Initialize + +HippoGridInfo::HippoGridInfo(const std::string &gridNick) : + mPlatform(PLATFORM_OTHER), + mGridNick(gridNick), + mRenderCompat(true), + mCurrencySymbol("OS$"), + mRealCurrencySymbol("US$"), + mDirectoryFee(30) +{ + cleanUpGridNick(mGridNick); +} + + +void HippoGridInfo::setPlatform(Platform platform) +{ + mPlatform = platform; + mCurrencySymbol = (mPlatform == PLATFORM_SECONDLIFE)? "L$": "OS$"; +} + + +void HippoGridInfo::setPlatform(const std::string &platform) +{ + std::string tmp = platform; + for (unsigned i=0; imXmlState = XML_GRIDNICK; + else if (strcasecmp(name, "gridname") == 0) + self->mXmlState = XML_GRIDNAME; + else if (strcasecmp(name, "platform") == 0) + self->mXmlState = XML_PLATFORM; + else if ((strcasecmp(name, "login") == 0) || (strcasecmp(name, "loginuri") == 0)) + self->mXmlState = XML_LOGINURI; + else if ((strcasecmp(name, "welcome") == 0) || (strcasecmp(name, "loginpage") == 0)) + self->mXmlState = XML_LOGINPAGE; + else if ((strcasecmp(name, "economy") == 0) || (strcasecmp(name, "helperuri") == 0)) + self->mXmlState = XML_HELPERURI; + else if ((strcasecmp(name, "about") == 0) || (strcasecmp(name, "website") == 0)) + self->mXmlState = XML_WEBSITE; + else if ((strcasecmp(name, "help") == 0) || (strcasecmp(name, "support") == 0)) + self->mXmlState = XML_SUPPORT; + else if ((strcasecmp(name, "register") == 0) || (strcasecmp(name, "account") == 0)) + self->mXmlState = XML_REGISTER; + else if (strcasecmp(name, "password") == 0) + self->mXmlState = XML_PASSWORD; + //else if (strcasecmp(name, "search") == 0) + //self->mXmlState = XML_SEARCH; +} + +//static +void HippoGridInfo::onXmlElementEnd(void *userData, const XML_Char *name) +{ + HippoGridInfo *self = (HippoGridInfo*)userData; + self->mXmlState = XML_VOID; +} + +//static +void HippoGridInfo::onXmlCharacterData(void *userData, const XML_Char *s, int len) +{ + HippoGridInfo *self = (HippoGridInfo*)userData; + switch (self->mXmlState) { + + case XML_GRIDNICK: + if (self->mGridNick == "") self->mGridNick.assign(s, len); + cleanUpGridNick(self->mGridNick); + break; + + case XML_PLATFORM: { + std::string platform(s, len); + self->setPlatform(platform); + break; + } + + case XML_LOGINURI: + self->mLoginUri.assign(s, len); + cleanUpUri(self->mLoginUri); + break; + + case XML_HELPERURI: + self->mHelperUri.assign(s, len); + cleanUpUri(self->mHelperUri); + break; + + case XML_SEARCH: + //self->mSearchUrl.assign(s, len); + //cleanUpQueryUrl(mSearchUrl); + break; + + case XML_GRIDNAME: self->mGridName.assign(s, len); break; + case XML_LOGINPAGE: self->mLoginPage.assign(s, len); break; + case XML_WEBSITE: self->mWebSite.assign(s, len); break; + case XML_SUPPORT: self->mSupportUrl.assign(s, len); break; + case XML_REGISTER: self->mRegisterUrl.assign(s, len); break; + case XML_PASSWORD: self->mPasswordUrl.assign(s, len); break; + + case XML_VOID: break; + } +} + + +bool HippoGridInfo::retrieveGridInfo() +{ + if (mLoginUri == "") return false; + + std::string reply; + int result = HippoRestRequest::getBlocking(mLoginUri + "get_grid_info", &reply); + if (result != 200) return false; + + llinfos << "Received: " << reply << llendl; + + bool success = true; + XML_Parser parser = XML_ParserCreate(0); + XML_SetUserData(parser, this); + XML_SetElementHandler(parser, onXmlElementStart, onXmlElementEnd); + XML_SetCharacterDataHandler(parser, onXmlCharacterData); + mXmlState = XML_VOID; + if (!XML_Parse(parser, reply.data(), reply.size(), TRUE)) { + llwarns << "XML Parse Error: " << XML_ErrorString(XML_GetErrorCode(parser)) << llendl; + success = false; + } + XML_ParserFree(parser); + + return success; +} + + +std::string HippoGridInfo::getUploadFee() const +{ + std::string fee; + formatFee(fee, LLGlobalEconomy::Singleton::getInstance()->getPriceUpload(), true); + return fee; +} + +std::string HippoGridInfo::getGroupCreationFee() const +{ + std::string fee; + formatFee(fee, LLGlobalEconomy::Singleton::getInstance()->getPriceGroupCreate(), false); + return fee; +} + +std::string HippoGridInfo::getDirectoryFee() const +{ + std::string fee; + formatFee(fee, mDirectoryFee, true); + if (fee != "free") fee += "/week"; + return fee; +} + +void HippoGridInfo::formatFee(std::string &fee, int cost, bool showFree) const +{ + if (showFree && (cost == 0)) { + fee = "free"; + } else { + fee = llformat("%s%d", getCurrencySymbol().c_str(), cost); + } +} + + +// ******************************************************************** +// Static Helpers + +// static +const char *HippoGridInfo::getPlatformString(Platform platform) +{ + static const char *platformStrings[PLATFORM_LAST] = { + "Other", "OpenSim", "SecondLife" + }; + + if ((platform < PLATFORM_OTHER) || (platform >= PLATFORM_LAST)) + platform = PLATFORM_OTHER; + return platformStrings[platform]; +} + + +// static +void HippoGridInfo::cleanUpGridNick(std::string &gridnick) +{ + std::string tmp; + int size = gridnick.size(); + for (int i=0; i::iterator it, end = mGridInfo.end(); + for (it=mGridInfo.begin(); it != end; ++it) { + delete it->second; + } + mGridInfo.clear(); +} + + +void HippoGridManager::init() +{ + HippoGridInfo::initFallback(); + loadFromFile(); + + // !!!### gSavedSettings.getControl("CmdLineLoginURI"); + // !!!### gSavedSettings.getString("CmdLineLoginPage"); + // !!!### gSavedSettings.getString("CmdLineHelperURI"); + // !!!### LLString::compareInsensitive(gGridInfo[grid_index].mLabel, grid_name.c_str())) +} + + +void HippoGridManager::discardAndReload() +{ + cleanup(); + loadFromFile(); +} + + +// ******************************************************************** +// Public Access + +HippoGridInfo *HippoGridManager::getGrid(const std::string &grid) const +{ + std::map::const_iterator it; + it = mGridInfo.find(grid); + if (it != mGridInfo.end()) { + return it->second; + } else { + return 0; + } +} + + +HippoGridInfo *HippoGridManager::getCurrentGrid() const +{ + HippoGridInfo *grid = getGrid(mCurrentGrid); + if (grid) { + return grid; + } else { + return &HippoGridInfo::FALLBACK_GRIDINFO; + } +} + + +void HippoGridManager::addGrid(HippoGridInfo *grid) +{ + if (!grid) return; + const std::string &nick = grid->getGridNick(); + if (nick == "") { + llwarns << "Ignoring to try adding grid with empty nick." << llendl; + delete grid; + return; + } + if (mGridInfo.find(nick) != mGridInfo.end()) { + llwarns << "Ignoring to try adding existing grid " << nick << '.' << llendl; + delete grid; + return; + } + mGridInfo[nick] = grid; +} + + +void HippoGridManager::deleteGrid(const std::string &grid) +{ + GridIterator it = mGridInfo.find(grid); + if (it == mGridInfo.end()) { + llwarns << "Trying to delete non-existing grid " << grid << '.' << llendl; + return; + } + mGridInfo.erase(it); + llinfos << "Number of grids now: " << mGridInfo.size() << llendl; + if (mGridInfo.empty()) llinfos << "Grid info map is empty." << llendl; + if (grid == mDefaultGrid) + setDefaultGrid(""); // sets first grid, if map not empty + if (grid == mCurrentGrid) + mCurrentGrid = mDefaultGrid; +} + + +void HippoGridManager::setDefaultGrid(const std::string &grid) +{ + GridIterator it = mGridInfo.find(grid); + if (it != mGridInfo.end()) { + mDefaultGrid = grid; + } else if (mGridInfo.find("secondlife") != mGridInfo.end()) { + mDefaultGrid = "secondlife"; + } else if (!mGridInfo.empty()) { + mDefaultGrid = mGridInfo.begin()->first; + } else { + mDefaultGrid = ""; + } +} + + +void HippoGridManager::setCurrentGrid(const std::string &grid) +{ + GridIterator it = mGridInfo.find(grid); + if (it != mGridInfo.end()) { + mCurrentGrid = grid; + } else if (!mGridInfo.empty()) { + llwarns << "Unknown grid '" << grid << "'. Setting to default grid." << llendl; + mCurrentGrid = mDefaultGrid; + } +} + + +// ******************************************************************** +// Persistent Store + +void HippoGridManager::loadFromFile() +{ + mDefaultGridsVersion = 0; + // load user grid info + parseFile(gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "grid_info.xml"), false); + // merge default grid info, if newer. Force load, if list of grids is empty. + parseFile(gDirUtilp->getExpandedFilename(LL_PATH_APP_SETTINGS, "default_grids.xml"), !mGridInfo.empty()); + // merge grid info from web site, if newer. Force load, if list of grids is empty. + if (gSavedSettings.getBOOL("CheckForGridUpdates")) + parseUrl("http://opensim-viewer.sourceforge.net/db/grids.php", !mGridInfo.empty()); + + setDefaultGrid(gSavedSettings.getString("DefaultGrid")); + setCurrentGrid(gSavedSettings.getString("CmdLineGridChoice")); +} + + +void HippoGridManager::parseUrl(const char *url, bool mergeIfNewer) +{ + llinfos << "Loading grid info from '" << url << "'." << llendl; + + // query update server + std::string escaped_url = LLWeb::escapeURL(url); + LLSD response = LLHTTPClient::blockingGet(url); + + // check response, return on error + S32 status = response["status"].asInteger(); + if ((status != 200) || !response["body"].isArray()) { + llinfos << "GridInfo Update failed (" << status << "): " + << (response["body"].isString()? response["body"].asString(): "") + << llendl; + return; + } + + LLSD gridInfo = response["body"]; + parseData(gridInfo, mergeIfNewer); +} + +void HippoGridManager::parseFile(const std::string &fileName, bool mergeIfNewer) +{ + llifstream infile; + infile.open(fileName.c_str()); + if(!infile.is_open()) { + llwarns << "Cannot find grid info file " << fileName << " to load." << llendl; + return; + } + + LLSD gridInfo; + if (LLSDSerialize::fromXML(gridInfo, infile) <= 0) { + llwarns << "Unable to parse grid info file " << fileName << '.' << llendl; + return; + } + + llinfos << "Loading grid info file " << fileName << '.' << llendl; + parseData(gridInfo, mergeIfNewer); +} + + +void HippoGridManager::parseData(LLSD &gridInfo, bool mergeIfNewer) +{ + if (mergeIfNewer) { + LLSD::array_const_iterator it, end = gridInfo.endArray(); + for (it = gridInfo.beginArray(); it != end; ++it) { + LLSD gridMap = *it; + if (gridMap.has("default_grids_version")) { + int version = gridMap["default_grids_version"]; + if (version <= mDefaultGridsVersion) return; + else break; + } + } + if (it == end) { + llwarns << "Grid data has no version number." << llendl; + return; + } + } + + llinfos << "Loading grid data." << llendl; + + LLSD::array_const_iterator it, end = gridInfo.endArray(); + for (it = gridInfo.beginArray(); it != end; ++it) { + LLSD gridMap = *it; + if (gridMap.has("default_grids_version")) { + mDefaultGridsVersion = gridMap["default_grids_version"]; + } else if (gridMap.has("gridnick") && gridMap.has("loginuri")) { + std::string gridnick = gridMap["gridnick"]; + HippoGridInfo *grid; + GridIterator it = mGridInfo.find(gridnick); + bool newGrid = (it == mGridInfo.end()); + if (newGrid) { + // create new grid info + grid = new HippoGridInfo(gridnick); + } else { + // update existing grid info + grid = it->second; + } + grid->setLoginUri(gridMap["loginuri"]); + if (gridMap.has("platform")) grid->setPlatform(gridMap["platform"]); + if (gridMap.has("gridname")) grid->setGridName(gridMap["gridname"]); + if (gridMap.has("loginpage")) grid->setLoginPage(gridMap["loginpage"]); + if (gridMap.has("helperuri")) grid->setHelperUri(gridMap["helperuri"]); + if (gridMap.has("website")) grid->setWebSite(gridMap["website"]); + if (gridMap.has("support")) grid->setSupportUrl(gridMap["support"]); + if (gridMap.has("register")) grid->setRegisterUrl(gridMap["register"]); + if (gridMap.has("password")) grid->setPasswordUrl(gridMap["password"]); + //if (gridMap.has("search")) grid->setSearchUrl(gridMap["search"]); + if (gridMap.has("render_compat")) grid->setRenderCompat(gridMap["render_compat"]); + if (gridMap.has("firstname")) grid->setFirstName(gridMap["firstname"]); + if (gridMap.has("lastname")) grid->setLastName(gridMap["lastname"]); + if (gridMap.has("avatarpassword")) grid->setAvatarPassword(gridMap["avatarpassword"]); + if (newGrid) addGrid(grid); + } + } +} + + +void HippoGridManager::saveFile() +{ + // save default grid to client settings + gSavedSettings.setString("DefaultGrid", mDefaultGrid); + + // build LLSD + LLSD gridInfo; + gridInfo[0]["default_grids_version"] = mDefaultGridsVersion; + + // add grids + S32 i = 1; + GridIterator it, end = mGridInfo.end(); + for (it = mGridInfo.begin(); it != end; ++it, i++) { + HippoGridInfo *grid = it->second; + gridInfo[i]["gridnick"] = grid->getGridNick(); + gridInfo[i]["platform"] = HippoGridInfo::getPlatformString(grid->getPlatform()); + gridInfo[i]["gridname"] = grid->getGridName(); + gridInfo[i]["loginuri"] = grid->getLoginUri(); + gridInfo[i]["loginpage"] = grid->getLoginPage(); + gridInfo[i]["helperuri"] = grid->getHelperUri(); + gridInfo[i]["website"] = grid->getWebSite(); + gridInfo[i]["support"] = grid->getSupportUrl(); + gridInfo[i]["register"] = grid->getRegisterUrl(); + gridInfo[i]["firstname"] = grid->getFirstName(); + gridInfo[i]["lastname"] = grid->getLastName(); + gridInfo[i]["avatarpassword"] = grid->getAvatarPassword(); + + //gridInfo[i]["search"] = grid->getSearchUrl(); + gridInfo[i]["render_compat"] = grid->isRenderCompat(); + } + + // write client grid info file + std::string fileName = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "grid_info.xml"); + llofstream file; + file.open(fileName.c_str()); + if (file.is_open()) { + LLSDSerialize::toPrettyXML(gridInfo, file); + file.close(); + llinfos << "Saved grids to " << fileName << llendl; + } else { + llerrs << "Unable to open grid info file: " << fileName << llendl; + } +} 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 @@ -#ifndef __HIPPO_GRID_MANAGER_H__ -#define __HIPPO_GRID_MANAGER_H__ - - -#include -#include - -#ifndef XML_STATIC -#define XML_STATIC -#endif -#include - - -class LLSD; - - -class HippoGridInfo -{ -public: - enum Platform { - PLATFORM_OTHER = 0, - PLATFORM_OPENSIM, - PLATFORM_SECONDLIFE, - PLATFORM_LAST - }; - enum SearchType { - SEARCH_ALL_EMPTY, - SEARCH_ALL_QUERY, - SEARCH_ALL_TEMPLATE - }; - - explicit HippoGridInfo(const std::string &gridNick); - - Platform getPlatform() const { return mPlatform; } - const std::string &getGridNick() const { return mGridNick; } - const std::string &getGridName() const { return mGridName; } - const std::string &getLoginUri() const { return mLoginUri; } - const std::string &getLoginPage() const { return mLoginPage; } - const std::string &getHelperUri() const { return mHelperUri; } - const std::string &getWebSite() const { return mWebSite; } - const std::string &getSupportUrl() const { return mSupportUrl; } - const std::string &getRegisterUrl() const { return mRegisterUrl; } - const std::string &getPasswordUrl() const { return mPasswordUrl; } - const std::string &getSearchUrl() const { return mSearchUrl; } - const std::string &getFirstName() const { return mFirstName; } - const std::string &getLastName() const { return mLastName; } - const std::string &getAvatarPassword() const { return mAvatarPassword; } - std::string getSearchUrl(SearchType ty) const; - bool isRenderCompat() const { return mRenderCompat; } - - const std::string &getCurrencySymbol() const { return mCurrencySymbol; } - const std::string &getRealCurrencySymbol() const { return mRealCurrencySymbol; } - std::string getUploadFee() const; - std::string getGroupCreationFee() const; - std::string getDirectoryFee() const; - - bool isOpenSimulator() const { return (mPlatform == PLATFORM_OPENSIM ); } - bool isSecondLife() const { return (mPlatform == PLATFORM_SECONDLIFE); } - - void setPlatform (const std::string &platform); - void setPlatform (Platform platform); - void setGridName (const std::string &gridName) { mGridName = gridName; } - void setLoginUri (const std::string &loginUri) { mLoginUri = loginUri; cleanUpUri(mLoginUri); } - void setLoginPage(const std::string &loginPage) { mLoginPage = loginPage; } - void setHelperUri(const std::string &helperUri) { mHelperUri = helperUri; cleanUpUri(mHelperUri); } - void setWebSite (const std::string &website) { mWebSite = website; } - void setSupportUrl(const std::string &url) { mSupportUrl = url; } - void setRegisterUrl(const std::string &url) { mRegisterUrl = url; } - void setPasswordUrl(const std::string &url) { mPasswordUrl = url; } - void setSearchUrl(const std::string &url) { mSearchUrl = url; } - void setRenderCompat(bool compat) { mRenderCompat = compat; } - void setFirstName(const std::string &firstName) { mFirstName = firstName; } //aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - void setLastName(const std::string &lastName) { mLastName = lastName; } - void setAvatarPassword(const std::string &avatarPassword) { mAvatarPassword = avatarPassword; } - - void setCurrencySymbol(const std::string &sym) { mCurrencySymbol = sym.substr(0, 3); } - void setRealCurrencySymbol(const std::string &sym) { mRealCurrencySymbol = sym.substr(0, 3); } - void setDirectoryFee(int fee) { mDirectoryFee = fee; } - - bool retrieveGridInfo(); - - static const char *getPlatformString(Platform platform); - static void cleanUpGridNick(std::string &gridnick); - - static HippoGridInfo FALLBACK_GRIDINFO; - static void initFallback(); - -private: - Platform mPlatform; - std::string mGridNick; - std::string mGridName; - std::string mLoginUri; - std::string mLoginPage; - std::string mHelperUri; - std::string mWebSite; - std::string mSupportUrl; - std::string mRegisterUrl; - std::string mPasswordUrl; - std::string mSearchUrl; - std::string mFirstName; - std::string mLastName; - std::string mAvatarPassword; - bool mRenderCompat; - - std::string mCurrencySymbol; - std::string mRealCurrencySymbol; - int mDirectoryFee; - - // for parsing grid info XML - enum XmlState { - XML_VOID, XML_GRIDNICK, XML_PLATFORM, XML_GRIDNAME, - XML_LOGINURI, XML_LOGINPAGE, XML_HELPERURI, - XML_WEBSITE, XML_SUPPORT, XML_REGISTER, XML_PASSWORD, XML_SEARCH - }; - XmlState mXmlState; - - static void cleanUpUri(std::string &uri); - void formatFee(std::string &fee, int cost, bool showFree) const; - - static void onXmlElementStart(void *userData, const XML_Char *name, const XML_Char **atts); - static void onXmlElementEnd(void *userData, const XML_Char *name); - static void onXmlCharacterData(void *userData, const XML_Char *s, int len); -}; - - -class HippoGridManager -{ -public: - HippoGridManager(); - ~HippoGridManager(); - - void init(); - void saveFile(); - void discardAndReload(); - - HippoGridInfo *getGrid(const std::string &grid) const; - HippoGridInfo *getConnectedGrid() const { return (mConnectedGrid)? mConnectedGrid: getCurrentGrid(); } - HippoGridInfo *getCurrentGrid() const; - const std::string &getDefaultGridNick() const { return mDefaultGrid; } - const std::string &getCurrentGridNick() const { return mCurrentGrid; } - - void setDefaultGrid(const std::string &grid); - void setCurrentGrid(const std::string &grid); - void setCurrentGridAsConnected() { mConnectedGrid = getCurrentGrid(); } - - void addGrid(HippoGridInfo *grid); - void deleteGrid(const std::string &grid); - - typedef std::map::iterator GridIterator; - GridIterator beginGrid() { return mGridInfo.begin(); } - GridIterator endGrid() { return mGridInfo.end(); } - -private: - std::map mGridInfo; - std::string mDefaultGrid; - std::string mCurrentGrid; - HippoGridInfo *mConnectedGrid; - int mDefaultGridsVersion; - - void cleanup(); - void loadFromFile(); - void parseFile(const std::string &fileName, bool mergeIfNewer); - void parseUrl(const char *url, bool mergeIfNewer); - void parseData(LLSD &gridInfo, bool mergeIfNewer); -}; - - -extern HippoGridManager *gHippoGridManager; - - -#endif +#ifndef __HIPPO_GRID_MANAGER_H__ +#define __HIPPO_GRID_MANAGER_H__ + + +#include +#include + +#ifndef XML_STATIC +#define XML_STATIC +#endif +#include + + +class LLSD; + + +class HippoGridInfo +{ +public: + enum Platform { + PLATFORM_OTHER = 0, + PLATFORM_OPENSIM, + PLATFORM_SECONDLIFE, + PLATFORM_LAST + }; + enum SearchType { + SEARCH_ALL_EMPTY, + SEARCH_ALL_QUERY, + SEARCH_ALL_TEMPLATE + }; + + explicit HippoGridInfo(const std::string &gridNick); + + Platform getPlatform() const { return mPlatform; } + const std::string &getGridNick() const { return mGridNick; } + const std::string &getGridName() const { return mGridName; } + const std::string &getLoginUri() const { return mLoginUri; } + const std::string &getLoginPage() const { return mLoginPage; } + const std::string &getHelperUri() const { return mHelperUri; } + const std::string &getWebSite() const { return mWebSite; } + const std::string &getSupportUrl() const { return mSupportUrl; } + const std::string &getRegisterUrl() const { return mRegisterUrl; } + const std::string &getPasswordUrl() const { return mPasswordUrl; } + const std::string &getSearchUrl() const { return mSearchUrl; } + const std::string &getFirstName() const { return mFirstName; } + const std::string &getLastName() const { return mLastName; } + const std::string &getAvatarPassword() const { return mAvatarPassword; } + std::string getSearchUrl(SearchType ty) const; + bool isRenderCompat() const { return mRenderCompat; } + + const std::string &getCurrencySymbol() const { return mCurrencySymbol; } + const std::string &getRealCurrencySymbol() const { return mRealCurrencySymbol; } + std::string getUploadFee() const; + std::string getGroupCreationFee() const; + std::string getDirectoryFee() const; + + bool isOpenSimulator() const { return (mPlatform == PLATFORM_OPENSIM ); } + bool isSecondLife() const { return (mPlatform == PLATFORM_SECONDLIFE); } + + void setPlatform (const std::string &platform); + void setPlatform (Platform platform); + void setGridName (const std::string &gridName) { mGridName = gridName; } + void setLoginUri (const std::string &loginUri) { mLoginUri = loginUri; cleanUpUri(mLoginUri); } + void setLoginPage(const std::string &loginPage) { mLoginPage = loginPage; } + void setHelperUri(const std::string &helperUri) { mHelperUri = helperUri; cleanUpUri(mHelperUri); } + void setWebSite (const std::string &website) { mWebSite = website; } + void setSupportUrl(const std::string &url) { mSupportUrl = url; } + void setRegisterUrl(const std::string &url) { mRegisterUrl = url; } + void setPasswordUrl(const std::string &url) { mPasswordUrl = url; } + void setSearchUrl(const std::string &url) { mSearchUrl = url; } + void setRenderCompat(bool compat) { mRenderCompat = compat; } + void setFirstName(const std::string &firstName) { mFirstName = firstName; } //aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + void setLastName(const std::string &lastName) { mLastName = lastName; } + void setAvatarPassword(const std::string &avatarPassword) { mAvatarPassword = avatarPassword; } + + void setCurrencySymbol(const std::string &sym) { mCurrencySymbol = sym.substr(0, 3); } + void setRealCurrencySymbol(const std::string &sym) { mRealCurrencySymbol = sym.substr(0, 3); } + void setDirectoryFee(int fee) { mDirectoryFee = fee; } + + bool retrieveGridInfo(); + + static const char *getPlatformString(Platform platform); + static void cleanUpGridNick(std::string &gridnick); + + static HippoGridInfo FALLBACK_GRIDINFO; + static void initFallback(); + +private: + Platform mPlatform; + std::string mGridNick; + std::string mGridName; + std::string mLoginUri; + std::string mLoginPage; + std::string mHelperUri; + std::string mWebSite; + std::string mSupportUrl; + std::string mRegisterUrl; + std::string mPasswordUrl; + std::string mSearchUrl; + std::string mFirstName; + std::string mLastName; + std::string mAvatarPassword; + bool mRenderCompat; + + std::string mCurrencySymbol; + std::string mRealCurrencySymbol; + int mDirectoryFee; + + // for parsing grid info XML + enum XmlState { + XML_VOID, XML_GRIDNICK, XML_PLATFORM, XML_GRIDNAME, + XML_LOGINURI, XML_LOGINPAGE, XML_HELPERURI, + XML_WEBSITE, XML_SUPPORT, XML_REGISTER, XML_PASSWORD, XML_SEARCH + }; + XmlState mXmlState; + + static void cleanUpUri(std::string &uri); + void formatFee(std::string &fee, int cost, bool showFree) const; + + static void onXmlElementStart(void *userData, const XML_Char *name, const XML_Char **atts); + static void onXmlElementEnd(void *userData, const XML_Char *name); + static void onXmlCharacterData(void *userData, const XML_Char *s, int len); +}; + + +class HippoGridManager +{ +public: + HippoGridManager(); + ~HippoGridManager(); + + void init(); + void saveFile(); + void discardAndReload(); + + HippoGridInfo *getGrid(const std::string &grid) const; + HippoGridInfo *getConnectedGrid() const { return (mConnectedGrid)? mConnectedGrid: getCurrentGrid(); } + HippoGridInfo *getCurrentGrid() const; + const std::string &getDefaultGridNick() const { return mDefaultGrid; } + const std::string &getCurrentGridNick() const { return mCurrentGrid; } + + void setDefaultGrid(const std::string &grid); + void setCurrentGrid(const std::string &grid); + void setCurrentGridAsConnected() { mConnectedGrid = getCurrentGrid(); } + + void addGrid(HippoGridInfo *grid); + void deleteGrid(const std::string &grid); + + typedef std::map::iterator GridIterator; + GridIterator beginGrid() { return mGridInfo.begin(); } + GridIterator endGrid() { return mGridInfo.end(); } + +private: + std::map mGridInfo; + std::string mDefaultGrid; + std::string mCurrentGrid; + HippoGridInfo *mConnectedGrid; + int mDefaultGridsVersion; + + void cleanup(); + void loadFromFile(); + void parseFile(const std::string &fileName, bool mergeIfNewer); + void parseUrl(const char *url, bool mergeIfNewer); + void parseData(LLSD &gridInfo, bool mergeIfNewer); +}; + + +extern HippoGridManager *gHippoGridManager; + + +#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 @@ - - -#include "hippoLimits.h" - -#include "hippoGridManager.h" - -#include - - -HippoLimits *gHippoLimits = 0; - - -HippoLimits::HippoLimits() -{ - setLimits(); -} - - -void HippoLimits::setLimits() -{ - if (gHippoGridManager->getConnectedGrid()->getPlatform() == HippoGridInfo::PLATFORM_SECONDLIFE) { - setSecondLifeLimits(); - } else { - setOpenSimLimits(); - } -} - - -void HippoLimits::setOpenSimLimits() -{ - mMaxAgentGroups = 100; - mMaxPrimScale = 256.0f; - mMaxHeight = 10000.0f; - if (gHippoGridManager->getConnectedGrid()->isRenderCompat()) { - llinfos << "Using rendering compatible OpenSim limits." << llendl; - mMinHoleSize = 0.05f; - mMaxHollow = 0.95f; - } else { - llinfos << "Using Hippo OpenSim limits." << llendl; - mMinHoleSize = 0.01f; - mMaxHollow = 0.99f; - } -} - -void HippoLimits::setSecondLifeLimits() -{ - llinfos << "Using Second Life limits." << llendl; - mMaxAgentGroups = 25; - mMaxPrimScale = 10.0f; - mMaxHeight = 4096.0f; - mMinHoleSize = 0.05f; - mMaxHollow = 0.95f; -} - + + +#include "hippoLimits.h" + +#include "hippoGridManager.h" + +#include + + +HippoLimits *gHippoLimits = 0; + + +HippoLimits::HippoLimits() +{ + setLimits(); +} + + +void HippoLimits::setLimits() +{ + if (gHippoGridManager->getConnectedGrid()->getPlatform() == HippoGridInfo::PLATFORM_SECONDLIFE) { + setSecondLifeLimits(); + } else { + setOpenSimLimits(); + } +} + + +void HippoLimits::setOpenSimLimits() +{ + mMaxAgentGroups = 100; + mMaxPrimScale = 256.0f; + mMaxHeight = 10000.0f; + if (gHippoGridManager->getConnectedGrid()->isRenderCompat()) { + llinfos << "Using rendering compatible OpenSim limits." << llendl; + mMinHoleSize = 0.05f; + mMaxHollow = 0.95f; + } else { + llinfos << "Using Hippo OpenSim limits." << llendl; + mMinHoleSize = 0.01f; + mMaxHollow = 0.99f; + } +} + +void HippoLimits::setSecondLifeLimits() +{ + llinfos << "Using Second Life limits." << llendl; + mMaxAgentGroups = 25; + mMaxPrimScale = 10.0f; + mMaxHeight = 4096.0f; + mMinHoleSize = 0.05f; + mMaxHollow = 0.95f; +} + 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 @@ -#ifndef __HIPPO_LIMITS_H__ -#define __HIPPO_LIMITS_H__ - - -class HippoLimits -{ -public: - HippoLimits(); - - int getMaxAgentGroups() const { return mMaxAgentGroups; } - float getMaxHeight() const { return mMaxHeight; } - float getMinHoleSize() const { return mMinHoleSize; } - float getMaxHollow() const { return mMaxHollow; } - float getMaxPrimScale() const { return mMaxPrimScale; } - - void setLimits(); - -private: - int mMaxAgentGroups; - float mMaxHeight; - float mMinHoleSize; - float mMaxHollow; - float mMaxPrimScale; - - void setOpenSimLimits(); - void setSecondLifeLimits(); -}; - - -extern HippoLimits *gHippoLimits; - - -#endif +#ifndef __HIPPO_LIMITS_H__ +#define __HIPPO_LIMITS_H__ + + +class HippoLimits +{ +public: + HippoLimits(); + + int getMaxAgentGroups() const { return mMaxAgentGroups; } + float getMaxHeight() const { return mMaxHeight; } + float getMinHoleSize() const { return mMinHoleSize; } + float getMaxHollow() const { return mMaxHollow; } + float getMaxPrimScale() const { return mMaxPrimScale; } + + void setLimits(); + +private: + int mMaxAgentGroups; + float mMaxHeight; + float mMinHoleSize; + float mMaxHollow; + float mMaxPrimScale; + + void setOpenSimLimits(); + void setSecondLifeLimits(); +}; + + +extern HippoLimits *gHippoLimits; + + +#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 @@ - - -#include "hippoRestRequest.h" - -#ifndef CURL_STATICLIB -#define CURL_STATICLIB 1 -#endif -#include - -#include -#include - - -static size_t curlWrite(void *ptr, size_t size, size_t nmemb, void *userData) -{ - std::string *result = (std::string*)userData; - size_t bytes = (size * nmemb); - result->append((char*)ptr, bytes); - return nmemb; -} - - -//static -int HippoRestRequest::getBlocking(const std::string &url, std::string *result) -{ - llinfos << "Requesting: " << url << llendl; - - char curlErrorBuffer[CURL_ERROR_SIZE]; - CURL* curlp = curl_easy_init(); - - curl_easy_setopt(curlp, CURLOPT_NOSIGNAL, 1); // don't use SIGALRM for timeouts - curl_easy_setopt(curlp, CURLOPT_TIMEOUT, 5); // seconds - - curl_easy_setopt(curlp, CURLOPT_WRITEFUNCTION, curlWrite); - curl_easy_setopt(curlp, CURLOPT_WRITEDATA, result); - curl_easy_setopt(curlp, CURLOPT_URL, url.c_str()); - curl_easy_setopt(curlp, CURLOPT_ERRORBUFFER, curlErrorBuffer); - curl_easy_setopt(curlp, CURLOPT_FAILONERROR, 1); - - *result = ""; - S32 curlSuccess = curl_easy_perform(curlp); - S32 httpStatus = 499; - curl_easy_getinfo(curlp, CURLINFO_RESPONSE_CODE, &httpStatus); - - if (curlSuccess != 0) { - llwarns << "CURL ERROR (HTTP Status " << httpStatus << "): " << curlErrorBuffer << llendl; - } else if (httpStatus != 200) { - llwarns << "HTTP Error " << httpStatus << ", but no Curl error." << llendl; - } - - curl_easy_cleanup(curlp); - return httpStatus; -} - + + +#include "hippoRestRequest.h" + +#ifndef CURL_STATICLIB +#define CURL_STATICLIB 1 +#endif +#include + +#include +#include + + +static size_t curlWrite(void *ptr, size_t size, size_t nmemb, void *userData) +{ + std::string *result = (std::string*)userData; + size_t bytes = (size * nmemb); + result->append((char*)ptr, bytes); + return nmemb; +} + + +//static +int HippoRestRequest::getBlocking(const std::string &url, std::string *result) +{ + llinfos << "Requesting: " << url << llendl; + + char curlErrorBuffer[CURL_ERROR_SIZE]; + CURL* curlp = curl_easy_init(); + + curl_easy_setopt(curlp, CURLOPT_NOSIGNAL, 1); // don't use SIGALRM for timeouts + curl_easy_setopt(curlp, CURLOPT_TIMEOUT, 5); // seconds + + curl_easy_setopt(curlp, CURLOPT_WRITEFUNCTION, curlWrite); + curl_easy_setopt(curlp, CURLOPT_WRITEDATA, result); + curl_easy_setopt(curlp, CURLOPT_URL, url.c_str()); + curl_easy_setopt(curlp, CURLOPT_ERRORBUFFER, curlErrorBuffer); + curl_easy_setopt(curlp, CURLOPT_FAILONERROR, 1); + + *result = ""; + S32 curlSuccess = curl_easy_perform(curlp); + S32 httpStatus = 499; + curl_easy_getinfo(curlp, CURLINFO_RESPONSE_CODE, &httpStatus); + + if (curlSuccess != 0) { + llwarns << "CURL ERROR (HTTP Status " << httpStatus << "): " << curlErrorBuffer << llendl; + } else if (httpStatus != 200) { + llwarns << "HTTP Error " << httpStatus << ", but no Curl error." << llendl; + } + + curl_easy_cleanup(curlp); + return httpStatus; +} + 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 @@ -#ifndef __HIPPO_REST_REQTUEST_H__ -#define __HIPPO_REST_REQTUEST_H__ - - -#include - - -class HippoRestRequest -{ - public: - static int getBlocking(const std::string &url, std::string *result); - -}; - - -#endif +#ifndef __HIPPO_REST_REQTUEST_H__ +#define __HIPPO_REST_REQTUEST_H__ + + +#include + + +class HippoRestRequest +{ + public: + static int getBlocking(const std::string &url, std::string *result); + +}; + + +#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 @@ - -#include "hippoUpdate.h" - -#include -#include -#include - -#include -#include -#include -#include -#include "llviewercontrol.h" -#include "llviewernetwork.h" -#include "llweb.h" -#include - - -std::string gHippoChannel; - - -// static -bool HippoUpdate::checkUpdate() -{ - llinfos << "Hippo Update Check..." << llendl; - - // get channel name - gHippoChannel = gSavedSettings.getString("ChannelName"); - - // get mac address - char macAddress[18]; - sprintf(macAddress, "%02x:%02x:%02x:%02x:%02x:%02x", - gMACAddress[0], gMACAddress[1], gMACAddress[2], gMACAddress[3], gMACAddress[4], gMACAddress[5]); - - // build URL for update check - char url[1000]; - snprintf(url, 1000, -/* "http://update.mjm.game-host.org/os/viewer.php?" - "product=%s&channel=%s&" - "version_major=%d&version_minor=%d&version_patch=%d&version_base=%s&" - "platform=%s&mac=%s", - LL_PRODUCT, LL_CHANNEL_CSTR, - LL_VERSION_MAJOR, LL_VERSION_MINOR, LL_VERSION_PATCH, LL_VERSION_BASE, - LL_PLATFORM*/"", macAddress); - - // query update server - std::string escaped_url = LLWeb::escapeURL(url); - LLSD response = LLHTTPClient::blockingGet(escaped_url.c_str()); - - // check response, return on error - S32 status = response["status"].asInteger(); - if ((status != 200) || !response["body"].isMap()) { - llinfos << "Hippo Update failed (" << status << "): " - << (response["body"].isString()? response["body"].asString(): "") - << llendl; - return true; - } - - // get data from response - LLSD data = response["body"]; - std::string webpage = (data.has("webpage") && data["webpage"].isString())? data["webpage"].asString(): ""; - std::string message = (data.has("message") && data["message"].isString())? data["message"].asString(): ""; - std::string yourVersion = (data.has("yourVersion") && data["yourVersion"].isString())? data["yourVersion"].asString(): ""; - std::string curVersion = (data.has("curVersion") && data["curVersion"].isString())? data["curVersion"].asString(): ""; - bool update = (data.has("update") && data["update"].isBoolean())? data["update"].asBoolean(): false; - bool mandatory = (data.has("mandatory") && data["mandatory"].isBoolean())? data["mandatory"].asBoolean(): false; - - // log and return, if no update available - llinfos << "Your version is " << yourVersion << ", current version is " << curVersion << '.' << llendl; - if (!update) return true; - llinfos << "Update is " << (mandatory? "mandatory.": "optional.") << llendl; - - // show update dialog - char msg[1000]; - snprintf(msg, 1000, - "There is a new viewer version available.\n" - "\n" - "Your version: %s\n" - "Current version: %s\n" - "%s\n" - "Do you want to visit the web site?", - yourVersion.c_str(), curVersion.c_str(), - mandatory? "\nThis is a mandatory update.\n": ""); - S32 button = OSMessageBox(msg, "Hippo OpenSim Viewer Update", OSMB_YESNO); - if (button == OSBTN_YES) { - llinfos << "Taking user to " << webpage << llendl; - LLWeb::loadURLExternal(webpage); - // exit the viewer - return false; - } - - return !mandatory; -} + +#include "hippoUpdate.h" + +#include +#include +#include + +#include +#include +#include +#include +#include "llviewercontrol.h" +#include "llviewernetwork.h" +#include "llweb.h" +#include + + +std::string gHippoChannel; + + +// static +bool HippoUpdate::checkUpdate() +{ + llinfos << "Hippo Update Check..." << llendl; + + // get channel name + gHippoChannel = gSavedSettings.getString("ChannelName"); + + // get mac address + char macAddress[18]; + sprintf(macAddress, "%02x:%02x:%02x:%02x:%02x:%02x", + gMACAddress[0], gMACAddress[1], gMACAddress[2], gMACAddress[3], gMACAddress[4], gMACAddress[5]); + + // build URL for update check + char url[1000]; + snprintf(url, 1000, +/* "http://update.mjm.game-host.org/os/viewer.php?" + "product=%s&channel=%s&" + "version_major=%d&version_minor=%d&version_patch=%d&version_base=%s&" + "platform=%s&mac=%s", + LL_PRODUCT, LL_CHANNEL_CSTR, + LL_VERSION_MAJOR, LL_VERSION_MINOR, LL_VERSION_PATCH, LL_VERSION_BASE, + LL_PLATFORM*/"", macAddress); + + // query update server + std::string escaped_url = LLWeb::escapeURL(url); + LLSD response = LLHTTPClient::blockingGet(escaped_url.c_str()); + + // check response, return on error + S32 status = response["status"].asInteger(); + if ((status != 200) || !response["body"].isMap()) { + llinfos << "Hippo Update failed (" << status << "): " + << (response["body"].isString()? response["body"].asString(): "") + << llendl; + return true; + } + + // get data from response + LLSD data = response["body"]; + std::string webpage = (data.has("webpage") && data["webpage"].isString())? data["webpage"].asString(): ""; + std::string message = (data.has("message") && data["message"].isString())? data["message"].asString(): ""; + std::string yourVersion = (data.has("yourVersion") && data["yourVersion"].isString())? data["yourVersion"].asString(): ""; + std::string curVersion = (data.has("curVersion") && data["curVersion"].isString())? data["curVersion"].asString(): ""; + bool update = (data.has("update") && data["update"].isBoolean())? data["update"].asBoolean(): false; + bool mandatory = (data.has("mandatory") && data["mandatory"].isBoolean())? data["mandatory"].asBoolean(): false; + + // log and return, if no update available + llinfos << "Your version is " << yourVersion << ", current version is " << curVersion << '.' << llendl; + if (!update) return true; + llinfos << "Update is " << (mandatory? "mandatory.": "optional.") << llendl; + + // show update dialog + char msg[1000]; + snprintf(msg, 1000, + "There is a new viewer version available.\n" + "\n" + "Your version: %s\n" + "Current version: %s\n" + "%s\n" + "Do you want to visit the web site?", + yourVersion.c_str(), curVersion.c_str(), + mandatory? "\nThis is a mandatory update.\n": ""); + S32 button = OSMessageBox(msg, "Hippo OpenSim Viewer Update", OSMB_YESNO); + if (button == OSBTN_YES) { + llinfos << "Taking user to " << webpage << llendl; + LLWeb::loadURLExternal(webpage); + // exit the viewer + return false; + } + + return !mandatory; +} 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 @@ -#ifndef __HIPPO_UPDATE_H__ -#define __HIPPO_UPDATE_H__ - - -class HippoUpdate -{ - public: - static bool checkUpdate(); -}; - - -#endif +#ifndef __HIPPO_UPDATE_H__ +#define __HIPPO_UPDATE_H__ + + +class HippoUpdate +{ + public: + static bool checkUpdate(); +}; + + +#endif -- cgit v1.1