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
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
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 Archive
Alchemy Viewer
Commits
2f0e3de4
Commit
2f0e3de4
authored
9 years ago
by
Rider Linden
Browse files
Options
Downloads
Patches
Plain Diff
Land Media URL entry to coroutine.
parent
dcd36402
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
indra/newview/llfloaterurlentry.cpp
+55
-33
55 additions, 33 deletions
indra/newview/llfloaterurlentry.cpp
indra/newview/llfloaterurlentry.h
+6
-1
6 additions, 1 deletion
indra/newview/llfloaterurlentry.h
with
61 additions
and
34 deletions
indra/newview/llfloaterurlentry.cpp
+
55
−
33
View file @
2f0e3de4
...
@@ -40,40 +40,10 @@
...
@@ -40,40 +40,10 @@
#include
"lluictrlfactory.h"
#include
"lluictrlfactory.h"
#include
"llwindow.h"
#include
"llwindow.h"
#include
"llviewerwindow.h"
#include
"llviewerwindow.h"
#include
"llcorehttputil.h"
static
LLFloaterURLEntry
*
sInstance
=
NULL
;
static
LLFloaterURLEntry
*
sInstance
=
NULL
;
// Move this to its own file.
// helper class that tries to download a URL from a web site and calls a method
// on the Panel Land Media and to discover the MIME type
class
LLMediaTypeResponder
:
public
LLHTTPClient
::
Responder
{
LOG_CLASS
(
LLMediaTypeResponder
);
public:
LLMediaTypeResponder
(
const
LLHandle
<
LLFloater
>
parent
)
:
mParent
(
parent
)
{}
LLHandle
<
LLFloater
>
mParent
;
private
:
/* virtual */
void
httpCompleted
()
{
const
std
::
string
&
media_type
=
getResponseHeader
(
HTTP_IN_HEADER_CONTENT_TYPE
);
std
::
string
::
size_type
idx1
=
media_type
.
find_first_of
(
";"
);
std
::
string
mime_type
=
media_type
.
substr
(
0
,
idx1
);
// Set empty type to none/none. Empty string is reserved for legacy parcels
// which have no mime type set.
std
::
string
resolved_mime_type
=
!
mime_type
.
empty
()
?
mime_type
:
LLMIMETypes
::
getDefaultMimeType
();
LLFloaterURLEntry
*
floater_url_entry
=
(
LLFloaterURLEntry
*
)
mParent
.
get
();
if
(
floater_url_entry
)
{
floater_url_entry
->
headerFetchComplete
(
getStatus
(),
resolved_mime_type
);
}
}
};
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// LLFloaterURLEntry()
// LLFloaterURLEntry()
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
...
@@ -225,8 +195,8 @@ void LLFloaterURLEntry::onBtnOK( void* userdata )
...
@@ -225,8 +195,8 @@ void LLFloaterURLEntry::onBtnOK( void* userdata )
if
(
!
media_url
.
empty
()
&&
if
(
!
media_url
.
empty
()
&&
(
scheme
==
"http"
||
scheme
==
"https"
))
(
scheme
==
"http"
||
scheme
==
"https"
))
{
{
LLHTTPClient
::
getHeaderOnly
(
media_url
,
LLCoros
::
instance
().
launch
(
"LLFloaterURLEntry::getMediaTypeCoro"
,
new
LLMediaTypeResponder
(
self
->
getHandle
()));
boost
::
bind
(
&
LLFloaterURLEntry
::
getMediaTypeCoro
,
_1
,
media_url
,
self
->
getHandle
()));
}
}
else
else
{
{
...
@@ -239,6 +209,58 @@ void LLFloaterURLEntry::onBtnOK( void* userdata )
...
@@ -239,6 +209,58 @@ void LLFloaterURLEntry::onBtnOK( void* userdata )
self
->
getChildView
(
"media_entry"
)
->
setEnabled
(
false
);
self
->
getChildView
(
"media_entry"
)
->
setEnabled
(
false
);
}
}
// static
void
LLFloaterURLEntry
::
getMediaTypeCoro
(
LLCoros
::
self
&
self
,
std
::
string
url
,
LLHandle
<
LLFloater
>
parentHandle
)
{
LLCore
::
HttpRequest
::
policy_t
httpPolicy
(
LLCore
::
HttpRequest
::
DEFAULT_POLICY_ID
);
LLCoreHttpUtil
::
HttpCoroutineAdapter
::
ptr_t
httpAdapter
(
new
LLCoreHttpUtil
::
HttpCoroutineAdapter
(
"getMediaTypeCoro"
,
httpPolicy
));
LLCore
::
HttpRequest
::
ptr_t
httpRequest
(
new
LLCore
::
HttpRequest
);
LLCore
::
HttpOptions
::
ptr_t
httpOpts
=
LLCore
::
HttpOptions
::
ptr_t
(
new
LLCore
::
HttpOptions
);
httpOpts
->
setHeadersOnly
(
true
);
LL_INFOS
(
"HttpCoroutineAdapter"
,
"genericPostCoro"
)
<<
"Generic POST for "
<<
url
<<
LL_ENDL
;
LLSD
result
=
httpAdapter
->
getAndYield
(
self
,
httpRequest
,
url
,
httpOpts
);
LLSD
httpResults
=
result
[
LLCoreHttpUtil
::
HttpCoroutineAdapter
::
HTTP_RESULTS
];
LLCore
::
HttpStatus
status
=
LLCoreHttpUtil
::
HttpCoroutineAdapter
::
getStatusFromLLSD
(
httpResults
);
LLFloaterURLEntry
*
floaterUrlEntry
=
(
LLFloaterURLEntry
*
)
parentHandle
.
get
();
if
(
!
floaterUrlEntry
)
{
LL_WARNS
()
<<
"Could not get URL entry floater."
<<
LL_ENDL
;
return
;
}
// Set empty type to none/none. Empty string is reserved for legacy parcels
// which have no mime type set.
std
::
string
resolvedMimeType
=
LLMIMETypes
::
getDefaultMimeType
();
if
(
!
status
)
{
floaterUrlEntry
->
headerFetchComplete
(
status
.
getType
(),
resolvedMimeType
);
return
;
}
LLSD
resultHeaders
=
httpResults
[
LLCoreHttpUtil
::
HttpCoroutineAdapter
::
HTTP_RESULTS_HEADERS
];
if
(
resultHeaders
.
has
(
HTTP_IN_HEADER_CONTENT_TYPE
))
{
const
std
::
string
&
mediaType
=
resultHeaders
[
HTTP_IN_HEADER_CONTENT_TYPE
];
std
::
string
::
size_type
idx1
=
mediaType
.
find_first_of
(
";"
);
std
::
string
mimeType
=
mediaType
.
substr
(
0
,
idx1
);
if
(
!
mimeType
.
empty
())
{
resolvedMimeType
=
mimeType
;
}
}
floaterUrlEntry
->
headerFetchComplete
(
status
.
getType
(),
resolvedMimeType
);
}
// static
// static
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// onBtnCancel()
// onBtnCancel()
...
...
This diff is collapsed.
Click to expand it.
indra/newview/llfloaterurlentry.h
+
6
−
1
View file @
2f0e3de4
...
@@ -29,6 +29,8 @@
...
@@ -29,6 +29,8 @@
#include
"llfloater.h"
#include
"llfloater.h"
#include
"llpanellandmedia.h"
#include
"llpanellandmedia.h"
#include
"lleventcoro.h"
#include
"llcoros.h"
class
LLLineEditor
;
class
LLLineEditor
;
class
LLComboBox
;
class
LLComboBox
;
...
@@ -57,6 +59,9 @@ private:
...
@@ -57,6 +59,9 @@ private:
static
void
onBtnCancel
(
void
*
);
static
void
onBtnCancel
(
void
*
);
static
void
onBtnClear
(
void
*
);
static
void
onBtnClear
(
void
*
);
bool
callback_clear_url_list
(
const
LLSD
&
notification
,
const
LLSD
&
response
);
bool
callback_clear_url_list
(
const
LLSD
&
notification
,
const
LLSD
&
response
);
static
void
getMediaTypeCoro
(
LLCoros
::
self
&
self
,
std
::
string
url
,
LLHandle
<
LLFloater
>
parentHandle
);
};
};
#endif // LL_LLFLOATERURLENTRY_H
#endif // LL_LLFLOATERURLENTRY_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