diff --git a/indra/newview/llpanellogin.cpp b/indra/newview/llpanellogin.cpp index f0a950b40..6f0cdf10c 100644 --- a/indra/newview/llpanellogin.cpp +++ b/indra/newview/llpanellogin.cpp @@ -159,32 +159,22 @@ LLLoginRefreshHandler gLoginRefreshHandler; //--------------------------------------------------------------------------- // Public methods //--------------------------------------------------------------------------- -LLPanelLogin::LLPanelLogin(const LLRect &rect, - void (*callback)(S32 option, void* user_data), - void *cb_data) -: LLPanel(std::string("panel_login"), LLRect(0,600,800,0), FALSE), // not bordered - mLogoImage(), - mCallback(callback), - mCallbackData(cb_data) +LLPanelLogin::LLPanelLogin(const LLRect& rect) +: LLPanel(std::string("panel_login"), rect, FALSE), // not bordered + mLogoImage(LLUI::getUIImage("startup_logo.j2c")) { setFocusRoot(TRUE); setBackgroundVisible(FALSE); setBackgroundOpaque(TRUE); - gViewerWindow->abortShowProgress(); //Kill previous instance. It might still be alive, and if so, its probably pending - //deletion via the progressviews idle callback. Kill it now and unregister said idle callback. - LLPanelLogin::sInstance = this; // add to front so we are the bottom-most child gViewerWindow->getRootView()->addChildInBack(this); - // Logo - mLogoImage = LLUI::getUIImage("startup_logo.j2c"); - LLUICtrlFactory::getInstance()->buildPanel(this, "panel_login.xml"); - + reshape(rect.getWidth(), rect.getHeight()); LLComboBox* username_combo(getChild("username_combo")); @@ -243,12 +233,12 @@ LLPanelLogin::LLPanelLogin(const LLRect &rect, LLPanelLogin::onUpdateStartSLURL(start_slurl); // updates grid if needed } - childSetAction("connect_btn", onClickConnect, this); - setDefaultBtn("connect_btn"); // Also set default button for subpanels, otherwise hitting enter in text entry fields won't login { LLButton* connect_btn(findChild("connect_btn")); + connect_btn->setCommitCallback(boost::bind(&LLPanelLogin::onClickConnect, this)); + setDefaultBtn(connect_btn); findChild("name_panel")->setDefaultBtn(connect_btn); findChild("password_panel")->setDefaultBtn(connect_btn); findChild("grids_panel")->setDefaultBtn(connect_btn); @@ -287,6 +277,24 @@ LLPanelLogin::LLPanelLogin(const LLRect &rect, refreshLoginPage(); gHippoGridManager->setCurrentGridChangeCallback(boost::bind(&LLPanelLogin::onCurGridChange,this,_1,_2)); + + // Load login history + std::string login_hist_filepath = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "saved_logins_sg2.xml"); + mLoginHistoryData = LLSavedLogins::loadFile(login_hist_filepath); + + const LLSavedLoginsList& saved_login_entries(mLoginHistoryData.getEntries()); + for (LLSavedLoginsList::const_reverse_iterator i = saved_login_entries.rbegin(); + i != saved_login_entries.rend(); ++i) + { + LLSD e = i->asLLSD(); + if (e.isMap() && gHippoGridManager->getGrid(i->getGrid())) + username_combo->add(getDisplayString(*i), e); + } + + if (saved_login_entries.size() > 0) + { + setFields(*saved_login_entries.rbegin()); + } } void LLPanelLogin::setSiteIsAlive( bool alive ) @@ -355,24 +363,6 @@ LLPanelLogin::~LLPanelLogin() } } -void LLPanelLogin::setLoginHistory(LLSavedLogins const& login_history) -{ - sInstance->mLoginHistoryData = login_history; - - LLComboBox* login_combo = sInstance->getChild("username_combo"); - llassert(login_combo); - login_combo->clear(); - - LLSavedLoginsList const& saved_login_entries(login_history.getEntries()); - for (LLSavedLoginsList::const_reverse_iterator i = saved_login_entries.rbegin(); - i != saved_login_entries.rend(); ++i) - { - LLSD e = i->asLLSD(); - if (e.isMap() && gHippoGridManager->getGrid(i->getGrid())) - login_combo->add(getDisplayString(*i), e); - } -} - // virtual void LLPanelLogin::draw() { @@ -449,12 +439,6 @@ BOOL LLPanelLogin::handleKeyHere(KEY key, MASK mask) } #endif - if (KEY_RETURN == key && MASK_NONE == mask) - { - // let the panel handle UICtrl processing: calls onClickConnect() - return LLPanel::handleKeyHere(key, mask); - } - return LLPanel::handleKeyHere(key, mask); } @@ -514,11 +498,10 @@ void LLPanelLogin::giveFocus() // static -void LLPanelLogin::show(const LLRect &rect, - void (*callback)(S32 option, void* user_data), - void* callback_data) +void LLPanelLogin::show() { - new LLPanelLogin(rect, callback, callback_data); + if (sInstance) sInstance->setVisible(true); + else new LLPanelLogin(gViewerWindow->getVirtualWindowRect()); if( !gFocusMgr.getKeyboardFocus() ) { @@ -892,28 +875,24 @@ bool LLPanelLogin::getRememberLogin() //--------------------------------------------------------------------------- // static -void LLPanelLogin::onClickConnect(void *) +void LLPanelLogin::onClickConnect() { - if (sInstance && sInstance->mCallback) + // JC - Make sure the fields all get committed. + gFocusMgr.setKeyboardFocus(NULL); + + std::string first, last, password; + if (nameSplit(getChild("username_combo")->getTextEntry(), first, last)) { - - // JC - Make sure the fields all get committed. - gFocusMgr.setKeyboardFocus(NULL); - - std::string first, last, password; - if (nameSplit(sInstance->getChild("username_combo")->getTextEntry(), first, last)) - { - // has both first and last name typed - sInstance->mCallback(0, sInstance->mCallbackData); - } - else - { - if (gHippoGridManager->getCurrentGrid()->getRegisterUrl().empty()) { - LLNotificationsUtil::add("MustHaveAccountToLogInNoLinks"); - } else { - LLNotificationsUtil::add("MustHaveAccountToLogIn", LLSD(), LLSD(), - LLPanelLogin::newAccountAlertCallback); - } + // has both first and last name typed + LLStartUp::setStartupState(STATE_LOGIN_CLEANUP); + } + else + { + if (gHippoGridManager->getCurrentGrid()->getRegisterUrl().empty()) { + LLNotificationsUtil::add("MustHaveAccountToLogInNoLinks"); + } else { + LLNotificationsUtil::add("MustHaveAccountToLogIn", LLSD(), LLSD(), + LLPanelLogin::newAccountAlertCallback); } } } diff --git a/indra/newview/llpanellogin.h b/indra/newview/llpanellogin.h index b1a7ff935..05c4c3b18 100644 --- a/indra/newview/llpanellogin.h +++ b/indra/newview/llpanellogin.h @@ -49,18 +49,15 @@ class LLPanelLogin: { LOG_CLASS(LLPanelLogin); public: - LLPanelLogin(const LLRect &rect, - void (*callback)(S32 option, void* user_data), - void *callback_data); + LLPanelLogin(const LLRect& rect = LLRect()); ~LLPanelLogin(); virtual BOOL handleKeyHere(KEY key, MASK mask); virtual void draw(); virtual void setFocus( BOOL b ); - static void show(const LLRect &rect, - void (*callback)(S32 option, void* user_data), - void* callback_data); + static void show(); + static void hide() { if (sInstance) sInstance->setVisible(false); } // Remember password checkbox is set via gSavedSettings "RememberPassword" @@ -69,7 +66,6 @@ public: * @param firstname First name value. * @param lastname Last name value. * @param password Password, as plaintext or munged. - * @param is_secondlife True if First/Last refer to a SecondLife(tm) account. */ static void setFields(const std::string& firstname, const std::string& lastname, const std::string& password); @@ -110,7 +106,7 @@ private: void reshapeBrowser(); void onLocationSLURL(); - static void onClickConnect(void*); + void onClickConnect(); static void onClickNewAccount(); static bool newAccountAlertCallback(const LLSD& notification, const LLSD& response); static void onClickGrids(void*); @@ -124,10 +120,6 @@ private: static void clearPassword(); public: - /** - * @brief Set the login history data. - */ - static void setLoginHistory(LLSavedLogins const& login_history); /** * @brief Returns the login history data. @@ -144,14 +136,9 @@ public: */ static bool getRememberLogin(); - //static void selectFirstElement(void); - private: LLPointer mLogoImage; - void (*mCallback)(S32 option, void *userdata); - void* mCallbackData; - std::string mIncomingPassword; std::string mMungedPassword; diff --git a/indra/newview/llprogressview.cpp b/indra/newview/llprogressview.cpp index cbaa5d47e..23981e565 100644 --- a/indra/newview/llprogressview.cpp +++ b/indra/newview/llprogressview.cpp @@ -135,13 +135,6 @@ void LLProgressView::revealIntroPanel() gIdleCallbacks.addFunction(onIdle, this); } -void LLProgressView::abortShowProgress() -{ - mFadeFromLoginTimer.stop(); - LLPanelLogin::close(); - gIdleCallbacks.deleteFunction(onIdle, this); -} - void LLProgressView::setStartupComplete() { mStartupComplete = true; @@ -334,7 +327,7 @@ void LLProgressView::onIdle(void* user_data) self->mFadeFromLoginTimer.getElapsedTimeF32() > FADE_TO_WORLD_TIME) { self->mFadeFromLoginTimer.stop(); - LLPanelLogin::close(); + LLPanelLogin::hide(); // Nothing to do anymore. gIdleCallbacks.deleteFunction(onIdle, user_data); diff --git a/indra/newview/llprogressview.h b/indra/newview/llprogressview.h index 816305efd..bff970e29 100644 --- a/indra/newview/llprogressview.h +++ b/indra/newview/llprogressview.h @@ -62,7 +62,6 @@ public: void setMessage(const std::string& msg); void revealIntroPanel(); - void abortShowProgress(); void setStartupComplete(); diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 0cf590cd8..2077ccfec 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -291,8 +291,7 @@ boost::scoped_ptr LLStartUp::sPhases(new LLViewerStats: // local function declaration // -void login_show(LLSavedLogins const& saved_logins); -void login_callback(S32 option, void* userdata); +void login_show(); void show_first_run_dialog(); bool first_run_dialog_callback(const LLSD& notification, const LLSD& response); void set_startup_status(const F32 frac, const std::string& string, const std::string& msg); @@ -882,24 +881,17 @@ bool idle_startup() gViewerWindow->setShowProgress(FALSE); display_startup(); - // Load login history - std::string login_hist_filepath = gDirUtilp->getExpandedFilename(LL_PATH_USER_SETTINGS, "saved_logins_sg2.xml"); - LLSavedLogins login_history = LLSavedLogins::loadFile(login_hist_filepath); - display_startup(); - // Show the login dialog. - login_show(login_history); + login_show(); display_startup(); - if (login_history.size() > 0) - { - LLPanelLogin::setFields(*login_history.getEntries().rbegin()); - } - else + static bool sSetFields(LLPanelLogin::getLoginHistory().size() > 0); // If there were no entries to be loaded, use what's available + if (!sSetFields) { LLPanelLogin::setFields(firstname, lastname, password); + sSetFields = true; // Never reset the fields again! + display_startup(); + LLPanelLogin::giveFocus(); } - display_startup(); - LLPanelLogin::giveFocus(); gSavedSettings.setBOOL("FirstRunThisInstall", FALSE); @@ -1416,6 +1408,7 @@ bool idle_startup() // Yay, login! successful_login = true; Debug(if (gCurlIo) dc::curlio.off()); // Login succeeded: restore dc::curlio to original state. + LLPanelLogin::close(); // Singu Note: Actually destroy the login panel here, otherwise user interaction gets lost upon failed login. } else if(login_response == "indeterminate") { @@ -2712,59 +2705,17 @@ bool idle_startup() // local function definition // -void login_show(LLSavedLogins const& saved_logins) +void login_show() { LL_INFOS("AppInit") << "Initializing Login Screen" << LL_ENDL; // This creates the LLPanelLogin instance. - LLPanelLogin::show( gViewerWindow->getVirtualWindowRect(), - login_callback, NULL ); - - // Now that the LLPanelLogin instance is created, - // store the login history there. - LLPanelLogin::setLoginHistory(saved_logins); + LLPanelLogin::show(); // UI textures have been previously loaded in doPreloadImages() } -// Callback for when login screen is closed. Option 0 = connect, option 1 = quit. -void login_callback(S32 option, void *userdata) -{ - const S32 CONNECT_OPTION = 0; - const S32 QUIT_OPTION = 1; - - if (CONNECT_OPTION == option) - { - LLStartUp::setStartupState( STATE_LOGIN_CLEANUP ); - return; - } - else if (QUIT_OPTION == option) - { - // Make sure we don't save the password if the user is trying to clear it. - std::string first, last, password; - LLPanelLogin::getFields(&first, &last, &password); - if (!gSavedSettings.getBOOL("RememberPassword")) - { - // turn off the setting and write out to disk - gSavedSettings.saveToFile( gSavedSettings.getString("ClientSettingsFile") , TRUE ); - } - - // Next iteration through main loop should shut down the app cleanly. - LLAppViewer::instance()->userQuit(); - - if (LLAppViewer::instance()->quitRequested()) - { - LLPanelLogin::close(); - } - return; - } - else - { - LL_WARNS("AppInit") << "Unknown login button clicked" << LL_ENDL; - } -} - // static std::string LLStartUp::loadPasswordFromDisk() diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 4f2e5c931..e5ae8553c 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -5137,14 +5137,6 @@ void LLViewerWindow::revealIntroPanel() } } -void LLViewerWindow::abortShowProgress() -{ - if (mProgressView) - { - mProgressView->abortShowProgress(); - } -} - void LLViewerWindow::setShowProgress(const BOOL show) { if (mProgressView)