aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra
diff options
context:
space:
mode:
authorthickbrick2010-11-10 20:18:37 +0200
committerthickbrick2010-11-10 20:18:37 +0200
commit37aca802374aabd3932f49e8fd7b6bdee70069ca (patch)
tree3f4eda9e87129b25514e7899615f999914abfa19 /linden/indra
parentFix #700: View -> Web Browser does nothing (diff)
downloadmeta-impy-37aca802374aabd3932f49e8fd7b6bdee70069ca.zip
meta-impy-37aca802374aabd3932f49e8fd7b6bdee70069ca.tar.gz
meta-impy-37aca802374aabd3932f49e8fd7b6bdee70069ca.tar.bz2
meta-impy-37aca802374aabd3932f49e8fd7b6bdee70069ca.tar.xz
More #700: remove llfloaterhtmlhelp.cpp
This file is media plugin a merge leftover. It was renamed to llfloatermediabrowser.cpp, but somehow this got left behind.
Diffstat (limited to 'linden/indra')
-rw-r--r--linden/indra/newview/llfloaterhtmlhelp.cpp562
1 files changed, 0 insertions, 562 deletions
diff --git a/linden/indra/newview/llfloaterhtmlhelp.cpp b/linden/indra/newview/llfloaterhtmlhelp.cpp
deleted file mode 100644
index c89c2e2..0000000
--- a/linden/indra/newview/llfloaterhtmlhelp.cpp
+++ /dev/null
@@ -1,562 +0,0 @@
1/**
2 * @file llfloaterhtmlhelp.cpp
3 * @brief HTML Help floater - uses embedded web browser control
4 *
5 * $LicenseInfo:firstyear=2006&license=viewergpl$
6 *
7 * Copyright (c) 2006-2009, Linden Research, Inc.
8 *
9 * Second Life Viewer Source Code
10 * The source code in this file ("Source Code") is provided by Linden Lab
11 * to you under the terms of the GNU General Public License, version 2.0
12 * ("GPL"), unless you have obtained a separate licensing agreement
13 * ("Other License"), formally executed by you and Linden Lab. Terms of
14 * the GPL can be found in doc/GPL-license.txt in this distribution, or
15 * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
16 *
17 * There are special exceptions to the terms and conditions of the GPL as
18 * it is applied to this Source Code. View the full text of the exception
19 * in the file doc/FLOSS-exception.txt in this software distribution, or
20 * online at
21 * http://secondlifegrid.net/programs/open_source/licensing/flossexception
22 *
23 * By copying, modifying or distributing this software, you acknowledge
24 * that you have read and understood your obligations described above,
25 * and agree to abide by those obligations.
26 *
27 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
28 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
29 * COMPLETENESS OR PERFORMANCE.
30 * $/LicenseInfo$
31 */
32
33#include "llviewerprecompiledheaders.h"
34
35#include "llfloaterhtmlhelp.h"
36#include "llfloaterhtml.h"
37
38#include "llchat.h"
39#include "llfloaterchat.h"
40#include "llparcel.h"
41#include "lluictrlfactory.h"
42#include "llwebbrowserctrl.h"
43#include "llviewerwindow.h"
44#include "llviewercontrol.h"
45#include "llviewerparcelmgr.h"
46#include "llweb.h"
47#include "lltrans.h"
48#include "llui.h"
49#include "roles_constants.h"
50
51#include "llurlhistory.h"
52#include "llwebbrowserctrl.h"
53#include "llviewermedia.h"
54#include "llviewerparcelmedia.h"
55#include "llcombobox.h"
56
57#include "hippogridmanager.h"
58
59LLFloaterMediaBrowser::LLFloaterMediaBrowser(const LLSD& media_data)
60{
61 LLUICtrlFactory::getInstance()->buildFloater(this, "floater_media_browser.xml");
62}
63
64void LLFloaterMediaBrowser::draw()
65{
66 BOOL url_exists = !mAddressCombo->getValue().asString().empty();
67 childSetEnabled("go", url_exists);
68 childSetEnabled("set_home", url_exists);
69 LLParcel* parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();
70 if(parcel)
71 {
72 childSetVisible("parcel_owner_controls", LLViewerParcelMgr::isParcelModifiableByAgent(parcel, GP_LAND_CHANGE_MEDIA));
73 childSetEnabled("assign", !mAddressCombo->getValue().asString().empty());
74 }
75 LLFloater::draw();
76}
77
78BOOL LLFloaterMediaBrowser::postBuild()
79{
80 mBrowser = getChild<LLWebBrowserCtrl>("browser");
81 mBrowser->addObserver(this);
82
83 mAddressCombo = getChild<LLComboBox>("address");
84 mAddressCombo->setCommitCallback(onEnterAddress);
85 mAddressCombo->setCallbackUserData(this);
86
87 childSetAction("back", onClickBack, this);
88 childSetAction("forward", onClickForward, this);
89 childSetAction("reload", onClickRefresh, this);
90 childSetAction("go", onClickGo, this);
91 childSetAction("close", onClickClose, this);
92 childSetAction("open_browser", onClickOpenWebBrowser, this);
93 childSetAction("assign", onClickAssign, this);
94 childSetAction("home", onClickHome, this);
95 childSetAction("set_home", onClickSetHome, this);
96
97 buildURLHistory();
98
99 //Show home url if new session, last visited if not
100 std::string last_url = gSavedSettings.getString("BrowserLastVisited");
101 if (last_url.empty())
102 {
103 last_url = gSavedSettings.getString("BrowserHome");
104 }
105 openMedia(last_url);
106
107 return TRUE;
108}
109
110void LLFloaterMediaBrowser::buildURLHistory()
111{
112 LLCtrlListInterface* url_list = childGetListInterface("address");
113 if (url_list)
114 {
115 url_list->operateOnAll(LLCtrlListInterface::OP_DELETE);
116 }
117
118 // Get all of the entries in the "parcel" collection
119 LLSD parcel_history = LLURLHistory::getURLHistory("browser");
120
121 LLSD::array_iterator iter_history =
122 parcel_history.beginArray();
123 LLSD::array_iterator end_history =
124 parcel_history.endArray();
125 for(; iter_history != end_history; ++iter_history)
126 {
127 std::string url = (*iter_history).asString();
128 if(! url.empty())
129 url_list->addSimpleElement(url);
130 }
131}
132
133void LLFloaterMediaBrowser::onClose(bool app_quitting)
134{
135 //setVisible(FALSE);
136 destroy();
137}
138
139void LLFloaterMediaBrowser::onLocationChange( const EventType& eventIn )
140{
141 // hitting the refresh button will navigate to same URL, so don't add to address history
142 mCurrentURL = eventIn.getStringValue();
143 std::string::size_type string_start = mCurrentURL.find("://");
144 std::string truncated_url;
145 if ((string_start == std::string::npos) || (1)) // NOTE: this conditional is forced true to disable truncation DEV-9834
146 {
147 truncated_url = mCurrentURL;
148 }
149 else
150 {
151 truncated_url = mCurrentURL.substr(string_start + 3);
152 }
153 // redirects will navigate momentarily to about:blank, don't add to history
154 if (truncated_url != "about:blank")
155 {
156 mAddressCombo->remove(truncated_url);
157 mAddressCombo->add(truncated_url, ADD_SORTED);
158 mAddressCombo->selectByValue(truncated_url);
159
160 // Serialize url history
161 LLURLHistory::removeURL("browser", truncated_url);
162 LLURLHistory::addURL("browser", truncated_url);
163 }
164 childSetEnabled("back", mBrowser->canNavigateBack());
165 childSetEnabled("forward", mBrowser->canNavigateForward());
166 childSetEnabled("reload", TRUE);
167 gSavedSettings.setString("BrowserLastVisited", truncated_url);
168}
169
170//static
171void LLFloaterMediaBrowser::helpF1()
172{
173 std::string url = gSavedSettings.getString("HelpSupportURL");
174 LLSD payload;
175 payload["url"] = url;
176
177 LLNotifications::instance().add("ClickOpenF1Help", LLSD(), payload, onClickF1HelpLoadURL);
178}
179
180// static
181bool LLFloaterMediaBrowser::onClickF1HelpLoadURL(const LLSD& notification, const LLSD& response)
182{
183 S32 option = LLNotification::getSelectedOption(notification, response);
184 if (option == 0)
185 {
186 LLWeb::loadURL(notification["payload"]["url"].asString());
187 }
188 return false;
189}
190
191//static
192void LLFloaterMediaBrowser::onEnterAddress(LLUICtrl* ctrl, void* user_data)
193{
194 LLFloaterMediaBrowser* self = (LLFloaterMediaBrowser*)user_data;
195 self->mBrowser->navigateTo(self->mAddressCombo->getValue().asString());
196}
197
198//static
199void LLFloaterMediaBrowser::onClickRefresh(void* user_data)
200{
201 LLFloaterMediaBrowser* self = (LLFloaterMediaBrowser*)user_data;
202
203 self->mAddressCombo->remove(0);
204 self->mBrowser->navigateTo(self->mCurrentURL);
205}
206
207//static
208void LLFloaterMediaBrowser::onClickForward(void* user_data)
209{
210 LLFloaterMediaBrowser* self = (LLFloaterMediaBrowser*)user_data;
211
212 self->mBrowser->navigateForward();
213}
214
215//static
216void LLFloaterMediaBrowser::onClickBack(void* user_data)
217{
218 LLFloaterMediaBrowser* self = (LLFloaterMediaBrowser*)user_data;
219
220 self->mBrowser->navigateBack();
221}
222
223//static
224void LLFloaterMediaBrowser::onClickGo(void* user_data)
225{
226 LLFloaterMediaBrowser* self = (LLFloaterMediaBrowser*)user_data;
227
228 self->mBrowser->navigateTo(self->mAddressCombo->getValue().asString());
229}
230
231//static
232void LLFloaterMediaBrowser::onClickClose(void* user_data)
233{
234 LLFloaterMediaBrowser* self = (LLFloaterMediaBrowser*)user_data;
235
236 self->close();
237}
238
239//static
240void LLFloaterMediaBrowser::onClickOpenWebBrowser(void* user_data)
241{
242 LLFloaterMediaBrowser* self = (LLFloaterMediaBrowser*)user_data;
243
244 std::string url = self->mCurrentURL.empty() ?
245 self->mBrowser->getHomePageUrl() :
246 self->mCurrentURL;
247 LLWeb::loadURLExternal(url);
248}
249
250void LLFloaterMediaBrowser::onClickAssign(void* user_data)
251{
252 LLFloaterMediaBrowser* self = (LLFloaterMediaBrowser*)user_data;
253
254 LLParcel* parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();
255 if (!parcel)
256 {
257 return;
258 }
259 std::string media_url = self->mAddressCombo->getValue().asString();
260 LLStringUtil::trim(media_url);
261
262 parcel->setMediaURL(media_url);
263 parcel->setMediaType(std::string("text/html"));
264
265 // Send current parcel data upstream to server
266 LLViewerParcelMgr::getInstance()->sendParcelPropertiesUpdate( parcel, true );
267 // now check for video
268 LLViewerParcelMedia::update( parcel );
269}
270
271// static
272void LLFloaterMediaBrowser::onClickHome(void* user_data)
273{
274 LLFloaterMediaBrowser* self = (LLFloaterMediaBrowser*)user_data;
275 if (self)
276 {
277 if (self->mBrowser)
278 {
279 std::string home_url = gSavedSettings.getString("BrowserHome");
280 self->mBrowser->navigateTo(home_url);
281 }
282 }
283}
284
285void LLFloaterMediaBrowser::onClickSetHome(void* user_data)
286{
287 LLFloaterMediaBrowser* self = (LLFloaterMediaBrowser*)user_data;
288 std::string url = self->mCurrentURL;
289 if(!url.empty())
290 {
291 LLChat chat;
292 std::string log_message = LLTrans::getString("new_home_page") + " ";
293 log_message += url;
294 chat.mText = log_message;
295 LLFloaterChat::addChat(chat, FALSE, FALSE);
296 gSavedSettings.setString("BrowserHome", url);
297 }
298}
299
300void LLFloaterMediaBrowser::openMedia(const std::string& media_url)
301{
302 mBrowser->setHomePageUrl(media_url);
303 mBrowser->navigateTo(media_url);
304}
305
306LLViewerHtmlHelp gViewerHtmlHelp;
307
308class LLFloaterHtmlHelp :
309 public LLFloater,
310 public LLWebBrowserCtrlObserver
311{
312public:
313 LLFloaterHtmlHelp(std::string start_url, std::string title);
314 virtual ~LLFloaterHtmlHelp();
315
316 virtual void onClose( bool app_quitting );
317 virtual void draw();
318
319 static void show(std::string url, std::string title);
320
321private:
322 static void onClickBack( void* data );
323 //static void onClickHome( void* data );
324 static void onClickForward( void* data );
325 static void onClickClose( void* data );
326
327 // browser observer impls
328 virtual void onStatusTextChange( const EventType& eventIn );
329 virtual void onLocationChange( const EventType& eventIn );
330
331 // used for some stats logging - will be removed at some point
332 static BOOL sFloaterOpened;
333
334 static bool onClickF1HelpLoadURL(const LLSD& notification, const LLSD& response);
335
336 LLWebBrowserCtrl* mWebBrowser;
337 static LLFloaterHtmlHelp* sInstance;
338 LLButton* mBackButton;
339 LLButton* mForwardButton;
340 LLButton* mCloseButton;
341 LLTextBox* mStatusText;
342 std::string mStatusTextContents;
343 std::string mCurrentUrl;
344 std::string mSupportUrl;
345};
346
347LLFloaterHtmlHelp* LLFloaterHtmlHelp::sInstance = 0;
348
349BOOL LLFloaterHtmlHelp::sFloaterOpened = FALSE;
350
351////////////////////////////////////////////////////////////////////////////////
352//
353LLFloaterHtmlHelp::LLFloaterHtmlHelp(std::string start_url, std::string title)
354: LLFloater( std::string("HTML Help") ),
355 mWebBrowser( 0 ),
356 mStatusTextContents( LLStringUtil::null ),
357 mCurrentUrl( LLStringUtil::null )
358{
359 sInstance = this;
360
361 // create floater from its XML definition
362 LLUICtrlFactory::getInstance()->buildFloater( this, "floater_html_help.xml" );
363
364 childSetAction("back_btn", onClickBack, this);
365 //childSetAction("home_btn", onClickHome, this);
366 childSetAction("forward_btn", onClickForward, this);
367
368 if (!title.empty())
369 {
370 setTitle(title);
371 }
372
373 mWebBrowser = getChild<LLWebBrowserCtrl>("html_help_browser" );
374 if ( mWebBrowser )
375 {
376 // observe browser control events
377 mWebBrowser->addObserver( this );
378
379 if (start_url != "")
380 {
381 mWebBrowser->navigateTo( start_url );
382 }
383 else
384 {
385 // if the last page we were at before the client was closed is valid, go there and
386 // override what is in the XML file
387 // (not when the window was closed - it's only ever hidden - not closed)
388 std::string lastPageUrl = gSavedSettings.getString( "HtmlHelpLastPage" );
389 if ( lastPageUrl != "" )
390 {
391 mWebBrowser->navigateTo( lastPageUrl );
392 };
393 }
394 };
395}
396
397////////////////////////////////////////////////////////////////////////////////
398//
399LLFloaterHtmlHelp::~LLFloaterHtmlHelp()
400{
401 // stop observing browser events
402 if ( mWebBrowser )
403 {
404 mWebBrowser->remObserver( this );
405 };
406
407 // save position of floater
408 gSavedSettings.setRect( "HtmlHelpRect", getRect() );
409
410 // save the location we were at when SL closed
411 gSavedSettings.setString( "HtmlHelpLastPage", mCurrentUrl );
412
413 sInstance = 0;
414}
415
416////////////////////////////////////////////////////////////////////////////////
417// virtual
418void LLFloaterHtmlHelp::draw()
419{
420 // enable/disable buttons depending on state
421 if ( mWebBrowser )
422 {
423 bool enable_back = mWebBrowser->canNavigateBack();
424 childSetEnabled( "back_btn", enable_back );
425
426 bool enable_forward = mWebBrowser->canNavigateForward();
427 childSetEnabled( "forward_btn", enable_forward );
428 };
429
430 LLFloater::draw();
431}
432
433////////////////////////////////////////////////////////////////////////////////
434//
435void LLFloaterHtmlHelp::show(std::string url, std::string title)
436{
437 LLFloaterHtml* floater_html = LLFloaterHtml::getInstance();
438 floater_html->setVisible(FALSE);
439
440 url = gHippoGridManager->getConnectedGrid()->getSupportUrl();
441 if (!url.empty())
442 {
443 if (gSavedSettings.getBOOL("UseExternalBrowser"))
444 {
445 LLSD payload;
446 payload["url"] = url;
447 LLNotifications::instance().add("ClickOpenF1Help", LLSD(), payload, onClickF1HelpLoadURL);
448 }
449 else
450 {
451 // don't wait, just do it
452 LLWeb::loadURLInternal(url);
453 }
454 }
455 else
456 {
457 LLNotifications::instance().add("NoSupportUrl");
458 }
459}
460
461// static
462bool LLFloaterHtmlHelp::onClickF1HelpLoadURL(const LLSD& notification, const LLSD& response)
463{
464 S32 option = LLNotification::getSelectedOption(notification, response);
465 if (option == 0)
466 {
467 const std::string& url = notification["payload"]["url"].asString();
468 if (!url.empty())
469 {
470 LLWeb::loadURLExternal(url);
471 }
472 else
473 {
474 llwarns << "Support URL not available." << llendl;
475 }
476 }
477 return false;
478}
479
480////////////////////////////////////////////////////////////////////////////////
481//
482void LLFloaterHtmlHelp::onClose( bool app_quitting )
483{
484 setVisible( false );
485}
486
487////////////////////////////////////////////////////////////////////////////////
488//
489void LLFloaterHtmlHelp::onClickClose( void* data )
490{
491 LLFloaterHtmlHelp* self = ( LLFloaterHtmlHelp* )data;
492
493 self->setVisible( false );
494}
495
496////////////////////////////////////////////////////////////////////////////////
497//
498void LLFloaterHtmlHelp::onClickBack( void* data )
499{
500 LLFloaterHtmlHelp* self = ( LLFloaterHtmlHelp* )data;
501 if ( self )
502 {
503 if ( self->mWebBrowser )
504 {
505 self->mWebBrowser->navigateBack();
506 };
507 };
508}
509
510////////////////////////////////////////////////////////////////////////////////
511//
512void LLFloaterHtmlHelp::onClickForward( void* data )
513{
514 LLFloaterHtmlHelp* self = ( LLFloaterHtmlHelp* )data;
515 if ( self )
516 {
517 if ( self->mWebBrowser )
518 {
519 self->mWebBrowser->navigateForward();
520 };
521 };
522}
523
524////////////////////////////////////////////////////////////////////////////////
525//
526void LLFloaterHtmlHelp::onStatusTextChange( const EventType& eventIn )
527{
528 mStatusTextContents = std::string( eventIn.getStringValue() );
529
530 childSetText("status_text", mStatusTextContents);
531}
532
533////////////////////////////////////////////////////////////////////////////////
534//
535void LLFloaterHtmlHelp::onLocationChange( const EventType& eventIn )
536{
537 llinfos << "WEB> Location changed to " << eventIn.getStringValue() << llendl;
538 mCurrentUrl = std::string( eventIn.getStringValue() );
539}
540
541////////////////////////////////////////////////////////////////////////////////
542//
543LLViewerHtmlHelp::LLViewerHtmlHelp()
544{
545 LLUI::setHtmlHelp(this);
546}
547
548LLViewerHtmlHelp::~LLViewerHtmlHelp()
549{
550 LLUI::setHtmlHelp(NULL);
551}
552
553void LLViewerHtmlHelp::show()
554{
555 LLFloaterHtmlHelp::show("", "");
556}
557
558void LLViewerHtmlHelp::show(std::string url)
559{
560 std::string title; // empty
561 LLFloaterHtmlHelp::show(url, title);
562}