diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/llfloaterhtml.cpp | 164 |
1 files changed, 112 insertions, 52 deletions
diff --git a/linden/indra/newview/llfloaterhtml.cpp b/linden/indra/newview/llfloaterhtml.cpp index 8a10cfe..519a031 100644 --- a/linden/indra/newview/llfloaterhtml.cpp +++ b/linden/indra/newview/llfloaterhtml.cpp | |||
@@ -1,9 +1,10 @@ | |||
1 | /** | 1 | /** |
2 | * @file llfloaterhtml.cpp | 2 | * @file llfloaterhtml.cpp |
3 | * @brief In-world web browser | 3 | * @brief In-world HTML dialog |
4 | * | 4 | * |
5 | * Copyright (c) 2005-2007, Linden Research, Inc. | 5 | * Copyright (c) 2005-2007, Linden Research, Inc. |
6 | * | 6 | * |
7 | * Second Life Viewer Source Code | ||
7 | * The source code in this file ("Source Code") is provided by Linden Lab | 8 | * The source code in this file ("Source Code") is provided by Linden Lab |
8 | * to you under the terms of the GNU General Public License, version 2.0 | 9 | * to you under the terms of the GNU General Public License, version 2.0 |
9 | * ("GPL"), unless you have obtained a separate licensing agreement | 10 | * ("GPL"), unless you have obtained a separate licensing agreement |
@@ -27,68 +28,127 @@ | |||
27 | 28 | ||
28 | #include "llviewerprecompiledheaders.h" | 29 | #include "llviewerprecompiledheaders.h" |
29 | 30 | ||
30 | #include "llfloaterhtml.h" | ||
31 | |||
32 | #include "lldir.h" | ||
33 | |||
34 | #include "llbutton.h" | ||
35 | #include "llviewertexteditor.h" | ||
36 | #include "lllineeditor.h" | ||
37 | #include "lltextbox.h" | ||
38 | #include "llvieweruictrlfactory.h" | 31 | #include "llvieweruictrlfactory.h" |
32 | #include "llviewerwindow.h" | ||
39 | #include "llviewercontrol.h" | 33 | #include "llviewercontrol.h" |
40 | #include "llwebbrowserctrl.h" | 34 | #include "llfloaterhtml.h" |
41 | #include "llviewerwindow.h" // incBusyCount() | 35 | #include "llfloaterhtmlhelp.h" |
42 | #include "llfloaterworldmap.h" //for sl urls | ||
43 | #include "viewer.h" | ||
44 | 36 | ||
45 | const S32 LINE = 16; | 37 | LLFloaterHtml* LLFloaterHtml::sInstance = 0; |
46 | const S32 HPAD = 4; | ||
47 | const S32 HPAD_SMALL = 2; | ||
48 | const S32 HSEPARATOR = 3 * HPAD; | ||
49 | const S32 VPAD = 4; | ||
50 | 38 | ||
51 | const S32 SCROLLER_HPAD = 3; | 39 | //////////////////////////////////////////////////////////////////////////////// |
40 | // | ||
41 | LLFloaterHtml* LLFloaterHtml::getInstance() | ||
42 | { | ||
43 | if ( ! sInstance ) | ||
44 | sInstance = new LLFloaterHtml; | ||
52 | 45 | ||
53 | BOOL process_secondlife_url(LLString url) | 46 | return sInstance; |
47 | } | ||
48 | |||
49 | //////////////////////////////////////////////////////////////////////////////// | ||
50 | // | ||
51 | LLFloaterHtml::LLFloaterHtml() | ||
52 | : LLFloater( "HTML Floater" ), | ||
53 | mWebBrowser( 0 ) | ||
54 | { | 54 | { |
55 | S32 strpos, strpos2; | 55 | // create floater from its XML definition |
56 | gUICtrlFactory->buildFloater( this, "floater_html.xml" ); | ||
56 | 57 | ||
57 | LLString slurlID = "slurl.com/secondlife/"; | 58 | // reposition floater from saved settings |
58 | strpos = url.find(slurlID); | 59 | LLRect rect = gSavedSettings.getRect( "HtmlFloaterRect" ); |
59 | 60 | reshape( rect.getWidth(), rect.getHeight(), FALSE ); | |
60 | if (strpos < 0) | 61 | setRect( rect ); |
61 | { | 62 | |
62 | slurlID="secondlife://"; | 63 | mWebBrowser = LLViewerUICtrlFactory::getWebBrowserByName(this, "html_floater_browser" ); |
63 | strpos = url.find(slurlID); | 64 | if ( mWebBrowser ) |
64 | } | ||
65 | |||
66 | if (strpos >= 0) | ||
67 | { | 65 | { |
68 | LLString simname; | 66 | // observe browser events |
67 | mWebBrowser->addObserver( this ); | ||
68 | |||
69 | // make links open in external browser | ||
70 | mWebBrowser->setOpenInExternalBrowser( true ); | ||
71 | |||
72 | // don't automatically open secondlife links since we want to catch | ||
73 | // special ones that do other stuff (like open F1 Help) | ||
74 | mWebBrowser->setOpenSecondLifeLinksInMap( false ); | ||
75 | }; | ||
76 | |||
77 | childSetAction("close_btn", onClickClose, this); | ||
78 | setDefaultBtn("close_btn"); | ||
79 | } | ||
80 | |||
81 | //////////////////////////////////////////////////////////////////////////////// | ||
82 | // | ||
83 | LLFloaterHtml::~LLFloaterHtml() | ||
84 | { | ||
85 | // stop observing browser events | ||
86 | if ( mWebBrowser ) | ||
87 | mWebBrowser->remObserver( this ); | ||
88 | |||
89 | // save position of floater | ||
90 | gSavedSettings.setRect( "HtmlFloaterRect", mRect ); | ||
91 | |||
92 | sInstance = 0; | ||
93 | } | ||
69 | 94 | ||
70 | strpos+=slurlID.length(); | 95 | //////////////////////////////////////////////////////////////////////////////// |
71 | strpos2=url.find("/",strpos); | 96 | // |
72 | if (strpos2 < strpos) strpos2=url.length(); | 97 | void LLFloaterHtml::show( LLString content_id ) |
73 | simname="secondlife://" + url.substr(strpos,url.length() - strpos); | 98 | { |
99 | // calculate the XML labels we'll need (if only XML folders worked) | ||
100 | LLString title_str = content_id + "_title"; | ||
101 | LLString url_str = content_id + "_url"; | ||
102 | |||
103 | // set the title | ||
104 | setTitle( childGetValue( title_str ).asString() ); | ||
105 | |||
106 | // navigate to the URL | ||
107 | if ( mWebBrowser ) | ||
108 | mWebBrowser->navigateTo( childGetValue( url_str ).asString() ); | ||
109 | |||
110 | // make floater appear | ||
111 | setVisibleAndFrontmost(); | ||
112 | } | ||
113 | |||
114 | //////////////////////////////////////////////////////////////////////////////// | ||
115 | // | ||
116 | void LLFloaterHtml::onClose( bool app_quitting ) | ||
117 | { | ||
118 | setVisible( false ); | ||
119 | } | ||
120 | |||
121 | //////////////////////////////////////////////////////////////////////////////// | ||
122 | // | ||
123 | void LLFloaterHtml::onClickClose( void* data ) | ||
124 | { | ||
125 | LLFloaterHtml* self = ( LLFloaterHtml* )data; | ||
74 | 126 | ||
75 | LLURLSimString::setString( simname ); | 127 | self->setVisible( false ); |
76 | LLURLSimString::parse(); | 128 | } |
77 | 129 | ||
78 | // if there is a world map | 130 | //////////////////////////////////////////////////////////////////////////////// |
79 | if ( gFloaterWorldMap ) | 131 | // |
132 | void LLFloaterHtml::onClickLinkSecondLife( const EventType& eventIn ) | ||
133 | { | ||
134 | const std::string protocol( "secondlife://app." ); | ||
135 | |||
136 | // special 'app' secondlife link (using a different protocol - one that isn't registered in the browser) causes bad | ||
137 | // things to happen and Mozilla stops responding because it can't display the "invalid protocol dialog) | ||
138 | if ( LLString::compareInsensitive( eventIn.getStringValue().substr( 0, protocol.length() ).c_str(), protocol.c_str() ) == 0 ) | ||
139 | { | ||
140 | // extract the command string | ||
141 | LLString cmd = eventIn.getStringValue().substr( protocol.length() ); | ||
142 | |||
143 | // command is open the F1 Help floater | ||
144 | if ( LLString::compareInsensitive( cmd.c_str() , "floater.html.help" ) == 0 ) | ||
80 | { | 145 | { |
81 | // mark where the destination is | 146 | gViewerHtmlHelp.show(); |
82 | gFloaterWorldMap->trackURL( LLURLSimString::sInstance.mSimName.c_str(), | ||
83 | LLURLSimString::sInstance.mX, | ||
84 | LLURLSimString::sInstance.mY, | ||
85 | LLURLSimString::sInstance.mZ ); | ||
86 | |||
87 | // display map | ||
88 | LLFloaterWorldMap::show( NULL, TRUE ); | ||
89 | }; | 147 | }; |
90 | |||
91 | return TRUE; | ||
92 | } | 148 | } |
93 | return FALSE; | 149 | else |
94 | } | 150 | // regular secondlife link - just open the map as normal |
151 | { | ||
152 | mWebBrowser->openMapAtlocation( eventIn.getStringValue() ); | ||
153 | }; | ||
154 | }; \ No newline at end of file | ||