aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/floaterlogin.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2009-09-10 02:38:36 -0500
committerJacek Antonelli2009-09-10 02:38:36 -0500
commitb3c39a47e76f595fd953d9ccffc58b0dfb8359db (patch)
treea4bfdb28caf5f42c7ff1878b359aa3fa6a79bc2c /linden/indra/newview/floaterlogin.cpp
parentFixed line endings on hippo and grid manager files. (diff)
downloadmeta-impy-b3c39a47e76f595fd953d9ccffc58b0dfb8359db.zip
meta-impy-b3c39a47e76f595fd953d9ccffc58b0dfb8359db.tar.gz
meta-impy-b3c39a47e76f595fd953d9ccffc58b0dfb8359db.tar.bz2
meta-impy-b3c39a47e76f595fd953d9ccffc58b0dfb8359db.tar.xz
Updated Grid Manager from Meerkat's SVN (as of r215).
Diffstat (limited to 'linden/indra/newview/floaterlogin.cpp')
-rw-r--r--linden/indra/newview/floaterlogin.cpp348
1 files changed, 119 insertions, 229 deletions
diff --git a/linden/indra/newview/floaterlogin.cpp b/linden/indra/newview/floaterlogin.cpp
index b943c4e..6519962 100644
--- a/linden/indra/newview/floaterlogin.cpp
+++ b/linden/indra/newview/floaterlogin.cpp
@@ -1,9 +1,7 @@
1/* 1/*
2 * floaterlogin.cpp 2 * floaterlogin.cpp (floatergridmanager.cpp pls)
3 * SecondLife 3 * This is Meerkats grid manager, and I accidentally finished it with the wrong name :)
4 * 4 * -Patrick Sapinski (Monday, August 17, 2009)
5 * Created by RMS on 7/15/08.
6 *
7 */ 5 */
8 6
9#include "llviewerprecompiledheaders.h" 7#include "llviewerprecompiledheaders.h"
@@ -16,7 +14,6 @@
16#include "llmd5.h" 14#include "llmd5.h"
17#include "llurlsimstring.h" 15#include "llurlsimstring.h"
18#include "lluictrlfactory.h" 16#include "lluictrlfactory.h"
19#include "controllerlogin.h"
20#include "floaterlogin.h" 17#include "floaterlogin.h"
21#include "hippoGridManager.h" 18#include "hippoGridManager.h"
22#include "llviewernetwork.h" 19#include "llviewernetwork.h"
@@ -26,13 +23,11 @@
26 23
27LoginFloater* LoginFloater::sInstance = NULL; 24LoginFloater* LoginFloater::sInstance = NULL;
28LoginController* LoginFloater::sController = NULL; 25LoginController* LoginFloater::sController = NULL;
29AuthenticationModel* LoginFloater::sModel = NULL;
30bool LoginFloater::sIsInitialLogin; 26bool LoginFloater::sIsInitialLogin;
31std::string LoginFloater::sGrid; 27std::string LoginFloater::sGrid;
32 28
33LoginFloater::LoginFloater(void (*callback)(S32 option, void* user_data), 29LoginFloater::LoginFloater()
34 void *cb_data) 30: LLFloater("floater_login")
35: LLFloater("floater_login"), mCallback(callback), mCallbackData(cb_data)
36{ 31{
37 32
38 mState = NORMAL; 33 mState = NORMAL;
@@ -56,7 +51,7 @@ LoginFloater::LoginFloater(void (*callback)(S32 option, void* user_data),
56 } 51 }
57 52
58 center(); 53 center();
59 LLLineEditor* edit = getChild<LLLineEditor>("password_edit"); 54 LLLineEditor* edit = getChild<LLLineEditor>("avatar_password_edit");
60 if (edit) edit->setDrawAsterixes(TRUE); 55 if (edit) edit->setDrawAsterixes(TRUE);
61 LLComboBox* combo = getChild<LLComboBox>("start_location_combo"); 56 LLComboBox* combo = getChild<LLComboBox>("start_location_combo");
62 combo->setAllowTextEntry(TRUE, 128, FALSE); 57 combo->setAllowTextEntry(TRUE, 128, FALSE);
@@ -79,34 +74,11 @@ LoginFloater::LoginFloater(void (*callback)(S32 option, void* user_data),
79 { 74 {
80 combo->setCurrentByIndex( 0 ); 75 combo->setCurrentByIndex( 0 );
81 } 76 }
82
83 LLTextBox* version_text = getChild<LLTextBox>("version_text");
84 std::string version = llformat("%d.%d.%d (%d)",
85 LL_VERSION_MAJOR,
86 LL_VERSION_MINOR,
87 LL_VERSION_PATCH,
88 LL_VIEWER_BUILD );
89 version_text->setText(version);
90
91 LLTextBox* channel_text = getChild<LLTextBox>("channel_text");
92 channel_text->setText(gSavedSettings.getString("VersionChannelName"));
93
94 sendChildToBack(getChildView("channel_text"));
95 sendChildToBack(getChildView("version_text"));
96 sendChildToBack(getChildView("forgot_password_text"));
97
98 setDefaultBtn("connect_btn");
99
100
101
102} 77}
103 78
104 79
105LoginFloater::~LoginFloater() 80LoginFloater::~LoginFloater()
106{ 81{
107 delete LoginFloater::sController;
108
109 LoginFloater::sModel = NULL;
110 LoginFloater::sController = NULL; 82 LoginFloater::sController = NULL;
111 LoginFloater::sInstance = NULL; 83 LoginFloater::sInstance = NULL;
112} 84}
@@ -122,17 +94,19 @@ void LoginFloater::close()
122 94
123BOOL LoginFloater::postBuild() 95BOOL LoginFloater::postBuild()
124{ 96{
125 requires<LLComboBox>("grid_selector"); 97 requires<LLScrollListCtrl>("grid_selector");
126 requires<LLLineEditor>("gridnick"); 98 requires<LLLineEditor>("gridnick");
127 requires<LLComboBox>("platform");
128 requires<LLLineEditor>("gridname"); 99 requires<LLLineEditor>("gridname");
129 requires<LLLineEditor>("loginuri"); 100 requires<LLLineEditor>("loginuri");
130 requires<LLLineEditor>("loginpage"); 101 requires<LLLineEditor>("loginpage");
131 requires<LLLineEditor>("helperuri"); 102 requires<LLLineEditor>("helperuri");
132 requires<LLLineEditor>("website"); 103 requires<LLLineEditor>("website");
104 requires<LLLineEditor>("support");
105 requires<LLLineEditor>("register");
106 requires<LLLineEditor>("password");
133 requires<LLLineEditor>("first_name"); 107 requires<LLLineEditor>("first_name");
134 requires<LLLineEditor>("last_name"); 108 requires<LLLineEditor>("last_name");
135 requires<LLLineEditor>("password"); 109 requires<LLLineEditor>("avatar_password");
136 //requires<LLLineEditor>("search"); 110 //requires<LLLineEditor>("search");
137 requires<LLButton>("btn_delete"); 111 requires<LLButton>("btn_delete");
138 requires<LLButton>("btn_add"); 112 requires<LLButton>("btn_add");
@@ -141,17 +115,18 @@ BOOL LoginFloater::postBuild()
141 requires<LLButton>("btn_gridinfo"); 115 requires<LLButton>("btn_gridinfo");
142 requires<LLButton>("btn_help_render_compat"); 116 requires<LLButton>("btn_help_render_compat");
143 if (!checkRequirements()) return false; 117 if (!checkRequirements()) return false;
144 LLLineEditor* password_edit = getChild<LLLineEditor>("password"); 118 LLLineEditor* password_edit = getChild<LLLineEditor>("avatar_password");
145 if (password_edit) password_edit->setDrawAsterixes(TRUE); 119 if (password_edit) password_edit->setDrawAsterixes(TRUE);
146 120
147 childSetAction("btn_delete", onClickDelete, this); 121 childSetAction("btn_delete", onClickDelete, this);
148 childSetAction("btn_add", onClickAdd, this); 122 childSetAction("btn_add", onClickAdd, this);
149 childSetAction("btn_copy", onClickCopy, this); 123 childSetAction("btn_copy", onClickCopy, this);
124 childSetAction("btn_ok", onClickOk, this);
150 childSetAction("btn_apply", onClickApply, this); 125 childSetAction("btn_apply", onClickApply, this);
151 childSetAction("set_default", onClickDefault, this); 126 childSetAction("set_default", onClickDefault, this);
152 childSetAction("btn_cancel", onClickCancel, this); 127 childSetAction("btn_cancel", onClickCancel, this);
153//KOW childSetAction("set_default", onClickDefault, this); 128//KOW childSetAction("set_default", onClickDefault, this);
154//KOW childSetAction("btn_gridinfo", onClickGridInfo, this); 129 childSetAction("btn_gridinfo", onClickGridInfo, this);
155//KOW childSetAction("btn_help_render_compat", onClickHelpRenderCompat, this); 130//KOW childSetAction("btn_help_render_compat", onClickHelpRenderCompat, this);
156 131
157 childSetCommitCallback("grid_selector", onSelectGrid, this); 132 childSetCommitCallback("grid_selector", onSelectGrid, this);
@@ -209,29 +184,24 @@ void LoginFloater::refresh_grids()
209 sInstance->childSetEnabled("set_default", (sInstance->mState == NORMAL) && (selectIndex > 0)); 184 sInstance->childSetEnabled("set_default", (sInstance->mState == NORMAL) && (selectIndex > 0));
210 sInstance->childSetEnabled("gridnick", (sInstance->mState == ADD_NEW) || (sInstance->mState == ADD_COPY)); 185 sInstance->childSetEnabled("gridnick", (sInstance->mState == ADD_NEW) || (sInstance->mState == ADD_COPY));
211 186
212
213 LLComboBox *platform = sInstance->getChild<LLComboBox>("platform");
214 platform->removeall();
215 for (int p=HippoGridInfo::PLATFORM_OTHER; p<HippoGridInfo::PLATFORM_LAST; p++)
216 platform->add(HippoGridInfo::getPlatformString(static_cast<HippoGridInfo::Platform>(p)));
217
218
219 if (sInstance->mState == NORMAL) { 187 if (sInstance->mState == NORMAL) {
220 HippoGridInfo *gridInfo = gHippoGridManager->getGrid(sInstance->mCurGrid); 188 HippoGridInfo *gridInfo = gHippoGridManager->getGrid(sInstance->mCurGrid);
221 if (gridInfo) { 189 if (gridInfo) {
222 sInstance->childSetText("gridnick", gridInfo->getGridNick()); 190 sInstance->childSetText("gridnick", gridInfo->getGridNick());
223 platform->setCurrentByIndex(gridInfo->getPlatform());
224 //sInstance->childSetText("grid_name", gridInfo->getGridName()); 191 //sInstance->childSetText("grid_name", gridInfo->getGridName());
225 sInstance->childSetText("loginuri", gridInfo->getLoginUri()); 192 sInstance->childSetText("loginuri", gridInfo->getLoginUri());
226 sInstance->childSetText("loginpage", gridInfo->getLoginPage()); 193 sInstance->childSetText("loginpage", gridInfo->getLoginPage());
227 sInstance->childSetText("helperuri", gridInfo->getHelperUri()); 194 sInstance->childSetText("helperuri", gridInfo->getHelperUri());
228 sInstance->childSetText("website", gridInfo->getWebSite()); 195 sInstance->childSetText("website", gridInfo->getWebSite());
196 sInstance->childSetText("support", gridInfo->getSupportUrl());
197 sInstance->childSetText("register", gridInfo->getRegisterUrl());
198 sInstance->childSetText("password", gridInfo->getPasswordUrl());
229 sInstance->childSetText("first_name", gridInfo->getFirstName()); 199 sInstance->childSetText("first_name", gridInfo->getFirstName());
230 sInstance->childSetText("last_name", gridInfo->getLastName()); 200 sInstance->childSetText("last_name", gridInfo->getLastName());
231 if(gridInfo->getAvatarPassword().length() == 32) 201 if(gridInfo->getAvatarPassword().length() == 32)
232 sInstance->childSetText("password", std::string(PASSWORD_FILLER)); 202 sInstance->childSetText("avatar_password", std::string(PASSWORD_FILLER));
233 else if(gridInfo->getPasswordUrl().empty()) 203 else if(gridInfo->getPasswordUrl().empty())
234 sInstance->childSetText("password", std::string("")); 204 sInstance->childSetText("avatar_password", std::string(""));
235/* 205/*
236 if (gridInfo->getPlatform() == HippoGridInfo::PLATFORM_SECONDLIFE) { 206 if (gridInfo->getPlatform() == HippoGridInfo::PLATFORM_SECONDLIFE) {
237 //childSetEnabled("search", false); 207 //childSetEnabled("search", false);
@@ -248,7 +218,6 @@ void LoginFloater::refresh_grids()
248 } else { 218 } else {
249 std::string empty = ""; 219 std::string empty = "";
250 sInstance->childSetText("gridnick", empty); 220 sInstance->childSetText("gridnick", empty);
251 platform->setCurrentByIndex(HippoGridInfo::PLATFORM_OTHER);
252 sInstance->childSetText("gridname", empty); 221 sInstance->childSetText("gridname", empty);
253 sInstance->childSetText("loginuri", empty); 222 sInstance->childSetText("loginuri", empty);
254 sInstance->childSetText("loginpage", empty); 223 sInstance->childSetText("loginpage", empty);
@@ -256,28 +225,26 @@ void LoginFloater::refresh_grids()
256 sInstance->childSetText("website", empty); 225 sInstance->childSetText("website", empty);
257 sInstance->childSetText("first_name", empty); 226 sInstance->childSetText("first_name", empty);
258 sInstance->childSetText("last_name", empty); 227 sInstance->childSetText("last_name", empty);
259 sInstance->childSetText("password", empty); 228 sInstance->childSetText("avatar_password", empty);
260 sInstance->childSetEnabled("render_compat", true);
261 sInstance->childSetValue("render_compat", true);
262 } 229 }
263 } else if (sInstance->mState == ADD_NEW) { 230 } else if (sInstance->mState == ADD_NEW) {
264 llwarns << "ADD_NEW" << llendl; 231 llwarns << "ADD_NEW" << llendl;
265 std::string required = "<required>"; 232 std::string required = "<required>";
266 std::string empty = ""; 233 std::string empty = "";
267 sInstance->childSetText("gridnick", required); 234 sInstance->childSetText("gridnick", required);
268 platform->setCurrentByIndex(HippoGridInfo::PLATFORM_OTHER);
269 sInstance->childSetText("gridname", empty); 235 sInstance->childSetText("gridname", empty);
270 sInstance->childSetText("loginuri", required); 236 sInstance->childSetText("loginuri", required);
271 sInstance->childSetText("loginpage", empty); 237 sInstance->childSetText("loginpage", empty);
272 sInstance->childSetText("helperuri", empty); 238 sInstance->childSetText("helperuri", empty);
273 sInstance->childSetText("website", empty); 239 sInstance->childSetText("website", empty);
240 sInstance->childSetText("support", empty);
241 sInstance->childSetText("register", empty);
242 sInstance->childSetText("password", empty);
274 sInstance->childSetText("first_name", empty); 243 sInstance->childSetText("first_name", empty);
275 sInstance->childSetText("last_name", empty); 244 sInstance->childSetText("last_name", empty);
276 sInstance->childSetText("password", empty); 245 sInstance->childSetText("avatar_password", empty);
277 //childSetEnabled("search", true); 246 //childSetEnabled("search", true);
278 //childSetText("search", empty); 247 //childSetText("search", empty);
279 sInstance->childSetEnabled("render_compat", true);
280 sInstance->childSetValue("render_compat", true);
281 } else if (sInstance->mState == ADD_COPY) { 248 } else if (sInstance->mState == ADD_COPY) {
282 llwarns << "ADD_COPY" << llendl; 249 llwarns << "ADD_COPY" << llendl;
283 sInstance->childSetText("gridnick", LLStringExplicit("<required>")); 250 sInstance->childSetText("gridnick", LLStringExplicit("<required>"));
@@ -302,29 +269,32 @@ void LoginFloater::applyChanges()
302 { 269 {
303 if (gridInfo->getGridNick() == childGetValue("gridnick").asString()) 270 if (gridInfo->getGridNick() == childGetValue("gridnick").asString())
304 { 271 {
305 gridInfo->setPlatform(childGetValue("platform"));
306 gridInfo->setGridName(childGetValue("gridname")); 272 gridInfo->setGridName(childGetValue("gridname"));
307 gridInfo->setLoginUri(childGetValue("loginuri")); 273 gridInfo->setLoginUri(childGetValue("loginuri"));
308 gridInfo->setLoginPage(childGetValue("loginpage")); 274 gridInfo->setLoginPage(childGetValue("loginpage"));
309 gridInfo->setHelperUri(childGetValue("helperuri")); 275 gridInfo->setHelperUri(childGetValue("helperuri"));
310 gridInfo->setWebSite(childGetValue("website")); 276 gridInfo->setWebSite(childGetValue("website"));
277 gridInfo->setSupportUrl(childGetValue("support"));
278 gridInfo->setRegisterUrl(childGetValue("register"));
279 gridInfo->setPasswordUrl(childGetValue("password"));
311 gridInfo->setFirstName(childGetValue("first_name")); 280 gridInfo->setFirstName(childGetValue("first_name"));
312 gridInfo->setLastName(childGetValue("last_name")); 281 gridInfo->setLastName(childGetValue("last_name"));
313 //gridInfo->setSearchUrl(childGetValue("search")); 282 //gridInfo->setSearchUrl(childGetValue("search"));
314 gridInfo->setRenderCompat(childGetValue("render_compat")); 283 gridInfo->setRenderCompat(childGetValue("render_compat"));
315 284
316 if(childGetValue("password").asString().empty()) 285 if(childGetValue("avatar_password").asString().empty())
317 gridInfo->setPasswordUrl(std::string("")); 286 gridInfo->setAvatarPassword(std::string(""));
318 else if(childGetValue("password").asString() != std::string(PASSWORD_FILLER)) 287 else if(childGetValue("avatar_password").asString() != std::string(PASSWORD_FILLER))
319 { 288 {
320 // store account authentication data 289 // store account authentication data
321 std::string auth_password = childGetValue("password"); 290 std::string auth_password = childGetValue("avatar_password");
322 std::string hashed_password; 291 std::string hashed_password;
323 hashPassword(auth_password, hashed_password); 292 hashPassword(auth_password, hashed_password);
324 gridInfo->setAvatarPassword(hashed_password); 293 gridInfo->setAvatarPassword(hashed_password);
325 } 294 }
326 LLPanelLogin::setFields(gridInfo->getFirstName(), gridInfo->getLastName(), 295 //this bug was a feature -Patrick Sapinski (Friday, August 21, 2009)
327 gridInfo->getAvatarPassword(), true); 296 //LLPanelLogin::setFields(gridInfo->getFirstName(), gridInfo->getLastName(),
297 // gridInfo->getAvatarPassword(), true);
328 } 298 }
329 else 299 else
330 { 300 {
@@ -363,24 +333,26 @@ bool LoginFloater::createNewGrid()
363 333
364 // create new grid 334 // create new grid
365 HippoGridInfo *grid = new HippoGridInfo(gridnick); 335 HippoGridInfo *grid = new HippoGridInfo(gridnick);
366 grid->setPlatform(childGetValue("platform"));
367 grid->setGridName(childGetValue("gridname")); 336 grid->setGridName(childGetValue("gridname"));
368 grid->setLoginUri(loginuri); 337 grid->setLoginUri(loginuri);
369 grid->setLoginPage(childGetValue("loginpage")); 338 grid->setLoginPage(childGetValue("loginpage"));
370 grid->setHelperUri(childGetValue("helperuri")); 339 grid->setHelperUri(childGetValue("helperuri"));
371 grid->setWebSite(childGetValue("website")); 340 grid->setWebSite(childGetValue("website"));
341 grid->setSupportUrl(childGetValue("support"));
342 grid->setRegisterUrl(childGetValue("register"));
343 grid->setPasswordUrl(childGetValue("password"));
372 grid->setFirstName(childGetValue("first_name")); 344 grid->setFirstName(childGetValue("first_name"));
373 grid->setLastName(childGetValue("last_name")); 345 grid->setLastName(childGetValue("last_name"));
374 //grid->setSearchUrl(childGetValue("search")); 346 //grid->setSearchUrl(childGetValue("search"));
375 grid->setRenderCompat(childGetValue("render_compat")); 347 grid->setRenderCompat(childGetValue("render_compat"));
376 gHippoGridManager->addGrid(grid); 348 gHippoGridManager->addGrid(grid);
377 349
378 if(childGetValue("password").asString().empty()) 350 if(childGetValue("avatar_password").asString().empty())
379 grid->setAvatarPassword(std::string("")); 351 grid->setAvatarPassword(std::string(""));
380 else 352 else
381 { 353 {
382 std::string hashed_password; 354 std::string hashed_password;
383 hashPassword(childGetValue("password"), hashed_password); 355 hashPassword(childGetValue("avatar_password"), hashed_password);
384 grid->setAvatarPassword(hashed_password); 356 grid->setAvatarPassword(hashed_password);
385 } 357 }
386 358
@@ -388,6 +360,49 @@ bool LoginFloater::createNewGrid()
388 return true; 360 return true;
389} 361}
390 362
363void LoginFloater::retrieveGridInfo()
364{
365 std::string loginuri = childGetValue("loginuri");
366 if ((loginuri == "") || (loginuri == "<required>")) {
367 //KOW gViewerWindow->alertXml("GridInfoNoLoginUri");
368 return;
369 }
370
371 HippoGridInfo *grid = 0;
372 bool cleanupGrid = false;
373 if (mState == NORMAL) {
374 grid = gHippoGridManager->getGrid(mCurGrid);
375 } else if ((mState == ADD_NEW) || (mState == ADD_COPY)) {
376 grid = new HippoGridInfo("");
377 cleanupGrid = true;
378 } else {
379 llerrs << "Illegal state " << mState << '.' << llendl;
380 return;
381 }
382 if (!grid) {
383 llerrs << "Internal error retrieving grid info." << llendl;
384 return;
385 }
386
387 grid->setLoginUri(loginuri);
388 if (grid->retrieveGridInfo()) {
389 if (grid->getGridNick() != "") childSetText("gridnick", grid->getGridNick());
390 if (grid->getGridName() != "") childSetText("gridname", grid->getGridName());
391 if (grid->getLoginUri() != "") childSetText("loginuri", grid->getLoginUri());
392 if (grid->getLoginPage() != "") childSetText("loginpage", grid->getLoginPage());
393 if (grid->getHelperUri() != "") childSetText("helperuri", grid->getHelperUri());
394 if (grid->getWebSite() != "") childSetText("website", grid->getWebSite());
395 if (grid->getSupportUrl() != "") childSetText("support", grid->getSupportUrl());
396 if (grid->getRegisterUrl() != "") childSetText("register", grid->getRegisterUrl());
397 if (grid->getPasswordUrl() != "") childSetText("password", grid->getPasswordUrl());
398 //if (grid->getSearchUrl() != "") childSetText("search", grid->getSearchUrl());
399 } else {
400 //KOW gViewerWindow->alertXml("GridInfoError");
401 }
402
403 if (cleanupGrid) delete grid;
404}
405
391void LoginFloater::apply() 406void LoginFloater::apply()
392{ 407{
393 if (mState == NORMAL) { 408 if (mState == NORMAL) {
@@ -417,8 +432,6 @@ void LoginFloater::setDefault()
417 } 432 }
418 gHippoGridManager->setCurrentGrid(mCurGrid); 433 gHippoGridManager->setCurrentGrid(mCurGrid);
419 gHippoGridManager->setDefaultGrid(mCurGrid); 434 gHippoGridManager->setDefaultGrid(mCurGrid);
420 llwarns << "I think me grid is " << mCurGrid << llendl;
421 //LLPanelLogin::refreshLoginPage();
422 gHippoGridManager->saveFile(); 435 gHippoGridManager->saveFile();
423 LLPanelLogin::addServer(LLViewerLogin::getInstance()->getGridLabel()); 436 LLPanelLogin::addServer(LLViewerLogin::getInstance()->getGridLabel());
424} 437}
@@ -426,7 +439,6 @@ void LoginFloater::setDefault()
426void LoginFloater::cancel() 439void LoginFloater::cancel()
427{ 440{
428 gHippoGridManager->discardAndReload(); 441 gHippoGridManager->discardAndReload();
429 LoginFloater::sModel->revert();
430 update(); 442 update();
431} 443}
432 444
@@ -439,14 +451,8 @@ void LoginFloater::onSelectGrid(LLUICtrl* ctrl, void *data)
439 if (self->createNewGrid()) { 451 if (self->createNewGrid()) {
440 self->mState = NORMAL; 452 self->mState = NORMAL;
441 } else { 453 } else {
442 //LLCtrlListInterface *grids = self->childGetListInterface("search_results"); 454 //LLScrollListCtrl *grids = self->getChild<LLScrollListCtrl>("grid_selector");
443 //if (!grids) return; 455 //grids->setCurrentByIndex(grids->getItemCount() - 1);
444
445 //LLSD selected_value = grids->getSelectedValue();
446 //std::string sim_name = selected_value.asString();
447
448 LLComboBox *grids = self->getChild<LLComboBox>("grid_selector");
449 grids->setCurrentByIndex(grids->getItemCount() - 1);
450 return; 456 return;
451 } 457 }
452 } else { 458 } else {
@@ -454,8 +460,6 @@ void LoginFloater::onSelectGrid(LLUICtrl* ctrl, void *data)
454 return; 460 return;
455 } 461 }
456 self->mCurGrid = ctrl->getValue().asString(); 462 self->mCurGrid = ctrl->getValue().asString();
457 llwarns << "I think me grid is " << self->mCurGrid << llendl;
458
459 self->refresh_grids(); 463 self->refresh_grids();
460} 464}
461 465
@@ -488,16 +492,38 @@ void LoginFloater::onClickCopy(void *data)
488 self->refresh_grids(); 492 self->refresh_grids();
489} 493}
490 494
495// static
496void LoginFloater::onClickOk(void* data)
497{
498 if(NULL==sInstance)
499 return;
500
501 sInstance->apply();
502 sInstance->close();
503}
504
491//static 505//static
492void LoginFloater::onClickApply(void *data) 506void LoginFloater::onClickApply(void *data)
493{ 507{
508 if(NULL==sInstance)
509 return;
510
494 sInstance->apply(); 511 sInstance->apply();
512 refresh_grids();
495} 513}
496 514
497//static 515//static
498void LoginFloater::onClickDefault(void *data) 516void LoginFloater::onClickDefault(void *data)
499{ 517{
500 sInstance->setDefault(); 518 sInstance->setDefault();
519 sInstance->refresh_grids();
520}
521
522//static
523void LoginFloater::onClickGridInfo(void *data)
524{
525 //HippoPanelGrids* self = (HippoPanelGrids*)data;
526 sInstance->retrieveGridInfo();
501} 527}
502 528
503//static 529//static
@@ -542,64 +568,28 @@ void LoginFloater::refreshLocation( bool force_visible )
542 sInstance->childSetVisible("server_combo", TRUE); 568 sInstance->childSetVisible("server_combo", TRUE);
543} 569}
544 570
545void LoginFloater::newShow(const std::string &grid, bool initialLogin, 571void LoginFloater::newShow(const std::string &grid, bool initialLogin)
546 void (*callback)(S32 option, void* user_data),
547 void* callback_data)
548{ 572{
549 573
550 llwarns << "newShow called" << llendl; 574 llwarns << "newShow called" << llendl;
551 if(NULL==sInstance) 575 if(NULL==sInstance)
552 { 576 {
553 LoginFloater::sGrid = grid; 577 LoginFloater::sGrid = grid;
554 LoginFloater::sIsInitialLogin = initialLogin; 578 LoginFloater::sIsInitialLogin = initialLogin;
555 sInstance = new LoginFloater(callback, callback_data); 579 sInstance = new LoginFloater();
556 580
557 llwarns << "sInstance assigned. sInstance=" << sInstance << llendl; 581 llwarns << "sInstance assigned. sInstance=" << sInstance << llendl;
558 } 582 }
559
560 // floater controller requires initialized floater and model
561 if(NULL==sModel)
562 sModel = AuthenticationModel::getInstance();
563 if(NULL==sController)
564 //sController = new LoginController(sInstance, sModel, sGrid);
565
566
567
568 llwarns << "newshow called" << llendl;
569 sInstance->mCurGrid = gHippoGridManager->getCurrentGridNick();
570 refresh_grids();
571 583
572 // we're important 584 llwarns << "newshow called" << llendl;
573 sInstance->setFrontmost(TRUE); 585 sInstance->mCurGrid = gHippoGridManager->getCurrentGridNick();
574 sInstance->setFocus(TRUE); 586 refresh_grids();
575
576}
577 587
578void LoginFloater::testShow(void *lies) 588 sInstance->open(); /*Flawfinder: ignore*/
579{ 589 // we're important
580 // this is if we want to call LoginFloater from a menu option 590 //sInstance->setFrontmost(TRUE);
581 // or you know whatever 591 //sInstance->setFocus(TRUE);
582 newShow(std::string("Test"), false, testCallback, NULL);
583}
584 592
585void LoginFloater::testCallback(S32 option, void *user_data)
586{
587 // test callback, referenced by testShow()
588 if(LOGIN_OPTION_CONNECT == option)
589 {
590 llinfos << "this is how we connect to a METAVERSE" << llendl;
591 std::string first, last, password;
592 BOOL remember = TRUE;
593 getFields(first, last, password, remember);
594 llinfos << "first\t\tlast\t\tpassword" << llendl;
595 llinfos << first << "\t\t" << last << "\t\t" << password << llendl;
596 }
597 else if(LOGIN_OPTION_QUIT == option)
598 {
599 llinfos << "my login, she die" << llendl;
600 llinfos << ":(" << llendl;
601 close();
602 }
603} 593}
604 594
605void LoginFloater::show(const LLRect &rect, BOOL show_server, 595void LoginFloater::show(const LLRect &rect, BOOL show_server,
@@ -608,7 +598,7 @@ void LoginFloater::show(const LLRect &rect, BOOL show_server,
608{ 598{
609 // we don't need a grid passed in because this is old-style login 599 // we don't need a grid passed in because this is old-style login
610 std::string grid = ""; 600 std::string grid = "";
611 newShow(grid, TRUE, callback, callback_data); 601 newShow(grid, TRUE);
612} 602}
613 603
614void LoginFloater::setFocus(BOOL b) 604void LoginFloater::setFocus(BOOL b)
@@ -628,7 +618,7 @@ void LoginFloater::setFocus(BOOL b)
628 618
629void LoginFloater::giveFocus() 619void LoginFloater::giveFocus()
630{ 620{
631 LLComboBox *combo = NULL; 621 LLScrollListCtrl *combo = NULL;
632 622
633 if(NULL==sInstance) 623 if(NULL==sInstance)
634 { 624 {
@@ -638,91 +628,10 @@ void LoginFloater::giveFocus()
638 628
639 // for our combo box approach, selecting the combo box is almost always 629 // for our combo box approach, selecting the combo box is almost always
640 // the right thing to do on the floater receiving focus 630 // the right thing to do on the floater receiving focus
641 combo = sInstance->getChild<LLComboBox>("name_combo"); 631 combo = sInstance->getChild<LLScrollListCtrl>("grid_selector");
642 combo->setFocus(TRUE); 632 combo->setFocus(TRUE);
643} 633}
644 634
645void LoginFloater::getFields(std::string &firstname, std::string &lastname, std::string &password,
646 BOOL &remember)
647{
648 if (!sInstance)
649 {
650 llwarns << "Attempted getFields with no login view shown" << llendl;
651 return;
652 }
653
654 std::string loginname = sInstance->childGetText("name_combo");
655
656 LLStringUtil::replaceTabsWithSpaces(loginname, 1);
657 LLStringUtil::trim(loginname);
658 std::vector<std::string> loginVec;
659 boost::split(loginVec, loginname, boost::is_any_of(" "), boost::token_compress_on);
660 if(loginVec.size() == 2)
661 {
662 firstname = loginVec[0];
663 lastname = loginVec[1];
664 }
665
666 password = sInstance->mMungedPassword;
667 remember = sInstance->childGetValue("remember_check");
668}
669
670void LoginFloater::getFields(std::string &loginname, std::string &password, BOOL &remember)
671{
672 std::string first, last, pass;
673 BOOL rem;
674 getFields(first, last, pass, rem);
675 loginname = first + " " + last;
676 password = pass;
677 remember = rem;
678}
679
680void LoginFloater::setFields(const std::string& firstname, const std::string& lastname, const std::string& password,
681 BOOL remember)
682{
683 if (!sInstance)
684 {
685 llwarns << "Attempted setFields with no login view shown" << llendl;
686 return;
687 }
688
689 std::string loginname = firstname + " " + lastname;
690 sInstance->childSetText("name_combo", loginname);
691
692 // Max "actual" password length is 16 characters.
693 // Hex digests are always 32 characters.
694 if (password.length() == 32)
695 {
696 // This is a MD5 hex digest of a password.
697 // We don't actually use the password input field,
698 // fill it with MAX_PASSWORD characters so we get a
699 // nice row of asterixes.
700 const std::string filler("123456789!123456");
701 sInstance->childSetText("password_edit", filler);
702 sInstance->mIncomingPassword = filler;
703 sInstance->mMungedPassword = password;
704 }
705 else
706 {
707 // this is a normal text password
708 sInstance->childSetText("password_edit", password);
709 sInstance->mIncomingPassword = password;
710 LLMD5 pass((unsigned char *)password.c_str());
711 char munged_password[MD5HEX_STR_SIZE];
712 pass.hex_digest(munged_password);
713 sInstance->mMungedPassword = munged_password;
714 }
715
716 sInstance->childSetValue("remember_check", remember);
717}
718
719void LoginFloater::setFields(const std::string &loginname, const std::string &password, BOOL remember)
720{
721 std::vector<std::string> loginVec;
722 boost::split(loginVec, loginname, boost::is_any_of(" "), boost::token_compress_on);
723 setFields(loginVec[0], loginVec[1], password, remember);
724}
725
726BOOL LoginFloater::isGridComboDirty() 635BOOL LoginFloater::isGridComboDirty()
727{ 636{
728 BOOL user_picked = FALSE; 637 BOOL user_picked = FALSE;
@@ -778,25 +687,6 @@ void LoginFloater::addServer(const std::string& server, S32 domain_name)
778 combo->setCurrentByIndex(0); 687 combo->setCurrentByIndex(0);
779} 688}
780 689
781void LoginFloater::accept()
782{
783 if(NULL==sInstance || NULL==sInstance->mCallback)
784 return;
785
786 sInstance->setFocus(FALSE);
787
788 std::string name_combo = sInstance->childGetText("name_combo");
789 if(!name_combo.empty())
790 {
791 sInstance->mCallback(LOGIN_OPTION_CONNECT, sInstance->mCallbackData);
792 }
793 else
794 {
795 // TODO: new account call goes here
796 return;
797 }
798}
799
800void LoginFloater::cancel_old() 690void LoginFloater::cancel_old()
801{ 691{
802 if(NULL==sInstance) 692 if(NULL==sInstance)