From dc934629919bdcaea72c78e5291263914fb958ec Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Mon, 11 May 2009 20:05:46 +0000 Subject: svn merge -r113003:119136 svn+ssh://svn.lindenlab.com/svn/linden/branches/login-api/login-api-2 svn+ssh://svn.lindenlab.com/svn/linden/branches/login-api/login-api-3 --- indra/newview/lllogininstance.cpp | 532 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 532 insertions(+) create mode 100644 indra/newview/lllogininstance.cpp (limited to 'indra/newview/lllogininstance.cpp') diff --git a/indra/newview/lllogininstance.cpp b/indra/newview/lllogininstance.cpp new file mode 100644 index 0000000000..388bf38d61 --- /dev/null +++ b/indra/newview/lllogininstance.cpp @@ -0,0 +1,532 @@ +/** + * @file lllogininstance.cpp + * @brief Viewer's host for a login connection. + * + * $LicenseInfo:firstyear=2009&license=viewergpl$ + * + * Copyright (c) 2009, Linden Research, Inc. + * + * Second Life Viewer Source Code + * The source code in this file ("Source Code") is provided by Linden Lab + * to you under the terms of the GNU General Public License, version 2.0 + * ("GPL"), unless you have obtained a separate licensing agreement + * ("Other License"), formally executed by you and Linden Lab. Terms of + * the GPL can be found in doc/GPL-license.txt in this distribution, or + * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 + * + * There are special exceptions to the terms and conditions of the GPL as + * it is applied to this Source Code. View the full text of the exception + * in the file doc/FLOSS-exception.txt in this software distribution, or + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception + * + * By copying, modifying or distributing this software, you acknowledge + * that you have read and understood your obligations described above, + * and agree to abide by those obligations. + * + * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO + * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, + * COMPLETENESS OR PERFORMANCE. + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "lllogininstance.h" + +// llcommon +#include "llevents.h" +#include "llmd5.h" +#include "stringize.h" + +// llmessage (!) +#include "llfiltersd2xmlrpc.h" // for xml_escape_string() + +// login +#include "lllogin.h" + +// newview +#include "llviewernetwork.h" +#include "llappviewer.h" // Wish I didn't have to, but... +#include "llviewercontrol.h" +#include "llurlsimstring.h" +#include "llfloatertos.h" +#include "llwindow.h" + +std::string construct_start_string(); + +LLLoginInstance::LLLoginInstance() : + mLoginModule(new LLLogin()), + mLoginState("offline"), + mUserInteraction(true), + mSkipOptionalUpdate(false), + mAttemptComplete(false), + mTransferRate(0.0f) +{ + mLoginModule->getEventPump().listen("lllogininstance", + boost::bind(&LLLoginInstance::handleLoginEvent, this, _1)); +} + +LLLoginInstance::~LLLoginInstance() +{ +} + + +void LLLoginInstance::connect(const LLSD& credentials) +{ + std::vector uris; + LLViewerLogin::getInstance()->getLoginURIs(uris); + connect(uris.front(), credentials); +} + +void LLLoginInstance::connect(const std::string& uri, const LLSD& credentials) +{ + constructAuthParams(credentials); + mLoginModule->connect(uri, mRequestData); +} + +void LLLoginInstance::reconnect() +{ + // Sort of like connect, only using the pre-existing + // request params. + std::vector uris; + LLViewerLogin::getInstance()->getLoginURIs(uris); + mLoginModule->connect(uris.front(), mRequestData); +} + +void LLLoginInstance::disconnect() +{ + mRequestData.clear(); + mLoginModule->disconnect(); +} + +LLSD LLLoginInstance::getResponse() +{ + return mResponseData; +} + +void LLLoginInstance::constructAuthParams(const LLSD& credentials) +{ + // Set up auth request options. +//#define LL_MINIMIAL_REQUESTED_OPTIONS + LLSD requested_options; + // *Note: this is where gUserAuth used to be created. + requested_options.append("inventory-root"); + requested_options.append("inventory-skeleton"); + //requested_options.append("inventory-meat"); + //requested_options.append("inventory-skel-targets"); +#if (!defined LL_MINIMIAL_REQUESTED_OPTIONS) + if(FALSE == gSavedSettings.getBOOL("NoInventoryLibrary")) + { + requested_options.append("inventory-lib-root"); + requested_options.append("inventory-lib-owner"); + requested_options.append("inventory-skel-lib"); + // requested_options.append("inventory-meat-lib"); + } + + requested_options.append("initial-outfit"); + requested_options.append("gestures"); + requested_options.append("event_categories"); + requested_options.append("event_notifications"); + requested_options.append("classified_categories"); + //requested_options.append("inventory-targets"); + requested_options.append("buddy-list"); + requested_options.append("ui-config"); +#endif + requested_options.append("tutorial_setting"); + requested_options.append("login-flags"); + requested_options.append("global-textures"); + if(gSavedSettings.getBOOL("ConnectAsGod")) + { + gSavedSettings.setBOOL("UseDebugMenus", TRUE); + requested_options.append("god-connect"); + } + + char hashed_mac_string[MD5HEX_STR_SIZE]; /* Flawfinder: ignore */ + LLMD5 hashed_mac; + hashed_mac.update( gMACAddress, MAC_ADDRESS_BYTES ); + hashed_mac.finalize(); + hashed_mac.hex_digest(hashed_mac_string); + + // prepend "$1$" to the password to indicate its the md5'd version. + std::string dpasswd("$1$"); + dpasswd.append(credentials["passwd"].asString()); + + // (re)initialize the request params with creds. + LLSD request_params(credentials); + request_params["passwd"] = dpasswd; + request_params["start"] = construct_start_string(); + request_params["skipoptional"] = mSkipOptionalUpdate; + request_params["agree_to_tos"] = false; // Always false here. Set true in + request_params["read_critical"] = false; // handleTOSResponse + request_params["last_exec_event"] = gLastExecEvent; + request_params["mac"] = hashed_mac_string; + request_params["version"] = gCurrentVersion; // Includes channel name + request_params["channel"] = gSavedSettings.getString("VersionChannelName"); + request_params["id0"] = LLAppViewer::instance()->getSerialNumber(); + + mRequestData["method"] = "login_to_simulator"; + mRequestData["params"] = request_params; + mRequestData["options"] = requested_options; +} + +bool LLLoginInstance::handleLoginEvent(const LLSD& event) +{ + std::cout << "LoginListener called!: \n"; + std::cout << event << "\n"; + + if(!(event.has("state") && event.has("progress"))) + { + llerrs << "Unknown message from LLLogin!" << llendl; + } + + mLoginState = event["state"].asString(); + mResponseData = event["data"]; + + if(event.has("transfer_rate")) + { + mTransferRate = event["transfer_rate"].asReal(); + } + + if(mLoginState == "offline") + { + handleLoginFailure(event); + } + else if(mLoginState == "online") + { + handleLoginSuccess(event); + } + + return false; +} + +bool LLLoginInstance::handleLoginFailure(const LLSD& event) +{ + // Login has failed. + // Figure out why and respond... + LLSD response = event["data"]; + std::string reason_response = response["reason"].asString(); + std::string message_response = response["message"].asString(); + if(mUserInteraction) + { + // For the cases of critical message or TOS agreement, + // start the TOS dialog. The dialog response will be handled + // by the LLLoginInstance::handleTOSResponse() callback. + // The callback intiates the login attempt next step, either + // to reconnect or to end the attempt in failure. + if(reason_response == "tos") + { + LLFloaterTOS* tos_dialog = LLFloaterTOS::show(LLFloaterTOS::TOS_TOS, + message_response, + boost::bind(&LLLoginInstance::handleTOSResponse, + this, _1, "agree_to_tos") + ); + tos_dialog->startModal(); + } + else if(reason_response == "critical") + { + LLFloaterTOS* tos_dialog = LLFloaterTOS::show(LLFloaterTOS::TOS_CRITICAL_MESSAGE, + message_response, + boost::bind(&LLLoginInstance::handleTOSResponse, + this, _1, "read_critical") + ); + tos_dialog->startModal(); + } + else if(reason_response == "update" || gSavedSettings.getBOOL("ForceMandatoryUpdate")) + { + gSavedSettings.setBOOL("ForceMandatoryUpdate", FALSE); + updateApp(true, message_response); + } + else if(reason_response == "optional") + { + updateApp(false, message_response); + } + else + { + attemptComplete(); + } + } + else // no user interaction + { + attemptComplete(); + } + + return false; +} + +bool LLLoginInstance::handleLoginSuccess(const LLSD& event) +{ + LLSD response = event["data"]; + std::string message_response = response["message"].asString(); + if(gSavedSettings.getBOOL("ForceMandatoryUpdate")) + { + // Testing update... + gSavedSettings.setBOOL("ForceMandatoryUpdate", FALSE); + // Don't confuse startup by leaving login "online". + mLoginModule->disconnect(); + updateApp(true, message_response); + } + else + { + attemptComplete(); + } + return false; +} + +void LLLoginInstance::handleTOSResponse(bool accepted, const std::string& key) +{ + if(accepted) + { + // Set the request data to true and retry login. + mRequestData[key] = true; + reconnect(); + } + else + { + attemptComplete(); + } +} + + +void LLLoginInstance::updateApp(bool mandatory, const std::string& auth_msg) +{ + // store off config state, as we might quit soon + gSavedSettings.saveToFile(gSavedSettings.getString("ClientSettingsFile"), TRUE); + + std::ostringstream message; + + //*TODO:translate + std::string msg; + if (!auth_msg.empty()) + { + msg = "(" + auth_msg + ") \n"; + } + + LLSD args; + args["MESSAGE"] = msg; + + LLSD payload; + payload["mandatory"] = mandatory; + +/* + We're constructing one of the following 6 strings here: + "DownloadWindowsMandatory" + "DownloadWindowsReleaseForDownload" + "DownloadWindows" + "DownloadMacMandatory" + "DownloadMacReleaseForDownload" + "DownloadMac" + + I've called them out explicitly in this comment so that they can be grepped for. + + Also, we assume that if we're not Windows we're Mac. If we ever intend to support + Linux with autoupdate, this should be an explicit #elif LL_DARWIN, but + we'd rather deliver the wrong message than no message, so until Linux is supported + we'll leave it alone. + */ + std::string notification_name = "Download"; + +#if LL_WINDOWS + notification_name += "Windows"; +#else + notification_name += "Mac"; +#endif + + if (mandatory) + { + notification_name += "Mandatory"; + } + else + { +#if LL_RELEASE_FOR_DOWNLOAD + notification_name += "ReleaseForDownload"; +#endif + } + + LLNotifications::instance().add(notification_name, args, payload, + boost::bind(&LLLoginInstance::updateDialogCallback, this, _1, _2)); +} + +bool LLLoginInstance::updateDialogCallback(const LLSD& notification, const LLSD& response) +{ + S32 option = LLNotification::getSelectedOption(notification, response); + std::string update_exe_path; + bool mandatory = notification["payload"]["mandatory"].asBoolean(); + +#if !LL_RELEASE_FOR_DOWNLOAD + if (option == 2) + { + // This condition attempts to skip the + // update if using a dev build. + // The relog probably won't work if the + // update is mandatory. :) + + // *REMOVE:Mani - Saving for reference... + //LLStartUp::setStartupState( STATE_LOGIN_AUTH_INIT ); + mSkipOptionalUpdate = true; + reconnect(); + return false; + } +#endif + + if (option == 1) + { + // ...user doesn't want to do it + if (mandatory) + { + // Mandatory update, user chose to not to update... + // The login attemp is complete, startup should + // quit when detecting this. + attemptComplete(); + + // *REMOVE:Mani - Saving for reference... + //LLAppViewer::instance()->forceQuit(); + // // Bump them back to the login screen. + // //reset_login(); + } + else + { + // Optional update, user chose to skip + mSkipOptionalUpdate = true; + reconnect(); + } + return false; + } + + LLSD query_map = LLSD::emptyMap(); + // *TODO place os string in a global constant +#if LL_WINDOWS + query_map["os"] = "win"; +#elif LL_DARWIN + query_map["os"] = "mac"; +#elif LL_LINUX + query_map["os"] = "lnx"; +#elif LL_SOLARIS + query_map["os"] = "sol"; +#endif + // *TODO change userserver to be grid on both viewer and sim, since + // userserver no longer exists. + query_map["userserver"] = LLViewerLogin::getInstance()->getGridLabel(); + query_map["channel"] = gSavedSettings.getString("VersionChannelName"); + // *TODO constantize this guy + LLURI update_url = LLURI::buildHTTP("secondlife.com", 80, "update.php", query_map); + + if(LLAppViewer::sUpdaterInfo) + { + delete LLAppViewer::sUpdaterInfo; + } + LLAppViewer::sUpdaterInfo = new LLAppViewer::LLUpdaterInfo() ; + +#if LL_WINDOWS + LLAppViewer::sUpdaterInfo->mUpdateExePath = gDirUtilp->getTempFilename(); + if (LLAppViewer::sUpdaterInfo->mUpdateExePath.empty()) + { + delete LLAppViewer::sUpdaterInfo ; + LLAppViewer::sUpdaterInfo = NULL ; + + // We're hosed, bail + LL_WARNS("AppInit") << "LLDir::getTempFilename() failed" << LL_ENDL; + + attemptComplete(); + // *REMOVE:Mani - Saving for reference... + // LLAppViewer::instance()->forceQuit(); + return false; + } + + LLAppViewer::sUpdaterInfo->mUpdateExePath += ".exe"; + + std::string updater_source = gDirUtilp->getAppRODataDir(); + updater_source += gDirUtilp->getDirDelimiter(); + updater_source += "updater.exe"; + + LL_DEBUGS("AppInit") << "Calling CopyFile source: " << updater_source + << " dest: " << LLAppViewer::sUpdaterInfo->mUpdateExePath + << LL_ENDL; + + + if (!CopyFileA(updater_source.c_str(), LLAppViewer::sUpdaterInfo->mUpdateExePath.c_str(), FALSE)) + { + delete LLAppViewer::sUpdaterInfo ; + LLAppViewer::sUpdaterInfo = NULL ; + + LL_WARNS("AppInit") << "Unable to copy the updater!" << LL_ENDL; + attemptComplete(); + // *REMOVE:Mani - Saving for reference... + // LLAppViewer::instance()->forceQuit(); + return false; + } + + // if a sim name was passed in via command line parameter (typically through a SLURL) + if ( LLURLSimString::sInstance.mSimString.length() ) + { + // record the location to start at next time + gSavedSettings.setString( "NextLoginLocation", LLURLSimString::sInstance.mSimString ); + }; + + LLAppViewer::sUpdaterInfo->mParams << "-url \"" << update_url.asString() << "\""; + + LL_DEBUGS("AppInit") << "Calling updater: " << LLAppViewer::sUpdaterInfo->mUpdateExePath << " " << LLAppViewer::sUpdaterInfo->mParams.str() << LL_ENDL; + + //Explicitly remove the marker file, otherwise we pass the lock onto the child process and things get weird. + LLAppViewer::instance()->removeMarkerFile(); // In case updater fails + + // *NOTE:Mani The updater is spawned as the last thing before the WinMain exit. + // see LLAppViewerWin32.cpp + +#elif LL_DARWIN + // if a sim name was passed in via command line parameter (typically through a SLURL) + if ( LLURLSimString::sInstance.mSimString.length() ) + { + // record the location to start at next time + gSavedSettings.setString( "NextLoginLocation", LLURLSimString::sInstance.mSimString ); + }; + + LLAppViewer::sUpdaterInfo->mUpdateExePath = "'"; + LLAppViewer::sUpdaterInfo->mUpdateExePath += gDirUtilp->getAppRODataDir(); + LLAppViewer::sUpdaterInfo->mUpdateExePath += "/mac-updater.app/Contents/MacOS/mac-updater' -url \""; + LLAppViewer::sUpdaterInfo->mUpdateExePath += update_url.asString(); + LLAppViewer::sUpdaterInfo->mUpdateExePath += "\" -name \""; + LLAppViewer::sUpdaterInfo->mUpdateExePath += LLAppViewer::instance()->getSecondLifeTitle(); + LLAppViewer::sUpdaterInfo->mUpdateExePath += "\" &"; + + LL_DEBUGS("AppInit") << "Calling updater: " << LLAppViewer::sUpdaterInfo->mUpdateExePath << LL_ENDL; + + // Run the auto-updater. + system(LLAppViewer::sUpdaterInfo->mUpdateExePath.c_str()); /* Flawfinder: ignore */ + +#elif LL_LINUX || LL_SOLARIS + OSMessageBox("Automatic updating is not yet implemented for Linux.\n" + "Please download the latest version from www.secondlife.com.", + LLStringUtil::null, OSMB_OK); +#endif + + // *REMOVE:Mani - Saving for reference... + // LLAppViewer::instance()->forceQuit(); + + return false; +} + +std::string construct_start_string() +{ + std::string start; + if (LLURLSimString::parse()) + { + // a startup URL was specified + std::string unescaped_start = + STRINGIZE( "uri:" + << LLURLSimString::sInstance.mSimName << "&" + << LLURLSimString::sInstance.mX << "&" + << LLURLSimString::sInstance.mY << "&" + << LLURLSimString::sInstance.mZ); + start = xml_escape_string(unescaped_start); + } + else if (gSavedSettings.getBOOL("LoginLastLocation")) + { + start = "last"; + } + else + { + start = "home"; + } + return start; +} -- cgit v1.2.3 From 3975de991d2afa2ed903ac28bcc91246dfb22c20 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Wed, 13 May 2009 23:35:42 +0000 Subject: svn merge -r113003:119136 svn+ssh://svn.lindenlab.com/svn/linden/branches/login-api/login-api-2 svn+ssh://svn.lindenlab.com/svn/linden/branches/login-api/login-api-3 (finish) --- indra/newview/lllogininstance.cpp | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'indra/newview/lllogininstance.cpp') diff --git a/indra/newview/lllogininstance.cpp b/indra/newview/lllogininstance.cpp index 388bf38d61..606f145d3b 100644 --- a/indra/newview/lllogininstance.cpp +++ b/indra/newview/lllogininstance.cpp @@ -292,10 +292,9 @@ void LLLoginInstance::updateApp(bool mandatory, const std::string& auth_msg) { // store off config state, as we might quit soon gSavedSettings.saveToFile(gSavedSettings.getString("ClientSettingsFile"), TRUE); + gSavedSkinSettings.saveToFile(gSavedSettings.getString("SkinningSettingsFile"), TRUE); std::ostringstream message; - - //*TODO:translate std::string msg; if (!auth_msg.empty()) { @@ -409,6 +408,7 @@ bool LLLoginInstance::updateDialogCallback(const LLSD& notification, const LLSD& query_map["userserver"] = LLViewerLogin::getInstance()->getGridLabel(); query_map["channel"] = gSavedSettings.getString("VersionChannelName"); // *TODO constantize this guy + // *NOTE: This URL is also used in win_setup/lldownloader.cpp LLURI update_url = LLURI::buildHTTP("secondlife.com", 80, "update.php", query_map); if(LLAppViewer::sUpdaterInfo) @@ -495,9 +495,7 @@ bool LLLoginInstance::updateDialogCallback(const LLSD& notification, const LLSD& system(LLAppViewer::sUpdaterInfo->mUpdateExePath.c_str()); /* Flawfinder: ignore */ #elif LL_LINUX || LL_SOLARIS - OSMessageBox("Automatic updating is not yet implemented for Linux.\n" - "Please download the latest version from www.secondlife.com.", - LLStringUtil::null, OSMB_OK); + OSMessageBox(LLTrans::getString("MBNoAutoUpdate"), LLStringUtil::null, OSMB_OK); #endif // *REMOVE:Mani - Saving for reference... @@ -520,13 +518,9 @@ std::string construct_start_string() << LLURLSimString::sInstance.mZ); start = xml_escape_string(unescaped_start); } - else if (gSavedSettings.getBOOL("LoginLastLocation")) - { - start = "last"; - } else { - start = "home"; + start = gSavedSettings.getString("LoginLocation"); } return start; } -- cgit v1.2.3 From d4330d33964bb5888b5f1eb3ec389b03dadd826d Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Tue, 23 Jun 2009 20:20:01 +0000 Subject: QAR-1619: fix Linux-only missing #include (Linux-only reference to LLTrans) --- indra/newview/lllogininstance.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'indra/newview/lllogininstance.cpp') diff --git a/indra/newview/lllogininstance.cpp b/indra/newview/lllogininstance.cpp index 606f145d3b..22497ed291 100644 --- a/indra/newview/lllogininstance.cpp +++ b/indra/newview/lllogininstance.cpp @@ -52,6 +52,9 @@ #include "llurlsimstring.h" #include "llfloatertos.h" #include "llwindow.h" +#if LL_LINUX || LL_SOLARIS +#include "lltrans.h" +#endif std::string construct_start_string(); -- cgit v1.2.3 From db7f15df68cda2850c3d8a7ffcc59fc136de6f95 Mon Sep 17 00:00:00 2001 From: "Mark Palange (Mani)" Date: Wed, 22 Jul 2009 14:53:55 -0700 Subject: Adding LLLoginInstance unit test --- indra/newview/lllogininstance.cpp | 183 +++++++++++--------------------------- 1 file changed, 52 insertions(+), 131 deletions(-) (limited to 'indra/newview/lllogininstance.cpp') diff --git a/indra/newview/lllogininstance.cpp b/indra/newview/lllogininstance.cpp index 22497ed291..bf42129fc1 100644 --- a/indra/newview/lllogininstance.cpp +++ b/indra/newview/lllogininstance.cpp @@ -47,7 +47,6 @@ // newview #include "llviewernetwork.h" -#include "llappviewer.h" // Wish I didn't have to, but... #include "llviewercontrol.h" #include "llurlsimstring.h" #include "llfloatertos.h" @@ -74,7 +73,6 @@ LLLoginInstance::~LLLoginInstance() { } - void LLLoginInstance::connect(const LLSD& credentials) { std::vector uris; @@ -84,6 +82,7 @@ void LLLoginInstance::connect(const LLSD& credentials) void LLLoginInstance::connect(const std::string& uri, const LLSD& credentials) { + mAttemptComplete = false; // Reset attempt complete at this point! constructAuthParams(credentials); mLoginModule->connect(uri, mRequestData); } @@ -99,6 +98,7 @@ void LLLoginInstance::reconnect() void LLLoginInstance::disconnect() { + mAttemptComplete = false; // Reset attempt complete at this point! mRequestData.clear(); mLoginModule->disconnect(); } @@ -162,12 +162,13 @@ void LLLoginInstance::constructAuthParams(const LLSD& credentials) request_params["skipoptional"] = mSkipOptionalUpdate; request_params["agree_to_tos"] = false; // Always false here. Set true in request_params["read_critical"] = false; // handleTOSResponse - request_params["last_exec_event"] = gLastExecEvent; + request_params["last_exec_event"] = mLastExecEvent; request_params["mac"] = hashed_mac_string; request_params["version"] = gCurrentVersion; // Includes channel name request_params["channel"] = gSavedSettings.getString("VersionChannelName"); - request_params["id0"] = LLAppViewer::instance()->getSerialNumber(); + request_params["id0"] = mSerialNumber; + mRequestData.clear(); mRequestData["method"] = "login_to_simulator"; mRequestData["params"] = request_params; mRequestData["options"] = requested_options; @@ -219,21 +220,18 @@ bool LLLoginInstance::handleLoginFailure(const LLSD& event) // to reconnect or to end the attempt in failure. if(reason_response == "tos") { - LLFloaterTOS* tos_dialog = LLFloaterTOS::show(LLFloaterTOS::TOS_TOS, - message_response, - boost::bind(&LLLoginInstance::handleTOSResponse, - this, _1, "agree_to_tos") - ); - tos_dialog->startModal(); + LLFloaterTOS::show(LLFloaterTOS::TOS_TOS, + message_response, + boost::bind(&LLLoginInstance::handleTOSResponse, + this, _1, "agree_to_tos")); } else if(reason_response == "critical") { - LLFloaterTOS* tos_dialog = LLFloaterTOS::show(LLFloaterTOS::TOS_CRITICAL_MESSAGE, - message_response, - boost::bind(&LLLoginInstance::handleTOSResponse, - this, _1, "read_critical") + LLFloaterTOS::show(LLFloaterTOS::TOS_CRITICAL_MESSAGE, + message_response, + boost::bind(&LLLoginInstance::handleTOSResponse, + this, _1, "read_critical") ); - tos_dialog->startModal(); } else if(reason_response == "update" || gSavedSettings.getBOOL("ForceMandatoryUpdate")) { @@ -259,12 +257,14 @@ bool LLLoginInstance::handleLoginFailure(const LLSD& event) bool LLLoginInstance::handleLoginSuccess(const LLSD& event) { - LLSD response = event["data"]; - std::string message_response = response["message"].asString(); if(gSavedSettings.getBOOL("ForceMandatoryUpdate")) { + LLSD response = event["data"]; + std::string message_response = response["message"].asString(); + // Testing update... gSavedSettings.setBOOL("ForceMandatoryUpdate", FALSE); + // Don't confuse startup by leaving login "online". mLoginModule->disconnect(); updateApp(true, message_response); @@ -281,7 +281,7 @@ void LLLoginInstance::handleTOSResponse(bool accepted, const std::string& key) if(accepted) { // Set the request data to true and retry login. - mRequestData[key] = true; + mRequestData["params"][key] = true; reconnect(); } else @@ -344,13 +344,36 @@ void LLLoginInstance::updateApp(bool mandatory, const std::string& auth_msg) notification_name += "ReleaseForDownload"; #endif } - - LLNotifications::instance().add(notification_name, args, payload, - boost::bind(&LLLoginInstance::updateDialogCallback, this, _1, _2)); + + // *NOTE:Mani - for reference +// LLNotifications::instance().add(notification_name, args, payload, +// boost::bind(&LLLoginInstance::updateDialogCallback, this, _1, _2)); + + if(!mUpdateAppResponse) + { + bool make_unique = true; + mUpdateAppResponse.reset(new LLEventStream("logininstance_updateapp", make_unique)); + mUpdateAppResponse->listen("diaupdateDialogCallback", + boost::bind(&LLLoginInstance::updateDialogCallback, + this, _1 + ) + ); + } + + LLSD event; + event["op"] = "requestAdd"; + event["name"] = notification_name; + event["substitutions"] = args; + event["payload"] = payload; + event["reply"] = mUpdateAppResponse->getName(); + + LLEventPumps::getInstance()->obtain("LLNotifications").post(event); } -bool LLLoginInstance::updateDialogCallback(const LLSD& notification, const LLSD& response) +bool LLLoginInstance::updateDialogCallback(const LLSD& event) { + LLSD notification = event["notification"]; + LLSD response = event["response"]; S32 option = LLNotification::getSelectedOption(notification, response); std::string update_exe_path; bool mandatory = notification["payload"]["mandatory"].asBoolean(); @@ -395,114 +418,12 @@ bool LLLoginInstance::updateDialogCallback(const LLSD& notification, const LLSD& return false; } - LLSD query_map = LLSD::emptyMap(); - // *TODO place os string in a global constant -#if LL_WINDOWS - query_map["os"] = "win"; -#elif LL_DARWIN - query_map["os"] = "mac"; -#elif LL_LINUX - query_map["os"] = "lnx"; -#elif LL_SOLARIS - query_map["os"] = "sol"; -#endif - // *TODO change userserver to be grid on both viewer and sim, since - // userserver no longer exists. - query_map["userserver"] = LLViewerLogin::getInstance()->getGridLabel(); - query_map["channel"] = gSavedSettings.getString("VersionChannelName"); - // *TODO constantize this guy - // *NOTE: This URL is also used in win_setup/lldownloader.cpp - LLURI update_url = LLURI::buildHTTP("secondlife.com", 80, "update.php", query_map); - - if(LLAppViewer::sUpdaterInfo) - { - delete LLAppViewer::sUpdaterInfo; - } - LLAppViewer::sUpdaterInfo = new LLAppViewer::LLUpdaterInfo() ; - -#if LL_WINDOWS - LLAppViewer::sUpdaterInfo->mUpdateExePath = gDirUtilp->getTempFilename(); - if (LLAppViewer::sUpdaterInfo->mUpdateExePath.empty()) - { - delete LLAppViewer::sUpdaterInfo ; - LLAppViewer::sUpdaterInfo = NULL ; - - // We're hosed, bail - LL_WARNS("AppInit") << "LLDir::getTempFilename() failed" << LL_ENDL; - - attemptComplete(); - // *REMOVE:Mani - Saving for reference... - // LLAppViewer::instance()->forceQuit(); - return false; - } - - LLAppViewer::sUpdaterInfo->mUpdateExePath += ".exe"; - - std::string updater_source = gDirUtilp->getAppRODataDir(); - updater_source += gDirUtilp->getDirDelimiter(); - updater_source += "updater.exe"; - - LL_DEBUGS("AppInit") << "Calling CopyFile source: " << updater_source - << " dest: " << LLAppViewer::sUpdaterInfo->mUpdateExePath - << LL_ENDL; - - - if (!CopyFileA(updater_source.c_str(), LLAppViewer::sUpdaterInfo->mUpdateExePath.c_str(), FALSE)) - { - delete LLAppViewer::sUpdaterInfo ; - LLAppViewer::sUpdaterInfo = NULL ; - - LL_WARNS("AppInit") << "Unable to copy the updater!" << LL_ENDL; - attemptComplete(); - // *REMOVE:Mani - Saving for reference... - // LLAppViewer::instance()->forceQuit(); - return false; - } - - // if a sim name was passed in via command line parameter (typically through a SLURL) - if ( LLURLSimString::sInstance.mSimString.length() ) - { - // record the location to start at next time - gSavedSettings.setString( "NextLoginLocation", LLURLSimString::sInstance.mSimString ); - }; - - LLAppViewer::sUpdaterInfo->mParams << "-url \"" << update_url.asString() << "\""; - - LL_DEBUGS("AppInit") << "Calling updater: " << LLAppViewer::sUpdaterInfo->mUpdateExePath << " " << LLAppViewer::sUpdaterInfo->mParams.str() << LL_ENDL; - - //Explicitly remove the marker file, otherwise we pass the lock onto the child process and things get weird. - LLAppViewer::instance()->removeMarkerFile(); // In case updater fails - - // *NOTE:Mani The updater is spawned as the last thing before the WinMain exit. - // see LLAppViewerWin32.cpp - -#elif LL_DARWIN - // if a sim name was passed in via command line parameter (typically through a SLURL) - if ( LLURLSimString::sInstance.mSimString.length() ) - { - // record the location to start at next time - gSavedSettings.setString( "NextLoginLocation", LLURLSimString::sInstance.mSimString ); - }; - - LLAppViewer::sUpdaterInfo->mUpdateExePath = "'"; - LLAppViewer::sUpdaterInfo->mUpdateExePath += gDirUtilp->getAppRODataDir(); - LLAppViewer::sUpdaterInfo->mUpdateExePath += "/mac-updater.app/Contents/MacOS/mac-updater' -url \""; - LLAppViewer::sUpdaterInfo->mUpdateExePath += update_url.asString(); - LLAppViewer::sUpdaterInfo->mUpdateExePath += "\" -name \""; - LLAppViewer::sUpdaterInfo->mUpdateExePath += LLAppViewer::instance()->getSecondLifeTitle(); - LLAppViewer::sUpdaterInfo->mUpdateExePath += "\" &"; - - LL_DEBUGS("AppInit") << "Calling updater: " << LLAppViewer::sUpdaterInfo->mUpdateExePath << LL_ENDL; - - // Run the auto-updater. - system(LLAppViewer::sUpdaterInfo->mUpdateExePath.c_str()); /* Flawfinder: ignore */ - -#elif LL_LINUX || LL_SOLARIS - OSMessageBox(LLTrans::getString("MBNoAutoUpdate"), LLStringUtil::null, OSMB_OK); -#endif - - // *REMOVE:Mani - Saving for reference... - // LLAppViewer::instance()->forceQuit(); + if(mUpdaterLauncher) + { + mUpdaterLauncher(); + } + + attemptComplete(); return false; } @@ -526,4 +447,4 @@ std::string construct_start_string() start = gSavedSettings.getString("LoginLocation"); } return start; -} +} \ No newline at end of file -- cgit v1.2.3 From 9538328d5f7cf0f0be5dd77b8e27032e09104fff Mon Sep 17 00:00:00 2001 From: "Mark Palange (Mani)" Date: Fri, 24 Jul 2009 15:08:16 -0700 Subject: Adding LLLoginInstance unit test. - Added LLNotificationsInterface class. - Removed LLLoginInstance use of LLNotifications EventAPI --- indra/newview/lllogininstance.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'indra/newview/lllogininstance.cpp') diff --git a/indra/newview/lllogininstance.cpp b/indra/newview/lllogininstance.cpp index bf42129fc1..c08cc2baae 100644 --- a/indra/newview/lllogininstance.cpp +++ b/indra/newview/lllogininstance.cpp @@ -59,6 +59,7 @@ std::string construct_start_string(); LLLoginInstance::LLLoginInstance() : mLoginModule(new LLLogin()), + mNotifications(NULL), mLoginState("offline"), mUserInteraction(true), mSkipOptionalUpdate(false), @@ -345,10 +346,13 @@ void LLLoginInstance::updateApp(bool mandatory, const std::string& auth_msg) #endif } - // *NOTE:Mani - for reference -// LLNotifications::instance().add(notification_name, args, payload, -// boost::bind(&LLLoginInstance::updateDialogCallback, this, _1, _2)); + if(mNotifications) + { + mNotifications->add(notification_name, args, payload, + boost::bind(&LLLoginInstance::updateDialogCallback, this, _1, _2)); + } + /* *NOTE:Mani Experiment with Event API interface. if(!mUpdateAppResponse) { bool make_unique = true; @@ -368,12 +372,11 @@ void LLLoginInstance::updateApp(bool mandatory, const std::string& auth_msg) event["reply"] = mUpdateAppResponse->getName(); LLEventPumps::getInstance()->obtain("LLNotifications").post(event); + */ } -bool LLLoginInstance::updateDialogCallback(const LLSD& event) +bool LLLoginInstance::updateDialogCallback(const LLSD& notification, const LLSD& response) { - LLSD notification = event["notification"]; - LLSD response = event["response"]; S32 option = LLNotification::getSelectedOption(notification, response); std::string update_exe_path; bool mandatory = notification["payload"]["mandatory"].asBoolean(); -- cgit v1.2.3 From 91497c40c53f145749ae418c8f49e05916d87f5b Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Tue, 28 Jul 2009 13:46:34 -0700 Subject: Fix Linux compile problem --- indra/newview/lllogininstance.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/lllogininstance.cpp') diff --git a/indra/newview/lllogininstance.cpp b/indra/newview/lllogininstance.cpp index c08cc2baae..16192079a2 100644 --- a/indra/newview/lllogininstance.cpp +++ b/indra/newview/lllogininstance.cpp @@ -450,4 +450,4 @@ std::string construct_start_string() start = gSavedSettings.getString("LoginLocation"); } return start; -} \ No newline at end of file +} -- cgit v1.2.3 From ec2219724023144a0098199229aee7947a29af08 Mon Sep 17 00:00:00 2001 From: brad kittenbrink Date: Fri, 31 Jul 2009 15:32:03 -0700 Subject: Fixups for conflicts that got dropped in the changeset 486d51877332 merge of viewer-2.0.0-3 with login-api. Mostly code that had been modified in viewer-2.0.0-3 that had been moved elsewhere in login-api. --- indra/newview/lllogininstance.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/lllogininstance.cpp') diff --git a/indra/newview/lllogininstance.cpp b/indra/newview/lllogininstance.cpp index 16192079a2..f967fcaf97 100644 --- a/indra/newview/lllogininstance.cpp +++ b/indra/newview/lllogininstance.cpp @@ -296,7 +296,7 @@ void LLLoginInstance::updateApp(bool mandatory, const std::string& auth_msg) { // store off config state, as we might quit soon gSavedSettings.saveToFile(gSavedSettings.getString("ClientSettingsFile"), TRUE); - gSavedSkinSettings.saveToFile(gSavedSettings.getString("SkinningSettingsFile"), TRUE); + LLUIColorTable::instance().saveUserSettings(); std::ostringstream message; std::string msg; -- cgit v1.2.3 From 0bf8a15cc03b48432a5b9e0011a01908ef903960 Mon Sep 17 00:00:00 2001 From: brad kittenbrink Date: Wed, 5 Aug 2009 18:39:02 -0700 Subject: Fixups after the latest merge with viewer-2.0.0-3. Updated LLLoginInstance to use the new LLFloaterReg way of getting hold of floaters. --- indra/newview/lllogininstance.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'indra/newview/lllogininstance.cpp') diff --git a/indra/newview/lllogininstance.cpp b/indra/newview/lllogininstance.cpp index f967fcaf97..3c59cb83cd 100644 --- a/indra/newview/lllogininstance.cpp +++ b/indra/newview/lllogininstance.cpp @@ -49,6 +49,7 @@ #include "llviewernetwork.h" #include "llviewercontrol.h" #include "llurlsimstring.h" +#include "llfloaterreg.h" #include "llfloatertos.h" #include "llwindow.h" #if LL_LINUX || LL_SOLARIS @@ -221,18 +222,19 @@ bool LLLoginInstance::handleLoginFailure(const LLSD& event) // to reconnect or to end the attempt in failure. if(reason_response == "tos") { - LLFloaterTOS::show(LLFloaterTOS::TOS_TOS, - message_response, - boost::bind(&LLLoginInstance::handleTOSResponse, + LLFloaterTOS * tos = + LLFloaterReg::showTypedInstance("message_tos", LLSD(message_response)); + + tos->setTOSCallback(boost::bind(&LLLoginInstance::handleTOSResponse, this, _1, "agree_to_tos")); } else if(reason_response == "critical") { - LLFloaterTOS::show(LLFloaterTOS::TOS_CRITICAL_MESSAGE, - message_response, - boost::bind(&LLLoginInstance::handleTOSResponse, - this, _1, "read_critical") - ); + LLFloaterTOS * tos = + LLFloaterReg::showTypedInstance("message_critical",LLSD(message_response)); + + tos->setTOSCallback(boost::bind(&LLLoginInstance::handleTOSResponse, + this, _1, "read_critical")); } else if(reason_response == "update" || gSavedSettings.getBOOL("ForceMandatoryUpdate")) { -- cgit v1.2.3 From e6c9f944380d3a9b6562cf580e8c43a69c060dfd Mon Sep 17 00:00:00 2001 From: brad kittenbrink Date: Thu, 6 Aug 2009 18:45:37 -0700 Subject: Backed out changeset bfb246df4655: rolling back LLFloaterTOS post-merge fixups because they didn't work on linux. --- indra/newview/lllogininstance.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'indra/newview/lllogininstance.cpp') diff --git a/indra/newview/lllogininstance.cpp b/indra/newview/lllogininstance.cpp index 3c59cb83cd..f967fcaf97 100644 --- a/indra/newview/lllogininstance.cpp +++ b/indra/newview/lllogininstance.cpp @@ -49,7 +49,6 @@ #include "llviewernetwork.h" #include "llviewercontrol.h" #include "llurlsimstring.h" -#include "llfloaterreg.h" #include "llfloatertos.h" #include "llwindow.h" #if LL_LINUX || LL_SOLARIS @@ -222,19 +221,18 @@ bool LLLoginInstance::handleLoginFailure(const LLSD& event) // to reconnect or to end the attempt in failure. if(reason_response == "tos") { - LLFloaterTOS * tos = - LLFloaterReg::showTypedInstance("message_tos", LLSD(message_response)); - - tos->setTOSCallback(boost::bind(&LLLoginInstance::handleTOSResponse, + LLFloaterTOS::show(LLFloaterTOS::TOS_TOS, + message_response, + boost::bind(&LLLoginInstance::handleTOSResponse, this, _1, "agree_to_tos")); } else if(reason_response == "critical") { - LLFloaterTOS * tos = - LLFloaterReg::showTypedInstance("message_critical",LLSD(message_response)); - - tos->setTOSCallback(boost::bind(&LLLoginInstance::handleTOSResponse, - this, _1, "read_critical")); + LLFloaterTOS::show(LLFloaterTOS::TOS_CRITICAL_MESSAGE, + message_response, + boost::bind(&LLLoginInstance::handleTOSResponse, + this, _1, "read_critical") + ); } else if(reason_response == "update" || gSavedSettings.getBOOL("ForceMandatoryUpdate")) { -- cgit v1.2.3 From 8f4811f3fd7f252a5f5bc50ed11fecd8e42f3e68 Mon Sep 17 00:00:00 2001 From: brad kittenbrink Date: Tue, 11 Aug 2009 12:09:18 -0400 Subject: Better solution for fixing up the LLFloaterTOS callback after the last viewer-2.0.0-3 merge. LLFloaterTOS and LLLoginInstance now communicate through an event pump "lllogininstance_tos_callback". reviewed by Mani. --- indra/newview/lllogininstance.cpp | 42 ++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 18 deletions(-) (limited to 'indra/newview/lllogininstance.cpp') diff --git a/indra/newview/lllogininstance.cpp b/indra/newview/lllogininstance.cpp index 428bed7b72..cb7dbc2de0 100644 --- a/indra/newview/lllogininstance.cpp +++ b/indra/newview/lllogininstance.cpp @@ -56,6 +56,9 @@ #include "lltrans.h" #endif +static const char * const TOS_REPLY_PUMP = "lllogininstance_tos_callback"; +static const char * const TOS_LISTENER_NAME = "lllogininstance_tos"; + std::string construct_start_string(); LLLoginInstance::LLLoginInstance() : @@ -222,26 +225,25 @@ bool LLLoginInstance::handleLoginFailure(const LLSD& event) // to reconnect or to end the attempt in failure. if(reason_response == "tos") { - LLFloaterTOS * tos = - LLFloaterReg::showTypedInstance("message_tos", LLSD(message_response)); - /* - LLFloaterTOS::show(LLFloaterTOS::TOS_TOS, - message_response, - boost::bind(&LLLoginInstance::handleTOSResponse, - this, _1, "agree_to_tos")); - */ + LLSD data(LLSD::emptyMap()); + data["message"] = message_response; + data["reply_pump"] = TOS_REPLY_PUMP; + LLFloaterReg::showInstance("message_tos", data); + LLEventPumps::instance().obtain(TOS_REPLY_PUMP) + .listen(TOS_LISTENER_NAME, + boost::bind(&LLLoginInstance::handleTOSResponse, + this, _1, "agree_to_tos")); } else if(reason_response == "critical") { - LLFloaterTOS * tos = - LLFloaterReg::showTypedInstance("message_critical",LLSD(message_response)); - /* - LLFloaterTOS::show(LLFloaterTOS::TOS_CRITICAL_MESSAGE, - message_response, - boost::bind(&LLLoginInstance::handleTOSResponse, - this, _1, "read_critical") - ); - */ + LLSD data(LLSD::emptyMap()); + data["message"] = message_response; + data["reply_pump"] = TOS_REPLY_PUMP; + LLFloaterReg::showInstance("message_critical", data); + LLEventPumps::instance().obtain(TOS_REPLY_PUMP) + .listen(TOS_LISTENER_NAME, + boost::bind(&LLLoginInstance::handleTOSResponse, + this, _1, "read_critical")); } else if(reason_response == "update" || gSavedSettings.getBOOL("ForceMandatoryUpdate")) { @@ -286,7 +288,7 @@ bool LLLoginInstance::handleLoginSuccess(const LLSD& event) return false; } -void LLLoginInstance::handleTOSResponse(bool accepted, const std::string& key) +bool LLLoginInstance::handleTOSResponse(bool accepted, const std::string& key) { if(accepted) { @@ -298,6 +300,9 @@ void LLLoginInstance::handleTOSResponse(bool accepted, const std::string& key) { attemptComplete(); } + + LLEventPumps::instance().obtain(TOS_REPLY_PUMP).stopListening(TOS_LISTENER_NAME); + return true; } @@ -460,3 +465,4 @@ std::string construct_start_string() } return start; } + -- cgit v1.2.3 From 81d3f7ec6b348a08ad8c330d8d9ba90cd10ee816 Mon Sep 17 00:00:00 2001 From: brad kittenbrink Date: Mon, 31 Aug 2009 20:00:09 -0400 Subject: Post-merge cleanups (ported llstartup.cpp changes to where the surrounding code has been moved to in LLLoginInstance and LLAppViewer) --- indra/newview/lllogininstance.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'indra/newview/lllogininstance.cpp') diff --git a/indra/newview/lllogininstance.cpp b/indra/newview/lllogininstance.cpp index cb7dbc2de0..2f4d00786c 100644 --- a/indra/newview/lllogininstance.cpp +++ b/indra/newview/lllogininstance.cpp @@ -137,6 +137,7 @@ void LLLoginInstance::constructAuthParams(const LLSD& credentials) requested_options.append("event_categories"); requested_options.append("event_notifications"); requested_options.append("classified_categories"); + requested_options.append("adult_compliant"); //requested_options.append("inventory-targets"); requested_options.append("buddy-list"); requested_options.append("ui-config"); @@ -345,8 +346,10 @@ void LLLoginInstance::updateApp(bool mandatory, const std::string& auth_msg) #if LL_WINDOWS notification_name += "Windows"; -#else - notification_name += "Mac"; +#elif LL_DARWIN + notification_name += "Mac"; +#else + notification_name += "Linux"; #endif if (mandatory) -- cgit v1.2.3 From 5e4edfb83fbc2dd20415514efa33ba80c7fa1e94 Mon Sep 17 00:00:00 2001 From: brad kittenbrink Date: Tue, 1 Sep 2009 13:12:17 -0400 Subject: Fixups for eol-style copy pasta... --- indra/newview/lllogininstance.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'indra/newview/lllogininstance.cpp') diff --git a/indra/newview/lllogininstance.cpp b/indra/newview/lllogininstance.cpp index 2f4d00786c..e56d28e066 100644 --- a/indra/newview/lllogininstance.cpp +++ b/indra/newview/lllogininstance.cpp @@ -346,9 +346,9 @@ void LLLoginInstance::updateApp(bool mandatory, const std::string& auth_msg) #if LL_WINDOWS notification_name += "Windows"; -#elif LL_DARWIN - notification_name += "Mac"; -#else +#elif LL_DARWIN + notification_name += "Mac"; +#else notification_name += "Linux"; #endif -- cgit v1.2.3 From 08f3ea28f5681bbbd755947ec09970c11410bd0a Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Fri, 11 Sep 2009 22:12:34 -0400 Subject: QAR-1619: Remove unneeded llfloatertos.h #includes. Neither lllogininstance.cpp nor lllogininstance_test.cpp need llfloatertos.h any more, since LLLoginInstance talks to LLFloaterTOS only via LLFloaterReg and LLEventPumps. However, both sources depended on llfloatertos.h dragging in llnotifications.h, so include that explicitly instead of llfloatertos.h. --- indra/newview/lllogininstance.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/lllogininstance.cpp') diff --git a/indra/newview/lllogininstance.cpp b/indra/newview/lllogininstance.cpp index e56d28e066..8bf769a132 100644 --- a/indra/newview/lllogininstance.cpp +++ b/indra/newview/lllogininstance.cpp @@ -50,7 +50,7 @@ #include "llviewercontrol.h" #include "llurlsimstring.h" #include "llfloaterreg.h" -#include "llfloatertos.h" +#include "llnotifications.h" #include "llwindow.h" #if LL_LINUX || LL_SOLARIS #include "lltrans.h" -- cgit v1.2.3 From e3a4e3dc10a96b0822674cea262f41774e55a660 Mon Sep 17 00:00:00 2001 From: Nat Goodspeed Date: Fri, 9 Oct 2009 19:42:59 -0400 Subject: DEV-40930: Added ["change"] key to login-module status events. Changed existing event calls to use state as "offline" or "online", with "change" indicating the reason for this status event. Changed disconnect() to send state "offline", change "disconnect" -- instead of replaying last auth failure. Changed unit tests accordingly. Changed LLLoginInstance::handleLoginEvent() to use LLEventDispatcher to route calls to handleLoginFailure() et al. Added LLEventDispatcher::get() to allow retrieving Callable by name and testing for empty(). --- indra/newview/lllogininstance.cpp | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) (limited to 'indra/newview/lllogininstance.cpp') diff --git a/indra/newview/lllogininstance.cpp b/indra/newview/lllogininstance.cpp index 8bf769a132..e5f347ddc4 100644 --- a/indra/newview/lllogininstance.cpp +++ b/indra/newview/lllogininstance.cpp @@ -68,10 +68,14 @@ LLLoginInstance::LLLoginInstance() : mUserInteraction(true), mSkipOptionalUpdate(false), mAttemptComplete(false), - mTransferRate(0.0f) + mTransferRate(0.0f), + mDispatcher("LLLoginInstance", "change") { mLoginModule->getEventPump().listen("lllogininstance", boost::bind(&LLLoginInstance::handleLoginEvent, this, _1)); + mDispatcher.add("fail.login", boost::bind(&LLLoginInstance::handleLoginFailure, this, _1)); + mDispatcher.add("connect", boost::bind(&LLLoginInstance::handleLoginSuccess, this, _1)); + mDispatcher.add("disconnect", boost::bind(&LLLoginInstance::handleDisconnect, this, _1)); } LLLoginInstance::~LLLoginInstance() @@ -185,9 +189,9 @@ bool LLLoginInstance::handleLoginEvent(const LLSD& event) std::cout << "LoginListener called!: \n"; std::cout << event << "\n"; - if(!(event.has("state") && event.has("progress"))) + if(!(event.has("state") && event.has("change") && event.has("progress"))) { - llerrs << "Unknown message from LLLogin!" << llendl; + llerrs << "Unknown message from LLLogin: " << event << llendl; } mLoginState = event["state"].asString(); @@ -198,19 +202,17 @@ bool LLLoginInstance::handleLoginEvent(const LLSD& event) mTransferRate = event["transfer_rate"].asReal(); } - if(mLoginState == "offline") + // Call the method registered in constructor, if any, for more specific + // handling + LLEventDispatcher::Callable method(mDispatcher.get(event["change"])); + if (! method.empty()) { - handleLoginFailure(event); + method(event); } - else if(mLoginState == "online") - { - handleLoginSuccess(event); - } - return false; } -bool LLLoginInstance::handleLoginFailure(const LLSD& event) +void LLLoginInstance::handleLoginFailure(const LLSD& event) { // Login has failed. // Figure out why and respond... @@ -264,11 +266,9 @@ bool LLLoginInstance::handleLoginFailure(const LLSD& event) { attemptComplete(); } - - return false; } -bool LLLoginInstance::handleLoginSuccess(const LLSD& event) +void LLLoginInstance::handleLoginSuccess(const LLSD& event) { if(gSavedSettings.getBOOL("ForceMandatoryUpdate")) { @@ -286,7 +286,11 @@ bool LLLoginInstance::handleLoginSuccess(const LLSD& event) { attemptComplete(); } - return false; +} + +void LLLoginInstance::handleDisconnect(const LLSD& event) +{ + // placeholder } bool LLLoginInstance::handleTOSResponse(bool accepted, const std::string& key) -- cgit v1.2.3