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
9dee1618
Commit
9dee1618
authored
3 years ago
by
Andrey Kleshchev
Browse files
Options
Downloads
Patches
Plain Diff
SL-15168 Changed format
instead of an url function takes an uri
parent
48394bdc
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
indra/newview/llurlfloaterdispatchhandler.cpp
+67
-30
67 additions, 30 deletions
indra/newview/llurlfloaterdispatchhandler.cpp
with
67 additions
and
30 deletions
indra/newview/llurlfloaterdispatchhandler.cpp
+
67
−
30
View file @
9dee1618
...
...
@@ -36,25 +36,30 @@
#include
"llviewergenericmessage.h"
#include
"llweb.h"
#include
<boost/regex.hpp>
// Example:
// llOpenFloater("My Help Title", "secondlife://guidebook", []);
// values specified by server side's dispatcher
// for llopenfloater
const
std
::
string
MESSAGE_URL_FLOATER
(
"URLFloater"
);
const
std
::
string
KEY_ACTION
(
"action"
);
// "action" will be the string constant "OpenURL"
const
std
::
string
VALUE_OPEN_URL
(
"OpenURL"
);
const
std
::
string
KEY_DATA
(
"action_data"
);
const
std
::
string
KEY_FLOATER
(
"floater_title"
);
const
std
::
string
KEY_UR
L
(
"floater_url"
);
const
std
::
string
KEY_FLOATER
_TITLE
(
"floater_title"
);
const
std
::
string
KEY_UR
I
(
"floater_url"
);
const
std
::
string
KEY_PARAMS
(
"floater_params"
);
// Supported floaters
const
std
::
string
FLOATER_GUIDEBOOK
(
"guidebook"
);
// alias for how_to
const
std
::
string
FLOATER_HOW_TO
(
"how_to"
);
const
std
::
string
FLOATER_WEB_CONTENT
(
"web_content"
);
// Supported floaters, for now it's exact matching, later it might get extended
const
std
::
string
FLOATER_GUIDEBOOK
(
"secondlife://guidebook"
);
// translates to "how_to"
const
std
::
string
FLOATER_WEB_CONTENT
(
"secondlife://browser"
);
// translates to "web_content"
// Web content universal argument
// Web content universal argument
s
const
std
::
string
KEY_TRUSTED_CONTENT
(
"trusted_content"
);
const
std
::
string
KEY_URL
(
"url"
);
// Guidebook specific arguments
// Guidebook
("how_to")
specific arguments
const
std
::
string
KEY_WIDTH
(
"width"
);
const
std
::
string
KEY_HEGHT
(
"height"
);
const
std
::
string
KEY_CAN_CLOSE
(
"can_close"
);
...
...
@@ -63,6 +68,10 @@ const std::string KEY_CAN_CLOSE("can_close");
const
std
::
string
KEY_SHOW_PAGE_TITLE
(
"show_page_title"
);
const
std
::
string
KEY_ALLOW_ADRESS_ENTRY
(
"allow_address_entry"
);
// It is not recomended to set this to true if trusted content is allowed
// expected format secondlife:///floater_alias
// intended to be extended to: secondlife:///floater_alias/instance_id
const
boost
::
regex
expression
(
"secondlife:///[^
\n
]{1,256}"
);
LLUrlFloaterDispatchHandler
LLUrlFloaterDispatchHandler
::
sUrlDispatchhandler
;
...
...
@@ -101,25 +110,25 @@ bool LLUrlFloaterDispatchHandler::operator()(const LLDispatcher *, const std::st
}
}
std
::
string
floater
;
std
::
string
floater
_title
;
LLSD
command_params
;
std
::
string
ur
l
;
std
::
string
floater_
ur
i
;
if
(
message
.
has
(
KEY_ACTION
)
&&
message
[
KEY_ACTION
].
asString
()
==
VALUE_OPEN_URL
)
{
LLSD
&
action_data
=
message
[
KEY_DATA
];
if
(
action_data
.
isMap
())
{
floater
=
action_data
[
KEY_FLOATER
].
asString
();
floater
_title
=
action_data
[
KEY_FLOATER
_TITLE
].
asString
();
command_params
=
action_data
[
KEY_PARAMS
];
ur
l
=
action_data
[
KEY_UR
L
].
asString
();
floater_
ur
i
=
action_data
[
KEY_UR
I
].
asString
();
}
}
else
if
(
message
.
has
(
KEY_FLOATER
))
else
if
(
message
.
has
(
KEY_FLOATER
_TITLE
))
{
floater
=
message
[
KEY_FLOATER
].
asString
();
floater
_title
=
message
[
KEY_FLOATER
_TITLE
].
asString
();
command_params
=
message
[
KEY_PARAMS
];
ur
l
=
message
[
KEY_UR
L
].
asString
();
floater_
ur
i
=
message
[
KEY_UR
I
].
asString
();
}
else
{
...
...
@@ -127,16 +136,33 @@ bool LLUrlFloaterDispatchHandler::operator()(const LLDispatcher *, const std::st
return
false
;
}
if
(
ur
l
.
find
(
"://"
)
==
std
::
string
::
npos
)
if
(
floater_
ur
i
.
find
(
"://
/
"
)
==
std
::
string
::
npos
)
{
// try unescaping
url
=
LLURI
::
unescape
(
url
);
floater_uri
=
LLURI
::
unescape
(
floater_uri
);
}
boost
::
cmatch
what
;
if
(
!
boost
::
regex_match
(
floater_uri
.
c_str
(),
what
,
expression
))
{
LL_WARNS
(
"URLFloater"
)
<<
"Received "
<<
MESSAGE_URL_FLOATER
<<
" with invalid uri: "
<<
floater_uri
<<
LL_ENDL
;
return
false
;
}
LLFloaterWebContent
::
Params
params
;
params
.
url
=
url
;
if
(
command_params
.
isMap
())
{
if
(
command_params
.
has
(
KEY_TRUSTED_CONTENT
))
{
params
.
trusted_content
=
command_params
[
KEY_TRUSTED_CONTENT
].
asBoolean
();
}
if
(
command_params
.
has
(
KEY_URL
))
{
params
.
url
=
command_params
[
KEY_URL
].
asString
();
}
}
if
(
floater
==
FLOATER_GUIDEBOOK
||
floater
==
FLOATER_HOW_TO
)
if
(
floater
_uri
==
FLOATER_GUIDEBOOK
)
{
if
(
command_params
.
isMap
())
// by default is undefines
{
...
...
@@ -162,34 +188,45 @@ bool LLUrlFloaterDispatchHandler::operator()(const LLDispatcher *, const std::st
}
LLFloaterReg
::
toggleInstanceOrBringToFront
(
"how_to"
,
params
);
instance
=
LLFloaterReg
::
findInstance
(
"how_to"
);
instance
->
setTitle
(
floater_title
);
if
(
command_params
.
isMap
()
&&
command_params
.
has
(
KEY_CAN_CLOSE
))
{
LLFloater
*
instance
=
LLFloaterReg
::
findInstance
(
"how_to"
);
instance
->
setCanClose
(
command_params
[
KEY_CAN_CLOSE
].
asBoolean
());
}
}
else
if
(
floater
==
FLOATER_WEB_CONTENT
)
else
if
(
floater
_uri
==
FLOATER_WEB_CONTENT
)
{
if
(
command_params
.
isMap
())
// by default is undefines, might be better idea to init params from command_params
if
(
command_params
.
has
(
KEY_URL
))
{
params
.
trusted_content
=
command_params
.
has
(
KEY_TRUSTED_CONTENT
)
?
command_params
[
KEY_TRUSTED_CONTENT
].
asBoolean
()
:
false
;
params
.
show_page_title
=
command_params
.
has
(
KEY_SHOW_PAGE_TITLE
)
?
command_params
[
KEY_SHOW_PAGE_TITLE
].
asBoolean
()
:
true
;
params
.
allow_address_entry
=
command_params
.
has
(
KEY_ALLOW_ADRESS_ENTRY
)
?
command_params
[
KEY_ALLOW_ADRESS_ENTRY
].
asBoolean
()
:
true
;
if
(
command_params
.
isMap
())
// by default is undefines, might be better idea to init params from command_params
{
params
.
trusted_content
=
command_params
.
has
(
KEY_TRUSTED_CONTENT
)
?
command_params
[
KEY_TRUSTED_CONTENT
].
asBoolean
()
:
false
;
params
.
show_page_title
=
command_params
.
has
(
KEY_SHOW_PAGE_TITLE
)
?
command_params
[
KEY_SHOW_PAGE_TITLE
].
asBoolean
()
:
true
;
params
.
allow_address_entry
=
command_params
.
has
(
KEY_ALLOW_ADRESS_ENTRY
)
?
command_params
[
KEY_ALLOW_ADRESS_ENTRY
].
asBoolean
()
:
true
;
}
LLFloater
*
instance
=
LLFloaterReg
::
showInstance
(
"web_content"
,
params
);
instance
->
setTitle
(
floater_title
);
}
LLFloaterReg
::
showInstance
(
"web_content"
,
params
);
}
else
{
if
(
LLFloaterReg
::
isRegistered
(
floater
))
LLSD
path_array
=
LLURI
(
floater_uri
).
pathArray
();
S32
path_parts
=
path_array
.
size
();
if
(
path_parts
==
0
)
{
LL_INFOS
(
"URLFloater"
)
<<
"received an empty uri: "
<<
floater_uri
<<
LL_ENDL
;
}
else
if
(
LLFloaterReg
::
isRegistered
(
path_array
[
0
]))
{
// A valid floater
LL_INFOS
(
"URLFloater"
)
<<
"Floater "
<<
floater
<<
" is not supported by llopenfloater or URLFloater"
<<
LL_ENDL
;
LL_INFOS
(
"URLFloater"
)
<<
"Floater "
<<
path_array
[
0
]
<<
" is not supported by llopenfloater or URLFloater"
<<
LL_ENDL
;
}
else
{
// A valid message, but no such flaoter
LL_WARNS
(
"URLFloater"
)
<<
"Recieved a command to open unknown floater: "
<<
floater
<<
LL_ENDL
;
LL_WARNS
(
"URLFloater"
)
<<
"Recieved a command to open unknown floater: "
<<
floater
_uri
<<
LL_ENDL
;
}
}
...
...
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