aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llpanelweb.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:34 -0500
committerJacek Antonelli2008-08-15 23:45:34 -0500
commitcd17687f01420952712a500107e0f93e7ab8d5f8 (patch)
treece48c2b706f2c1176290e39fb555fbdf6648ce01 /linden/indra/newview/llpanelweb.cpp
parentSecond Life viewer sources 1.19.0.5 (diff)
downloadmeta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.zip
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.gz
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.bz2
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.xz
Second Life viewer sources 1.19.1.0
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/llpanelweb.cpp163
1 files changed, 112 insertions, 51 deletions
diff --git a/linden/indra/newview/llpanelweb.cpp b/linden/indra/newview/llpanelweb.cpp
index 9083e3d..0de828a 100644
--- a/linden/indra/newview/llpanelweb.cpp
+++ b/linden/indra/newview/llpanelweb.cpp
@@ -43,16 +43,52 @@
43#include "llbutton.h" 43#include "llbutton.h"
44#include "llcheckboxctrl.h" 44#include "llcheckboxctrl.h"
45#include "lllineeditor.h" 45#include "lllineeditor.h"
46#include "llmozlib.h"
47#include "llui.h" 46#include "llui.h"
48#include "lluictrlfactory.h" 47#include "lluictrlfactory.h"
49#include "llviewercontrol.h" 48#include "llviewercontrol.h"
50#include "llvieweruictrlfactory.h" 49#include "llvieweruictrlfactory.h"
51#include "llviewerwindow.h" 50#include "llviewerwindow.h"
51#include "llmediamanager.h"
52 52
53#if LL_LIBXUL_ENABLED 53
54#include "llmozlib.h" 54// helper functions for getting/freeing the web browser media
55#endif // LL_LIBXUL_ENABLED 55// if creating/destroying these is too slow, we'll need to create
56// a static member and update all our static callbacks
57LLMediaBase *get_web_media()
58{
59 LLMediaBase *media_source;
60 LLMediaManager *mgr = LLMediaManager::getInstance();
61
62 if (!mgr)
63 {
64 llwarns << "cannot get media manager" << llendl;
65 return NULL;
66 }
67
68 media_source = mgr->createSourceFromMimeType("http", "text/html" );
69 if ( !media_source )
70 {
71 llwarns << "media source create failed " << llendl;
72 return NULL;
73 }
74
75 return media_source;
76}
77
78void free_web_media(LLMediaBase *media_source)
79{
80 if (!media_source)
81 return;
82
83 LLMediaManager *mgr = LLMediaManager::getInstance();
84 if (!mgr)
85 {
86 llwarns << "cannot get media manager" << llendl;
87 return;
88 }
89
90 mgr->destroySource(media_source);
91}
56 92
57LLPanelWeb::LLPanelWeb() 93LLPanelWeb::LLPanelWeb()
58{ 94{
@@ -63,6 +99,8 @@ BOOL LLPanelWeb::postBuild()
63{ 99{
64 childSetAction( "clear_cache", onClickClearCache, this ); 100 childSetAction( "clear_cache", onClickClearCache, this );
65 childSetAction( "clear_cookies", onClickClearCookies, this ); 101 childSetAction( "clear_cookies", onClickClearCookies, this );
102 childSetCommitCallback("use_external_browser", onSelectBrowser, this );
103// childSetEnabled( "connection_port", gSavedSettings.getBOOL( "CookiesEnabled" ) );
66 childSetCommitCallback( "cookies_enabled", onCommitCookies, this ); 104 childSetCommitCallback( "cookies_enabled", onCommitCookies, this );
67 childSetCommitCallback( "web_proxy_editor", onCommitWebProxyAddress, this); 105 childSetCommitCallback( "web_proxy_editor", onCommitWebProxyAddress, this);
68 childSetCommitCallback( "web_proxy_port", onCommitWebProxyPort, this); 106 childSetCommitCallback( "web_proxy_port", onCommitWebProxyPort, this);
@@ -105,67 +143,70 @@ void LLPanelWeb::refresh()
105 { 143 {
106 web_proxy_editor->setText( gSavedSettings.getString("BrowserProxyAddress") ); 144 web_proxy_editor->setText( gSavedSettings.getString("BrowserProxyAddress") );
107 } 145 }
146 mExternalBrowser = gSavedSettings.getBOOL("UseExternalBrowser");
108 147
109#if LL_LIBXUL_ENABLED 148 childSetValue("use_external_browser", mExternalBrowser ? "external" : "internal");
110 llinfos << "setting cookies enabled to " << mCookiesEnabled << llendl; 149
111 LLMozLib::getInstance()->enableCookies( mCookiesEnabled ); 150 LLMediaBase *media_source = get_web_media();
112#endif // LL_LIBXUL_ENABLED 151 if (media_source)
152 media_source->enableCookies(mCookiesEnabled);
153 free_web_media(media_source);
113 154
114} 155}
115 156
116void LLPanelWeb::cancel() 157void LLPanelWeb::cancel()
117{ 158{
118#if LL_LIBXUL_ENABLED 159
119 llinfos << "setting cookies enabled to " << mCookiesEnabled << llendl;
120 LLMozLib::getInstance()->enableCookies( mCookiesEnabled );
121#endif // LL_LIBXUL_ENABLED
122
123 gSavedSettings.setBOOL( "CookiesEnabled", mCookiesEnabled ); 160 gSavedSettings.setBOOL( "CookiesEnabled", mCookiesEnabled );
124 gSavedSettings.setBOOL( "BrowserProxyEnabled", mWebProxyEnabled ); 161 gSavedSettings.setBOOL( "BrowserProxyEnabled", mWebProxyEnabled );
125 gSavedSettings.setString( "BrowserProxyAddress", mWebProxyAddress ); 162 gSavedSettings.setString( "BrowserProxyAddress", mWebProxyAddress );
126 gSavedSettings.setS32( "BrowserProxyPort", mWebProxyPort ); 163 gSavedSettings.setS32( "BrowserProxyPort", mWebProxyPort );
127 164
128 LLMozLib::getInstance()->enableProxy( mWebProxyEnabled, mWebProxyAddress, mWebProxyPort ); 165 gSavedSettings.setBOOL("UseExternalBrowser", mExternalBrowser);
166 LLMediaBase *media_source = get_web_media();
167 if (media_source)
168 {
169 media_source->enableCookies(mCookiesEnabled);
170 media_source->enableProxy( mWebProxyEnabled, mWebProxyAddress, mWebProxyPort );
171 }
172 free_web_media(media_source);
173
129} 174}
130 175
131// static 176// static
132void LLPanelWeb::onClickClearCache(void*) 177void LLPanelWeb::onClickClearCache(void*)
133{ 178{
134#if LL_LIBXUL_ENABLED
135 gViewerWindow->alertXml("ConfirmClearBrowserCache", callback_clear_browser_cache, 0); 179 gViewerWindow->alertXml("ConfirmClearBrowserCache", callback_clear_browser_cache, 0);
136#endif // LL_LIBXUL_ENABLED
137} 180}
138 181
139//static 182//static
140void LLPanelWeb::callback_clear_browser_cache(S32 option, void* userdata) 183void LLPanelWeb::callback_clear_browser_cache(S32 option, void* userdata)
141{ 184{
142#if LL_LIBXUL_ENABLED
143 if ( option == 0 ) // YES 185 if ( option == 0 ) // YES
144 { 186 {
145 llinfos << "clearing browser cache" << llendl; 187 LLMediaBase *media_source = get_web_media();
146 LLMozLib::getInstance()->clearCache(); 188 if (media_source)
189 media_source->clearCache();
190 free_web_media(media_source);
147 } 191 }
148#endif // LL_LIBXUL_ENABLED
149} 192}
150 193
151// static 194// static
152void LLPanelWeb::onClickClearCookies(void*) 195void LLPanelWeb::onClickClearCookies(void*)
153{ 196{
154#if LL_LIBXUL_ENABLED
155 gViewerWindow->alertXml("ConfirmClearCookies", callback_clear_cookies, 0); 197 gViewerWindow->alertXml("ConfirmClearCookies", callback_clear_cookies, 0);
156#endif // LL_LIBXUL_ENABLED
157} 198}
158 199
159//static 200//static
160void LLPanelWeb::callback_clear_cookies(S32 option, void* userdata) 201void LLPanelWeb::callback_clear_cookies(S32 option, void* userdata)
161{ 202{
162#if LL_LIBXUL_ENABLED
163 if ( option == 0 ) // YES 203 if ( option == 0 ) // YES
164 { 204 {
165 llinfos << "clearing browser cookies" << llendl; 205 LLMediaBase *media_source = get_web_media();
166 LLMozLib::getInstance()->clearAllCookies(); 206 if (media_source)
207 media_source->clearCookies();
208 free_web_media(media_source);
167 } 209 }
168#endif // LL_LIBXUL_ENABLED
169} 210}
170 211
171// static 212// static
@@ -176,29 +217,34 @@ void LLPanelWeb::onCommitCookies(LLUICtrl* ctrl, void* data)
176 217
177 if (!self || !check) return; 218 if (!self || !check) return;
178 219
179#if LL_LIBXUL_ENABLED 220 LLMediaBase *media_source = get_web_media();
180 llinfos << "setting cookies enabled to " << check->get() << llendl; 221 if (media_source)
181 LLMozLib::getInstance()->enableCookies( check->get() ); 222 media_source->enableCookies(check->get());
182#endif // LL_LIBXUL_ENABLED 223 free_web_media(media_source);
183
184} 224}
185// static 225// static
186void LLPanelWeb::onCommitWebProxyEnabled(LLUICtrl* ctrl, void* data) 226void LLPanelWeb::onCommitWebProxyEnabled(LLUICtrl* ctrl, void* data)
187{ 227{
188 LLPanelWeb* self = (LLPanelWeb*)data; 228 LLPanelWeb* self = (LLPanelWeb*)data;
189 LLCheckBoxCtrl* check = (LLCheckBoxCtrl*)ctrl; 229 LLCheckBoxCtrl* check = (LLCheckBoxCtrl*)ctrl;
230
231 if (!self || !check) return;
232 self->childSetEnabled("web_proxy_editor",
233 check->get());
234 self->childSetEnabled("web_proxy_port",
235 check->get());
236 self->childSetEnabled("proxy_text_label",
237 check->get());
238
239 LLMediaBase *media_source = get_web_media();
240 if (media_source)
241 {
242 media_source->enableProxy( gSavedSettings.getBOOL("BrowserProxyEnabled"),
243 gSavedSettings.getString("BrowserProxyAddress"),
244 gSavedSettings.getS32("BrowserProxyPort") );
245 }
246 free_web_media(media_source);
190 247
191 if (!self || !check) return;
192 self->childSetEnabled("web_proxy_editor",
193 check->get());
194 self->childSetEnabled("web_proxy_port",
195 check->get());
196 self->childSetEnabled("proxy_text_label",
197 check->get());
198
199 LLMozLib::getInstance()->enableProxy( gSavedSettings.getBOOL("BrowserProxyEnabled"),
200 gSavedSettings.getString("BrowserProxyAddress"),
201 gSavedSettings.getS32("BrowserProxyPort") );
202} 248}
203 249
204void LLPanelWeb::onCommitWebProxyAddress(LLUICtrl *ctrl, void *userdata) 250void LLPanelWeb::onCommitWebProxyAddress(LLUICtrl *ctrl, void *userdata)
@@ -209,16 +255,31 @@ void LLPanelWeb::onCommitWebProxyAddress(LLUICtrl *ctrl, void *userdata)
209 { 255 {
210 gSavedSettings.setString("BrowserProxyAddress", web_proxy->getText()); 256 gSavedSettings.setString("BrowserProxyAddress", web_proxy->getText());
211 } 257 }
212 258 LLMediaBase *media_source = get_web_media();
213 LLMozLib::getInstance()->enableProxy( gSavedSettings.getBOOL("BrowserProxyEnabled"), 259 if (media_source)
214 gSavedSettings.getString("BrowserProxyAddress"), 260 {
215 gSavedSettings.getS32("BrowserProxyPort") ); 261 media_source->enableProxy( gSavedSettings.getBOOL("BrowserProxyEnabled"),
262 gSavedSettings.getString("BrowserProxyAddress"),
263 gSavedSettings.getS32("BrowserProxyPort") );
264 }
265 free_web_media(media_source);
216} 266}
217 267
218void LLPanelWeb::onCommitWebProxyPort(LLUICtrl *ctrl, void *userdata) 268void LLPanelWeb::onCommitWebProxyPort(LLUICtrl *ctrl, void *userdata)
219{ 269{
220 LLMozLib::getInstance()->enableProxy( gSavedSettings.getBOOL("BrowserProxyEnabled"), 270 LLMediaBase *media_source = get_web_media();
221 gSavedSettings.getString("BrowserProxyAddress"), 271 if (media_source)
222 gSavedSettings.getS32("BrowserProxyPort") ); 272 {
273 media_source->enableProxy( gSavedSettings.getBOOL("BrowserProxyEnabled"),
274 gSavedSettings.getString("BrowserProxyAddress"),
275 gSavedSettings.getS32("BrowserProxyPort") );
276 }
277 free_web_media(media_source);
278}
223 279
280// static
281void LLPanelWeb::onSelectBrowser(LLUICtrl* ctrl, void* data)
282{
283 // "external" or "internal"
284 gSavedSettings.setBOOL("UseExternalBrowser", ctrl->getValue().asString() == "external");
224} 285}