diff options
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llfloatertos.cpp | 17 | ||||
-rw-r--r-- | indra/newview/llfloatertos.h | 6 | ||||
-rw-r--r-- | indra/newview/lllogininstance.cpp | 42 | ||||
-rw-r--r-- | indra/newview/lllogininstance.h | 2 | ||||
-rw-r--r-- | indra/newview/tests/lllogininstance_test.cpp | 33 |
5 files changed, 53 insertions, 47 deletions
diff --git a/indra/newview/llfloatertos.cpp b/indra/newview/llfloatertos.cpp index 11f35bedad..e43c3ecde7 100644 --- a/indra/newview/llfloatertos.cpp +++ b/indra/newview/llfloatertos.cpp @@ -52,12 +52,12 @@ #include "message.h" -LLFloaterTOS::LLFloaterTOS(const LLSD& message) -: LLModalDialog( message, 100, 100 ), - mMessage(message.asString()), +LLFloaterTOS::LLFloaterTOS(const LLSD& data) +: LLModalDialog( data["message"].asString(), 100, 100 ), + mMessage(data["message"].asString()), mWebBrowserWindowId( 0 ), mLoadCompleteCount( 0 ), - mCallback() + mReplyPumpName(data["reply_pump"].asString()) { } @@ -205,9 +205,9 @@ void LLFloaterTOS::onContinue( void* userdata ) LLFloaterTOS* self = (LLFloaterTOS*) userdata; llinfos << "User agrees with TOS." << llendl; - if(self->mCallback) + if(self->mReplyPumpName != "") { - self->mCallback(true); + LLEventPumps::instance().obtain(self->mReplyPumpName).post(LLSD(true)); } self->closeFloater(); // destroys this object @@ -219,9 +219,9 @@ void LLFloaterTOS::onCancel( void* userdata ) LLFloaterTOS* self = (LLFloaterTOS*) userdata; llinfos << "User disagrees with TOS." << llendl; - if(self->mCallback) + if(self->mReplyPumpName != "") { - self->mCallback(false); + LLEventPumps::instance().obtain(self->mReplyPumpName).post(LLSD(false)); } self->mLoadCompleteCount = 0; // reset counter for next time we come to TOS @@ -240,3 +240,4 @@ void LLFloaterTOS::onNavigateComplete( const EventType& eventIn ) tos_agreement->setEnabled( true ); }; } + diff --git a/indra/newview/llfloatertos.h b/indra/newview/llfloatertos.h index 0be440d92b..89ad29170c 100644 --- a/indra/newview/llfloatertos.h +++ b/indra/newview/llfloatertos.h @@ -49,11 +49,9 @@ class LLFloaterTOS : public LLWebBrowserCtrlObserver { public: - LLFloaterTOS(const LLSD& message); + LLFloaterTOS(const LLSD& data); virtual ~LLFloaterTOS(); - typedef boost::function<void(bool)> YesNoCallback; - BOOL postBuild(); virtual void draw(); @@ -70,7 +68,7 @@ private: std::string mMessage; int mWebBrowserWindowId; int mLoadCompleteCount; - YesNoCallback mCallback; + std::string mReplyPumpName; }; #endif // LL_LLFLOATERTOS_H 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<LLFloaterTOS>("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<LLFloaterTOS>("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; } + diff --git a/indra/newview/lllogininstance.h b/indra/newview/lllogininstance.h index 47d52a6184..6a2ccf919e 100644 --- a/indra/newview/lllogininstance.h +++ b/indra/newview/lllogininstance.h @@ -88,7 +88,7 @@ private: bool handleLoginFailure(const LLSD& event); bool handleLoginSuccess(const LLSD& event); - void handleTOSResponse(bool v, const std::string& key); + bool handleTOSResponse(bool v, const std::string& key); void attemptComplete() { mAttemptComplete = true; } // In the future an event? diff --git a/indra/newview/tests/lllogininstance_test.cpp b/indra/newview/tests/lllogininstance_test.cpp index 5af8acebaf..a84e796159 100644 --- a/indra/newview/tests/lllogininstance_test.cpp +++ b/indra/newview/tests/lllogininstance_test.cpp @@ -92,14 +92,15 @@ bool LLURLSimString::parse() { return true; } //-----------------------------------------------------------------------------
#include "../llfloatertos.h"
-static LLFloaterTOS::ETOSType gTOSType;
-static LLFloaterTOS::YesNoCallback gTOSCallback;
-LLFloaterTOS* LLFloaterTOS::show(LLFloaterTOS::ETOSType type,
- const std::string & message,
- const YesNoCallback& callback)
+#include "llfloaterreg.h"
+static std::string gTOSType;
+static LLEventPump * gTOSReplyPump = NULL;
+
+//static
+LLFloater* LLFloaterReg::showInstance(const std::string& name, const LLSD& key, BOOL focus)
{
- gTOSType = type;
- gTOSCallback = callback;
+ gTOSType = name;
+ gTOSReplyPump = &LLEventPumps::instance().obtain(key["reply_pump"]);
return NULL;
}
@@ -182,8 +183,8 @@ namespace tut gLoginCreds.clear();
gDisconnectCalled = false;
- // gTOSType = -1; // Set to invalid value.
- gTOSCallback = 0; // clear the callback.
+ gTOSType = ""; // Set to invalid value.
+ gTOSReplyPump = 0; // clear the callback.
gSavedSettings.declareBOOL("NoInventoryLibrary", FALSE, "", FALSE);
@@ -271,15 +272,15 @@ namespace tut response["data"]["reason"] = "tos";
gTestPump.post(response);
- ensure_equals("TOS Dialog type", gTOSType, LLFloaterTOS::TOS_TOS);
- ensure("TOS callback given", gTOSCallback != 0);
- gTOSCallback(false); // Call callback denying TOS.
+ ensure_equals("TOS Dialog type", gTOSType, "message_tos");
+ ensure("TOS callback given", gTOSReplyPump != 0);
+ gTOSReplyPump->post(false); // Call callback denying TOS.
ensure("No TOS, failed auth", logininstance->authFailure());
// Start again.
logininstance->connect(test_uri, credentials);
gTestPump.post(response); // Fail for tos again.
- gTOSCallback(true); // Accept tos, should reconnect w/ agree_to_tos.
+ gTOSReplyPump->post(true); // Accept tos, should reconnect w/ agree_to_tos.
ensure_equals("Accepted agree to tos", gLoginCreds["params"]["agree_to_tos"].asBoolean(), true);
ensure("Incomplete login status", !logininstance->authFailure() && !logininstance->authSuccess());
@@ -297,9 +298,9 @@ namespace tut response["data"]["reason"] = "critical"; // Change response to "critical message"
gTestPump.post(response);
- ensure_equals("TOS Dialog type", gTOSType, LLFloaterTOS::TOS_CRITICAL_MESSAGE);
- ensure("TOS callback given", gTOSCallback != 0);
- gTOSCallback(true);
+ ensure_equals("TOS Dialog type", gTOSType, "message_critical");
+ ensure("TOS callback given", gTOSReplyPump != 0);
+ gTOSReplyPump->post(true);
ensure_equals("Accepted read critical message", gLoginCreds["params"]["read_critical"].asBoolean(), true);
ensure("Incomplete login status", !logininstance->authFailure() && !logininstance->authSuccess());
|