Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Alchemy Viewer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package Registry
Operate
Terraform modules
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Silent mode is enabled
All outbound communications are blocked.
Learn more
.
Show more breadcrumbs
Alchemy Viewer
Alchemy Viewer
Commits
dcd36402
Commit
dcd36402
authored
9 years ago
by
Rider Linden
Browse files
Options
Downloads
Patches
Plain Diff
TOS retrieval to coroutine
parent
bd3dc9cf
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
indra/newview/llfloatertos.cpp
+27
-57
27 additions, 57 deletions
indra/newview/llfloatertos.cpp
indra/newview/llfloatertos.h
+5
-0
5 additions, 0 deletions
indra/newview/llfloatertos.h
with
32 additions
and
57 deletions
indra/newview/llfloatertos.cpp
+
27
−
57
View file @
dcd36402
...
...
@@ -45,7 +45,7 @@
#include
"llvfile.h"
#include
"message.h"
#include
"llstartup.h"
// login_alert_done
#include
"llcorehttputil.h"
LLFloaterTOS
::
LLFloaterTOS
(
const
LLSD
&
data
)
:
LLModalDialog
(
data
[
"message"
].
asString
()
),
...
...
@@ -57,57 +57,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
);
...
...
@@ -180,9 +129,6 @@ void LLFloaterTOS::setSiteIsAlive( bool alive )
LLFloaterTOS
::~
LLFloaterTOS
()
{
// tell the responder we're not here anymore
if
(
gResponsePtr
)
gResponsePtr
->
setParent
(
0
);
}
// virtual
...
...
@@ -243,9 +189,10 @@ 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
);
LLCoros
::
instance
().
launch
(
"LLFloaterTOS::testSiteIsAliveCoro"
,
boost
::
bind
(
&
LLFloaterTOS
::
testSiteIsAliveCoro
,
this
,
_1
,
url
)
);
}
else
if
(
mRealNavigateBegun
)
{
...
...
@@ -257,3 +204,26 @@ void LLFloaterTOS::handleMediaEvent(LLPluginClassMedia* /*self*/, EMediaEvent ev
}
}
void
LLFloaterTOS
::
testSiteIsAliveCoro
(
LLCoros
::
self
&
self
,
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
(
"HttpCoroutineAdapter"
,
"genericPostCoro"
)
<<
"Generic POST for "
<<
url
<<
LL_ENDL
;
LLSD
result
=
httpAdapter
->
getAndYield
(
self
,
httpRequest
,
url
);
LLSD
httpResults
=
result
[
LLCoreHttpUtil
::
HttpCoroutineAdapter
::
HTTP_RESULTS
];
LLCore
::
HttpStatus
status
=
LLCoreHttpUtil
::
HttpCoroutineAdapter
::
getStatusFromLLSD
(
httpResults
);
// double not.
// First ! returns a boolean error status, second ! is true if success result.
setSiteIsAlive
(
!!
status
);
}
This diff is collapsed.
Click to expand it.
indra/newview/llfloatertos.h
+
5
−
0
View file @
dcd36402
...
...
@@ -31,6 +31,8 @@
#include
"llassetstorage.h"
#include
"llmediactrl.h"
#include
<boost/function.hpp>
#include
"lleventcoro.h"
#include
"llcoros.h"
class
LLButton
;
class
LLRadioGroup
;
...
...
@@ -60,12 +62,15 @@ class LLFloaterTOS :
/*virtual*/
void
handleMediaEvent
(
LLPluginClassMedia
*
self
,
EMediaEvent
event
);
private:
void
testSiteIsAliveCoro
(
LLCoros
::
self
&
self
,
std
::
string
url
);
std
::
string
mMessage
;
bool
mLoadingScreenLoaded
;
bool
mSiteAlive
;
bool
mRealNavigateBegun
;
std
::
string
mReplyPumpName
;
};
#endif // LL_LLFLOATERTOS_H
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment