From a72ab74505d12a341edb4c2fa19d8f071b4277f9 Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Sat, 3 Jul 2010 20:22:30 -0700 Subject: Basic cleanup of the grid manager code --- linden/indra/newview/CMakeLists.txt | 6 +- linden/indra/newview/floatergridmanager.cpp | 750 +++++++++++++++++++++ linden/indra/newview/floatergridmanager.h | 93 +++ linden/indra/newview/floaterlogin.cpp | 722 -------------------- linden/indra/newview/floaterlogin.h | 90 --- linden/indra/newview/llpanellogin.cpp | 6 +- .../default/xui/en-us/floater_grid_manager.xml | 263 ++++++++ .../skins/default/xui/en-us/floater_login.xml | 260 ------- 8 files changed, 1112 insertions(+), 1078 deletions(-) create mode 100644 linden/indra/newview/floatergridmanager.cpp create mode 100644 linden/indra/newview/floatergridmanager.h delete mode 100644 linden/indra/newview/floaterlogin.cpp delete mode 100644 linden/indra/newview/floaterlogin.h create mode 100644 linden/indra/newview/skins/default/xui/en-us/floater_grid_manager.xml delete mode 100644 linden/indra/newview/skins/default/xui/en-us/floater_login.xml (limited to 'linden/indra') diff --git a/linden/indra/newview/CMakeLists.txt b/linden/indra/newview/CMakeLists.txt index 2b4395d..ab0159f 100644 --- a/linden/indra/newview/CMakeLists.txt +++ b/linden/indra/newview/CMakeLists.txt @@ -69,7 +69,7 @@ set(viewer_SOURCE_FILES emeraldboobutils.cpp floaterao.cpp floaterbusy.cpp - floaterlogin.cpp + floatergridmanager.cpp hbfloatergrouptitles.cpp hippoGridManager.cpp hippoLimits.cpp @@ -498,7 +498,7 @@ set(viewer_HEADER_FILES emeraldboobutils.h floaterao.h floaterbusy.h - floaterlogin.h + floatergridmanager.h hbfloatergrouptitles.h hippoGridManager.h hippoLimits.h @@ -1125,6 +1125,7 @@ set(viewer_XUI_FILES skins/default/xui/en-us/floater_font_test.xml skins/default/xui/en-us/floater_gesture.xml skins/default/xui/en-us/floater_god_tools.xml + skins/default/xui/en-us/floater_grid_manager.xml skins/default/xui/en-us/floater_group_info.xml skins/default/xui/en-us/floater_group_titles.xml skins/default/xui/en-us/floater_hardware_settings.xml @@ -1145,7 +1146,6 @@ set(viewer_XUI_FILES skins/default/xui/en-us/floater_land_holdings.xml skins/default/xui/en-us/floater_landmark_ctrl.xml skins/default/xui/en-us/floater_live_lsleditor.xml - skins/default/xui/en-us/floater_login.xml skins/default/xui/en-us/floater_lsl_guide.xml skins/default/xui/en-us/floater_media_browser.xml skins/default/xui/en-us/floater_mini_map.xml diff --git a/linden/indra/newview/floatergridmanager.cpp b/linden/indra/newview/floatergridmanager.cpp new file mode 100644 index 0000000..efd02ca --- /dev/null +++ b/linden/indra/newview/floatergridmanager.cpp @@ -0,0 +1,750 @@ +/* + * floatergridmanager.cpp + * This is Meerkats grid manager. + * -Patrick Sapinski (Monday, August 17, 2009) + * + * Modified by McCabe Maxsted for Imprudence + */ + +#include "llviewerprecompiledheaders.h" + +#include "floatergridmanager.h" + +#include +#include "llviewercontrol.h" +#include "llcombobox.h" +#include "llscrolllistctrl.h" +#include "llmd5.h" +#include "llurlsimstring.h" +#include "lluictrlfactory.h" +#include "hippoGridManager.h" +#include "llviewernetwork.h" +#include "llpanellogin.h" + +#define PASSWORD_FILLER "123456789!123456" + +LoginController* FloaterGridManager::sController = NULL; +bool FloaterGridManager::sIsInitialLogin; +std::string FloaterGridManager::sGrid; + +FloaterGridManager::FloaterGridManager(const LLSD& key) +: mState(NORMAL), + mCurGrid(gHippoGridManager->getCurrentGridNick()), + mIncomingPassword(""), + mMungedPassword("") +{ + llinfos << "Opening grid manager" << llendl; + + LLUICtrlFactory::getInstance()->buildFloater(this, "floater_grid_manager.xml"); + center(); + + LLLineEditor* edit = getChild("avatar_password_edit"); + if (edit) + { + edit->setDrawAsterixes(TRUE); + } +} + + +FloaterGridManager::~FloaterGridManager() +{ + FloaterGridManager::sController = NULL; +} + +BOOL FloaterGridManager::postBuild() +{ + /*requires("grid_selector"); + requires("gridnick"); + requires("gridname"); + requires("loginuri"); + requires("loginpage"); + requires("helperuri"); + requires("website"); + requires("support"); + requires("register"); + requires("password"); + requires("first_name"); + requires("last_name"); + requires("avatar_password"); + //requires("search"); + requires("btn_delete"); + requires("btn_add"); + requires("btn_copy"); + requires("set_default"); + requires("btn_gridinfo");*/ + //requires("btn_help_render_compat"); + + /*if (!checkRequirements()) + { + return false; + }*/ + + LLLineEditor* password_edit = getChild("avatar_password"); + if (password_edit) + { + password_edit->setDrawAsterixes(TRUE); + } + + childSetAction("btn_delete", onClickDelete, this); + childSetAction("btn_add", onClickAdd, this); + childSetAction("btn_copy", onClickCopy, this); + childSetAction("btn_ok", onClickOk, this); + childSetAction("btn_apply", onClickApply, this); + // childSetAction("set_default", onClickDefault, this); // We use the last selected grid as the default + childSetAction("btn_cancel", onClickCancel, this); + childSetAction("btn_clear", onClickClear, this); + childSetAction("btn_gridinfo", onClickGridInfo, this); + // childSetAction("btn_help_render_compat", onClickHelpRenderCompat, this); // Ugly ugly ugly + + childSetCommitCallback("grid_selector", onSelectGrid, this); + LLScrollListCtrl* combo = getChild("grid_selector"); + combo->setFocus(TRUE); + + refreshGrids(); + + return TRUE; +} + +void FloaterGridManager::refreshGrids() +{ + const std::string &defaultGrid = gHippoGridManager->getDefaultGridNick(); + LLScrollListCtrl *grids = FloaterGridManager::getInstance()->getChild("grid_selector"); + grids->deleteAllItems(); + + S32 selectIndex = -1; + S32 i = 0; + if (defaultGrid != "") + { + LLSD value; + value["id"] = defaultGrid; + value["columns"][0]["column"] = "grid"; + value["columns"][0]["value"] = defaultGrid; + grids->addElement(value); + selectIndex = i++; + } + + HippoGridManager::GridIterator it = gHippoGridManager->beginGrid(); + HippoGridManager::GridIterator end = gHippoGridManager->endGrid(); + for (it; it != end; ++it) + { + const std::string &grid = it->second->getGridNick(); + if (grid != defaultGrid) + { + LLSD value; + value["id"] = grid; + value["columns"][0]["column"] = "grid"; + value["columns"][0]["value"] = grid; + grids->addElement(value); + + if (grid == FloaterGridManager::getInstance()->getCurGrid()) + { + selectIndex = i; + } + i++; + } + } + + if ((FloaterGridManager::getInstance()->getState() == ADD_NEW) || (FloaterGridManager::getInstance()->getState() == ADD_COPY)) + { + grids->addElement(""); + selectIndex = i++; + } + + //if (selectIndex >= 0) + //{ + // grids->setCurrentByIndex(selectIndex); + //} + //else + //{ + // grids->setLabel(LLStringExplicit("")); // LLComboBox::removeall() does not clear the label + //} + + // FloaterGridManager::getInstance()->childSetTextArg("default_grid", "[DEFAULT]", (defaultGrid != "")? defaultGrid: " "); + + FloaterGridManager::getInstance()->childSetEnabled("btn_delete", (selectIndex >= 0)); + FloaterGridManager::getInstance()->childSetEnabled("btn_copy", (FloaterGridManager::getInstance()->getState() == NORMAL) && (selectIndex >= 0)); + // FloaterGridManager::getInstance()->childSetEnabled("set_default", (FloaterGridManager::getInstance()->getState() == NORMAL) && (selectIndex > 0)); + FloaterGridManager::getInstance()->childSetEnabled("gridnick", (FloaterGridManager::getInstance()->getState() == ADD_NEW) || (FloaterGridManager::getInstance()->getState() == ADD_COPY)); + + if (FloaterGridManager::getInstance()->getState() == NORMAL) + { + HippoGridInfo *gridInfo = gHippoGridManager->getGrid(FloaterGridManager::getInstance()->getCurGrid()); + if (gridInfo) + { + FloaterGridManager::getInstance()->childSetText("gridnick", gridInfo->getGridNick()); + //FloaterGridManager::getInstance()->childSetText("grid_name", gridInfo->getGridName()); + FloaterGridManager::getInstance()->childSetText("loginuri", gridInfo->getLoginUri()); + FloaterGridManager::getInstance()->childSetText("loginpage", gridInfo->getLoginPage()); + FloaterGridManager::getInstance()->childSetText("helperuri", gridInfo->getHelperUri()); + FloaterGridManager::getInstance()->childSetText("website", gridInfo->getWebSite()); + FloaterGridManager::getInstance()->childSetText("support", gridInfo->getSupportUrl()); + FloaterGridManager::getInstance()->childSetText("register", gridInfo->getRegisterUrl()); + FloaterGridManager::getInstance()->childSetText("password", gridInfo->getPasswordUrl()); + + // FloaterGridManager::getInstance()->childSetText("first_name", gridInfo->getFirstName()); + // FloaterGridManager::getInstance()->childSetText("last_name", gridInfo->getLastName()); + // if(gridInfo->getAvatarPassword().length() == 32) + // FloaterGridManager::getInstance()->childSetText("avatar_password", std::string(PASSWORD_FILLER)); + // else if(gridInfo->getPasswordUrl().empty()) + // FloaterGridManager::getInstance()->childSetText("avatar_password", std::string("")); + + // if (gridInfo->getPlatform() == HippoGridInfo::PLATFORM_SECONDLIFE) { + // //childSetEnabled("search", false); + // //childSetText("search", LLStringExplicit("")); + // childSetEnabled("render_compat", false); + // childSetValue("render_compat", false); + // } else { + // //childSetEnabled("search", true); + // //childSetText("search", gridInfo->getSearchUrl()); + // childSetEnabled("render_compat", true); + // childSetValue("render_compat", gridInfo->isRenderCompat()); + // } + + } + else + { + std::string empty = ""; + FloaterGridManager::getInstance()->childSetText("gridnick", empty); + FloaterGridManager::getInstance()->childSetText("gridname", empty); + FloaterGridManager::getInstance()->childSetText("loginuri", empty); + FloaterGridManager::getInstance()->childSetText("loginpage", empty); + FloaterGridManager::getInstance()->childSetText("helperuri", empty); + FloaterGridManager::getInstance()->childSetText("website", empty); + // FloaterGridManager::getInstance()->childSetText("first_name", empty); + // FloaterGridManager::getInstance()->childSetText("last_name", empty); + // FloaterGridManager::getInstance()->childSetText("avatar_password", empty); + } + } + else if (FloaterGridManager::getInstance()->getState() == ADD_NEW) + { + llinfos << "mState == ADD_NEW" << llendl; + std::string required = ""; + std::string empty = ""; + FloaterGridManager::getInstance()->childSetText("gridnick", required); + FloaterGridManager::getInstance()->childSetText("gridname", empty); + FloaterGridManager::getInstance()->childSetText("loginuri", required); + FloaterGridManager::getInstance()->childSetText("loginpage", empty); + FloaterGridManager::getInstance()->childSetText("helperuri", empty); + FloaterGridManager::getInstance()->childSetText("website", empty); + FloaterGridManager::getInstance()->childSetText("support", empty); + FloaterGridManager::getInstance()->childSetText("register", empty); + FloaterGridManager::getInstance()->childSetText("password", empty); + // FloaterGridManager::getInstance()->childSetText("first_name", empty); + // FloaterGridManager::getInstance()->childSetText("last_name", empty); + // FloaterGridManager::getInstance()->childSetText("avatar_password", empty); + //childSetEnabled("search", true); + //childSetText("search", empty); + } + else if (FloaterGridManager::getInstance()->getState() == ADD_COPY) + { + llinfos << "mState == ADD_COPY" << llendl; + FloaterGridManager::getInstance()->childSetText("gridnick", LLStringExplicit("")); + } + else + { + llwarns << "Illegal state " << FloaterGridManager::getInstance()->getState() << llendl; + } + return; +} + +void FloaterGridManager::update() +{ + setState(NORMAL); + setCurGrid(gHippoGridManager->getCurrentGridNick()); + refreshGrids(); + //KOW gHippoLimits->setLimits(); +} + +void FloaterGridManager::applyChanges() +{ + HippoGridInfo* gridInfo = gHippoGridManager->getGrid(mCurGrid); + if (gridInfo) + { + if (gridInfo->getGridNick() == childGetValue("gridnick").asString()) + { + gridInfo->setGridName(childGetValue("gridname")); + gridInfo->setLoginUri(childGetValue("loginuri")); + gridInfo->setLoginPage(childGetValue("loginpage")); + gridInfo->setHelperUri(childGetValue("helperuri")); + gridInfo->setWebSite(childGetValue("website")); + gridInfo->setSupportUrl(childGetValue("support")); + gridInfo->setRegisterUrl(childGetValue("register")); + gridInfo->setPasswordUrl(childGetValue("password")); + //gridInfo->setSearchUrl(childGetValue("search")); + gridInfo->setRenderCompat(childGetValue("render_compat")); + + // gridInfo->setFirstName(childGetValue("first_name")); + // gridInfo->setLastName(childGetValue("last_name")); + // if(childGetValue("avatar_password").asString().empty()) + // gridInfo->setAvatarPassword(std::string("")); + // else if(childGetValue("avatar_password").asString() != std::string(PASSWORD_FILLER)) + // { + // // store account authentication data + // std::string auth_password = childGetValue("avatar_password"); + // std::string hashed_password; + // hashPassword(auth_password, hashed_password); + // gridInfo->setAvatarPassword(hashed_password); + // } + + //this bug was a feature -Patrick Sapinski (Friday, August 21, 2009) + //LLPanelLogin::setFields(gridInfo->getFirstName(), gridInfo->getLastName(), + // gridInfo->getAvatarPassword(), true); + } + else + { + llwarns << "Grid nickname mismatch, ignoring changes." << llendl; + } + } +} + + +bool FloaterGridManager::createNewGrid() +{ + // check nickname + std::string gridnick = childGetValue("gridnick"); + if (gridnick == "") + { + gridnick = ""; + } + + if (gridnick.empty()) + { + //KOW gViewerWindow->alertXml("GridsNoNick"); + return false; + } + + if (gHippoGridManager->getGrid(gridnick)) + { + //LLStringUtil::format_map_t args; + //args["[NAME]"] = gridnick; + //KOW gViewerWindow->alertXml("GridExists", args); + return false; + } + + // check login URI + std::string loginuri = childGetValue("loginuri"); + if ((loginuri.empty()) || (loginuri == "")) + { + //LLStringUtil::format_map_t args; + //args["[NAME]"] = gridnick; + //KOW gViewerWindow->alertXml("GridsNoLoginUri", args); + return false; + } + + // create new grid + HippoGridInfo* grid = new HippoGridInfo(gridnick); + grid->setGridName(childGetValue("gridname")); + grid->setLoginUri(loginuri); + grid->setLoginPage(childGetValue("loginpage")); + grid->setHelperUri(childGetValue("helperuri")); + grid->setWebSite(childGetValue("website")); + grid->setSupportUrl(childGetValue("support")); + grid->setRegisterUrl(childGetValue("register")); + grid->setPasswordUrl(childGetValue("password")); + //grid->setSearchUrl(childGetValue("search")); + grid->setRenderCompat(childGetValue("render_compat")); + gHippoGridManager->addGrid(grid); + + // grid->setFirstName(childGetValue("first_name")); + // grid->setLastName(childGetValue("last_name")); + // if(childGetValue("avatar_password").asString().empty()) + // grid->setAvatarPassword(std::string("")); + // else + // { + // std::string hashed_password; + // hashPassword(childGetValue("avatar_password"), hashed_password); + // grid->setAvatarPassword(hashed_password); + // } + + setCurGrid(gridnick); + return true; +} + +void FloaterGridManager::retrieveGridInfo() +{ + std::string loginuri = childGetValue("loginuri"); + if ((loginuri == "") || (loginuri == "")) + { + //KOW gViewerWindow->alertXml("GridInfoNoLoginUri"); + return; + } + + HippoGridInfo* grid = 0; + bool cleanupGrid = false; + + if (mState == NORMAL) + { + grid = gHippoGridManager->getGrid(mCurGrid); + } + else if ((mState == ADD_NEW) || (mState == ADD_COPY)) + { + grid = new HippoGridInfo(""); + cleanupGrid = true; + } + else + { + llerrs << "Illegal state " << mState << '.' << llendl; + return; + } + if (!grid) + { + llerrs << "Internal error retrieving grid info." << llendl; + return; + } + + grid->setLoginUri(loginuri); + if (grid->retrieveGridInfo()) + { + if (grid->getGridNick() != "") childSetText("gridnick", grid->getGridNick()); + if (grid->getGridName() != "") childSetText("gridname", grid->getGridName()); + if (grid->getLoginUri() != "") childSetText("loginuri", grid->getLoginUri()); + if (grid->getLoginPage() != "") childSetText("loginpage", grid->getLoginPage()); + if (grid->getHelperUri() != "") childSetText("helperuri", grid->getHelperUri()); + if (grid->getWebSite() != "") childSetText("website", grid->getWebSite()); + if (grid->getSupportUrl() != "") childSetText("support", grid->getSupportUrl()); + if (grid->getRegisterUrl() != "") childSetText("register", grid->getRegisterUrl()); + if (grid->getPasswordUrl() != "") childSetText("password", grid->getPasswordUrl()); + //if (grid->getSearchUrl() != "") childSetText("search", grid->getSearchUrl()); + } + else + { + //KOW gViewerWindow->alertXml("GridInfoError"); + } + + if (cleanupGrid) delete grid; +} + +void FloaterGridManager::apply() +{ + if (mState == NORMAL) + { + applyChanges(); + } + else if ((mState == ADD_NEW) || (mState == ADD_COPY)) + { + if (!createNewGrid()) return; + } + else + { + llwarns << "Illegal state " << mState << '.' << llendl; + return; + } + //gHippoGridManager->setCurrentGrid(mCurGrid); + //gHippoGridManager->setDefaultGrid(mCurGrid); + gHippoGridManager->saveFile(); + LLPanelLogin::addServer(LLViewerLogin::getInstance()->getGridLabel()); +} + +//void FloaterGridManager::setDefault() +//{ +// if (mState == NORMAL) +// { +// applyChanges(); +// } +// else if ((mState == ADD_NEW) || (mState == ADD_COPY)) +// { +// if (!createNewGrid()) return; +// } +// else +// { +// llwarns << "Illegal state " << mState << '.' << llendl; +// return; +// } +// gHippoGridManager->setCurrentGrid(mCurGrid); +// gHippoGridManager->setDefaultGrid(mCurGrid); +// gHippoGridManager->saveFile(); +// LLPanelLogin::addServer(LLViewerLogin::getInstance()->getGridLabel()); +//} + +void FloaterGridManager::onSelectGrid(LLUICtrl* ctrl, void* data) +{ + FloaterGridManager* self = (FloaterGridManager*)data; + if (self->getState() == NORMAL) + { + self->applyChanges(); + } + else if ((self->getState() == ADD_NEW) || (self->getState() == ADD_COPY)) + { + if (self->createNewGrid()) + { + self->setState(NORMAL); + } + else + { + //LLScrollListCtrl *grids = self->getChild("grid_selector"); + //grids->setCurrentByIndex(grids->getItemCount() - 1); + return; + } + } + else + { + llwarns << "Illegal state " << self->getState() << llendl; + return; + } + self->setCurGrid(ctrl->getValue().asString()); + self->refreshGrids(); +} + +//static +void FloaterGridManager::onClickDelete(void* data) +{ + //llinfos << "onClickDelete" << llendl; + FloaterGridManager* self = (FloaterGridManager*)data; + if (self->getState() == NORMAL) + { + gHippoGridManager->deleteGrid(self->getCurGrid()); + } + self->update(); +} + +//static +void FloaterGridManager::onClickAdd(void* data) +{ + //llinfos << "onClickAdd" << llendl; + FloaterGridManager* self = (FloaterGridManager*)data; + self->setState(ADD_NEW); + self->refreshGrids(); +} + + +//static +void FloaterGridManager::onClickCopy(void* data) +{ + //llinfos << "onClickCopy" << llendl; + FloaterGridManager* self = (FloaterGridManager*)data; + self->setState(ADD_COPY); + self->refreshGrids(); +} + +// static +void FloaterGridManager::onClickOk(void* data) +{ + FloaterGridManager::getInstance()->apply(); + FloaterGridManager::getInstance()->close(); +} + +//static +void FloaterGridManager::onClickApply(void* data) +{ + FloaterGridManager::getInstance()->apply(); + refreshGrids(); +} + +// static +void FloaterGridManager::onClickClear(void* data) +{ + gHippoGridManager->discardAndReload(); + FloaterGridManager::getInstance()->update(); +} + +//static +//void FloaterGridManager::onClickDefault(void* data) +//{ +// FloaterGridManager::getInstance()->setDefault(); +// FloaterGridManager::getInstance()->refreshGrids(); +//} + +//static +void FloaterGridManager::onClickGridInfo(void* data) +{ + //HippoPanelGrids* self = (HippoPanelGrids*)data; + FloaterGridManager::getInstance()->retrieveGridInfo(); +} + +//static +void FloaterGridManager::onClickCancel(void* data) +{ + FloaterGridManager::getInstance()->close(); +} + +//void FloaterGridManager::setAlwaysRefresh(bool refresh) +//{ +// // wargames 2: dead code, LLPanelLogin compatibility +// return; +//} + +//void FloaterGridManager::refreshLocation( bool force_visible ) +//{ +// llinfos << "refreshLocation called" << llendl; +// +// if (!FloaterGridManager::getInstance()) +// { +// return; +// } + + //LLComboBox* combo = FloaterGridManager::getInstance()->getChild("start_location_combo"); + // + //if (LLURLSimString::parse()) + //{ + // combo->setCurrentByIndex( 3 ); // BUG? Maybe 2? + // combo->setTextEntry(LLURLSimString::FloaterGridManager::getInstance().mSimString); + //} + //else + //{ + // BOOL login_last = gSavedSettings.getBOOL("LoginLastLocation"); + // combo->setCurrentByIndex( login_last ? 1 : 0 ); + //} + // + //BOOL show_start = TRUE; + // + //if (!force_visible) + // show_start = gSavedSettings.getBOOL("ShowStartLocation"); + // + //FloaterGridManager::getInstance()->childSetVisible("start_location_combo", show_start); + //FloaterGridManager::getInstance()->childSetVisible("start_location_text", show_start); + //FloaterGridManager::getInstance()->childSetVisible("server_combo", TRUE); +//} + +//void FloaterGridManager::newShow(const std::string &grid, bool initialLogin) +//{ +// llinfos << "newShow called" << llendl; +// /*if (!FloaterGridManager::getInstance()) +// { +// FloaterGridManager::sGrid = grid; +// FloaterGridManager::sIsInitialLogin = initialLogin; +// FloaterGridManager::getInstance() = new FloaterGridManager(); +// +// llinfos << "FloaterGridManager::getInstance() assigned. FloaterGridManager::getInstance()=" << FloaterGridManager::getInstance() << llendl; +// }*/ +// +// llinfos << "newshow called" << llendl; +// FloaterGridManager::getInstance()->setCurGrid(gHippoGridManager->getCurrentGridNick()); +// refreshGrids(); +// +// FloaterGridManager::getInstance()->open(); +// // we're important +// //FloaterGridManager::getInstance()->setFrontmost(TRUE); +// //FloaterGridManager::getInstance()->setFocus(TRUE); +// +//} + +//void FloaterGridManager::show(const LLRect &rect, BOOL show_server, +// void (*callback)(S32 option, void* user_data), +// void* callback_data) +//{ +// // we don't need a grid passed in because this is old-style login +// std::string grid = ""; +// newShow(grid, TRUE); +//} + +//void FloaterGridManager::setFocus(BOOL b) +//{ +// if(b != hasFocus()) +// { +// if(b) +// { +// FloaterGridManager::giveFocus(); +// } +// else +// { +// LLPanel::setFocus(b); +// } +// } +//} +// +//void FloaterGridManager::giveFocus() +//{ +// LLScrollListCtrl *combo = NULL; +// +// if (!FloaterGridManager::getInstance()) +// { +// llinfos << "giveFocus has no FloaterGridManager instance. FloaterGridManager::getInstance()=" << FloaterGridManager::getInstance() << llendl; +// return; +// } +// +// // for our combo box approach, selecting the combo box is almost always +// // the right thing to do on the floater receiving focus +// combo = FloaterGridManager::getInstance()->getChild("grid_selector"); +// combo->setFocus(TRUE); +//} + +BOOL FloaterGridManager::isGridComboDirty() +{ + BOOL user_picked = FALSE; + if (!FloaterGridManager::getInstance()) + { + llwarns << "Attempted getServer with no login view shown" << llendl; + } + else + { + LLComboBox* combo = FloaterGridManager::getInstance()->getChild("server_combo"); + user_picked = combo->isDirty(); + } + return user_picked; +} + +void FloaterGridManager::getLocation(std::string &location) +{ + if (!FloaterGridManager::getInstance()) + { + llwarns << "Attempted getLocation with no login view shown" << llendl; + return; + } + + LLComboBox* combo = FloaterGridManager::getInstance()->getChild("start_location_combo"); + location = combo->getValue().asString(); +} + +std::string& FloaterGridManager::getPassword() +{ + return mMungedPassword; +} + +void FloaterGridManager::setPassword(std::string &password) +{ + mMungedPassword = password; +} + +bool FloaterGridManager::isSamePassword(std::string &password) +{ + return mMungedPassword == password; +} + +//void FloaterGridManager::addServer(const std::string& server, S32 domain_name) +//{ +// if (!FloaterGridManager::getInstance()) +// { +// llwarns << "Attempted addServer with no login view shown" << llendl; +// return; +// } +// +// /*LLComboBox* combo = FloaterGridManager::getInstance()->getChild("server_combo"); +// combo->add(server, LLSD(domain_name) ); +// combo->setCurrentByIndex(0);*/ +//} + +//void FloaterGridManager::cancel_old() +//{ +// if (!FloaterGridManager::getInstance()) +// { +// return; +// } +// +// if (FloaterGridManager::getInstance()->sIsInitialLogin) +// { +// // send a callback that indicates we're quitting or closing +// if (FloaterGridManager::getInstance()->mCallback) +// FloaterGridManager::getInstance()->mCallback(LOGIN_OPTION_QUIT, FloaterGridManager::getInstance()->mCallbackData); +// return; +// } +// +// FloaterGridManager::getInstance()->close(); +//} + +void FloaterGridManager::hashPassword(const std::string& password, std::string& hashedPassword) +{ + // Max "actual" password length is 16 characters. + // Hex digests are always 32 characters. + if (password.length() == 32) + { + hashedPassword = password; + } + else + { + // this is a normal text password + LLMD5 pass((unsigned char *)password.c_str()); + char munged_password[MD5HEX_STR_SIZE]; + pass.hex_digest(munged_password); + hashedPassword = munged_password; + } +} diff --git a/linden/indra/newview/floatergridmanager.h b/linden/indra/newview/floatergridmanager.h new file mode 100644 index 0000000..16720bd --- /dev/null +++ b/linden/indra/newview/floatergridmanager.h @@ -0,0 +1,93 @@ +/* + * floatergridmanager.h + * This is Meerkats grid manager. + * -Patrick Sapinski (Monday, August 17, 2009) + * + * Modified by McCabe Maxsted for Imprudence + */ + +#ifndef PL_floaterlogin_H +#define PL_floaterlogin_H + +#define LOGIN_OPTION_CONNECT 0 +#define LOGIN_OPTION_QUIT 1 + +#include "llfloater.h" + +class LoginController; +class AuthenticationModel; + +class FloaterGridManager : public LLFloater, public LLFloaterSingleton +{ +public: + FloaterGridManager(const LLSD& key); + virtual ~FloaterGridManager(); + + /*virtual*/ BOOL postBuild(); + + static void refreshGrids(); + void apply(); + //void setDefault(); + void cancel(); + + // new-style login methods + virtual std::string& getPassword(); + virtual void setPassword(std::string &password); + virtual bool isSamePassword(std::string &password); + static void getFields(std::string &loginname, std::string &password, + BOOL &remember); + static void setFields(const std::string &loginname, const std::string &password, + BOOL remember); + + // LLLoginPanel compatibility + /*static void setAlwaysRefresh(bool refresh); + static void refreshLocation(bool force_visible); + virtual void setFocus(BOOL b); + static void giveFocus();*/ + static void getLocation(std::string &location); + static BOOL isGridComboDirty(); + //static void addServer(const std::string& server, S32 domain_name); + static void hashPassword(const std::string& password, std::string& hashedPassword); +protected: + static bool sIsInitialLogin; + static std::string sGrid; +private: + enum State + { + NORMAL, + ADD_NEW, + ADD_COPY + }; + + State mState; + void setState(const State& state) { mState = state; } + State getState() { return mState; } + + std::string mCurGrid; + void setCurGrid(const std::string& grid) { mCurGrid = grid; } + std::string getCurGrid() { return mCurGrid; } + + std::string mIncomingPassword; + std::string mMungedPassword; + + void applyChanges(); + bool createNewGrid(); + void update(); + void retrieveGridInfo(); + + static void onSelectGrid(LLUICtrl* ctrl, void* data); + static void onClickDelete(void* data); + static void onClickAdd(void* data); + static void onClickCopy(void* data); + static void onClickOk(void* data); + static void onClickApply(void* data); + static void onClickDefault(void* data); + static void onClickGridInfo(void* data); + static void onClickCancel(void* data); + static void onClickClear(void* data); + + static LoginController* sController; + static AuthenticationModel* sModel; +}; + +#endif // PL_floaterlogin_H diff --git a/linden/indra/newview/floaterlogin.cpp b/linden/indra/newview/floaterlogin.cpp deleted file mode 100644 index 78aa0a2..0000000 --- a/linden/indra/newview/floaterlogin.cpp +++ /dev/null @@ -1,722 +0,0 @@ -/* - * floaterlogin.cpp (floatergridmanager.cpp pls) - * This is Meerkats grid manager, and I accidentally finished it with the wrong name :) - * -Patrick Sapinski (Monday, August 17, 2009) - */ - -#include "llviewerprecompiledheaders.h" - -#include -#include "llviewercontrol.h" -#include "llcombobox.h" -#include "llscrolllistctrl.h" -#include "llmd5.h" -#include "llurlsimstring.h" -#include "lluictrlfactory.h" -#include "floaterlogin.h" -#include "hippoGridManager.h" -#include "llviewernetwork.h" -#include "llpanellogin.h" - -#define PASSWORD_FILLER "123456789!123456" - -LoginFloater* LoginFloater::sInstance = NULL; -LoginController* LoginFloater::sController = NULL; -bool LoginFloater::sIsInitialLogin; -std::string LoginFloater::sGrid; - -LoginFloater::LoginFloater() -: LLFloater("floater_login") -{ - - mState = NORMAL; - LLUICtrlFactory::getInstance()->buildFloater(this, "floater_login.xml"); - - - llwarns << "LoginFloater called" << llendl; - - - // configure the floater interface for non-initial login - setCanMinimize(!sIsInitialLogin); - setCanClose(!sIsInitialLogin); - setCanDrag(!sIsInitialLogin); - childSetVisible("server_combo", sIsInitialLogin); - - if(!sIsInitialLogin) - { - LLButton* quit_btn = getChild("quit_btn"); - quit_btn->setLabel(std::string("Cancel")); - setTitle(std::string("Grid Manager")); - } - - center(); - LLLineEditor* edit = getChild("avatar_password_edit"); - if (edit) edit->setDrawAsterixes(TRUE); - LLComboBox* combo = getChild("start_location_combo"); - combo->setAllowTextEntry(TRUE, 128, FALSE); - - BOOL login_last = gSavedSettings.getBOOL("LoginLastLocation"); - std::string sim_string = LLURLSimString::sInstance.mSimString; - if (!sim_string.empty()) - { - // Replace "" with this region name - combo->remove(2); - combo->add( sim_string ); - combo->setTextEntry(sim_string); - combo->setCurrentByIndex( 2 ); - } - else if (login_last) - { - combo->setCurrentByIndex( 1 ); - } - else - { - combo->setCurrentByIndex( 0 ); - } -} - - -LoginFloater::~LoginFloater() -{ - LoginFloater::sController = NULL; - LoginFloater::sInstance = NULL; -} - -void LoginFloater::close() -{ - if(sInstance) - { - delete sInstance; - sInstance = NULL; - } -} - -BOOL LoginFloater::postBuild() -{ - requires("grid_selector"); - requires("gridnick"); - requires("gridname"); - requires("loginuri"); - requires("loginpage"); - requires("helperuri"); - requires("website"); - requires("support"); - requires("register"); - requires("password"); - requires("first_name"); - requires("last_name"); - requires("avatar_password"); - //requires("search"); - requires("btn_delete"); - requires("btn_add"); - requires("btn_copy"); - requires("set_default"); - requires("btn_gridinfo"); - requires("btn_help_render_compat"); - if (!checkRequirements()) return false; - LLLineEditor* password_edit = getChild("avatar_password"); - if (password_edit) password_edit->setDrawAsterixes(TRUE); - - childSetAction("btn_delete", onClickDelete, this); - childSetAction("btn_add", onClickAdd, this); - childSetAction("btn_copy", onClickCopy, this); - childSetAction("btn_ok", onClickOk, this); - childSetAction("btn_apply", onClickApply, this); - // childSetAction("set_default", onClickDefault, this); - childSetAction("btn_cancel", onClickCancel, this); - childSetAction("btn_gridinfo", onClickGridInfo, this); - // childSetAction("btn_help_render_compat", onClickHelpRenderCompat, this); - - childSetCommitCallback("grid_selector", onSelectGrid, this); -//KOW childSetCommitCallback("platform", onSelectPlatform, this); - - // !!!### server_choice_combo->setFocusLostCallback(onServerComboLostFocus); - -//KOW update(); - return TRUE; -} - -void LoginFloater::refresh_grids() -{ - const std::string &defaultGrid = gHippoGridManager->getDefaultGridNick(); - LLScrollListCtrl *grids = sInstance->getChild("grid_selector"); - S32 selectIndex = -1, i = 0; - grids->deleteAllItems(); - if (defaultGrid != "") { - LLSD value; - value["id"] = defaultGrid; - value["columns"][0]["column"] = "grid"; - value["columns"][0]["value"] = defaultGrid; - grids->addElement(value); - selectIndex = i++; - } - - HippoGridManager::GridIterator it, end = gHippoGridManager->endGrid(); - for (it = gHippoGridManager->beginGrid(); it != end; ++it) { - const std::string &grid = it->second->getGridNick(); - if (grid != defaultGrid) { - LLSD value; - value["id"] = grid; - value["columns"][0]["column"] = "grid"; - value["columns"][0]["value"] = grid; - grids->addElement(value); - - if (grid == sInstance->mCurGrid) selectIndex = i; - i++; - } - } - if ((sInstance->mState == ADD_NEW) || (sInstance->mState == ADD_COPY)) { - grids->addElement(""); - selectIndex = i++; - } - if (selectIndex >= 0) { - //grids->setCurrentByIndex(selectIndex); - } else { - //grids->setLabel(LLStringExplicit("")); // LLComboBox::removeall() does not clear the label - } - - // sInstance->childSetTextArg("default_grid", "[DEFAULT]", (defaultGrid != "")? defaultGrid: " "); - - sInstance->childSetEnabled("btn_delete", (selectIndex >= 0)); - sInstance->childSetEnabled("btn_copy", (sInstance->mState == NORMAL) && (selectIndex >= 0)); - // sInstance->childSetEnabled("set_default", (sInstance->mState == NORMAL) && (selectIndex > 0)); - sInstance->childSetEnabled("gridnick", (sInstance->mState == ADD_NEW) || (sInstance->mState == ADD_COPY)); - - if (sInstance->mState == NORMAL) { - HippoGridInfo *gridInfo = gHippoGridManager->getGrid(sInstance->mCurGrid); - if (gridInfo) { - sInstance->childSetText("gridnick", gridInfo->getGridNick()); - //sInstance->childSetText("grid_name", gridInfo->getGridName()); - sInstance->childSetText("loginuri", gridInfo->getLoginUri()); - sInstance->childSetText("loginpage", gridInfo->getLoginPage()); - sInstance->childSetText("helperuri", gridInfo->getHelperUri()); - sInstance->childSetText("website", gridInfo->getWebSite()); - sInstance->childSetText("support", gridInfo->getSupportUrl()); - sInstance->childSetText("register", gridInfo->getRegisterUrl()); - sInstance->childSetText("password", gridInfo->getPasswordUrl()); - - // sInstance->childSetText("first_name", gridInfo->getFirstName()); - // sInstance->childSetText("last_name", gridInfo->getLastName()); - // if(gridInfo->getAvatarPassword().length() == 32) - // sInstance->childSetText("avatar_password", std::string(PASSWORD_FILLER)); - // else if(gridInfo->getPasswordUrl().empty()) - // sInstance->childSetText("avatar_password", std::string("")); - - // if (gridInfo->getPlatform() == HippoGridInfo::PLATFORM_SECONDLIFE) { - // //childSetEnabled("search", false); - // //childSetText("search", LLStringExplicit("")); - // childSetEnabled("render_compat", false); - // childSetValue("render_compat", false); - // } else { - // //childSetEnabled("search", true); - // //childSetText("search", gridInfo->getSearchUrl()); - // childSetEnabled("render_compat", true); - // childSetValue("render_compat", gridInfo->isRenderCompat()); - // } - - } else { - std::string empty = ""; - sInstance->childSetText("gridnick", empty); - sInstance->childSetText("gridname", empty); - sInstance->childSetText("loginuri", empty); - sInstance->childSetText("loginpage", empty); - sInstance->childSetText("helperuri", empty); - sInstance->childSetText("website", empty); - // sInstance->childSetText("first_name", empty); - // sInstance->childSetText("last_name", empty); - // sInstance->childSetText("avatar_password", empty); - } - } else if (sInstance->mState == ADD_NEW) { - llwarns << "ADD_NEW" << llendl; - std::string required = ""; - std::string empty = ""; - sInstance->childSetText("gridnick", required); - sInstance->childSetText("gridname", empty); - sInstance->childSetText("loginuri", required); - sInstance->childSetText("loginpage", empty); - sInstance->childSetText("helperuri", empty); - sInstance->childSetText("website", empty); - sInstance->childSetText("support", empty); - sInstance->childSetText("register", empty); - sInstance->childSetText("password", empty); - // sInstance->childSetText("first_name", empty); - // sInstance->childSetText("last_name", empty); - // sInstance->childSetText("avatar_password", empty); - //childSetEnabled("search", true); - //childSetText("search", empty); - } else if (sInstance->mState == ADD_COPY) { - llwarns << "ADD_COPY" << llendl; - sInstance->childSetText("gridnick", LLStringExplicit("")); - } else { - llwarns << "Illegal state " << sInstance->mState << '.' << llendl; - } - return; -} - -void LoginFloater::update() -{ - mState = NORMAL; - mCurGrid = gHippoGridManager->getCurrentGridNick(); - refresh_grids(); - //KOW gHippoLimits->setLimits(); -} - -void LoginFloater::applyChanges() -{ - HippoGridInfo *gridInfo = gHippoGridManager->getGrid(mCurGrid); - if (gridInfo) - { - if (gridInfo->getGridNick() == childGetValue("gridnick").asString()) - { - gridInfo->setGridName(childGetValue("gridname")); - gridInfo->setLoginUri(childGetValue("loginuri")); - gridInfo->setLoginPage(childGetValue("loginpage")); - gridInfo->setHelperUri(childGetValue("helperuri")); - gridInfo->setWebSite(childGetValue("website")); - gridInfo->setSupportUrl(childGetValue("support")); - gridInfo->setRegisterUrl(childGetValue("register")); - gridInfo->setPasswordUrl(childGetValue("password")); - //gridInfo->setSearchUrl(childGetValue("search")); - gridInfo->setRenderCompat(childGetValue("render_compat")); - - // gridInfo->setFirstName(childGetValue("first_name")); - // gridInfo->setLastName(childGetValue("last_name")); - // if(childGetValue("avatar_password").asString().empty()) - // gridInfo->setAvatarPassword(std::string("")); - // else if(childGetValue("avatar_password").asString() != std::string(PASSWORD_FILLER)) - // { - // // store account authentication data - // std::string auth_password = childGetValue("avatar_password"); - // std::string hashed_password; - // hashPassword(auth_password, hashed_password); - // gridInfo->setAvatarPassword(hashed_password); - // } - - //this bug was a feature -Patrick Sapinski (Friday, August 21, 2009) - //LLPanelLogin::setFields(gridInfo->getFirstName(), gridInfo->getLastName(), - // gridInfo->getAvatarPassword(), true); - } - else - { - llwarns << "Grid nickname mismatch, ignoring changes." << llendl; - } - } -} - - -bool LoginFloater::createNewGrid() -{ - // check nickname - std::string gridnick = childGetValue("gridnick"); - if (gridnick == "") gridnick = ""; - if (gridnick == "") { - //KOW gViewerWindow->alertXml("GridsNoNick"); - return false; - } - if (gHippoGridManager->getGrid(gridnick)) { - LLStringUtil::format_map_t args; - args["[NAME]"] = gridnick; - //KOW gViewerWindow->alertXml("GridExists", args); - return false; - } - - // check login URI - std::string loginuri = childGetValue("loginuri"); - if ((loginuri == "") || (loginuri == "")) { - LLStringUtil::format_map_t args; - args["[NAME]"] = gridnick; - //KOW gViewerWindow->alertXml("GridsNoLoginUri", args); - return false; - } - - // create new grid - HippoGridInfo *grid = new HippoGridInfo(gridnick); - grid->setGridName(childGetValue("gridname")); - grid->setLoginUri(loginuri); - grid->setLoginPage(childGetValue("loginpage")); - grid->setHelperUri(childGetValue("helperuri")); - grid->setWebSite(childGetValue("website")); - grid->setSupportUrl(childGetValue("support")); - grid->setRegisterUrl(childGetValue("register")); - grid->setPasswordUrl(childGetValue("password")); - //grid->setSearchUrl(childGetValue("search")); - grid->setRenderCompat(childGetValue("render_compat")); - gHippoGridManager->addGrid(grid); - - // grid->setFirstName(childGetValue("first_name")); - // grid->setLastName(childGetValue("last_name")); - // if(childGetValue("avatar_password").asString().empty()) - // grid->setAvatarPassword(std::string("")); - // else - // { - // std::string hashed_password; - // hashPassword(childGetValue("avatar_password"), hashed_password); - // grid->setAvatarPassword(hashed_password); - // } - - mCurGrid = gridnick; - return true; -} - -void LoginFloater::retrieveGridInfo() -{ - std::string loginuri = childGetValue("loginuri"); - if ((loginuri == "") || (loginuri == "")) { - //KOW gViewerWindow->alertXml("GridInfoNoLoginUri"); - return; - } - - HippoGridInfo *grid = 0; - bool cleanupGrid = false; - if (mState == NORMAL) { - grid = gHippoGridManager->getGrid(mCurGrid); - } else if ((mState == ADD_NEW) || (mState == ADD_COPY)) { - grid = new HippoGridInfo(""); - cleanupGrid = true; - } else { - llerrs << "Illegal state " << mState << '.' << llendl; - return; - } - if (!grid) { - llerrs << "Internal error retrieving grid info." << llendl; - return; - } - - grid->setLoginUri(loginuri); - if (grid->retrieveGridInfo()) { - if (grid->getGridNick() != "") childSetText("gridnick", grid->getGridNick()); - if (grid->getGridName() != "") childSetText("gridname", grid->getGridName()); - if (grid->getLoginUri() != "") childSetText("loginuri", grid->getLoginUri()); - if (grid->getLoginPage() != "") childSetText("loginpage", grid->getLoginPage()); - if (grid->getHelperUri() != "") childSetText("helperuri", grid->getHelperUri()); - if (grid->getWebSite() != "") childSetText("website", grid->getWebSite()); - if (grid->getSupportUrl() != "") childSetText("support", grid->getSupportUrl()); - if (grid->getRegisterUrl() != "") childSetText("register", grid->getRegisterUrl()); - if (grid->getPasswordUrl() != "") childSetText("password", grid->getPasswordUrl()); - //if (grid->getSearchUrl() != "") childSetText("search", grid->getSearchUrl()); - } else { - //KOW gViewerWindow->alertXml("GridInfoError"); - } - - if (cleanupGrid) delete grid; -} - -void LoginFloater::apply() -{ - if (mState == NORMAL) { - applyChanges(); - } else if ((mState == ADD_NEW) || (mState == ADD_COPY)) { - if (!createNewGrid()) return; - } else { - llwarns << "Illegal state " << mState << '.' << llendl; - return; - } - //gHippoGridManager->setCurrentGrid(mCurGrid); - //gHippoGridManager->setDefaultGrid(mCurGrid); - //LLPanelLogin::refreshLoginPage(); - gHippoGridManager->saveFile(); - LLPanelLogin::addServer(LLViewerLogin::getInstance()->getGridLabel()); -} - -void LoginFloater::setDefault() -{ - if (mState == NORMAL) { - applyChanges(); - } else if ((mState == ADD_NEW) || (mState == ADD_COPY)) { - if (!createNewGrid()) return; - } else { - llwarns << "Illegal state " << mState << '.' << llendl; - return; - } - gHippoGridManager->setCurrentGrid(mCurGrid); - gHippoGridManager->setDefaultGrid(mCurGrid); - gHippoGridManager->saveFile(); - LLPanelLogin::addServer(LLViewerLogin::getInstance()->getGridLabel()); -} - -void LoginFloater::cancel() -{ - gHippoGridManager->discardAndReload(); - update(); -} - -void LoginFloater::onSelectGrid(LLUICtrl* ctrl, void *data) -{ - LoginFloater* self = (LoginFloater*)data; - if (self->mState == NORMAL) { - self->applyChanges(); - } else if ((self->mState == ADD_NEW) || (self->mState == ADD_COPY)) { - if (self->createNewGrid()) { - self->mState = NORMAL; - } else { - //LLScrollListCtrl *grids = self->getChild("grid_selector"); - //grids->setCurrentByIndex(grids->getItemCount() - 1); - return; - } - } else { - llwarns << "Illegal state " << self->mState << '.' << llendl; - return; - } - self->mCurGrid = ctrl->getValue().asString(); - self->refresh_grids(); -} - -//static -void LoginFloater::onClickDelete(void *data) -{ - llwarns << "onclickdelete" << llendl; - LoginFloater* self = (LoginFloater*)data; - if (self->mState == NORMAL) - gHippoGridManager->deleteGrid(self->mCurGrid); - self->update(); -} - -//static -void LoginFloater::onClickAdd(void *data) -{ - llwarns << "add" << llendl; - LoginFloater* self = (LoginFloater*)data; - self->mState = ADD_NEW; - self->refresh_grids(); -} - - -//static -void LoginFloater::onClickCopy(void *data) -{ - llwarns << "copy" << llendl; - LoginFloater* self = (LoginFloater*)data; - self->mState = ADD_COPY; - self->refresh_grids(); -} - -// static -void LoginFloater::onClickOk(void* data) -{ - if(NULL==sInstance) - return; - - sInstance->apply(); - sInstance->close(); -} - -//static -void LoginFloater::onClickApply(void *data) -{ - if(NULL==sInstance) - return; - - sInstance->apply(); - refresh_grids(); -} - -//static -void LoginFloater::onClickDefault(void *data) -{ - sInstance->setDefault(); - sInstance->refresh_grids(); -} - -//static -void LoginFloater::onClickGridInfo(void *data) -{ - //HippoPanelGrids* self = (HippoPanelGrids*)data; - sInstance->retrieveGridInfo(); -} - -//static -void LoginFloater::onClickCancel(void *data) -{ - sInstance->cancel(); -} - -void LoginFloater::setAlwaysRefresh(bool refresh) -{ - // wargames 2: dead code, LLPanelLogin compatibility - return; -} - -void LoginFloater::refreshLocation( bool force_visible ) -{ - - llwarns << "refreshLocation called" << llendl; - - if (!sInstance) return; - - LLComboBox* combo = sInstance->getChild("start_location_combo"); - - if (LLURLSimString::parse()) - { - combo->setCurrentByIndex( 3 ); // BUG? Maybe 2? - combo->setTextEntry(LLURLSimString::sInstance.mSimString); - } - else - { - BOOL login_last = gSavedSettings.getBOOL("LoginLastLocation"); - combo->setCurrentByIndex( login_last ? 1 : 0 ); - } - - BOOL show_start = TRUE; - - if ( ! force_visible ) - show_start = gSavedSettings.getBOOL("ShowStartLocation"); - - sInstance->childSetVisible("start_location_combo", show_start); - sInstance->childSetVisible("start_location_text", show_start); - sInstance->childSetVisible("server_combo", TRUE); -} - -void LoginFloater::newShow(const std::string &grid, bool initialLogin) -{ - - llwarns << "newShow called" << llendl; - if(NULL==sInstance) - { - LoginFloater::sGrid = grid; - LoginFloater::sIsInitialLogin = initialLogin; - sInstance = new LoginFloater(); - - llwarns << "sInstance assigned. sInstance=" << sInstance << llendl; - } - - llwarns << "newshow called" << llendl; - sInstance->mCurGrid = gHippoGridManager->getCurrentGridNick(); - refresh_grids(); - - sInstance->open(); /*Flawfinder: ignore*/ - // we're important - //sInstance->setFrontmost(TRUE); - //sInstance->setFocus(TRUE); - -} - -void LoginFloater::show(const LLRect &rect, BOOL show_server, - void (*callback)(S32 option, void* user_data), - void* callback_data) -{ - // we don't need a grid passed in because this is old-style login - std::string grid = ""; - newShow(grid, TRUE); -} - -void LoginFloater::setFocus(BOOL b) -{ - if(b != hasFocus()) - { - if(b) - { - LoginFloater::giveFocus(); - } - else - { - LLPanel::setFocus(b); - } - } -} - -void LoginFloater::giveFocus() -{ - LLScrollListCtrl *combo = NULL; - - if(NULL==sInstance) - { - llwarns << "giveFocus has no LoginFloater instance. sInstance=" << sInstance << llendl; - return; - } - - // for our combo box approach, selecting the combo box is almost always - // the right thing to do on the floater receiving focus - combo = sInstance->getChild("grid_selector"); - combo->setFocus(TRUE); -} - -BOOL LoginFloater::isGridComboDirty() -{ - BOOL user_picked = FALSE; - if (!sInstance) - { - llwarns << "Attempted getServer with no login view shown" << llendl; - } - else - { - LLComboBox* combo = sInstance->getChild("server_combo"); - user_picked = combo->isDirty(); - } - return user_picked; -} - -void LoginFloater::getLocation(std::string &location) -{ - if (!sInstance) - { - llwarns << "Attempted getLocation with no login view shown" << llendl; - return; - } - - LLComboBox* combo = sInstance->getChild("start_location_combo"); - location = combo->getValue().asString(); -} - -std::string& LoginFloater::getPassword() -{ - return mMungedPassword; -} - -void LoginFloater::setPassword(std::string &password) -{ - mMungedPassword = password; -} - -bool LoginFloater::isSamePassword(std::string &password) -{ - return mMungedPassword == password; -} - -void LoginFloater::addServer(const std::string& server, S32 domain_name) -{ - if (!sInstance) - { - llwarns << "Attempted addServer with no login view shown" << llendl; - return; - } - - LLComboBox* combo = sInstance->getChild("server_combo"); - combo->add(server, LLSD(domain_name) ); - combo->setCurrentByIndex(0); -} - -void LoginFloater::cancel_old() -{ - if(NULL==sInstance) - return; - - if(sInstance->sIsInitialLogin) - { - // send a callback that indicates we're quitting or closing - if(sInstance->mCallback) - sInstance->mCallback(LOGIN_OPTION_QUIT, sInstance->mCallbackData); - return; - } - - sInstance->close(); -} - -void LoginFloater::hashPassword(const std::string& password, std::string& hashedPassword) -{ - // Max "actual" password length is 16 characters. - // Hex digests are always 32 characters. - if (password.length() == 32) - { - hashedPassword = password; - } - else - { - // this is a normal text password - LLMD5 pass((unsigned char *)password.c_str()); - char munged_password[MD5HEX_STR_SIZE]; - pass.hex_digest(munged_password); - hashedPassword = munged_password; - } - -} - diff --git a/linden/indra/newview/floaterlogin.h b/linden/indra/newview/floaterlogin.h deleted file mode 100644 index cdb60b0..0000000 --- a/linden/indra/newview/floaterlogin.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * floaterlogin.h (floatergridmanager.h pls) - * This is Meerkats grid manager, and I accidentally finished it with the wrong name :) - * -Patrick Sapinski (Monday, August 17, 2009) - */ - -#ifndef PL_floaterlogin_H -#define PL_floaterlogin_H - -#define LOGIN_OPTION_CONNECT 0 -#define LOGIN_OPTION_QUIT 1 - -#include "llfloater.h" - -class LoginController; -class AuthenticationModel; - -class LoginFloater : public LLFloater -{ -public: - LoginFloater(); - virtual ~LoginFloater(); - - virtual BOOL postBuild(); - - static void refresh_grids(); - void apply(); - void setDefault(); - void cancel(); - - // new-style login methods - static void newShow(const std::string &grid, bool initialLogin); - virtual std::string& getPassword(); - virtual void setPassword(std::string &password); - virtual bool isSamePassword(std::string &password); - static void getFields(std::string &loginname, std::string &password, - BOOL &remember); - static void setFields(const std::string &loginname, const std::string &password, - BOOL remember); - - // LLLoginPanel compatibility - //TODO: Make this not suck - static void show(const LLRect &rect, BOOL show_server, - void (*callback)(S32 option, void *user_data), - void *callback_data); - static void close(); - static void setAlwaysRefresh(bool refresh); - static void refreshLocation(bool force_visible); - virtual void setFocus(BOOL b); - static void giveFocus(); - static void getLocation(std::string &location); - static BOOL isGridComboDirty(); - static void addServer(const std::string& server, S32 domain_name); - static void cancel_old(); - static void hashPassword(const std::string& password, std::string& hashedPassword); -protected: - static bool sIsInitialLogin; - static std::string sGrid; -private: - enum State { NORMAL, ADD_NEW, ADD_COPY }; - State mState; - std::string mCurGrid; - - std::string mIncomingPassword; - std::string mMungedPassword; - - void applyChanges(); - bool createNewGrid(); - void update(); - void retrieveGridInfo(); - - static void onSelectGrid(LLUICtrl *ctrl, void *data); - static void onClickDelete(void *data); - static void onClickAdd(void *data); - static void onClickCopy(void *data); - static void onClickOk(void *data); - static void onClickApply(void *data); - static void onClickDefault(void *data); - static void onClickGridInfo(void *data); - static void onClickCancel(void *data); - - static LoginFloater *sInstance; - static LoginController *sController; - static AuthenticationModel *sModel; - - void (*mCallback)(S32 option, void *userdata); - void *mCallbackData; -}; - -#endif // PL_floaterlogin_H diff --git a/linden/indra/newview/llpanellogin.cpp b/linden/indra/newview/llpanellogin.cpp index 8dde683..ea84fee 100644 --- a/linden/indra/newview/llpanellogin.cpp +++ b/linden/indra/newview/llpanellogin.cpp @@ -38,8 +38,7 @@ #include "hippoGridManager.h" #include "hippoLimits.h" - -#include "floaterlogin.h" +#include "floatergridmanager.h" #include "indra_constants.h" // for key and mask constants #include "llfontgl.h" @@ -1006,7 +1005,8 @@ void LLPanelLogin::onClickGrid(void *) { if (sInstance && sInstance->mCallback) { - LoginFloater::newShow(std::string("Test"), false); + FloaterGridManager::getInstance()->open(); + FloaterGridManager::getInstance()->center(); } } diff --git a/linden/indra/newview/skins/default/xui/en-us/floater_grid_manager.xml b/linden/indra/newview/skins/default/xui/en-us/floater_grid_manager.xml new file mode 100644 index 0000000..401780f --- /dev/null +++ b/linden/indra/newview/skins/default/xui/en-us/floater_grid_manager.xml @@ -0,0 +1,263 @@ + + + + + + Select a grid: + + + + + + + +