diff options
Diffstat (limited to 'linden/indra/newview/llpanelweb.cpp')
-rw-r--r-- | linden/indra/newview/llpanelweb.cpp | 176 |
1 files changed, 32 insertions, 144 deletions
diff --git a/linden/indra/newview/llpanelweb.cpp b/linden/indra/newview/llpanelweb.cpp index 13ed9bf..85ddc71 100644 --- a/linden/indra/newview/llpanelweb.cpp +++ b/linden/indra/newview/llpanelweb.cpp | |||
@@ -4,7 +4,7 @@ | |||
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ | 5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ |
6 | * | 6 | * |
7 | * Copyright (c) 2001-2008, Linden Research, Inc. | 7 | * Copyright (c) 2001-2009, Linden Research, Inc. |
8 | * | 8 | * |
9 | * Second Life Viewer Source Code | 9 | * Second Life Viewer Source Code |
10 | * The source code in this file ("Source Code") is provided by Linden Lab | 10 | * The source code in this file ("Source Code") is provided by Linden Lab |
@@ -34,22 +34,12 @@ | |||
34 | // file include | 34 | // file include |
35 | #include "llpanelweb.h" | 35 | #include "llpanelweb.h" |
36 | 36 | ||
37 | // linden library includes | ||
38 | #include "llerror.h" | ||
39 | #include "llrect.h" | ||
40 | #include "llstring.h" | ||
41 | |||
42 | // project includes | 37 | // project includes |
43 | #include "llbutton.h" | ||
44 | #include "llcheckboxctrl.h" | 38 | #include "llcheckboxctrl.h" |
45 | #include "lllineeditor.h" | 39 | #include "llmediamanager.h" |
46 | #include "llui.h" | ||
47 | #include "lluictrlfactory.h" | 40 | #include "lluictrlfactory.h" |
48 | #include "llviewercontrol.h" | 41 | #include "llviewercontrol.h" |
49 | #include "lluictrlfactory.h" | ||
50 | #include "llviewerwindow.h" | 42 | #include "llviewerwindow.h" |
51 | #include "llmediamanager.h" | ||
52 | |||
53 | 43 | ||
54 | // helper functions for getting/freeing the web browser media | 44 | // helper functions for getting/freeing the web browser media |
55 | // if creating/destroying these is too slow, we'll need to create | 45 | // if creating/destroying these is too slow, we'll need to create |
@@ -97,23 +87,21 @@ LLPanelWeb::LLPanelWeb() | |||
97 | 87 | ||
98 | BOOL LLPanelWeb::postBuild() | 88 | BOOL LLPanelWeb::postBuild() |
99 | { | 89 | { |
100 | childSetAction( "clear_cache", onClickClearCache, this ); | 90 | childSetAction("clear_cache", onClickClearCache, this); |
101 | childSetAction( "clear_cookies", onClickClearCookies, this ); | ||
102 | childSetCommitCallback("use_external_browser", onSelectBrowser, this ); | ||
103 | // childSetEnabled( "connection_port", gSavedSettings.getBOOL( "CookiesEnabled" ) ); | ||
104 | childSetCommitCallback( "cookies_enabled", onCommitCookies, this ); | ||
105 | childSetCommitCallback( "web_proxy_editor", onCommitWebProxyAddress, this); | ||
106 | childSetCommitCallback( "web_proxy_port", onCommitWebProxyPort, this); | ||
107 | |||
108 | childSetEnabled("web_proxy_editor", | ||
109 | gSavedSettings.getBOOL("BrowserProxyEnabled")); | ||
110 | childSetEnabled("web_proxy_port", | ||
111 | gSavedSettings.getBOOL("BrowserProxyEnabled")); | ||
112 | childSetEnabled("proxy_text_label", | ||
113 | gSavedSettings.getBOOL("BrowserProxyEnabled")); | ||
114 | childSetCommitCallback("web_proxy_enabled", onCommitWebProxyEnabled, this); | 91 | childSetCommitCallback("web_proxy_enabled", onCommitWebProxyEnabled, this); |
115 | 92 | ||
116 | refresh(); | 93 | std::string value = gSavedSettings.getBOOL("UseExternalBrowser") ? "external" : "internal"; |
94 | childSetValue("use_external_browser", value); | ||
95 | |||
96 | childSetValue("cookies_enabled", gSavedSettings.getBOOL("CookiesEnabled")); | ||
97 | |||
98 | childSetValue("web_proxy_enabled", gSavedSettings.getBOOL("BrowserProxyEnabled")); | ||
99 | childSetValue("web_proxy_editor", gSavedSettings.getString("BrowserProxyAddress")); | ||
100 | childSetValue("web_proxy_port", gSavedSettings.getS32("BrowserProxyPort")); | ||
101 | |||
102 | childSetEnabled("proxy_text_label", gSavedSettings.getBOOL("BrowserProxyEnabled")); | ||
103 | childSetEnabled("web_proxy_editor", gSavedSettings.getBOOL("BrowserProxyEnabled")); | ||
104 | childSetEnabled("web_proxy_port", gSavedSettings.getBOOL("BrowserProxyEnabled")); | ||
117 | 105 | ||
118 | return TRUE; | 106 | return TRUE; |
119 | } | 107 | } |
@@ -127,50 +115,29 @@ LLPanelWeb::~LLPanelWeb() | |||
127 | 115 | ||
128 | void LLPanelWeb::apply() | 116 | void LLPanelWeb::apply() |
129 | { | 117 | { |
130 | } | 118 | gSavedSettings.setBOOL("CookiesEnabled", childGetValue("cookies_enabled")); |
131 | 119 | gSavedSettings.setBOOL("BrowserProxyEnabled", childGetValue("web_proxy_enabled")); | |
132 | void LLPanelWeb::refresh() | 120 | gSavedSettings.setString("BrowserProxyAddress", childGetValue("web_proxy_editor")); |
133 | { | 121 | gSavedSettings.setS32("BrowserProxyPort", childGetValue("web_proxy_port")); |
134 | LLPanel::refresh(); | ||
135 | 122 | ||
136 | mCookiesEnabled = gSavedSettings.getBOOL("CookiesEnabled"); | 123 | bool value = childGetValue("use_external_browser").asString() == "external" ? true : false; |
137 | mWebProxyEnabled = gSavedSettings.getBOOL("BrowserProxyEnabled"); | 124 | gSavedSettings.setBOOL("UseExternalBrowser", value); |
138 | mWebProxyAddress = gSavedSettings.getString("BrowserProxyAddress"); | ||
139 | mWebProxyPort = gSavedSettings.getS32("BrowserProxyPort"); | ||
140 | 125 | ||
141 | LLLineEditor* web_proxy_editor = getChild<LLLineEditor>("web_proxy_editor"); | ||
142 | if (web_proxy_editor) | ||
143 | { | ||
144 | web_proxy_editor->setText( gSavedSettings.getString("BrowserProxyAddress") ); | ||
145 | } | ||
146 | mExternalBrowser = gSavedSettings.getBOOL("UseExternalBrowser"); | ||
147 | |||
148 | childSetValue("use_external_browser", mExternalBrowser ? "external" : "internal"); | ||
149 | |||
150 | LLMediaBase *media_source = get_web_media(); | 126 | LLMediaBase *media_source = get_web_media(); |
151 | if (media_source) | 127 | if (media_source) |
152 | media_source->enableCookies(mCookiesEnabled); | 128 | { |
153 | free_web_media(media_source); | 129 | media_source->enableCookies(childGetValue("cookies_enabled")); |
154 | 130 | ||
131 | bool proxy_enable = childGetValue("web_proxy_enabled"); | ||
132 | std::string proxy_address = childGetValue("web_proxy_editor"); | ||
133 | int proxy_port = childGetValue("web_proxy_port"); | ||
134 | media_source->enableProxy(proxy_enable, proxy_address, proxy_port); | ||
135 | } | ||
136 | free_web_media(media_source); | ||
155 | } | 137 | } |
156 | 138 | ||
157 | void LLPanelWeb::cancel() | 139 | void LLPanelWeb::cancel() |
158 | { | 140 | { |
159 | |||
160 | gSavedSettings.setBOOL( "CookiesEnabled", mCookiesEnabled ); | ||
161 | gSavedSettings.setBOOL( "BrowserProxyEnabled", mWebProxyEnabled ); | ||
162 | gSavedSettings.setString( "BrowserProxyAddress", mWebProxyAddress ); | ||
163 | gSavedSettings.setS32( "BrowserProxyPort", mWebProxyPort ); | ||
164 | |||
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 | |||
174 | } | 141 | } |
175 | 142 | ||
176 | // static | 143 | // static |
@@ -192,94 +159,15 @@ void LLPanelWeb::callback_clear_browser_cache(S32 option, void* userdata) | |||
192 | } | 159 | } |
193 | 160 | ||
194 | // static | 161 | // static |
195 | void LLPanelWeb::onClickClearCookies(void*) | ||
196 | { | ||
197 | gViewerWindow->alertXml("ConfirmClearCookies", callback_clear_cookies, 0); | ||
198 | } | ||
199 | |||
200 | //static | ||
201 | void LLPanelWeb::callback_clear_cookies(S32 option, void* userdata) | ||
202 | { | ||
203 | if ( option == 0 ) // YES | ||
204 | { | ||
205 | LLMediaBase *media_source = get_web_media(); | ||
206 | if (media_source) | ||
207 | media_source->clearCookies(); | ||
208 | free_web_media(media_source); | ||
209 | } | ||
210 | } | ||
211 | |||
212 | // static | ||
213 | void LLPanelWeb::onCommitCookies(LLUICtrl* ctrl, void* data) | ||
214 | { | ||
215 | LLPanelWeb* self = (LLPanelWeb*)data; | ||
216 | LLCheckBoxCtrl* check = (LLCheckBoxCtrl*)ctrl; | ||
217 | |||
218 | if (!self || !check) return; | ||
219 | |||
220 | LLMediaBase *media_source = get_web_media(); | ||
221 | if (media_source) | ||
222 | media_source->enableCookies(check->get()); | ||
223 | free_web_media(media_source); | ||
224 | } | ||
225 | // static | ||
226 | void LLPanelWeb::onCommitWebProxyEnabled(LLUICtrl* ctrl, void* data) | 162 | void LLPanelWeb::onCommitWebProxyEnabled(LLUICtrl* ctrl, void* data) |
227 | { | 163 | { |
228 | LLPanelWeb* self = (LLPanelWeb*)data; | 164 | LLPanelWeb* self = (LLPanelWeb*)data; |
229 | LLCheckBoxCtrl* check = (LLCheckBoxCtrl*)ctrl; | 165 | LLCheckBoxCtrl* check = (LLCheckBoxCtrl*)ctrl; |
230 | 166 | ||
231 | if (!self || !check) return; | 167 | if (!self || !check) return; |
232 | self->childSetEnabled("web_proxy_editor", | 168 | self->childSetEnabled("web_proxy_editor", check->get()); |
233 | check->get()); | 169 | self->childSetEnabled("web_proxy_port", check->get()); |
234 | self->childSetEnabled("web_proxy_port", | 170 | self->childSetEnabled("proxy_text_label", check->get()); |
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); | ||
247 | |||
248 | } | ||
249 | |||
250 | void LLPanelWeb::onCommitWebProxyAddress(LLUICtrl *ctrl, void *userdata) | ||
251 | { | ||
252 | LLLineEditor* web_proxy = (LLLineEditor*)ctrl; | ||
253 | |||
254 | if (web_proxy) | ||
255 | { | ||
256 | gSavedSettings.setString("BrowserProxyAddress", web_proxy->getText()); | ||
257 | } | ||
258 | LLMediaBase *media_source = get_web_media(); | ||
259 | if (media_source) | ||
260 | { | ||
261 | media_source->enableProxy( gSavedSettings.getBOOL("BrowserProxyEnabled"), | ||
262 | gSavedSettings.getString("BrowserProxyAddress"), | ||
263 | gSavedSettings.getS32("BrowserProxyPort") ); | ||
264 | } | ||
265 | free_web_media(media_source); | ||
266 | } | ||
267 | 171 | ||
268 | void LLPanelWeb::onCommitWebProxyPort(LLUICtrl *ctrl, void *userdata) | ||
269 | { | ||
270 | LLMediaBase *media_source = get_web_media(); | ||
271 | if (media_source) | ||
272 | { | ||
273 | media_source->enableProxy( gSavedSettings.getBOOL("BrowserProxyEnabled"), | ||
274 | gSavedSettings.getString("BrowserProxyAddress"), | ||
275 | gSavedSettings.getS32("BrowserProxyPort") ); | ||
276 | } | ||
277 | free_web_media(media_source); | ||
278 | } | ||
279 | 172 | ||
280 | // static | ||
281 | void LLPanelWeb::onSelectBrowser(LLUICtrl* ctrl, void* data) | ||
282 | { | ||
283 | // "external" or "internal" | ||
284 | gSavedSettings.setBOOL("UseExternalBrowser", ctrl->getValue().asString() == "external"); | ||
285 | } | 173 | } |