Get rid of grid nicks, and just use the Grid Name everywhere (its cleaner, and one less thing to fill out).

This commit is contained in:
RevolutionSmythe
2011-08-14 20:57:50 -05:00
committed by Siana Gearz
parent 8fc875cee8
commit b8cd305f89
9 changed files with 41 additions and 111 deletions

View File

@@ -39,10 +39,9 @@ HippoGridInfo HippoGridInfo::FALLBACK_GRIDINFO("");
// ********************************************************************
// Initialize
HippoGridInfo::HippoGridInfo(const std::string& gridNick) :
mPlatform(PLATFORM_OPENSIM),
mGridNick(gridNick),
mGridName(LLStringUtil::null),
HippoGridInfo::HippoGridInfo(const std::string& gridName) :
mPlatform(PLATFORM_AURORA),
mGridName(gridName),
mLoginUri(LLStringUtil::null),
mLoginPage(LLStringUtil::null),
mHelperUri(LLStringUtil::null),
@@ -64,8 +63,6 @@ HippoGridInfo::HippoGridInfo(const std::string& gridNick) :
mRealCurrencySymbol("US$"),
mDirectoryFee(30)
{
std::string nick = gridNick;
mGridNick = sanitizeGridNick( nick );
}
@@ -87,11 +84,6 @@ bool HippoGridInfo::isSecondLife() const
return (mPlatform == HippoGridInfo::PLATFORM_SECONDLIFE);
}
const std::string& HippoGridInfo::getGridNick() const
{
return mGridNick;
}
const std::string& HippoGridInfo::getGridName() const
{
return mGridName;
@@ -270,7 +262,7 @@ void HippoGridInfo::setSearchUrl(const std::string& url)
void HippoGridInfo::setGridMessage(const std::string& message)
{
mGridMessage = url;
mGridMessage = message;
}
void HippoGridInfo::setFirstName(const std::string& firstName)
@@ -410,9 +402,7 @@ std::string HippoGridInfo::getSearchUrl(SearchType ty, bool is_web) const
void HippoGridInfo::onXmlElementStart(void* userData, const XML_Char* name, const XML_Char** atts)
{
HippoGridInfo* self = (HippoGridInfo*)userData;
if (strcasecmp(name, "gridnick") == 0)
self->mXmlState = XML_GRIDNICK;
else if (strcasecmp(name, "gridname") == 0)
if (strcasecmp(name, "gridname") == 0)
self->mXmlState = XML_GRIDNAME;
else if (strcasecmp(name, "platform") == 0)
self->mXmlState = XML_PLATFORM;
@@ -449,13 +439,6 @@ void HippoGridInfo::onXmlCharacterData(void* userData, const XML_Char* s, int le
HippoGridInfo* self = (HippoGridInfo*)userData;
switch (self->mXmlState)
{
case XML_GRIDNICK:
{
if (self->mGridNick == "") self->mGridNick.assign(s, len);
self->mGridNick = sanitizeGridNick(self->mGridNick);
break;
}
case XML_PLATFORM:
{
std::string platform(s, len);
@@ -581,27 +564,6 @@ const char* HippoGridInfo::getPlatformString(Platform platform)
return platformStrings[platform];
}
// static
std::string HippoGridInfo::sanitizeGridNick(std::string &gridnick)
{
std::string tmp;
int size = gridnick.size();
for (int i=0; i<size; i++)
{
char c = gridnick[i];
if ((c == '_') || isalnum(c))
{
tmp += tolower(c);
}
else if (isspace(c))
{
tmp += "_";
}
}
return tmp;
}
// static
std::string HippoGridInfo::sanitizeUri(std::string &uri)
{
@@ -621,7 +583,6 @@ std::string HippoGridInfo::sanitizeUri(std::string &uri)
void HippoGridInfo::initFallback()
{
FALLBACK_GRIDINFO.mGridNick = "localhost";
FALLBACK_GRIDINFO.setPlatform(PLATFORM_OPENSIM);
FALLBACK_GRIDINFO.setGridName("Local Host");
FALLBACK_GRIDINFO.setLoginUri("http://127.0.0.1:9000/");
@@ -656,8 +617,8 @@ void HippoGridInfo::setSupportsInvLinks(bool b) {
HippoGridManager::HippoGridManager() :
mConnectedGrid(0),
mDefaultGridsVersion(0),
mCurrentGrid("osgrid"),
mDefaultGrid("osgrid")
mCurrentGrid("Local Host"),
mDefaultGrid("Local Host")
{
}
@@ -757,7 +718,7 @@ void HippoGridManager::setCurrentGridAsConnected()
void HippoGridManager::addGrid(HippoGridInfo* grid)
{
if (!grid) return;
const std::string& nick = grid->getGridNick();
const std::string& nick = grid->getGridName();
if (nick == "")
{
llwarns << "Ignoring to try adding grid with empty nick." << llendl;
@@ -925,16 +886,16 @@ void HippoGridManager::parseData(LLSD &gridInfo, bool mergeIfNewer)
{
mDefaultGridsVersion = gridMap["default_grids_version"];
}
else if (gridMap.has("gridnick") && gridMap.has("loginuri"))
else if (gridMap.has("gridname") && gridMap.has("loginuri"))
{
std::string gridnick = gridMap["gridnick"];
std::string gridname = gridMap["gridname"];
HippoGridInfo* grid;
GridIterator it = mGridInfo.find(gridnick);
GridIterator it = mGridInfo.find(gridname);
bool newGrid = (it == mGridInfo.end());
if (newGrid)
{
// create new grid info
grid = new HippoGridInfo(gridnick);
grid = new HippoGridInfo(gridname);
}
else
{
@@ -977,7 +938,6 @@ void HippoGridManager::saveFile()
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();

View File

@@ -34,12 +34,11 @@ public:
SEARCH_ALL_TEMPLATE
};
explicit HippoGridInfo(const std::string& gridNick);
explicit HippoGridInfo(const std::string& gridName);
Platform getPlatform();
bool isOpenSimulator() const;
bool isSecondLife() const;
const std::string& getGridNick() const;
const std::string& getGridName() const;
const std::string& getGridOwner() const;
const std::string& getLoginUri() const;
@@ -95,14 +94,12 @@ public:
bool retrieveGridInfo();
static const char* getPlatformString(Platform platform);
static std::string sanitizeGridNick(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;
@@ -128,7 +125,7 @@ private:
// for parsing grid info XML
enum XmlState
{
XML_VOID, XML_GRIDNICK, XML_PLATFORM, XML_GRIDNAME,
XML_VOID, XML_PLATFORM, XML_GRIDNAME,
XML_LOGINURI, XML_LOGINPAGE, XML_HELPERURI,
XML_WEBSITE, XML_SUPPORT, XML_REGISTER, XML_PASSWORD, XML_SEARCH, XML_MESSAGE
};

View File

@@ -119,7 +119,6 @@ HippoPanelGridsImpl::~HippoPanelGridsImpl()
BOOL HippoPanelGridsImpl::postBuild()
{
requires<LLComboBox>("grid_selector");
requires<LLLineEditor>("gridnick");
requires<LLComboBox>("platform");
requires<LLLineEditor>("gridname");
requires<LLLineEditor>("loginuri");
@@ -176,7 +175,7 @@ void HippoPanelGridsImpl::refresh()
}
HippoGridManager::GridIterator it, end = gHippoGridManager->endGrid();
for (it = gHippoGridManager->beginGrid(); it != end; ++it) {
const std::string &grid = it->second->getGridNick();
const std::string &grid = it->second->getGridName();
if (grid != defaultGrid) {
grids->add(grid);
if (grid == mCurGrid) selectIndex = i;
@@ -198,13 +197,13 @@ void HippoPanelGridsImpl::refresh()
childSetEnabled("btn_delete", (selectIndex >= 0));
childSetEnabled("btn_copy", (mState == NORMAL) && (selectIndex >= 0));
childSetEnabled("btn_default", (mState == NORMAL) && (selectIndex > 0));
childSetEnabled("gridnick", (mState == ADD_NEW) || (mState == ADD_COPY));
childSetEnabled("gridname", (mState == ADD_NEW) || (mState == ADD_COPY));
if (childGetValue("platform").asString() == "SecondLife") {
// disable platform selector, if logged into the grid edited and it is SL
// so object export restrictions cannot be circumvented by changing the platform
bool enablePlatform = (LLStartUp::getStartupState() < STATE_LOGIN_CLEANUP) ||
(mCurGrid != gHippoGridManager->getConnectedGrid()->getGridNick());
(mCurGrid != gHippoGridManager->getConnectedGrid()->getGridName());
childSetEnabled("platform", enablePlatform);
childSetEnabled("search", false);
childSetText("search", LLStringExplicit(""));
@@ -232,7 +231,7 @@ void HippoPanelGridsImpl::apply()
gHippoGridManager->saveFile();
refresh();
// update render compatibility
if (mCurGrid == gHippoGridManager->getConnectedGrid()->getGridNick())
if (mCurGrid == gHippoGridManager->getConnectedGrid()->getGridName())
gHippoLimits->setLimits();
}
@@ -250,7 +249,6 @@ void HippoPanelGridsImpl::loadCurGrid()
{
HippoGridInfo *gridInfo = gHippoGridManager->getGrid(mCurGrid);
if (gridInfo && (mState != ADD_NEW)) {
childSetText("gridnick", gridInfo->getGridNick());
LLComboBox *platform = getChild<LLComboBox>("platform");
if (platform) platform->setCurrentByIndex(gridInfo->getPlatform());
childSetText("gridname", gridInfo->getGridName());
@@ -264,7 +262,6 @@ void HippoPanelGridsImpl::loadCurGrid()
childSetValue("render_compat", gridInfo->isRenderCompat());
} else {
std::string empty = "";
childSetText("gridnick", empty);
LLComboBox *platform = getChild<LLComboBox>("platform");
if (platform) platform->setCurrentByIndex(HippoGridInfo::PLATFORM_OTHER);
childSetText("gridname", empty);
@@ -281,10 +278,10 @@ void HippoPanelGridsImpl::loadCurGrid()
if (mState == ADD_NEW) {
std::string required = "<required>";
childSetText("gridnick", required);
childSetText("gridname", required);
childSetText("loginuri", required);
} else if (mState == ADD_COPY) {
childSetText("gridnick", std::string("<required>"));
childSetText("gridname", std::string("<required>"));
} else if (mState != NORMAL) {
llwarns << "Illegal state " << mState << '.' << llendl;
}
@@ -300,21 +297,21 @@ bool HippoPanelGridsImpl::saveCurGrid()
if (mState == NORMAL) {
gridInfo = gHippoGridManager->getGrid(mCurGrid);
gridInfo->retrieveGridInfo();
refresh();
} else if ((mState == ADD_NEW) || (mState == ADD_COPY)) {
// check nickname
std::string gridnick = childGetValue("gridnick");
if (gridnick == "<required>") gridnick = "";
HippoGridInfo::sanitizeGridNick(gridnick);
childSetValue("gridnick", (gridnick != "")? gridnick: "<required>");
if (gridnick == "") {
std::string gridname = childGetValue("gridname");
if (gridname == "<required>") gridname = "";
childSetValue("gridname", (gridname != "")? gridname: "<required>");
if (gridname == "") {
LLNotifications::instance().add("GridsNoNick");
return false;
}
if (gHippoGridManager->getGrid(gridnick)) {
if (gHippoGridManager->getGrid(gridname)) {
LLSD args;
args["NAME"] = gridnick;
args["NAME"] = gridname;
LLNotifications::instance().add("GridExists", args);
return false;
}
@@ -323,18 +320,16 @@ bool HippoPanelGridsImpl::saveCurGrid()
std::string loginuri = childGetValue("loginuri");
if ((loginuri == "") || (loginuri == "<required>")) {
LLSD args;
args["NAME"] = gridnick;
args["NAME"] = gridname;
LLNotifications::instance().add("GridsNoLoginUri", args);
return false;
}
mState = NORMAL;
mCurGrid = gridnick;
gridInfo = new HippoGridInfo(gridnick);
mCurGrid = gridname;
gridInfo = new HippoGridInfo(gridname);
gHippoGridManager->addGrid(gridInfo);
gridInfo->retrieveGridInfo();
refresh();
return true;
} else {
llwarns << "Illegal state " << mState << '.' << llendl;
@@ -346,12 +341,7 @@ bool HippoPanelGridsImpl::saveCurGrid()
llwarns << "Grid not found, ignoring changes." << llendl;
return true;
}
if (gridInfo->getGridNick() != childGetValue("gridnick").asString()) {
llwarns << "Grid nickname mismatch, ignoring changes." << llendl;
return true;
}
gridInfo->setPlatform(childGetValue("platform"));
gridInfo->setGridName(childGetValue("gridname"));
gridInfo->setLoginUri(childGetValue("loginuri"));
@@ -406,7 +396,6 @@ void HippoPanelGridsImpl::retrieveGridInfo()
grid->setLoginUri(loginuri);
if (grid->retrieveGridInfo()) {
if (grid->getGridNick() != "") childSetText("gridnick", grid->getGridNick());
if (grid->getPlatform() != HippoGridInfo::PLATFORM_OTHER)
getChild<LLComboBox>("platform")->setCurrentByIndex(grid->getPlatform());
if (grid->getGridName() != "") childSetText("gridname", grid->getGridName());
@@ -418,6 +407,7 @@ void HippoPanelGridsImpl::retrieveGridInfo()
if (grid->getRegisterUrl() != "") childSetText("register", grid->getRegisterUrl());
if (grid->getPasswordUrl() != "") childSetText("password", grid->getPasswordUrl());
if (grid->getSearchUrl() != "") childSetText("search", grid->getSearchUrl());
if (grid->getGridMessage() != "") childSetText("gridmessage", grid->getGridMessage());
} else {
LLNotifications::instance().add("GridInfoError");
}

View File

@@ -145,8 +145,7 @@ LLFloaterAbout::LLFloaterAbout()
std::string support;
support.append("\n\n");
support.append("Grid: " + gHippoGridManager->getConnectedGrid()->getGridName()
+ " (" + gHippoGridManager->getConnectedGrid()->getGridNick() + ")\n\n");
support.append("Grid: " + gHippoGridManager->getConnectedGrid()->getGridName() + "\n\n");
#if LL_MSVC
support.append(llformat("Built with MSVC version %d\n\n", _MSC_VER));

View File

@@ -860,7 +860,7 @@ void LLPanelLogin::updateGridCombo()
}
HippoGridManager::GridIterator it, end = gHippoGridManager->endGrid();
for (it = gHippoGridManager->beginGrid(); it != end; ++it) {
const std::string &grid = it->second->getGridNick();
const std::string &grid = it->second->getGridName();
if (grid != defaultGrid) {
grids->add(grid);
if (grid == currentGrid) selectIndex = i;

View File

@@ -1588,7 +1588,7 @@ bool idle_startup()
std::string history_file = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "saved_logins_sg2.xml");
LLSavedLogins history_data = LLSavedLogins::loadFile(history_file);
std::string grid_nick = gHippoGridManager->getConnectedGrid()->getGridNick();
std::string grid_nick = gHippoGridManager->getConnectedGrid()->getGridName();
history_data.deleteEntry(firstname, lastname, grid_nick);
if (gSavedSettings.getBOOL("RememberLogin"))
{

View File

@@ -52,7 +52,7 @@ void LLViewerLogin::getLoginURIs(std::vector<std::string>& uris) const
const std::string &LLViewerLogin::getGridLabel() const
{
return gHippoGridManager->getConnectedGrid()->getGridNick();
return gHippoGridManager->getConnectedGrid()->getGridName();
}
const std::string &LLViewerLogin::getLoginPage() const

View File

@@ -431,7 +431,7 @@ void LLXMLRPCTransaction::Impl::setStatus(Status status,
mStatusMessage =
"Despite our best efforts, something unexpected has gone wrong. \n"
" \n"
"Please check " + gHippoGridManager->getCurrentGrid()->getGridNick() + "'s status \n"
"Please check " + gHippoGridManager->getCurrentGrid()->getGridName() + "'s status \n"
"to see if there is a known problem with the service.";
//mStatusURI = "http://secondlife.com/status/";
@@ -449,7 +449,7 @@ void LLXMLRPCTransaction::Impl::setCurlStatus(CURLcode code)
case CURLE_COULDNT_RESOLVE_HOST:
message =
"DNS could not resolve the host name.\n"
"Please verify that you can connect to " + gHippoGridManager->getCurrentGrid()->getGridNick() + "'s\n"
"Please verify that you can connect to " + gHippoGridManager->getCurrentGrid()->getGridName() + "'s\n"
"web site. If you can, but continue to receive this error,\n"
"please go to the support section and report this problem.";
break;
@@ -458,7 +458,7 @@ void LLXMLRPCTransaction::Impl::setCurlStatus(CURLcode code)
message =
"The login server couldn't verify itself via SSL.\n"
"If you continue to receive this error, please go\n"
"to the Support section of " + gHippoGridManager->getCurrentGrid()->getGridNick() + "'s web site\n"
"to the Support section of " + gHippoGridManager->getCurrentGrid()->getGridName() + "'s web site\n"
"and report the problem.";
break;
@@ -470,7 +470,7 @@ void LLXMLRPCTransaction::Impl::setCurlStatus(CURLcode code)
"are set correctly.\n"
"\n"
"If you continue to receive this error, please go\n"
"to the Support section of " + gHippoGridManager->getCurrentGrid()->getGridNick() + "'s web site\n"
"to the Support section of " + gHippoGridManager->getCurrentGrid()->getGridName() + "'s web site\n"
"and report the problem.";
break;

View File

@@ -82,22 +82,6 @@
<combo_box max_chars="20" allow_text_entry="false" name="platform"
height="18" width="200" left="120" bottom_delta="-4"
follows="left|top" mouse_opaque="true" />
<!-- Grid Nickname -->
<text type="string" length="1" enabled="true" name="gridnick_label"
height="10" width="100" left="12" bottom_delta="-22"
h_pad="0" v_pad="0" halign="left"
font="SansSerifSmall"
follows="left|top" bg_visible="false" border_visible="false" mouse_opaque="true"
drop_shadow_visible="true" border_drop_shadow_visible="false">
Grid Nickname:
</text>
<line_editor max_length="25" enabled="false" name="gridnick"
handle_edit_keys_directly="true"
height="18" width="175" left="120" bottom_delta="-4"
halign="right"
font="SansSerifSmall"
follows="left|top" border_visible="false" mouse_opaque="false"
drop_shadow_visible="true" border_drop_shadow_visible="false" />
<!-- Grid Name -->
<text type="string" length="1" enabled="true" name="gridname_label"
height="10" width="100" left="12" bottom_delta="-20"