diff options
Diffstat (limited to 'indra/viewer_components')
-rw-r--r-- | indra/viewer_components/login/lllogin.cpp | 29 | ||||
-rw-r--r-- | indra/viewer_components/login/tests/lllogin_test.cpp | 16 |
2 files changed, 26 insertions, 19 deletions
diff --git a/indra/viewer_components/login/lllogin.cpp b/indra/viewer_components/login/lllogin.cpp index c0d35f31d3..7a30315b9a 100644 --- a/indra/viewer_components/login/lllogin.cpp +++ b/indra/viewer_components/login/lllogin.cpp @@ -70,10 +70,12 @@ public: LLEventPump& getEventPump() { return mPump; } private: - void sendProgressEvent(const std::string& desc, const LLSD& data = LLSD::emptyMap()) + void sendProgressEvent(const std::string& state, const std::string& change, + const LLSD& data = LLSD()) { LLSD status_data; - status_data["state"] = desc; + status_data["state"] = state; + status_data["change"] = change; status_data["progress"] = 0.0f; if(mAuthResponse.has("transfer_rate")) @@ -81,7 +83,7 @@ private: status_data["transfer_rate"] = mAuthResponse["transfer_rate"]; } - if(data.size() != 0) + if(data.isDefined()) { status_data["data"] = data; } @@ -133,7 +135,7 @@ void LLLogin::Impl::login_(LLCoros::self& self, std::string uri, LLSD credential LLSD rewrittenURIs; { LLEventTimeout filter(replyPump); - sendProgressEvent("srvrequest"); + sendProgressEvent("offline", "srvrequest"); // Request SRV record. LL_INFOS("LLLogin") << "Requesting SRV record from " << uri << LL_ENDL; @@ -172,7 +174,7 @@ void LLLogin::Impl::login_(LLCoros::self& self, std::string uri, LLSD credential LLSD progress_data; progress_data["attempt"] = attempts; progress_data["request"] = request; - sendProgressEvent("authenticating", progress_data); + sendProgressEvent("offline", "authenticating", progress_data); // We expect zero or more "Downloading" status events, followed by // exactly one event with some other status. Use postAndWait() the @@ -187,7 +189,7 @@ void LLLogin::Impl::login_(LLCoros::self& self, std::string uri, LLSD credential waitForEventOn(self, replyPump))) { // Still Downloading -- send progress update. - sendProgressEvent("downloading"); + sendProgressEvent("offline", "downloading"); } status = mAuthResponse["status"].asString(); @@ -215,9 +217,14 @@ void LLLogin::Impl::login_(LLCoros::self& self, std::string uri, LLSD credential // StatusComplete does not imply auth success. Check the // actual outcome of the request. We've already handled the // "indeterminate" case in the loop above. - sendProgressEvent((mAuthResponse["responses"]["login"].asString() == "true")? - "online" : "offline", - mAuthResponse["responses"]); + if (mAuthResponse["responses"]["login"].asString() == "true") + { + sendProgressEvent("online", "connect", mAuthResponse["responses"]); + } + else + { + sendProgressEvent("offline", "fail.login", mAuthResponse["responses"]); + } return; // Done! } // If we don't recognize status at all, trouble @@ -236,12 +243,12 @@ void LLLogin::Impl::login_(LLCoros::self& self, std::string uri, LLSD credential // Here we got through all the rewrittenURIs without succeeding. Tell // caller this didn't work out so well. Of course, the only failure data // we can reasonably show are from the last of the rewrittenURIs. - sendProgressEvent("offline", mAuthResponse["responses"]); + sendProgressEvent("offline", "fail.login", mAuthResponse["responses"]); } void LLLogin::Impl::disconnect() { - sendProgressEvent("offline", mAuthResponse["responses"]); + sendProgressEvent("offline", "disconnect"); } //********************* diff --git a/indra/viewer_components/login/tests/lllogin_test.cpp b/indra/viewer_components/login/tests/lllogin_test.cpp index 51f00c8344..a8ae2883d5 100644 --- a/indra/viewer_components/login/tests/lllogin_test.cpp +++ b/indra/viewer_components/login/tests/lllogin_test.cpp @@ -265,12 +265,12 @@ namespace tut login.connect("login.bar.com", credentials); - ensure_equals("SRV state", listener.lastEvent()["state"].asString(), "srvrequest"); + ensure_equals("SRV state", listener.lastEvent()["change"].asString(), "srvrequest"); dummyLLAres.sendReply(); // Test Authenticating State prior to first response. - ensure_equals("Auth state 1", listener.lastEvent()["state"].asString(), "authenticating"); + ensure_equals("Auth state 1", listener.lastEvent()["change"].asString(), "authenticating"); ensure_equals("Attempt 1", listener.lastEvent()["data"]["attempt"].asInteger(), 1); ensure_equals("URI 1", listener.lastEvent()["data"]["request"]["uri"].asString(), "login.foo.com"); @@ -285,7 +285,7 @@ namespace tut dummyXMLRPC.setResponse(data); dummyXMLRPC.sendReply(); - ensure_equals("Fail back to authenticate 1", listener.lastEvent()["state"].asString(), "authenticating"); + ensure_equals("Fail back to authenticate 1", listener.lastEvent()["change"].asString(), "authenticating"); ensure_equals("Attempt 2", listener.lastEvent()["data"]["attempt"].asInteger(), 2); ensure_equals("URI 2", listener.lastEvent()["data"]["request"]["uri"].asString(), "login.bar.com"); @@ -301,7 +301,7 @@ namespace tut dummyXMLRPC.setResponse(data); dummyXMLRPC.sendReply(); - ensure_equals("Fail back to authenticate 2", listener.lastEvent()["state"].asString(), "authenticating"); + ensure_equals("Fail back to authenticate 2", listener.lastEvent()["change"].asString(), "authenticating"); ensure_equals("Attempt 3", listener.lastEvent()["data"]["attempt"].asInteger(), 3); ensure_equals("URI 3", listener.lastEvent()["data"]["request"]["uri"].asString(), "login.indeterminate.com"); @@ -350,11 +350,11 @@ namespace tut login.connect("login.bar.com", credentials); - ensure_equals("SRV state", listener.lastEvent()["state"].asString(), "srvrequest"); + ensure_equals("SRV state", listener.lastEvent()["change"].asString(), "srvrequest"); dummyLLAres.sendReply(); - ensure_equals("Auth state", listener.lastEvent()["state"].asString(), "authenticating"); + ensure_equals("Auth state", listener.lastEvent()["change"].asString(), "authenticating"); // Send the failed auth request reponse LLSD data; @@ -397,11 +397,11 @@ namespace tut login.connect("login.bar.com", credentials); - ensure_equals("SRV state", listener.lastEvent()["state"].asString(), "srvrequest"); + ensure_equals("SRV state", listener.lastEvent()["change"].asString(), "srvrequest"); dummyLLAres.sendReply(); - ensure_equals("Auth state", listener.lastEvent()["state"].asString(), "authenticating"); + ensure_equals("Auth state", listener.lastEvent()["change"].asString(), "authenticating"); // Send the failed auth request reponse LLSD data; |