Fix up some of the broken SLURL<->HippoGridManager logic.
This commit is contained in:
@@ -506,7 +506,7 @@ void HippoGridInfo::formatFee(std::string &fee, int cost, bool showFree) const
|
||||
}
|
||||
|
||||
//static
|
||||
std::string HippoGridInfo::sanitizeGridNick(std::string &gridnick)
|
||||
std::string HippoGridInfo::sanitizeGridNick(const std::string &gridnick)
|
||||
{
|
||||
std::string tmp;
|
||||
int size = gridnick.size();
|
||||
@@ -529,7 +529,7 @@ std::string HippoGridInfo::sanitizeGridNick(std::string &gridnick)
|
||||
}
|
||||
|
||||
|
||||
std::string HippoGridInfo::getGridNick()
|
||||
std::string HippoGridInfo::getGridNick() const
|
||||
{
|
||||
if(!mGridNick.empty())
|
||||
{
|
||||
@@ -684,42 +684,57 @@ void HippoGridManager::discardAndReload()
|
||||
|
||||
HippoGridInfo* HippoGridManager::getGrid(const std::string& grid) const
|
||||
{
|
||||
if(grid.empty())
|
||||
return NULL;
|
||||
|
||||
std::map<std::string, HippoGridInfo*>::const_iterator it;
|
||||
it = mGridInfo.find(grid);
|
||||
|
||||
//The grids are keyed by 'name' which equates to something like "Second Life"
|
||||
//Try to match such first.
|
||||
if (it != mGridInfo.end())
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
else
|
||||
else //Fall back to nick short names. (so something like "secondlife" will work)
|
||||
{
|
||||
return 0;
|
||||
for(it = mGridInfo.begin(); it != mGridInfo.end(); ++it)
|
||||
{
|
||||
if(it->second && LLStringUtil::compareInsensitive(it->second->getGridNick(), grid)==0)
|
||||
return it->second;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
HippoGridInfo* HippoGridManager::getCurrentGrid() const
|
||||
{
|
||||
HippoGridInfo* grid = getGrid(mCurrentGrid);
|
||||
if (grid)
|
||||
if(!grid)
|
||||
{
|
||||
return grid;
|
||||
}
|
||||
else
|
||||
{
|
||||
return &HippoGridInfo::FALLBACK_GRIDINFO;
|
||||
grid = getGrid(mDefaultGrid);
|
||||
}
|
||||
return grid ? grid : &HippoGridInfo::FALLBACK_GRIDINFO;
|
||||
}
|
||||
|
||||
const std::string& HippoGridManager::getDefaultGridNick() const
|
||||
std::string HippoGridManager::getDefaultGridNick() const
|
||||
{
|
||||
HippoGridInfo* grid = getGrid(mDefaultGrid);
|
||||
return grid ? grid->getGridNick() : HippoGridInfo::FALLBACK_GRIDINFO.getGridNick();
|
||||
}
|
||||
|
||||
std::string HippoGridManager::getCurrentGridNick() const
|
||||
{
|
||||
return getCurrentGrid()->getGridNick();
|
||||
}
|
||||
|
||||
const std::string& HippoGridManager::getDefaultGridName() const
|
||||
{
|
||||
return mDefaultGrid;
|
||||
}
|
||||
|
||||
const std::string& HippoGridManager::getCurrentGridNick() const
|
||||
const std::string& HippoGridManager::getCurrentGridName() const
|
||||
{
|
||||
if (mCurrentGrid.empty())
|
||||
{
|
||||
return mDefaultGrid;
|
||||
}
|
||||
return mCurrentGrid;
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
const std::string& getVoiceConnector() const { return mVoiceConnector; }
|
||||
std::string getSearchUrl(SearchType ty, bool is_web) const;
|
||||
bool isRenderCompat() const { return mRenderCompat; }
|
||||
std::string getGridNick();
|
||||
std::string getGridNick() const;
|
||||
int getMaxAgentGroups() const { return mMaxAgentGroups; }
|
||||
|
||||
const std::string& getCurrencySymbol() const { return mCurrencySymbol; }
|
||||
@@ -99,7 +99,7 @@ public:
|
||||
bool retrieveGridInfo();
|
||||
|
||||
static const char* getPlatformString(Platform platform);
|
||||
static std::string sanitizeGridNick(std::string &gridnick);
|
||||
static std::string sanitizeGridNick(const std::string &gridnick);
|
||||
|
||||
static HippoGridInfo FALLBACK_GRIDINFO;
|
||||
static void initFallback();
|
||||
@@ -163,8 +163,10 @@ public:
|
||||
HippoGridInfo* getConnectedGrid() const { return mConnectedGrid ? mConnectedGrid : getCurrentGrid(); }
|
||||
|
||||
HippoGridInfo* getCurrentGrid() const;
|
||||
const std::string& getDefaultGridNick() const;
|
||||
const std::string& getCurrentGridNick() const;
|
||||
std::string getDefaultGridNick() const;
|
||||
std::string getCurrentGridNick() const;
|
||||
const std::string& getDefaultGridName() const;
|
||||
const std::string& getCurrentGridName() const;
|
||||
|
||||
void setDefaultGrid(const std::string& grid);
|
||||
void setCurrentGrid(const std::string& grid);
|
||||
|
||||
@@ -130,7 +130,8 @@ static std::string nameJoin(const std::string& first,const std::string& last, bo
|
||||
}
|
||||
|
||||
static std::string getDisplayString(const std::string& first, const std::string& last, const std::string& grid, bool is_secondlife) {
|
||||
if(grid == gHippoGridManager->getDefaultGridNick())
|
||||
//grid comes via LLSavedLoginEntry, which uses full grid names, not nicks
|
||||
if(grid == gHippoGridManager->getDefaultGridName())
|
||||
return nameJoin(first, last, is_secondlife);
|
||||
else
|
||||
return nameJoin(first, last, is_secondlife) + " (" + grid + ")";
|
||||
@@ -633,7 +634,9 @@ void LLPanelLogin::setFields(const LLSavedLoginEntry& entry, bool takeFocus)
|
||||
//sInstance->childSetText("name_combo", fullname);
|
||||
|
||||
std::string grid = entry.getGrid();
|
||||
if(!grid.empty() && gHippoGridManager->getGrid(grid) && grid != gHippoGridManager->getCurrentGridNick()) {
|
||||
//grid comes via LLSavedLoginEntry, which uses full grid names, not nicks
|
||||
if(!grid.empty() && gHippoGridManager->getGrid(grid) && grid != gHippoGridManager->getCurrentGridName())
|
||||
{
|
||||
gHippoGridManager->setCurrentGrid(grid);
|
||||
LLPanelLogin::refreshLoginPage();
|
||||
}
|
||||
@@ -791,27 +794,34 @@ void LLPanelLogin::setAlwaysRefresh(bool refresh)
|
||||
|
||||
void LLPanelLogin::updateGridCombo()
|
||||
{
|
||||
const std::string &defaultGrid = gHippoGridManager->getDefaultGridNick();
|
||||
const std::string ¤tGrid = gHippoGridManager->getCurrentGridNick();
|
||||
const std::string &defaultGrid = gHippoGridManager->getDefaultGridName();
|
||||
|
||||
LLComboBox *grids = getChild<LLComboBox>("grids_combo");
|
||||
S32 selectIndex = -1, i = 0;
|
||||
std::string top_entry;
|
||||
|
||||
grids->removeall();
|
||||
if (defaultGrid != "") {
|
||||
grids->add(defaultGrid);
|
||||
selectIndex = i++;
|
||||
}
|
||||
|
||||
const HippoGridInfo *curGrid = gHippoGridManager->getCurrentGrid();
|
||||
const HippoGridInfo *defGrid = gHippoGridManager->getGrid(defaultGrid);
|
||||
|
||||
HippoGridManager::GridIterator it, end = gHippoGridManager->endGrid();
|
||||
for (it = gHippoGridManager->beginGrid(); it != end; ++it) {
|
||||
for (it = gHippoGridManager->beginGrid(); it != end; ++it)
|
||||
{
|
||||
std::string grid = it->second->getGridName();
|
||||
if (grid != defaultGrid) {
|
||||
grids->add(grid);
|
||||
if (grid == currentGrid) selectIndex = i;
|
||||
i++;
|
||||
}
|
||||
if(grid.empty() || it->second == defGrid || it->second == curGrid)
|
||||
continue;
|
||||
grids->add(grid,it->second->getGridNick());
|
||||
}
|
||||
if (selectIndex >= 0) {
|
||||
grids->setCurrentByIndex(selectIndex);
|
||||
} else {
|
||||
if(curGrid || defGrid)
|
||||
{
|
||||
if(defGrid)
|
||||
grids->add(defGrid->getGridName(),defGrid->getGridNick(),ADD_TOP);
|
||||
if(curGrid && defGrid != curGrid)
|
||||
grids->add(curGrid->getGridName(),curGrid->getGridNick(),ADD_TOP);
|
||||
grids->setCurrentByIndex(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
grids->setLabel(LLStringExplicit("")); // LLComboBox::removeall() does not clear the label
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,11 +53,14 @@ const char* LLSLURL::SLURL_REGION_PATH = "region";
|
||||
const char* LLSLURL::SIM_LOCATION_HOME = "home";
|
||||
const char* LLSLURL::SIM_LOCATION_LAST = "last";
|
||||
|
||||
|
||||
const std::string MAIN_GRID_SLURL_BASE = "http://maps.secondlife.com/secondlife/";
|
||||
const std::string SYSTEM_GRID_APP_SLURL_BASE = "secondlife:///app";
|
||||
#define MAINGRID "util.agni.lindenlab.com"
|
||||
|
||||
const char* SYSTEM_GRID_SLURL_BASE = "secondlife://%s/secondlife/";
|
||||
const char* DEFAULT_SLURL_BASE = "https://%s/region/";
|
||||
const char* DEFAULT_APP_SLURL_BASE = "x-grid-location-info://%s/app";
|
||||
|
||||
#define MAINGRID "secondlife"
|
||||
// resolve a simstring from a slurl
|
||||
LLSLURL::LLSLURL(const std::string& slurl)
|
||||
{
|
||||
@@ -87,7 +90,19 @@ LLSLURL::LLSLURL(const std::string& slurl)
|
||||
// where the user can type in <regionname>/<x>/<y>/<z>
|
||||
//std::string fixed_slurl = LLGridManager::getInstance()->getSLURLBase();
|
||||
//Singu TODO: Implement LLHippoGridMgr::getSLURLBase some day. For now it's hardcoded.
|
||||
std::string fixed_slurl = MAIN_GRID_SLURL_BASE;
|
||||
std::string fixed_slurl;
|
||||
|
||||
if(gHippoGridManager->getCurrentGrid()->isSecondLife())
|
||||
{
|
||||
if(gHippoGridManager->getCurrentGrid()->isInProductionGrid())
|
||||
fixed_slurl = MAIN_GRID_SLURL_BASE;
|
||||
else
|
||||
fixed_slurl = llformat(SYSTEM_GRID_SLURL_BASE, gHippoGridManager->getCurrentGridNick());
|
||||
}
|
||||
else
|
||||
fixed_slurl = llformat(DEFAULT_SLURL_BASE, gHippoGridManager->getCurrentGridNick());
|
||||
|
||||
//std::string fixed_slurl = MAIN_GRID_SLURL_BASE;
|
||||
|
||||
// the slurl that was passed in might have a prepended /, or not. So,
|
||||
// we strip off the prepended '/' so we don't end up with http://slurl.com/secondlife/<region>/<x>/<y>/<z>
|
||||
@@ -147,7 +162,15 @@ LLSLURL::LLSLURL(const std::string& slurl)
|
||||
// so parse the grid name to derive the grid ID
|
||||
if (!slurl_uri.hostName().empty())
|
||||
{
|
||||
mGrid = gHippoGridManager->getGrid(slurl_uri.hostName())->getGridNick();
|
||||
if(slurl_uri.hostName() == "util.agni.lindenlab.com")
|
||||
mGrid = MAINGRID;
|
||||
else if(slurl_uri.hostName() == "util.aditi.lindenlab.com")
|
||||
mGrid = "secondlife_beta";
|
||||
else
|
||||
{
|
||||
HippoGridInfo* grid = gHippoGridManager->getGrid(slurl_uri.hostName());
|
||||
mGrid = grid ? grid->getGridNick() : gHippoGridManager->getDefaultGridNick();
|
||||
}
|
||||
}
|
||||
else if(path_array[0].asString() == LLSLURL::SLURL_SECONDLIFE_PATH)
|
||||
{
|
||||
@@ -353,8 +376,8 @@ LLSLURL::LLSLURL(const std::string& grid,
|
||||
const std::string& region,
|
||||
const LLVector3d& global_position)
|
||||
{
|
||||
HippoGridInfo* target_grid = gHippoGridManager->getGrid(grid);
|
||||
*this = LLSLURL((target_grid ? target_grid->getGridNick() : ""),
|
||||
HippoGridInfo* gridp = gHippoGridManager->getGrid(grid);
|
||||
*this = LLSLURL(gridp ? gridp->getGridNick() : gHippoGridManager->getDefaultGridNick(),
|
||||
region, LLVector3(global_position.mdV[VX],
|
||||
global_position.mdV[VY],
|
||||
global_position.mdV[VZ]));
|
||||
@@ -394,7 +417,17 @@ std::string LLSLURL::getSLURLString() const
|
||||
S32 z = llround( (F32)mPosition[VZ] );
|
||||
//return LLGridManager::getInstance()->getSLURLBase(mGrid) +
|
||||
//Singu TODO: Implement LLHippoGridMgr::getSLURLBase some day. For now it's hardcoded.
|
||||
return MAIN_GRID_SLURL_BASE +
|
||||
std::string fixed_slurl;
|
||||
if(gHippoGridManager->getCurrentGrid()->isSecondLife())
|
||||
{
|
||||
if(gHippoGridManager->getCurrentGrid()->isInProductionGrid())
|
||||
fixed_slurl = MAIN_GRID_SLURL_BASE;
|
||||
else
|
||||
fixed_slurl = llformat(SYSTEM_GRID_SLURL_BASE, gHippoGridManager->getCurrentGridNick());
|
||||
}
|
||||
else
|
||||
fixed_slurl = llformat(DEFAULT_SLURL_BASE, gHippoGridManager->getCurrentGridNick());
|
||||
return fixed_slurl +
|
||||
LLURI::escape(mRegion) + llformat("/%d/%d/%d",x,y,z);
|
||||
}
|
||||
case APP:
|
||||
@@ -402,7 +435,10 @@ std::string LLSLURL::getSLURLString() const
|
||||
std::ostringstream app_url;
|
||||
//app_url << LLGridManager::getInstance()->getAppSLURLBase() << "/" << mAppCmd;
|
||||
//Singu TODO: Implement LLHippoGridMgr::getAppSLURLBase some day. For now it's hardcoded.
|
||||
app_url << SYSTEM_GRID_APP_SLURL_BASE << "/" << mAppCmd;
|
||||
if(gHippoGridManager->getCurrentGrid()->isSecondLife())
|
||||
app_url << SYSTEM_GRID_APP_SLURL_BASE << "/" << mAppCmd;
|
||||
else
|
||||
app_url << llformat(DEFAULT_APP_SLURL_BASE, gHippoGridManager->getCurrentGridNick()) << "/" << mAppCmd;
|
||||
for(LLSD::array_const_iterator i = mAppPath.beginArray();
|
||||
i != mAppPath.endArray();
|
||||
i++)
|
||||
|
||||
@@ -3918,11 +3918,11 @@ bool process_login_success_response(std::string& password)
|
||||
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()->getGridName();
|
||||
history_data.deleteEntry(firstname, lastname, grid_nick);
|
||||
std::string grid_name = gHippoGridManager->getConnectedGrid()->getGridName();
|
||||
history_data.deleteEntry(firstname, lastname, grid_name);
|
||||
if (gSavedSettings.getBOOL("RememberLogin"))
|
||||
{
|
||||
LLSavedLoginEntry login_entry(firstname, lastname, password, grid_nick);
|
||||
LLSavedLoginEntry login_entry(firstname, lastname, password, grid_name);
|
||||
history_data.addEntry(login_entry);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -216,9 +216,9 @@ void LLURLDispatcherImpl::regionHandleCallback(U64 region_handle, const LLSLURL&
|
||||
{
|
||||
LLSD args;
|
||||
args["SLURL"] = slurl.getLocationString();
|
||||
args["CURRENT_GRID"] = gHippoGridManager->getCurrentGridNick();
|
||||
args["CURRENT_GRID"] = gHippoGridManager->getCurrentGrid()->getGridName();
|
||||
|
||||
std::string grid_label = new_grid ? new_grid->getGridNick() : "";
|
||||
std::string grid_label = new_grid ? new_grid->getGridName() : "";
|
||||
|
||||
if(!grid_label.empty())
|
||||
{
|
||||
@@ -226,7 +226,7 @@ void LLURLDispatcherImpl::regionHandleCallback(U64 region_handle, const LLSLURL&
|
||||
}
|
||||
else
|
||||
{
|
||||
args["GRID"] = slurl.getGrid();
|
||||
args["GRID"] = slurl.getGrid() + " (Unrecognized)";
|
||||
}
|
||||
LLNotificationsUtil::add("CantTeleportToGrid", args);
|
||||
return;
|
||||
@@ -255,8 +255,7 @@ void LLURLDispatcherImpl::regionHandleCallback(U64 region_handle, const LLSLURL&
|
||||
{
|
||||
url_displayp->setSnapshotDisplay(snapshot_id);
|
||||
}
|
||||
LLVector3 pos = slurl.getPosition();
|
||||
std::string locationString = llformat("%s %d, %d, %d", slurl.getRegion().c_str(), local_pos.mV[VX],local_pos.mV[VY],local_pos.mV[VZ]);
|
||||
std::string locationString = llformat("%s %i, %i, %i", slurl.getRegion().c_str(), (S32)local_pos.mV[VX],(S32)local_pos.mV[VY],(S32)local_pos.mV[VZ]);
|
||||
url_displayp->setLocationString(locationString);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user