diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/llpanellogin.cpp | 642 |
1 files changed, 252 insertions, 390 deletions
diff --git a/linden/indra/newview/llpanellogin.cpp b/linden/indra/newview/llpanellogin.cpp index 292f5c3..3e64bba 100644 --- a/linden/indra/newview/llpanellogin.cpp +++ b/linden/indra/newview/llpanellogin.cpp | |||
@@ -44,13 +44,16 @@ | |||
44 | 44 | ||
45 | #include "llbutton.h" | 45 | #include "llbutton.h" |
46 | #include "llcheckboxctrl.h" | 46 | #include "llcheckboxctrl.h" |
47 | #include "llcommandhandler.h" | ||
47 | #include "llcombobox.h" | 48 | #include "llcombobox.h" |
49 | #include "llcurl.h" | ||
48 | #include "llviewercontrol.h" | 50 | #include "llviewercontrol.h" |
49 | #include "llfloaterabout.h" | 51 | #include "llfloaterabout.h" |
50 | #include "llfloatertest.h" | 52 | #include "llfloatertest.h" |
51 | #include "llfloaterpreference.h" | 53 | #include "llfloaterpreference.h" |
52 | #include "llfocusmgr.h" | 54 | #include "llfocusmgr.h" |
53 | #include "lllineeditor.h" | 55 | #include "lllineeditor.h" |
56 | #include "llstartup.h" | ||
54 | #include "lltextbox.h" | 57 | #include "lltextbox.h" |
55 | #include "llui.h" | 58 | #include "llui.h" |
56 | #include "lluiconstants.h" | 59 | #include "lluiconstants.h" |
@@ -61,7 +64,8 @@ | |||
61 | #include "llviewernetwork.h" | 64 | #include "llviewernetwork.h" |
62 | #include "llviewerwindow.h" // to link into child list | 65 | #include "llviewerwindow.h" // to link into child list |
63 | #include "llnotify.h" | 66 | #include "llnotify.h" |
64 | #include "viewer.h" // for gHideLinks | 67 | #include "llappviewer.h" // for gHideLinks |
68 | #include "llurlsimstring.h" | ||
65 | #include "llvieweruictrlfactory.h" | 69 | #include "llvieweruictrlfactory.h" |
66 | #include "llhttpclient.h" | 70 | #include "llhttpclient.h" |
67 | #include "llweb.h" | 71 | #include "llweb.h" |
@@ -72,11 +76,146 @@ | |||
72 | 76 | ||
73 | #include "llglheaders.h" | 77 | #include "llglheaders.h" |
74 | 78 | ||
79 | |||
80 | LLString load_password_from_disk(void); | ||
81 | void save_password_to_disk(const char* hashed_password); | ||
82 | |||
75 | const S32 BLACK_BORDER_HEIGHT = 160; | 83 | const S32 BLACK_BORDER_HEIGHT = 160; |
76 | const S32 MAX_PASSWORD = 16; | 84 | const S32 MAX_PASSWORD = 16; |
77 | 85 | ||
78 | LLPanelLogin *LLPanelLogin::sInstance = NULL; | 86 | LLPanelLogin *LLPanelLogin::sInstance = NULL; |
79 | BOOL LLPanelLogin::sCapslockDidNotification = FALSE; | 87 | |
88 | |||
89 | //parses the input url and returns true if afterwards | ||
90 | //a web-login-key, firstname and lastname is set | ||
91 | bool LLLoginHandler::parseDirectLogin(std::string url) | ||
92 | { | ||
93 | LLURI uri(url); | ||
94 | parse(uri.queryMap()); | ||
95 | |||
96 | if (mWebLoginKey.isNull() || | ||
97 | mFirstName.empty() || | ||
98 | mLastName.empty()) | ||
99 | { | ||
100 | return false; | ||
101 | } | ||
102 | else | ||
103 | { | ||
104 | return true; | ||
105 | } | ||
106 | } | ||
107 | |||
108 | |||
109 | void LLLoginHandler::parse(const LLSD& queryMap) | ||
110 | { | ||
111 | mWebLoginKey = queryMap["web_login_key"].asUUID(); | ||
112 | mFirstName = queryMap["first_name"].asString(); | ||
113 | mLastName = queryMap["last_name"].asString(); | ||
114 | |||
115 | if (queryMap["grid"].asString() == "aditi") | ||
116 | { | ||
117 | gGridChoice = GRID_INFO_ADITI; | ||
118 | } | ||
119 | else if (queryMap["grid"].asString() == "agni") | ||
120 | { | ||
121 | gGridChoice = GRID_INFO_AGNI; | ||
122 | } | ||
123 | else if (queryMap["grid"].asString() == "siva") | ||
124 | { | ||
125 | gGridChoice = GRID_INFO_SIVA; | ||
126 | } | ||
127 | else if (queryMap["grid"].asString() == "durga") | ||
128 | { | ||
129 | gGridChoice = GRID_INFO_DURGA; | ||
130 | } | ||
131 | else if (queryMap["grid"].asString() == "shakti") | ||
132 | { | ||
133 | gGridChoice = GRID_INFO_SHAKTI; | ||
134 | } | ||
135 | else if (queryMap["grid"].asString() == "soma") | ||
136 | { | ||
137 | gGridChoice = GRID_INFO_SOMA; | ||
138 | } | ||
139 | else if (queryMap["grid"].asString() == "ganga") | ||
140 | { | ||
141 | gGridChoice = GRID_INFO_GANGA; | ||
142 | } | ||
143 | else if (queryMap["grid"].asString() == "vaak") | ||
144 | { | ||
145 | gGridChoice = GRID_INFO_VAAK; | ||
146 | } | ||
147 | else if (queryMap["grid"].asString() == "uma") | ||
148 | { | ||
149 | gGridChoice = GRID_INFO_UMA; | ||
150 | } | ||
151 | |||
152 | snprintf(gGridName, MAX_STRING, "%s", gGridInfo[gGridChoice].mName); /* Flawfinder: ignore */ | ||
153 | LLAppViewer::instance()->resetURIs(); | ||
154 | |||
155 | LLString startLocation = queryMap["location"].asString(); | ||
156 | |||
157 | if (startLocation == "specify") | ||
158 | { | ||
159 | LLURLSimString::setString(queryMap["region"].asString()); | ||
160 | } | ||
161 | else if (startLocation == "home") | ||
162 | { | ||
163 | gSavedSettings.setBOOL("LoginLastLocation", FALSE); | ||
164 | LLURLSimString::setString(""); | ||
165 | } | ||
166 | else if (startLocation == "last") | ||
167 | { | ||
168 | gSavedSettings.setBOOL("LoginLastLocation", TRUE); | ||
169 | LLURLSimString::setString(""); | ||
170 | } | ||
171 | } | ||
172 | |||
173 | bool LLLoginHandler::handle(const LLSD& tokens, | ||
174 | const LLSD& queryMap) | ||
175 | { | ||
176 | parse(queryMap); | ||
177 | |||
178 | //if we haven't initialized stuff yet, this is | ||
179 | //coming in from the GURL handler, just parse | ||
180 | if (STATE_FIRST == LLStartUp::getStartupState()) | ||
181 | { | ||
182 | return true; | ||
183 | } | ||
184 | |||
185 | LLString password = queryMap["password"].asString(); | ||
186 | |||
187 | if (!password.empty()) | ||
188 | { | ||
189 | gSavedSettings.setBOOL("RememberPassword", TRUE); | ||
190 | |||
191 | if (password.substr(0,3) != "$1$") | ||
192 | { | ||
193 | LLMD5 pass((unsigned char*)password.c_str()); | ||
194 | char md5pass[33]; /* Flawfinder: ignore */ | ||
195 | pass.hex_digest(md5pass); | ||
196 | password = md5pass; | ||
197 | save_password_to_disk(password.c_str()); | ||
198 | } | ||
199 | } | ||
200 | else | ||
201 | { | ||
202 | save_password_to_disk(NULL); | ||
203 | gSavedSettings.setBOOL("RememberPassword", FALSE); | ||
204 | } | ||
205 | |||
206 | |||
207 | if (LLStartUp::getStartupState() < STATE_LOGIN_CLEANUP) //on splash page | ||
208 | { | ||
209 | if (mWebLoginKey.isNull()) { | ||
210 | LLPanelLogin::loadLoginPage(); | ||
211 | } else { | ||
212 | LLStartUp::setStartupState( STATE_LOGIN_CLEANUP ); | ||
213 | } | ||
214 | } | ||
215 | return true; | ||
216 | } | ||
217 | |||
218 | LLLoginHandler gLoginHandler; | ||
80 | 219 | ||
81 | // helper class that trys to download a URL from a web site and calls a method | 220 | // helper class that trys to download a URL from a web site and calls a method |
82 | // on parent class indicating if the web server is working or not | 221 | // on parent class indicating if the web server is working or not |
@@ -155,112 +294,11 @@ LLPanelLogin::LLPanelLogin(const LLRect &rect, | |||
155 | mLogoImage = gImageList.getImage("startup_logo.tga", LLUUID::null, MIPMAP_FALSE, TRUE); | 294 | mLogoImage = gImageList.getImage("startup_logo.tga", LLUUID::null, MIPMAP_FALSE, TRUE); |
156 | 295 | ||
157 | gUICtrlFactory->buildPanel(this, "panel_login.xml"); | 296 | gUICtrlFactory->buildPanel(this, "panel_login.xml"); |
158 | setRect(rect); | 297 | |
298 | //leave room for the login menu bar | ||
299 | setRect(LLRect(0, rect.getHeight()-18, rect.getWidth(), 0)); | ||
159 | reshape(rect.getWidth(), rect.getHeight()); | 300 | reshape(rect.getWidth(), rect.getHeight()); |
160 | |||
161 | childSetPrevalidate("first_name_edit", LLLineEditor::prevalidatePrintableNoSpace); | ||
162 | childSetPrevalidate("last_name_edit", LLLineEditor::prevalidatePrintableNoSpace); | ||
163 | |||
164 | childSetCommitCallback("password_edit", mungePassword); | ||
165 | childSetKeystrokeCallback("password_edit", onPassKey, this); | ||
166 | childSetUserData("password_edit", this); | ||
167 | |||
168 | LLLineEditor* edit = LLUICtrlFactory::getLineEditorByName(this, "password_edit"); | ||
169 | if (edit) edit->setDrawAsterixes(TRUE); | ||
170 | |||
171 | LLComboBox* combo = LLUICtrlFactory::getComboBoxByName(this, "start_location_combo"); | ||
172 | if (combo) | ||
173 | { | ||
174 | combo->setAllowTextEntry(TRUE, 128, FALSE); | ||
175 | |||
176 | // The XML file loads the combo with the following labels: | ||
177 | // 0 - "My Home" | ||
178 | // 1 - "My Last Location" | ||
179 | // 2 - "<Type region name>" | ||
180 | |||
181 | BOOL login_last = gSavedSettings.getBOOL("LoginLastLocation"); | ||
182 | LLString sim_string = LLURLSimString::sInstance.mSimString; | ||
183 | if (!sim_string.empty()) | ||
184 | { | ||
185 | // Replace "<Type region name>" with this region name | ||
186 | combo->remove(2); | ||
187 | combo->add( sim_string ); | ||
188 | combo->setTextEntry(sim_string); | ||
189 | combo->setCurrentByIndex( 2 ); | ||
190 | } | ||
191 | else if (login_last) | ||
192 | { | ||
193 | combo->setCurrentByIndex( 1 ); | ||
194 | } | ||
195 | else | ||
196 | { | ||
197 | combo->setCurrentByIndex( 0 ); | ||
198 | } | ||
199 | |||
200 | combo->setCommitCallback( &LLPanelGeneral::set_start_location ); | ||
201 | } | ||
202 | 301 | ||
203 | // Specific servers added later. | ||
204 | childSetVisible("server_combo", show_server); | ||
205 | |||
206 | childSetAction("new_account_btn", onClickNewAccount, this); | ||
207 | childSetVisible("new_account_btn", !gHideLinks); | ||
208 | |||
209 | childSetAction("connect_btn", onClickConnect, this); | ||
210 | |||
211 | setDefaultBtn("connect_btn"); | ||
212 | |||
213 | childSetAction("preferences_btn", LLFloaterPreference::show, this); | ||
214 | |||
215 | childSetAction("quit_btn", onClickQuit, this); | ||
216 | |||
217 | LLTextBox* text = LLUICtrlFactory::getTextBoxByName(this, "version_text"); | ||
218 | if (text) | ||
219 | { | ||
220 | LLString version = llformat("%d.%d.%d (%d)", | ||
221 | LL_VERSION_MAJOR, | ||
222 | LL_VERSION_MINOR, | ||
223 | LL_VERSION_PATCH, | ||
224 | LL_VIEWER_BUILD ); | ||
225 | text->setText(version); | ||
226 | text->setClickedCallback(onClickVersion); | ||
227 | text->setCallbackUserData(this); | ||
228 | |||
229 | // HACK to move to the lower-right of the window | ||
230 | // replace/remove this logic when we have dynamic layouts | ||
231 | S32 right = getRect().mRight; | ||
232 | LLRect r = text->getRect(); | ||
233 | const S32 PAD = 2; | ||
234 | r.setOriginAndSize( right - r.getWidth() - PAD, PAD, | ||
235 | r.getWidth(), r.getHeight() ); | ||
236 | text->setRect(r); | ||
237 | } | ||
238 | |||
239 | LLTextBox* channel_text = LLUICtrlFactory::getTextBoxByName(this, "channel_text"); | ||
240 | if (channel_text) | ||
241 | { | ||
242 | channel_text->setText(gChannelName); | ||
243 | channel_text->setClickedCallback(onClickVersion); | ||
244 | channel_text->setCallbackUserData(this); | ||
245 | |||
246 | // HACK to move to the right of the window, above the version string, | ||
247 | // replace/remove this logic when we have dynamic layouts | ||
248 | S32 right = getRect().mRight; | ||
249 | LLRect r = channel_text->getRect(); | ||
250 | const S32 PAD = 2; | ||
251 | S32 version_string_top = r.mTop; | ||
252 | if(text) | ||
253 | { | ||
254 | version_string_top = text->getRect().mTop; | ||
255 | } | ||
256 | r.setOriginAndSize( | ||
257 | right - r.getWidth() - PAD, | ||
258 | version_string_top, | ||
259 | r.getWidth(), | ||
260 | r.getHeight()); | ||
261 | channel_text->setRect(r); | ||
262 | } | ||
263 | |||
264 | // get the web browser control | 302 | // get the web browser control |
265 | #if LL_LIBXUL_ENABLED | 303 | #if LL_LIBXUL_ENABLED |
266 | LLWebBrowserCtrl* web_browser = LLUICtrlFactory::getWebBrowserCtrlByName(this, "login_html"); | 304 | LLWebBrowserCtrl* web_browser = LLUICtrlFactory::getWebBrowserCtrlByName(this, "login_html"); |
@@ -284,11 +322,11 @@ LLPanelLogin::LLPanelLogin(const LLRect &rect, | |||
284 | 322 | ||
285 | // force the size to be correct (XML doesn't seem to be sufficient to do this) (with some padding so the other login screen doesn't show through) | 323 | // force the size to be correct (XML doesn't seem to be sufficient to do this) (with some padding so the other login screen doesn't show through) |
286 | LLRect htmlRect = mRect; | 324 | LLRect htmlRect = mRect; |
287 | htmlRect.setCenterAndSize( mRect.getCenterX() - 2, mRect.getCenterY() + 40, mRect.getWidth() + 6, mRect.getHeight() - 78 ); | 325 | htmlRect.setCenterAndSize( mRect.getCenterX() - 2, mRect.getCenterY(), mRect.getWidth() + 6, mRect.getHeight()); |
288 | web_browser->setRect( htmlRect ); | 326 | web_browser->setRect( htmlRect ); |
289 | web_browser->reshape( htmlRect.getWidth(), htmlRect.getHeight(), TRUE ); | 327 | web_browser->reshape( htmlRect.getWidth(), htmlRect.getHeight(), TRUE ); |
290 | reshape( mRect.getWidth(), mRect.getHeight(), 1 ); | 328 | reshape( mRect.getWidth(), mRect.getHeight(), 1 ); |
291 | 329 | ||
292 | // kick off a request to grab the url manually | 330 | // kick off a request to grab the url manually |
293 | gResponsePtr = LLIamHereLogin::build( this ); | 331 | gResponsePtr = LLIamHereLogin::build( this ); |
294 | LLHTTPClient::get( childGetValue( "real_url" ).asString(), gResponsePtr ); | 332 | LLHTTPClient::get( childGetValue( "real_url" ).asString(), gResponsePtr ); |
@@ -298,7 +336,6 @@ LLPanelLogin::LLPanelLogin(const LLRect &rect, | |||
298 | #endif | 336 | #endif |
299 | 337 | ||
300 | // Initialize visibility (and don't force visibility - use prefs) | 338 | // Initialize visibility (and don't force visibility - use prefs) |
301 | refreshLocation( false ); | ||
302 | } | 339 | } |
303 | 340 | ||
304 | void LLPanelLogin::setSiteIsAlive( bool alive ) | 341 | void LLPanelLogin::setSiteIsAlive( bool alive ) |
@@ -310,9 +347,8 @@ void LLPanelLogin::setSiteIsAlive( bool alive ) | |||
310 | { | 347 | { |
311 | if ( web_browser ) | 348 | if ( web_browser ) |
312 | { | 349 | { |
313 | // navigate to the "real" page | 350 | loadLoginPage(); |
314 | web_browser->navigateTo( childGetValue( "real_url" ).asString() ); | 351 | |
315 | |||
316 | // mark as available | 352 | // mark as available |
317 | mHtmlAvailable = TRUE; | 353 | mHtmlAvailable = TRUE; |
318 | }; | 354 | }; |
@@ -334,21 +370,6 @@ void LLPanelLogin::setSiteIsAlive( bool alive ) | |||
334 | #endif | 370 | #endif |
335 | } | 371 | } |
336 | 372 | ||
337 | void LLPanelLogin::mungePassword(LLUICtrl* caller, void* user_data) | ||
338 | { | ||
339 | LLPanelLogin* self = (LLPanelLogin*)user_data; | ||
340 | LLLineEditor* editor = (LLLineEditor*)caller; | ||
341 | std::string password = editor->getText(); | ||
342 | |||
343 | // Re-md5 if we've changed at all | ||
344 | if (password != self->mIncomingPassword) | ||
345 | { | ||
346 | LLMD5 pass((unsigned char *)password.c_str()); | ||
347 | char munged_password[MD5HEX_STR_SIZE]; | ||
348 | pass.hex_digest(munged_password); | ||
349 | self->mMungedPassword = munged_password; | ||
350 | } | ||
351 | } | ||
352 | 373 | ||
353 | LLPanelLogin::~LLPanelLogin() | 374 | LLPanelLogin::~LLPanelLogin() |
354 | { | 375 | { |
@@ -384,13 +405,6 @@ void LLPanelLogin::draw() | |||
384 | glTranslatef(-0.5f * (image_aspect / view_aspect - 1.f) * mRect.getWidth(), 0.f, 0.f); | 405 | glTranslatef(-0.5f * (image_aspect / view_aspect - 1.f) * mRect.getWidth(), 0.f, 0.f); |
385 | glScalef(image_aspect / view_aspect, 1.f, 1.f); | 406 | glScalef(image_aspect / view_aspect, 1.f, 1.f); |
386 | } | 407 | } |
387 | // Don't maintain aspect ratio if screen wider than image. This results in the | ||
388 | // hand being partially cut off. JC | ||
389 | //else | ||
390 | //{ | ||
391 | // glTranslatef(0.f, -0.5f * (view_aspect / image_aspect - 1.f) * (F32)BLACK_BORDER_HEIGHT, 0.f); | ||
392 | // glScalef(1.f, view_aspect / image_aspect, 1.f); | ||
393 | //} | ||
394 | 408 | ||
395 | S32 width = mRect.getWidth(); | 409 | S32 width = mRect.getWidth(); |
396 | S32 height = mRect.getHeight(); | 410 | S32 height = mRect.getHeight(); |
@@ -399,9 +413,6 @@ void LLPanelLogin::draw() | |||
399 | { | 413 | { |
400 | // draw a background box in black | 414 | // draw a background box in black |
401 | gl_rect_2d( 0, height - 264, width, 264, LLColor4( 0.0f, 0.0f, 0.0f, 1.f ) ); | 415 | gl_rect_2d( 0, height - 264, width, 264, LLColor4( 0.0f, 0.0f, 0.0f, 1.f ) ); |
402 | |||
403 | // draw the bottom part of the background image - just the blue background to the native client UI | ||
404 | gl_draw_scaled_image(0, -264, width + 8, mLogoImage->getHeight(), mLogoImage); | ||
405 | } | 416 | } |
406 | else | 417 | else |
407 | { | 418 | { |
@@ -469,54 +480,14 @@ BOOL LLPanelLogin::handleKeyHere(KEY key, MASK mask, BOOL called_from_parent) | |||
469 | 480 | ||
470 | return LLPanel::handleKeyHere(key, mask, called_from_parent); | 481 | return LLPanel::handleKeyHere(key, mask, called_from_parent); |
471 | } | 482 | } |
472 | 483 | ||
473 | // virtual | ||
474 | void LLPanelLogin::setFocus(BOOL b) | ||
475 | { | ||
476 | if(b != hasFocus()) | ||
477 | { | ||
478 | if(b) | ||
479 | { | ||
480 | LLPanelLogin::giveFocus(); | ||
481 | } | ||
482 | else | ||
483 | { | ||
484 | LLPanel::setFocus(b); | ||
485 | } | ||
486 | } | ||
487 | } | ||
488 | 484 | ||
489 | // static | 485 | // static |
490 | void LLPanelLogin::giveFocus() | 486 | void LLPanelLogin::giveFocus() |
491 | { | 487 | { |
492 | if( sInstance ) | ||
493 | { | ||
494 | // Grab focus and move cursor to first blank input field | ||
495 | std::string first = sInstance->childGetText("first_name_edit"); | ||
496 | std::string pass = sInstance->childGetText("password_edit"); | ||
497 | |||
498 | BOOL have_first = !first.empty(); | ||
499 | BOOL have_pass = !pass.empty(); | ||
500 | |||
501 | LLLineEditor* edit = NULL; | ||
502 | if (have_first && !have_pass) | ||
503 | { | ||
504 | // User saved his name but not his password. Move | ||
505 | // focus to password field. | ||
506 | edit = LLUICtrlFactory::getLineEditorByName(sInstance, "password_edit"); | ||
507 | } | ||
508 | else | ||
509 | { | ||
510 | // User doesn't have a name, so start there. | ||
511 | edit = LLUICtrlFactory::getLineEditorByName(sInstance, "first_name_edit"); | ||
512 | } | ||
513 | 488 | ||
514 | if (edit) | 489 | if (sInstance) |
515 | { | 490 | sInstance->setFocus(TRUE); |
516 | edit->setFocus(TRUE); | ||
517 | edit->selectAll(); | ||
518 | } | ||
519 | } | ||
520 | } | 491 | } |
521 | 492 | ||
522 | 493 | ||
@@ -528,266 +499,167 @@ void LLPanelLogin::show(const LLRect &rect, | |||
528 | { | 499 | { |
529 | new LLPanelLogin(rect, show_server, callback, callback_data); | 500 | new LLPanelLogin(rect, show_server, callback, callback_data); |
530 | 501 | ||
502 | LLWebBrowserCtrl* web_browser = LLUICtrlFactory::getWebBrowserCtrlByName(sInstance, "login_html"); | ||
503 | |||
504 | if (!web_browser) return; | ||
505 | |||
531 | if( !gFocusMgr.getKeyboardFocus() ) | 506 | if( !gFocusMgr.getKeyboardFocus() ) |
532 | { | 507 | { |
533 | // Grab focus and move cursor to first enabled control | 508 | // Grab focus and move cursor to first enabled control |
534 | sInstance->setFocus(TRUE); | 509 | web_browser->setFocus(TRUE); |
535 | } | 510 | } |
536 | 511 | ||
537 | // Make sure that focus always goes here (and use the latest sInstance that was just created) | 512 | // Make sure that focus always goes here (and use the latest sInstance that was just created) |
538 | gFocusMgr.setDefaultKeyboardFocus(sInstance); | 513 | gFocusMgr.setDefaultKeyboardFocus(web_browser); |
539 | } | 514 | } |
540 | 515 | ||
516 | |||
541 | // static | 517 | // static |
542 | void LLPanelLogin::setFields(const std::string& firstname, const std::string& lastname, const std::string& password, | 518 | void LLPanelLogin::close() |
543 | BOOL remember) | ||
544 | { | 519 | { |
545 | if (!sInstance) | 520 | if (sInstance) |
546 | { | 521 | { |
547 | llwarns << "Attempted fillFields with no login view shown" << llendl; | 522 | gViewerWindow->getRootView()->removeChild( LLPanelLogin::sInstance ); |
548 | return; | 523 | |
549 | } | 524 | gFocusMgr.setDefaultKeyboardFocus(NULL); |
550 | |||
551 | sInstance->childSetText("first_name_edit", firstname); | ||
552 | sInstance->childSetText("last_name_edit", lastname); | ||
553 | 525 | ||
554 | // Max "actual" password length is 16 characters. | 526 | delete sInstance; |
555 | // Hex digests are always 32 characters. | 527 | sInstance = NULL; |
556 | if (password.length() == 32) | ||
557 | { | ||
558 | // This is a MD5 hex digest of a password. | ||
559 | // We don't actually use the password input field, | ||
560 | // fill it with MAX_PASSWORD characters so we get a | ||
561 | // nice row of asterixes. | ||
562 | const std::string filler("123456789!123456"); | ||
563 | sInstance->childSetText("password_edit", filler); | ||
564 | sInstance->mIncomingPassword = filler; | ||
565 | sInstance->mMungedPassword = password; | ||
566 | } | ||
567 | else | ||
568 | { | ||
569 | // this is a normal text password | ||
570 | sInstance->childSetText("password_edit", password); | ||
571 | sInstance->mIncomingPassword = password; | ||
572 | LLMD5 pass((unsigned char *)password.c_str()); | ||
573 | char munged_password[MD5HEX_STR_SIZE]; | ||
574 | pass.hex_digest(munged_password); | ||
575 | sInstance->mMungedPassword = munged_password; | ||
576 | } | 528 | } |
577 | |||
578 | sInstance->childSetValue("remember_check", remember); | ||
579 | } | 529 | } |
580 | 530 | ||
581 | |||
582 | // static | 531 | // static |
583 | void LLPanelLogin::addServer(const char *server, S32 domain_name) | 532 | void LLPanelLogin::setAlwaysRefresh(bool refresh) |
584 | { | 533 | { |
585 | if (!sInstance) | 534 | if (LLStartUp::getStartupState() >= STATE_LOGIN_CLEANUP) return; |
586 | { | ||
587 | llwarns << "Attempted addServer with no login view shown" << llendl; | ||
588 | return; | ||
589 | } | ||
590 | 535 | ||
591 | LLComboBox* combo = LLUICtrlFactory::getComboBoxByName(sInstance, "server_combo"); | 536 | LLWebBrowserCtrl* web_browser = LLUICtrlFactory::getWebBrowserCtrlByName(sInstance, "login_html"); |
592 | if (combo) | 537 | |
538 | if (web_browser) | ||
593 | { | 539 | { |
594 | combo->add(server, LLSD(domain_name) ); | 540 | web_browser->setAlwaysRefresh(refresh); |
595 | combo->setCurrentByIndex(0); | ||
596 | } | 541 | } |
597 | } | 542 | } |
598 | 543 | ||
599 | // static | ||
600 | void LLPanelLogin::getFields(LLString &firstname, LLString &lastname, LLString &password, | ||
601 | BOOL &remember) | ||
602 | { | ||
603 | if (!sInstance) | ||
604 | { | ||
605 | llwarns << "Attempted getFields with no login view shown" << llendl; | ||
606 | return; | ||
607 | } | ||
608 | 544 | ||
609 | firstname = sInstance->childGetText("first_name_edit"); | ||
610 | LLString::trim(firstname); | ||
611 | 545 | ||
612 | lastname = sInstance->childGetText("last_name_edit"); | 546 | void LLPanelLogin::loadLoginPage() |
613 | LLString::trim(lastname); | 547 | { |
548 | if (!sInstance) return; | ||
614 | 549 | ||
615 | password = sInstance->mMungedPassword; | 550 | LLURLSimString::sInstance.parse(); |
616 | remember = sInstance->childGetValue("remember_check"); | ||
617 | } | ||
618 | 551 | ||
552 | LLWebBrowserCtrl* web_browser = LLUICtrlFactory::getWebBrowserCtrlByName(sInstance, "login_html"); | ||
619 | 553 | ||
620 | // static. Return TRUE if user made a choice from the popup | 554 | std::ostringstream oStr; |
621 | BOOL LLPanelLogin::getServer(LLString &server, S32 &domain_name) | 555 | |
622 | { | 556 | LLString location; |
623 | BOOL user_picked = FALSE; | 557 | LLString region; |
624 | if (!sInstance) | 558 | LLString password; |
625 | { | 559 | |
626 | llwarns << "Attempted getServer with no login view shown" << llendl; | 560 | if (LLURLSimString::parse()) |
561 | { | ||
562 | std::ostringstream oRegionStr; | ||
563 | location = "specify"; | ||
564 | oRegionStr << LLURLSimString::sInstance.mSimName << "/" << LLURLSimString::sInstance.mX << "/" | ||
565 | << LLURLSimString::sInstance.mY << "/" | ||
566 | << LLURLSimString::sInstance.mZ; | ||
567 | region = oRegionStr.str(); | ||
627 | } | 568 | } |
628 | else | 569 | else |
629 | { | 570 | { |
630 | LLComboBox* combo = LLUICtrlFactory::getComboBoxByName(sInstance, "server_combo"); | 571 | if (gSavedSettings.getBOOL("LoginLastLocation")) |
631 | if (combo) | ||
632 | { | 572 | { |
633 | LLSD combo_val = combo->getValue(); | 573 | location = "last"; |
634 | if (LLSD::TypeInteger == combo_val.type()) | 574 | } |
635 | { | 575 | else |
636 | domain_name = combo->getValue().asInteger(); | 576 | { |
637 | 577 | location = "home"; | |
638 | if ((S32)USERSERVER_OTHER == domain_name) | ||
639 | { | ||
640 | server = gUserServerName; | ||
641 | } | ||
642 | } | ||
643 | else | ||
644 | { | ||
645 | // no valid selection, return other | ||
646 | domain_name = (S32)USERSERVER_OTHER; | ||
647 | server = combo_val.asString(); | ||
648 | } | ||
649 | user_picked = combo->isDirty(); | ||
650 | } | 578 | } |
651 | } | 579 | } |
652 | 580 | ||
653 | return user_picked; | 581 | LLString firstname, lastname; |
654 | } | 582 | |
655 | 583 | if (gCmdLineFirstName.empty()) | |
656 | // static | ||
657 | void LLPanelLogin::getLocation(LLString &location) | ||
658 | { | ||
659 | if (!sInstance) | ||
660 | { | 584 | { |
661 | llwarns << "Attempted getLocation with no login view shown" << llendl; | 585 | firstname = gSavedSettings.getString("FirstName"); |
662 | return; | ||
663 | } | 586 | } |
664 | 587 | else | |
665 | LLComboBox* combo = LLUICtrlFactory::getComboBoxByName(sInstance, "start_location_combo"); | ||
666 | if (combo) | ||
667 | { | 588 | { |
668 | location = combo->getValue().asString(); | 589 | firstname = gCmdLineFirstName; |
669 | } | 590 | } |
670 | } | 591 | |
671 | 592 | if (gCmdLineLastName.empty()) | |
672 | // static | ||
673 | void LLPanelLogin::refreshLocation( bool force_visible ) | ||
674 | { | ||
675 | if (!sInstance) return; | ||
676 | |||
677 | LLComboBox* combo = LLUICtrlFactory::getComboBoxByName(sInstance, "start_location_combo"); | ||
678 | if (!combo) return; | ||
679 | |||
680 | LLString sim_string = LLURLSimString::sInstance.mSimString; | ||
681 | if (!sim_string.empty()) | ||
682 | { | 593 | { |
683 | combo->setCurrentByIndex( 3 ); // BUG? Maybe 2? | 594 | lastname = gSavedSettings.getString("LastName"); |
684 | combo->setTextEntry(sim_string); | ||
685 | } | 595 | } |
686 | else | 596 | else |
687 | { | 597 | { |
688 | BOOL login_last = gSavedSettings.getBOOL("LoginLastLocation"); | 598 | lastname = gCmdLineLastName; |
689 | combo->setCurrentByIndex( login_last ? 1 : 0 ); | ||
690 | } | 599 | } |
600 | |||
601 | LLString version = llformat("%d.%d.%d (%d)", | ||
602 | LL_VERSION_MAJOR, LL_VERSION_MINOR, LL_VERSION_PATCH, LL_VIEWER_BUILD); | ||
691 | 603 | ||
692 | BOOL show_start = TRUE; | 604 | char* curl_region = curl_escape(region.c_str(), 0); |
605 | char* curl_channel = curl_escape(gChannelName.c_str(), 0); | ||
606 | char* curl_version = curl_escape(version.c_str(), 0); | ||
693 | 607 | ||
694 | if ( ! force_visible ) | 608 | |
695 | show_start = gSavedSettings.getBOOL("ShowStartLocation"); | 609 | oStr << sInstance->childGetValue( "real_url" ).asString() << "&firstname=" << firstname << |
610 | "&lastname=" << lastname << "&location=" << location << "®ion=" << curl_region << | ||
611 | "&grid=" << gGridInfo[gGridChoice].mLabel << "&channel=" << curl_channel << | ||
612 | "&version=" << curl_version; | ||
696 | 613 | ||
697 | sInstance->childSetVisible("start_location_combo", show_start); | 614 | |
698 | sInstance->childSetVisible("start_location_text", show_start); | 615 | curl_free(curl_region); |
699 | } | 616 | curl_free(curl_channel); |
617 | curl_free(curl_version); | ||
700 | 618 | ||
701 | // static | 619 | LLString language(gSavedSettings.getString("Language")); |
702 | void LLPanelLogin::close() | 620 | if(language == "default") |
703 | { | ||
704 | if (sInstance) | ||
705 | { | 621 | { |
706 | gViewerWindow->getRootView()->removeChild( LLPanelLogin::sInstance ); | 622 | language = gSavedSettings.getString("SystemLanguage"); |
707 | |||
708 | gFocusMgr.setDefaultKeyboardFocus(NULL); | ||
709 | |||
710 | delete sInstance; | ||
711 | sInstance = NULL; | ||
712 | } | 623 | } |
713 | } | ||
714 | |||
715 | 624 | ||
716 | //--------------------------------------------------------------------------- | 625 | oStr << "&lang=" << language; |
717 | // Protected methods | ||
718 | //--------------------------------------------------------------------------- | ||
719 | 626 | ||
720 | // static | 627 | if (!gCmdLinePassword.empty()) |
721 | void LLPanelLogin::onClickConnect(void *) | ||
722 | { | ||
723 | if (sInstance && sInstance->mCallback) | ||
724 | { | 628 | { |
725 | // tell the responder we're not here anymore | 629 | oStr << "&password=" << gCmdLinePassword; |
726 | if ( gResponsePtr ) | ||
727 | gResponsePtr->setParent( 0 ); | ||
728 | |||
729 | // JC - Make sure the fields all get committed. | ||
730 | sInstance->setFocus(FALSE); | ||
731 | |||
732 | LLString first = sInstance->childGetText("first_name_edit"); | ||
733 | LLString last = sInstance->childGetText("last_name_edit"); | ||
734 | if (!first.empty() && !last.empty()) | ||
735 | { | ||
736 | // has both first and last name typed | ||
737 | |||
738 | // store off custom server entry, if currently selected | ||
739 | LLComboBox* combo = LLUICtrlFactory::getComboBoxByName(sInstance, "server_combo"); | ||
740 | if (combo) | ||
741 | { | ||
742 | S32 selected_server = combo->getValue(); | ||
743 | if (selected_server == USERSERVER_NONE) | ||
744 | { | ||
745 | LLString custom_server = combo->getValue().asString(); | ||
746 | gSavedSettings.setString("CustomServer", custom_server); | ||
747 | } | ||
748 | } | ||
749 | sInstance->mCallback(0, sInstance->mCallbackData); | ||
750 | } | ||
751 | else | ||
752 | { | ||
753 | // empty first or last name | ||
754 | // same as clicking new account | ||
755 | onClickNewAccount(NULL); | ||
756 | } | ||
757 | } | 630 | } |
758 | } | 631 | else if (!(password = load_password_from_disk()).empty()) |
759 | |||
760 | |||
761 | // static | ||
762 | void LLPanelLogin::newAccountAlertCallback(S32 option, void*) | ||
763 | { | ||
764 | if (0 == option) | ||
765 | { | 632 | { |
766 | llinfos << "Going to account creation URL" << llendl; | 633 | oStr << "&password=$1$" << password; |
767 | LLWeb::loadURL( CREATE_ACCOUNT_URL ); | ||
768 | } | 634 | } |
769 | else | 635 | if (gAutoLogin) |
770 | { | 636 | { |
771 | sInstance->setFocus(TRUE); | 637 | oStr << "&auto_login=TRUE"; |
772 | } | 638 | } |
773 | } | 639 | if (gSavedSettings.getBOOL("ShowStartLocation")) |
774 | |||
775 | |||
776 | // static | ||
777 | void LLPanelLogin::onClickNewAccount(void*) | ||
778 | { | ||
779 | if (gHideLinks) | ||
780 | { | 640 | { |
781 | gViewerWindow->alertXml("MustHaveAccountToLogInNoLinks"); | 641 | oStr << "&show_start_location=TRUE"; |
782 | } | 642 | } |
783 | else | 643 | if (gSavedSettings.getBOOL("RememberPassword")) |
784 | { | 644 | { |
785 | gViewerWindow->alertXml("MustHaveAccountToLogIn", | 645 | oStr << "&remember_password=TRUE"; |
786 | LLPanelLogin::newAccountAlertCallback); | 646 | } |
787 | } | 647 | #ifndef LL_RELEASE_FOR_DOWNLOAD |
648 | oStr << "&show_grid=TRUE"; | ||
649 | #else | ||
650 | if (gSavedSettings.getBOOL("ForceShowGrid")) | ||
651 | oStr << "&show_grid=TRUE"; | ||
652 | #endif | ||
653 | |||
654 | // navigate to the "real" page | ||
655 | web_browser->navigateTo( oStr.str() ); | ||
788 | } | 656 | } |
789 | 657 | ||
790 | 658 | ||
659 | //--------------------------------------------------------------------------- | ||
660 | // Protected methods | ||
661 | //--------------------------------------------------------------------------- | ||
662 | |||
791 | // static | 663 | // static |
792 | void LLPanelLogin::onClickQuit(void*) | 664 | void LLPanelLogin::onClickQuit(void*) |
793 | { | 665 | { |
@@ -807,13 +679,3 @@ void LLPanelLogin::onClickVersion(void*) | |||
807 | { | 679 | { |
808 | LLFloaterAbout::show(NULL); | 680 | LLFloaterAbout::show(NULL); |
809 | } | 681 | } |
810 | |||
811 | // static | ||
812 | void LLPanelLogin::onPassKey(LLLineEditor* caller, void* user_data) | ||
813 | { | ||
814 | if (gKeyboard->getKeyDown(KEY_CAPSLOCK) && sCapslockDidNotification == FALSE) | ||
815 | { | ||
816 | LLNotifyBox::showXml("CapsKeyOn"); | ||
817 | sCapslockDidNotification = TRUE; | ||
818 | } | ||
819 | } | ||