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 ++++++++++++++++------------ indra/newview/lllogininstance.h | 7 ++++-- indra/newview/tests/lllogininstance_test.cpp | 7 ++++++ 3 files changed, 31 insertions(+), 17 deletions(-) (limited to 'indra/newview') 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) diff --git a/indra/newview/lllogininstance.h b/indra/newview/lllogininstance.h index 6a2ccf919e..19d7449bc1 100644 --- a/indra/newview/lllogininstance.h +++ b/indra/newview/lllogininstance.h @@ -33,6 +33,7 @@ #ifndef LL_LLLOGININSTANCE_H #define LL_LLLOGININSTANCE_H +#include "lleventdispatcher.h" #include #include class LLLogin; @@ -85,8 +86,9 @@ private: bool updateDialogCallback(const LLSD& notification, const LLSD& response); bool handleLoginEvent(const LLSD& event); - bool handleLoginFailure(const LLSD& event); - bool handleLoginSuccess(const LLSD& event); + void handleLoginFailure(const LLSD& event); + void handleLoginSuccess(const LLSD& event); + void handleDisconnect(const LLSD& event); bool handleTOSResponse(bool v, const std::string& key); @@ -106,6 +108,7 @@ private: int mLastExecEvent; UpdaterLauncherCallback mUpdaterLauncher; boost::scoped_ptr mUpdateAppResponse; + LLEventDispatcher mDispatcher; }; #endif diff --git a/indra/newview/tests/lllogininstance_test.cpp b/indra/newview/tests/lllogininstance_test.cpp index 75db76df27..009be35f64 100644 --- a/indra/newview/tests/lllogininstance_test.cpp +++ b/indra/newview/tests/lllogininstance_test.cpp @@ -225,6 +225,7 @@ namespace tut // Dummy success response. LLSD response; response["state"] = "online"; + response["change"] = "connect"; response["progress"] = 1.0; response["transfer_rate"] = 7; response["data"] = "test_data"; @@ -240,6 +241,7 @@ namespace tut response.clear(); response["state"] = "offline"; + response["change"] = "disconnect"; response["progress"] = 0.0; response["transfer_rate"] = 0; response["data"] = "test_data"; @@ -267,6 +269,7 @@ namespace tut // TOS failure response. LLSD response; response["state"] = "offline"; + response["change"] = "fail.login"; response["progress"] = 0.0; response["transfer_rate"] = 7; response["data"]["reason"] = "tos"; @@ -326,6 +329,7 @@ namespace tut // Update needed failure response. LLSD response; response["state"] = "offline"; + response["change"] = "fail.login"; response["progress"] = 0.0; response["transfer_rate"] = 7; response["data"]["reason"] = "update"; @@ -351,6 +355,7 @@ namespace tut // Update needed failure response. LLSD response; response["state"] = "offline"; + response["change"] = "fail.login"; response["progress"] = 0.0; response["transfer_rate"] = 7; response["data"]["reason"] = "update"; @@ -376,6 +381,7 @@ namespace tut // Update needed failure response. LLSD response; response["state"] = "offline"; + response["change"] = "fail.login"; response["progress"] = 0.0; response["transfer_rate"] = 7; response["data"]["reason"] = "optional"; @@ -401,6 +407,7 @@ namespace tut // Update needed failure response. LLSD response; response["state"] = "offline"; + response["change"] = "fail.login"; response["progress"] = 0.0; response["transfer_rate"] = 7; response["data"]["reason"] = "optional"; -- cgit v1.2.3