aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llpanelweb.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/newview/llpanelweb.cpp
parentREADME.txt (diff)
downloadmeta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/newview/llpanelweb.cpp')
-rw-r--r--linden/indra/newview/llpanelweb.cpp371
1 files changed, 371 insertions, 0 deletions
diff --git a/linden/indra/newview/llpanelweb.cpp b/linden/indra/newview/llpanelweb.cpp
new file mode 100644
index 0000000..d5805cd
--- /dev/null
+++ b/linden/indra/newview/llpanelweb.cpp
@@ -0,0 +1,371 @@
1/**
2 * @file llpanelweb.cpp
3 * @brief Web browser options
4 *
5 * Copyright (c) 2003-2007, Linden Research, Inc.
6 *
7 * 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 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28#include "llviewerprecompiledheaders.h"
29
30#include "llpanelweb.h"
31
32#include "llbutton.h"
33#include "llscrolllistctrl.h"
34#include "llcheckboxctrl.h"
35#include "llradiogroup.h"
36#include "lllineeditor.h"
37#include "llfirstuse.h"
38#include "llviewercontrol.h"
39#include "llmediaengine.h"
40#include "llstartup.h"
41#include "llurlwhitelist.h"
42#include "llvieweruictrlfactory.h"
43
44LLPanelWeb::LLPanelWeb()
45: LLPanel("Web Panel"),
46 mExternalBrowserCheck(NULL),
47 mBrowserHomePage(NULL),
48 mWebPagesOnPrimsCheck(NULL),
49 mTrustedSitesList(NULL),
50 mProxyEnabled(NULL),
51 mProxyAddress(NULL),
52 mProxyPort(NULL),
53 mProxySocks45(NULL),
54 mProxyExclusions(NULL),
55 mAddTrustedSite(NULL),
56 mTrustedSiteEntry(NULL),
57 mRemTrustedSite(NULL)
58{
59 mLoggedIn = ( gStartupState >= STATE_STARTED );
60}
61
62//-----------------------------------------------------------------------------
63// postBuild()
64//-----------------------------------------------------------------------------
65BOOL LLPanelWeb::postBuild()
66{
67 mExternalBrowserCheck = LLViewerUICtrlFactory::getCheckBoxByName(this, "external_browser_check");
68 mExternalBrowserCheck->setCallbackUserData ( this );
69 mExternalBrowserCheck->setCommitCallback ( onCommitExternalBrowser );
70
71 mWebPagesOnPrimsCheck = LLViewerUICtrlFactory::getCheckBoxByName(this, "web_pages_on_prims_check");
72
73 mBrowserHomePage = LLViewerUICtrlFactory::getLineEditorByName(this, "home_page");
74
75 mProxyEnabled = LLViewerUICtrlFactory::getCheckBoxByName(this, "proxy_enabled");
76 mProxyEnabled->setCallbackUserData ( this );
77 mProxyEnabled->setCommitCallback ( onCommitProxyEnabled );
78 mProxyAddress = LLViewerUICtrlFactory::getLineEditorByName(this, "proxy_address");
79 mProxyPort = LLViewerUICtrlFactory::getLineEditorByName(this, "proxy_port");
80 mProxySocks45 = LLViewerUICtrlFactory::getRadioGroupByName(this, "socks_4_5");
81 mProxyExclusions = LLViewerUICtrlFactory::getLineEditorByName(this, "proxy_exclusions");
82
83 mAddTrustedSite = LLViewerUICtrlFactory::getButtonByName(this, "add_trusted");
84 mAddTrustedSite->setEnabled ( FALSE );
85 mAddTrustedSite->setCallbackUserData ( this );
86 mAddTrustedSite->setClickedCallback ( onAddTrustedSite );
87
88 mTrustedSitesList = LLViewerUICtrlFactory::getScrollListByName(this, "trusted_sites_list");
89 mTrustedSitesList->setAllowMultipleSelection ( TRUE );
90 mTrustedSitesList->setCommitOnSelectionChange ( TRUE );
91 mTrustedSitesList->setCallbackUserData ( this );
92 mTrustedSitesList->setCommitCallback ( onTrustedSiteListCommit );
93
94 mTrustedSiteEntry = LLViewerUICtrlFactory::getLineEditorByName(this, "trusted_site_entry");
95 mTrustedSiteEntry->setCallbackUserData ( this );
96 mTrustedSiteEntry->setKeystrokeCallback ( onTrustedSiteEntryKeystroke );
97
98 mRemTrustedSite = LLViewerUICtrlFactory::getButtonByName(this, "rem_trusted");
99 mRemTrustedSite->setEnabled ( FALSE );
100 mRemTrustedSite->setCallbackUserData ( this );
101 mRemTrustedSite->setClickedCallback ( onRemTrustedSite );
102
103 BOOL use_external_browser = gSavedSettings.getBOOL("UseExternalBrowser");
104 mExternalBrowserCheck->set(use_external_browser);
105
106 LLString strVal = gSavedSettings.getString ( "BrowserHomePage" );
107 mBrowserHomePage->setText ( strVal );
108
109 BOOL boolVal = gSavedSettings.getBOOL ( "BrowserProxyEnabled" );
110 mProxyEnabled->set ( boolVal );
111
112 strVal = gSavedSettings.getString ( "BrowserProxyAddress" );
113 mProxyAddress->setText ( strVal );
114
115 S32 port = gSavedSettings.getS32 ( "BrowserProxyPort" );
116 std::stringstream codec;
117 codec << port;
118 mProxyPort->setText ( codec.str () );
119
120 S32 numVal = gSavedSettings.getS32 ( "BrowserProxySocks45" );
121 mProxySocks45->setSelectedIndex ( numVal - 4 );
122
123 strVal = gSavedSettings.getString ( "BrowserProxyExclusions" );
124 mProxyExclusions->setText ( strVal );
125
126 // switch on/off UI depending on state of 'use external browser' checkbox
127 configExternaBrowserEnabledUI ( mExternalBrowserCheck->get() );
128
129 // switch on/off UI depending on which type of proxy is chosen (only if internal browseR)
130 if ( ! mExternalBrowserCheck->get() )
131 configProxyEnabledUI ( mProxyEnabled->get() );
132
133 BOOL use_web_pages_on_prims = gSavedSettings.getBOOL("UseWebPagesOnPrims");
134 mWebPagesOnPrimsCheck->set(use_web_pages_on_prims);
135
136 // load the list of trusted sites
137 loadTrustedSiteList ();
138
139 return TRUE;
140}
141
142// helper function to enable/disable proxy UI based on what type of proxy is selected
143void LLPanelWeb::configProxyEnabledUI ( BOOL enabled )
144{
145 if ( enabled )
146 {
147 mProxyAddress->setEnabled ( TRUE );
148 mProxyPort->setEnabled ( TRUE );
149 mProxySocks45->setEnabled ( TRUE);
150 mProxyExclusions->setEnabled ( TRUE );
151 }
152 else
153 {
154 mProxyAddress->setEnabled ( FALSE );
155 mProxyPort->setEnabled ( FALSE );
156 mProxySocks45->setEnabled ( FALSE );
157 mProxyExclusions->setEnabled ( FALSE );
158 };
159}
160
161// helper function to enable/disable proxy UI based on what type of proxy is selected
162void LLPanelWeb::configExternaBrowserEnabledUI ( BOOL enabled )
163{
164 if ( enabled )
165 {
166 mBrowserHomePage->setEnabled ( FALSE );
167 mWebPagesOnPrimsCheck->setEnabled ( FALSE );
168 mTrustedSitesList->setEnabled ( FALSE );
169 mProxyEnabled->setEnabled ( FALSE );
170 mProxyAddress->setEnabled ( FALSE );
171 mProxyPort->setEnabled ( FALSE );
172 mProxySocks45->setEnabled ( FALSE );
173 mProxyExclusions->setEnabled ( FALSE );
174 mAddTrustedSite->setEnabled ( FALSE );
175 mTrustedSiteEntry->setEnabled ( FALSE );
176 mRemTrustedSite->setEnabled ( FALSE );
177 }
178 else
179 {
180 mBrowserHomePage->setEnabled ( TRUE );
181 mWebPagesOnPrimsCheck->setEnabled ( TRUE );
182 mTrustedSitesList->setEnabled ( TRUE );
183 mProxyEnabled->setEnabled ( TRUE );
184 mProxyAddress->setEnabled ( TRUE );
185 mProxyPort->setEnabled ( TRUE );
186 mProxySocks45->setEnabled ( TRUE);
187 mProxyExclusions->setEnabled ( TRUE );
188 mAddTrustedSite->setEnabled ( TRUE );
189 mTrustedSiteEntry->setEnabled ( TRUE );
190
191 // only set this to enabled if there is text in the entry widget
192 if ( mTrustedSiteEntry->getLength() )
193 mAddTrustedSite->setEnabled ( TRUE );
194 else
195 mAddTrustedSite->setEnabled ( FALSE );
196
197 // only set this to enabled if something is selected in the list of trusted sites
198 if ( mTrustedSitesList->getFirstSelected () )
199 mRemTrustedSite->setEnabled ( TRUE );
200 else
201 mRemTrustedSite->setEnabled ( FALSE );
202 };
203
204 // final check - disable the white list options if not
205 // logged in since they are on a per-user basis
206 if ( ! mLoggedIn )
207 {
208 mTrustedSitesList->setEnabled ( FALSE );
209 mAddTrustedSite->setEnabled ( FALSE );
210 mTrustedSiteEntry->setEnabled ( FALSE );
211 mRemTrustedSite->setEnabled ( FALSE );
212 };
213}
214
215void LLPanelWeb::onCommitExternalBrowser ( LLUICtrl* ctrl, void* data )
216{
217 LLPanelWeb* self = (LLPanelWeb*)data;
218
219 // update state of UI when proxy type changes
220 BOOL value = self->mExternalBrowserCheck->get ();
221 self->configExternaBrowserEnabledUI ( value );
222}
223
224void LLPanelWeb::onCommitProxyEnabled ( LLUICtrl* ctrl, void* data )
225{
226 LLPanelWeb* self = (LLPanelWeb*)data;
227
228 // update state of UI when proxy type changes
229 BOOL value = self->mProxyEnabled->get ();
230 self->configProxyEnabledUI ( value );
231}
232
233void LLPanelWeb::onTrustedSiteListCommit ( LLUICtrl* ctrl, void* data )
234{
235 LLPanelWeb* self = (LLPanelWeb*)data;
236
237 // something was selected so enable the REMOVE button
238 self->mRemTrustedSite->setEnabled ( TRUE );
239};
240
241void LLPanelWeb::onTrustedSiteEntryKeystroke ( LLLineEditor* caller, void* data )
242{
243 LLPanelWeb* self = (LLPanelWeb*)data;
244
245 if ( caller->getLength () )
246 self->mAddTrustedSite->setEnabled ( TRUE );
247 else
248 self->mAddTrustedSite->setEnabled ( FALSE );
249}
250
251// add site to list
252void LLPanelWeb::onAddTrustedSite ( void* data )
253{
254 LLPanelWeb* self = (LLPanelWeb*)data;
255
256 if ( self->mTrustedSiteEntry->getLength () )
257 {
258 // add to list
259 self->mTrustedSitesList->addSimpleItem ( self->mTrustedSiteEntry->getText () );
260
261 // remove from entry field
262 self->mTrustedSiteEntry->clear ();
263
264 // nothing in entry field so disable add button
265 self->mAddTrustedSite->setEnabled ( FALSE );
266 };
267}
268
269// remove site from list
270void LLPanelWeb::onRemTrustedSite ( void* data )
271{
272 LLPanelWeb* self = (LLPanelWeb*)data;
273
274 self->mTrustedSitesList->deleteSelectedItems ();
275
276 // once we delete something, nothing is selected so disable the REMOVE button
277 self->mRemTrustedSite->setEnabled ( FALSE );
278}
279
280// save off the list of trusted sites
281void LLPanelWeb::loadTrustedSiteList ()
282{
283 // can't access white list file when not logged in since
284 // the filename is based on the SL username
285 if ( ! mLoggedIn )
286 return;
287
288 LLUrlWhiteList* theWhiteList = LLUrlWhiteList::getInstance ();
289
290 if ( theWhiteList->load () )
291 {
292 mTrustedSitesList->clear ();
293
294 LLString each;
295 if ( theWhiteList->getFirst ( each ) )
296 {
297 mTrustedSitesList->addSimpleItem ( each );
298
299 while ( theWhiteList->getNext ( each ) )
300 {
301 mTrustedSitesList->addSimpleItem ( each );
302 };
303 };
304 };
305}
306
307// save off the list of trusted sites
308void LLPanelWeb::saveTrustedSiteList ()
309{
310 // can't access white list file when not logged in since
311 // the filename is based on the SL username
312 if ( ! mLoggedIn )
313 return;
314
315 // erase the white list before we re-add items to it
316 LLUrlWhiteList::getInstance ()->clear ();
317
318 // step through each item in the scroll list
319 std::vector<LLScrollListItem*> data_list = mTrustedSitesList->getAllData();
320 std::vector<LLScrollListItem*>::iterator data_itor;
321 for (data_itor = data_list.begin(); data_itor != data_list.end(); ++data_itor)
322 {
323 LLScrollListItem* each = *data_itor;
324 LLUrlWhiteList::getInstance ()->addItem ( each->getColumn ( 0 )->getText (), false );
325 }
326
327 LLUrlWhiteList::getInstance ()->save ();
328}
329
330// save off the list of trusted sites
331void LLPanelWeb::apply()
332{
333
334 BOOL use_external_browser = mExternalBrowserCheck->get();
335 gSavedSettings.setBOOL("UseExternalBrowser", use_external_browser);
336
337 gSavedSettings.setString ( "BrowserHomePage", mBrowserHomePage->getText() );
338
339 BOOL enabled = mProxyEnabled->get ();
340 gSavedSettings.setBOOL ( "BrowserProxyEnabled", enabled );
341
342 gSavedSettings.setString ( "BrowserProxyAddress", mProxyAddress->getText() );
343
344 S32 port;
345 std::stringstream codec ( mProxyPort->getText () );
346 codec >> port;
347 gSavedSettings.setS32 ( "BrowserProxyPort", port );
348
349 S32 socks = mProxySocks45->getSelectedIndex () + 4;
350 gSavedSettings.setS32 ( "BrowserProxySocks45", socks );
351
352 gSavedSettings.setString ( "BrowserProxyExclusions", mProxyExclusions->getText() );
353
354 BOOL use_web_pages_on_prims = mWebPagesOnPrimsCheck->get();
355 gSavedSettings.setBOOL("UseWebPagesOnPrims", use_web_pages_on_prims);
356
357 // save off the list of trusted sites
358 saveTrustedSiteList ();
359
360 // update the media engine with the proxy information
361 if ( LLMediaEngine::getInstance() && LLMediaEngine::getInstance()->isAvailable() )
362 {
363 LLMediaEngine::getInstance()->setNetworkProxy ( enabled,
364 mProxyAddress->getText(), port, socks,
365 mProxyExclusions->getText() );
366 };
367}
368
369void LLPanelWeb::cancel()
370{
371}