summaryrefslogtreecommitdiff
path: root/indra/newview/llfloatertos.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llfloatertos.cpp')
-rw-r--r--[-rwxr-xr-x]indra/newview/llfloatertos.cpp125
1 files changed, 66 insertions, 59 deletions
diff --git a/indra/newview/llfloatertos.cpp b/indra/newview/llfloatertos.cpp
index ae33acb842..1743d0fc69 100755..100644
--- a/indra/newview/llfloatertos.cpp
+++ b/indra/newview/llfloatertos.cpp
@@ -35,8 +35,6 @@
// linden library includes
#include "llbutton.h"
#include "llevents.h"
-#include "llhttpclient.h"
-#include "llhttpconstants.h"
#include "llnotificationsutil.h"
#include "llradiogroup.h"
#include "lltextbox.h"
@@ -45,7 +43,8 @@
#include "llvfile.h"
#include "message.h"
#include "llstartup.h" // login_alert_done
-
+#include "llcorehttputil.h"
+#include "llfloaterreg.h"
LLFloaterTOS::LLFloaterTOS(const LLSD& data)
: LLModalDialog( data["message"].asString() ),
@@ -57,57 +56,6 @@ LLFloaterTOS::LLFloaterTOS(const LLSD& data)
{
}
-// helper class that trys to download a URL from a web site and calls a method
-// on parent class indicating if the web server is working or not
-class LLIamHere : public LLHTTPClient::Responder
-{
- LOG_CLASS(LLIamHere);
-private:
- LLIamHere( LLFloaterTOS* parent ) :
- mParent( parent )
- {}
-
- LLFloaterTOS* mParent;
-
-public:
- static LLIamHere* build( LLFloaterTOS* parent )
- {
- return new LLIamHere( parent );
- }
-
- virtual void setParent( LLFloaterTOS* parentIn )
- {
- mParent = parentIn;
- }
-
-protected:
- virtual void httpSuccess()
- {
- if ( mParent )
- {
- mParent->setSiteIsAlive( true );
- }
- }
-
- virtual void httpFailure()
- {
- LL_DEBUGS("LLIamHere") << dumpResponse() << LL_ENDL;
- if ( mParent )
- {
- // *HACK: For purposes of this alive check, 302 Found
- // (aka Moved Temporarily) is considered alive. The web site
- // redirects this link to a "cache busting" temporary URL. JC
- bool alive = (getStatus() == HTTP_FOUND);
- mParent->setSiteIsAlive( alive );
- }
- }
-};
-
-// this is global and not a class member to keep crud out of the header file
-namespace {
- LLPointer< LLIamHere > gResponsePtr = 0;
-};
-
BOOL LLFloaterTOS::postBuild()
{
childSetAction("Continue", onContinue, this);
@@ -136,6 +84,20 @@ BOOL LLFloaterTOS::postBuild()
LLMediaCtrl* web_browser = getChild<LLMediaCtrl>("tos_html");
if ( web_browser )
{
+// if we are forced to send users to an external site in their system browser
+// (e.g.) Linux users because of lack of media support for HTML ToS page
+// remove exisiting UI and replace with a link to external page where users can accept ToS
+#ifdef EXTERNAL_TOS
+ LLTextBox* header = getChild<LLTextBox>("tos_heading");
+ if (header)
+ header->setVisible(false);
+
+ LLTextBox* external_prompt = getChild<LLTextBox>("external_tos_required");
+ if (external_prompt)
+ external_prompt->setVisible(true);
+
+ web_browser->setVisible(false);
+#else
web_browser->addObserver(this);
// Don't use the start_url parameter for this browser instance -- it may finish loading before we get to add our observer.
@@ -147,6 +109,7 @@ BOOL LLFloaterTOS::postBuild()
// All links from tos_html should be opened in external browser
media_plugin->setOverrideClickTarget("_external");
}
+#endif
}
return TRUE;
@@ -154,6 +117,13 @@ BOOL LLFloaterTOS::postBuild()
void LLFloaterTOS::setSiteIsAlive( bool alive )
{
+// if we are forced to send users to an external site in their system browser
+// (e.g.) Linux users because of lack of media support for HTML ToS page
+// force the regular HTML UI to deactivate so alternative is rendered instead.
+#ifdef EXTERNAL_TOS
+ mSiteAlive = false;
+#else
+
mSiteAlive = alive;
// only do this for TOS pages
@@ -182,13 +152,11 @@ void LLFloaterTOS::setSiteIsAlive( bool alive )
tos_agreement->setEnabled( true );
}
}
+#endif
}
LLFloaterTOS::~LLFloaterTOS()
{
- // tell the responder we're not here anymore
- if ( gResponsePtr )
- gResponsePtr->setParent( 0 );
}
// virtual
@@ -249,9 +217,12 @@ void LLFloaterTOS::handleMediaEvent(LLPluginClassMedia* /*self*/, EMediaEvent ev
if(!mLoadingScreenLoaded)
{
mLoadingScreenLoaded = true;
+ std::string url(getString("real_url"));
- gResponsePtr = LLIamHere::build( this );
- LLHTTPClient::get( getString( "real_url" ), gResponsePtr );
+ LLHandle<LLFloater> handle = getHandle();
+
+ LLCoros::instance().launch("LLFloaterTOS::testSiteIsAliveCoro",
+ boost::bind(&LLFloaterTOS::testSiteIsAliveCoro, handle, url));
}
else if(mRealNavigateBegun)
{
@@ -263,3 +234,39 @@ void LLFloaterTOS::handleMediaEvent(LLPluginClassMedia* /*self*/, EMediaEvent ev
}
}
+void LLFloaterTOS::testSiteIsAliveCoro(LLHandle<LLFloater> handle, std::string url)
+{
+ LLCore::HttpRequest::policy_t httpPolicy(LLCore::HttpRequest::DEFAULT_POLICY_ID);
+ LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t
+ httpAdapter(new LLCoreHttpUtil::HttpCoroutineAdapter("genericPostCoro", httpPolicy));
+ LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest);
+ LLCore::HttpOptions::ptr_t httpOpts = LLCore::HttpOptions::ptr_t(new LLCore::HttpOptions);
+
+
+ httpOpts->setWantHeaders(true);
+
+
+ LL_INFOS("testSiteIsAliveCoro") << "Generic POST for " << url << LL_ENDL;
+
+ LLSD result = httpAdapter->getAndSuspend(httpRequest, url);
+
+ LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS];
+ LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults);
+
+ if (handle.isDead())
+ {
+ LL_WARNS("testSiteIsAliveCoro") << "Dialog canceled before response." << LL_ENDL;
+ return;
+ }
+
+ LLFloaterTOS *that = dynamic_cast<LLFloaterTOS *>(handle.get());
+
+ if (that)
+ that->setSiteIsAlive(static_cast<bool>(status));
+ else
+ {
+ LL_WARNS("testSiteIsAliveCoro") << "Handle was not a TOS floater." << LL_ENDL;
+ }
+}
+
+