Prevent accidental modification of vital stock grid

This commit is contained in:
Siana Gearz
2013-11-20 05:49:43 +01:00
parent cde5b23353
commit f23dc157be
4 changed files with 50 additions and 29 deletions

View File

@@ -2,7 +2,7 @@
<array>
<map>
<key>default_grids_version</key><string>21</string>
<key>default_grids_version</key><string>22</string>
</map>
<!-- Second Life -->
@@ -20,6 +20,7 @@
<key>render_compat</key><boolean>1</boolean>
<key>inventory_links</key><boolean>1</boolean>
<key>auto_update</key><boolean>0</boolean>
<key>locked</key><boolean>1</boolean>
</map>
<map>

View File

@@ -57,6 +57,7 @@ HippoGridInfo::HippoGridInfo(const std::string& gridName) :
mRenderCompat(true),
mInvLinks(false),
mAutoUpdate(false),
mLocked(false),
mMaxAgentGroups(-1),
mCurrencySymbol("OS$"),
mCurrencyText("OS Dollars"),
@@ -174,10 +175,12 @@ void HippoGridInfo::setLoginUri(const std::string& loginUri)
{
mIsInProductionGrid = true;
useHttps();
setPlatform(PLATFORM_SECONDLIFE);
}
if (utf8str_tolower(LLURI(mLoginUri).hostName()) == "login.aditi.lindenlab.com")
{
useHttps();
setPlatform(PLATFORM_SECONDLIFE);
}
if (utf8str_tolower(LLURI(mLoginUri).hostName()) == "login.avination.com" ||
utf8str_tolower(LLURI(mLoginUri).hostName()) == "login.avination.net")
@@ -654,11 +657,6 @@ bool HippoGridInfo::getAutoUpdate()
return mAutoUpdate;
}
void HippoGridInfo::setAutoUpdate(bool b)
{
mAutoUpdate = b;
}
bool HippoGridInfo::getUPCSupported()
{
if(isSecondLife())
@@ -1014,7 +1012,8 @@ void HippoGridManager::parseData(LLSD &gridInfo, bool mergeIfNewer)
if (gridMap.has("search")) grid->setSearchUrl(gridMap["search"]);
if (gridMap.has("render_compat")) grid->setRenderCompat(gridMap["render_compat"]);
if (gridMap.has("inventory_links")) grid->setSupportsInvLinks(gridMap["inventory_links"]);
if (gridMap.has("auto_update")) grid->setAutoUpdate(gridMap["auto_update"]);
if (gridMap.has("auto_update")) grid->mAutoUpdate = gridMap["auto_update"];
if (gridMap.has("locked")) grid->mLocked = gridMap["locked"];
if (newGrid) addGrid(grid);
}
}
@@ -1051,6 +1050,7 @@ void HippoGridManager::saveFile()
gridInfo[i]["render_compat"] = grid->isRenderCompat();
gridInfo[i]["inventory_links"] = grid->supportsInvLinks();
gridInfo[i]["auto_update"] = grid->getAutoUpdate();
gridInfo[i]["locked"] = grid->getLocked();
}
// write client grid info file

View File

@@ -22,6 +22,7 @@ class LLSD;
class HippoGridInfo
{
friend class HippoGridManager;
public:
enum Platform {
PLATFORM_OTHER = 0,
@@ -96,7 +97,7 @@ public:
bool supportsInvLinks();
void setSupportsInvLinks(bool b);
bool getAutoUpdate();
void setAutoUpdate(bool b);
bool getLocked() { return mLocked; }
void getGridInfo();
@@ -124,6 +125,7 @@ private:
bool mRenderCompat;
bool mInvLinks;
bool mAutoUpdate;
bool mLocked;
bool mUPCSupported;
int mMaxAgentGroups;

View File

@@ -61,6 +61,7 @@ class HippoPanelGridsImpl : public HippoPanelGrids
enum State { NORMAL, ADD_NEW, ADD_COPY };
State mState;
std::string mCurGrid;
bool mIsEditable;
void loadCurGrid();
bool saveCurGrid();
@@ -78,6 +79,8 @@ class HippoPanelGridsImpl : public HippoPanelGrids
static void onClickGridInfo(void *data);
static void onClickHelpRenderCompat(void *data);
static void onClickAdvanced(void *data);
void enableEditing(bool);
};
@@ -103,7 +106,7 @@ HippoPanelGrids *HippoPanelGrids::create()
HippoPanelGridsImpl::HippoPanelGridsImpl() :
mState(NORMAL)
mState(NORMAL), mIsEditable(true)
{
LLUICtrlFactory::getInstance()->buildPanel(this, "panel_preferences_grids.xml");
}
@@ -194,27 +197,10 @@ void HippoPanelGridsImpl::refresh()
childSetTextArg("default_grid", "[DEFAULT]", (defaultGrid != "")? defaultGrid: " ");
childSetEnabled("btn_delete", (selectIndex >= 0));
childSetEnabled("btn_delete", (selectIndex >= 0) && mIsEditable );
childSetEnabled("btn_copy", (mState == NORMAL) && (selectIndex >= 0));
childSetEnabled("btn_default", (mState == NORMAL) && (selectIndex > 0));
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()->getGridName());
childSetEnabled("platform", enablePlatform);
childSetEnabled("search", false);
childSetText("search", LLStringExplicit(""));
childSetEnabled("render_compat", false);
childSetValue("render_compat", false);
} else {
childSetEnabled("platform", true);
childSetEnabled("search", true);
childSetText("search", gHippoGridManager->getConnectedGrid()->getSearchUrl());
childSetEnabled("render_compat", true);
}
childSetEnabled("gridname", (mState == ADD_NEW) || (mState == ADD_COPY));
}
@@ -256,9 +242,11 @@ void HippoPanelGridsImpl::loadCurGrid()
childSetText("helperuri", gridInfo->getHelperUri());
childSetText("website", gridInfo->getWebSite());
childSetText("support", gridInfo->getSupportUrl());
childSetText("search", gridInfo->getSearchUrl());
childSetText("register", gridInfo->getRegisterUrl());
childSetText("password", gridInfo->getPasswordUrl());
childSetValue("render_compat", gridInfo->isRenderCompat());
enableEditing(!gridInfo->getLocked());
} else {
std::string empty = "";
LLComboBox *platform = getChild<LLComboBox>("platform");
@@ -269,10 +257,11 @@ void HippoPanelGridsImpl::loadCurGrid()
childSetText("helperuri", empty);
childSetText("website", empty);
childSetText("support", empty);
childSetText("search", empty);
childSetText("register", empty);
childSetText("password", empty);
childSetEnabled("render_compat", true);
childSetValue("render_compat", true);
enableEditing(true);
}
if (mState == ADD_NEW) {
@@ -281,6 +270,7 @@ void HippoPanelGridsImpl::loadCurGrid()
childSetText("loginuri", required);
} else if (mState == ADD_COPY) {
childSetText("gridname", std::string("<required>"));
enableEditing(true);
} else if (mState != NORMAL) {
llwarns << "Illegal state " << mState << '.' << llendl;
}
@@ -574,3 +564,31 @@ void HippoPanelGridsImpl::onClickHelpRenderCompat(void *data)
{
LLNotificationsUtil::add("HelpRenderCompat");
}
void HippoPanelGridsImpl::enableEditing(bool b)
{
static const char * elements [] = {
"platform",
"gridname",
"loginuri",
"loginpage",
"helperuri",
"website",
"support",
"register",
"password",
"search",
"btn_delete",
"btn_gridinfo",
"render_compat",
"gridmessage",
0
};
for(int i = 0; elements[i]; ++i ) {
this->childSetEnabled(elements[i], b);
}
mIsEditable = b;
}