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.meow-7.2.2
parent
469836c4c7
commit
8f4811f3fd
|
|
@ -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 );
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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?
|
||||
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue