aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra
diff options
context:
space:
mode:
authorMcCabe Maxsted2010-07-03 20:22:30 -0700
committerMcCabe Maxsted2010-07-03 20:23:08 -0700
commita72ab74505d12a341edb4c2fa19d8f071b4277f9 (patch)
tree6ddfbbf173bd15ea7d07dd1cab17b6082f84a172 /linden/indra
parentFixed floater_login.xml missing from CMakeLists.txt (diff)
downloadmeta-impy-a72ab74505d12a341edb4c2fa19d8f071b4277f9.zip
meta-impy-a72ab74505d12a341edb4c2fa19d8f071b4277f9.tar.gz
meta-impy-a72ab74505d12a341edb4c2fa19d8f071b4277f9.tar.bz2
meta-impy-a72ab74505d12a341edb4c2fa19d8f071b4277f9.tar.xz
Basic cleanup of the grid manager code
Diffstat (limited to '')
-rw-r--r--linden/indra/newview/CMakeLists.txt6
-rw-r--r--linden/indra/newview/floatergridmanager.cpp750
-rw-r--r--linden/indra/newview/floatergridmanager.h93
-rw-r--r--linden/indra/newview/floaterlogin.cpp722
-rw-r--r--linden/indra/newview/floaterlogin.h90
-rw-r--r--linden/indra/newview/llpanellogin.cpp6
-rw-r--r--linden/indra/newview/skins/default/xui/en-us/floater_grid_manager.xml (renamed from linden/indra/newview/skins/default/xui/en-us/floater_login.xml)19
7 files changed, 860 insertions, 826 deletions
diff --git a/linden/indra/newview/CMakeLists.txt b/linden/indra/newview/CMakeLists.txt
index 2b4395d..ab0159f 100644
--- a/linden/indra/newview/CMakeLists.txt
+++ b/linden/indra/newview/CMakeLists.txt
@@ -69,7 +69,7 @@ set(viewer_SOURCE_FILES
69 emeraldboobutils.cpp 69 emeraldboobutils.cpp
70 floaterao.cpp 70 floaterao.cpp
71 floaterbusy.cpp 71 floaterbusy.cpp
72 floaterlogin.cpp 72 floatergridmanager.cpp
73 hbfloatergrouptitles.cpp 73 hbfloatergrouptitles.cpp
74 hippoGridManager.cpp 74 hippoGridManager.cpp
75 hippoLimits.cpp 75 hippoLimits.cpp
@@ -498,7 +498,7 @@ set(viewer_HEADER_FILES
498 emeraldboobutils.h 498 emeraldboobutils.h
499 floaterao.h 499 floaterao.h
500 floaterbusy.h 500 floaterbusy.h
501 floaterlogin.h 501 floatergridmanager.h
502 hbfloatergrouptitles.h 502 hbfloatergrouptitles.h
503 hippoGridManager.h 503 hippoGridManager.h
504 hippoLimits.h 504 hippoLimits.h
@@ -1125,6 +1125,7 @@ set(viewer_XUI_FILES
1125 skins/default/xui/en-us/floater_font_test.xml 1125 skins/default/xui/en-us/floater_font_test.xml
1126 skins/default/xui/en-us/floater_gesture.xml 1126 skins/default/xui/en-us/floater_gesture.xml
1127 skins/default/xui/en-us/floater_god_tools.xml 1127 skins/default/xui/en-us/floater_god_tools.xml
1128 skins/default/xui/en-us/floater_grid_manager.xml
1128 skins/default/xui/en-us/floater_group_info.xml 1129 skins/default/xui/en-us/floater_group_info.xml
1129 skins/default/xui/en-us/floater_group_titles.xml 1130 skins/default/xui/en-us/floater_group_titles.xml
1130 skins/default/xui/en-us/floater_hardware_settings.xml 1131 skins/default/xui/en-us/floater_hardware_settings.xml
@@ -1145,7 +1146,6 @@ set(viewer_XUI_FILES
1145 skins/default/xui/en-us/floater_land_holdings.xml 1146 skins/default/xui/en-us/floater_land_holdings.xml
1146 skins/default/xui/en-us/floater_landmark_ctrl.xml 1147 skins/default/xui/en-us/floater_landmark_ctrl.xml
1147 skins/default/xui/en-us/floater_live_lsleditor.xml 1148 skins/default/xui/en-us/floater_live_lsleditor.xml
1148 skins/default/xui/en-us/floater_login.xml
1149 skins/default/xui/en-us/floater_lsl_guide.xml 1149 skins/default/xui/en-us/floater_lsl_guide.xml
1150 skins/default/xui/en-us/floater_media_browser.xml 1150 skins/default/xui/en-us/floater_media_browser.xml
1151 skins/default/xui/en-us/floater_mini_map.xml 1151 skins/default/xui/en-us/floater_mini_map.xml
diff --git a/linden/indra/newview/floatergridmanager.cpp b/linden/indra/newview/floatergridmanager.cpp
new file mode 100644
index 0000000..efd02ca
--- /dev/null
+++ b/linden/indra/newview/floatergridmanager.cpp
@@ -0,0 +1,750 @@
1/*
2 * floatergridmanager.cpp
3 * This is Meerkats grid manager.
4 * -Patrick Sapinski (Monday, August 17, 2009)
5 *
6 * Modified by McCabe Maxsted for Imprudence
7 */
8
9#include "llviewerprecompiledheaders.h"
10
11#include "floatergridmanager.h"
12
13#include <boost/algorithm/string.hpp>
14#include "llviewercontrol.h"
15#include "llcombobox.h"
16#include "llscrolllistctrl.h"
17#include "llmd5.h"
18#include "llurlsimstring.h"
19#include "lluictrlfactory.h"
20#include "hippoGridManager.h"
21#include "llviewernetwork.h"
22#include "llpanellogin.h"
23
24#define PASSWORD_FILLER "123456789!123456"
25
26LoginController* FloaterGridManager::sController = NULL;
27bool FloaterGridManager::sIsInitialLogin;
28std::string FloaterGridManager::sGrid;
29
30FloaterGridManager::FloaterGridManager(const LLSD& key)
31: mState(NORMAL),
32 mCurGrid(gHippoGridManager->getCurrentGridNick()),
33 mIncomingPassword(""),
34 mMungedPassword("")
35{
36 llinfos << "Opening grid manager" << llendl;
37
38 LLUICtrlFactory::getInstance()->buildFloater(this, "floater_grid_manager.xml");
39 center();
40
41 LLLineEditor* edit = getChild<LLLineEditor>("avatar_password_edit");
42 if (edit)
43 {
44 edit->setDrawAsterixes(TRUE);
45 }
46}
47
48
49FloaterGridManager::~FloaterGridManager()
50{
51 FloaterGridManager::sController = NULL;
52}
53
54BOOL FloaterGridManager::postBuild()
55{
56 /*requires<LLScrollListCtrl>("grid_selector");
57 requires<LLLineEditor>("gridnick");
58 requires<LLLineEditor>("gridname");
59 requires<LLLineEditor>("loginuri");
60 requires<LLLineEditor>("loginpage");
61 requires<LLLineEditor>("helperuri");
62 requires<LLLineEditor>("website");
63 requires<LLLineEditor>("support");
64 requires<LLLineEditor>("register");
65 requires<LLLineEditor>("password");
66 requires<LLLineEditor>("first_name");
67 requires<LLLineEditor>("last_name");
68 requires<LLLineEditor>("avatar_password");
69 //requires<LLLineEditor>("search");
70 requires<LLButton>("btn_delete");
71 requires<LLButton>("btn_add");
72 requires<LLButton>("btn_copy");
73 requires<LLButton>("set_default");
74 requires<LLButton>("btn_gridinfo");*/
75 //requires<LLButton>("btn_help_render_compat");
76
77 /*if (!checkRequirements())
78 {
79 return false;
80 }*/
81
82 LLLineEditor* password_edit = getChild<LLLineEditor>("avatar_password");
83 if (password_edit)
84 {
85 password_edit->setDrawAsterixes(TRUE);
86 }
87
88 childSetAction("btn_delete", onClickDelete, this);
89 childSetAction("btn_add", onClickAdd, this);
90 childSetAction("btn_copy", onClickCopy, this);
91 childSetAction("btn_ok", onClickOk, this);
92 childSetAction("btn_apply", onClickApply, this);
93 // childSetAction("set_default", onClickDefault, this); // We use the last selected grid as the default
94 childSetAction("btn_cancel", onClickCancel, this);
95 childSetAction("btn_clear", onClickClear, this);
96 childSetAction("btn_gridinfo", onClickGridInfo, this);
97 // childSetAction("btn_help_render_compat", onClickHelpRenderCompat, this); // Ugly ugly ugly
98
99 childSetCommitCallback("grid_selector", onSelectGrid, this);
100 LLScrollListCtrl* combo = getChild<LLScrollListCtrl>("grid_selector");
101 combo->setFocus(TRUE);
102
103 refreshGrids();
104
105 return TRUE;
106}
107
108void FloaterGridManager::refreshGrids()
109{
110 const std::string &defaultGrid = gHippoGridManager->getDefaultGridNick();
111 LLScrollListCtrl *grids = FloaterGridManager::getInstance()->getChild<LLScrollListCtrl>("grid_selector");
112 grids->deleteAllItems();
113
114 S32 selectIndex = -1;
115 S32 i = 0;
116 if (defaultGrid != "")
117 {
118 LLSD value;
119 value["id"] = defaultGrid;
120 value["columns"][0]["column"] = "grid";
121 value["columns"][0]["value"] = defaultGrid;
122 grids->addElement(value);
123 selectIndex = i++;
124 }
125
126 HippoGridManager::GridIterator it = gHippoGridManager->beginGrid();
127 HippoGridManager::GridIterator end = gHippoGridManager->endGrid();
128 for (it; it != end; ++it)
129 {
130 const std::string &grid = it->second->getGridNick();
131 if (grid != defaultGrid)
132 {
133 LLSD value;
134 value["id"] = grid;
135 value["columns"][0]["column"] = "grid";
136 value["columns"][0]["value"] = grid;
137 grids->addElement(value);
138
139 if (grid == FloaterGridManager::getInstance()->getCurGrid())
140 {
141 selectIndex = i;
142 }
143 i++;
144 }
145 }
146
147 if ((FloaterGridManager::getInstance()->getState() == ADD_NEW) || (FloaterGridManager::getInstance()->getState() == ADD_COPY))
148 {
149 grids->addElement("<new>");
150 selectIndex = i++;
151 }
152
153 //if (selectIndex >= 0)
154 //{
155 // grids->setCurrentByIndex(selectIndex);
156 //}
157 //else
158 //{
159 // grids->setLabel(LLStringExplicit("")); // LLComboBox::removeall() does not clear the label
160 //}
161
162 // FloaterGridManager::getInstance()->childSetTextArg("default_grid", "[DEFAULT]", (defaultGrid != "")? defaultGrid: " ");
163
164 FloaterGridManager::getInstance()->childSetEnabled("btn_delete", (selectIndex >= 0));
165 FloaterGridManager::getInstance()->childSetEnabled("btn_copy", (FloaterGridManager::getInstance()->getState() == NORMAL) && (selectIndex >= 0));
166 // FloaterGridManager::getInstance()->childSetEnabled("set_default", (FloaterGridManager::getInstance()->getState() == NORMAL) && (selectIndex > 0));
167 FloaterGridManager::getInstance()->childSetEnabled("gridnick", (FloaterGridManager::getInstance()->getState() == ADD_NEW) || (FloaterGridManager::getInstance()->getState() == ADD_COPY));
168
169 if (FloaterGridManager::getInstance()->getState() == NORMAL)
170 {
171 HippoGridInfo *gridInfo = gHippoGridManager->getGrid(FloaterGridManager::getInstance()->getCurGrid());
172 if (gridInfo)
173 {
174 FloaterGridManager::getInstance()->childSetText("gridnick", gridInfo->getGridNick());
175 //FloaterGridManager::getInstance()->childSetText("grid_name", gridInfo->getGridName());
176 FloaterGridManager::getInstance()->childSetText("loginuri", gridInfo->getLoginUri());
177 FloaterGridManager::getInstance()->childSetText("loginpage", gridInfo->getLoginPage());
178 FloaterGridManager::getInstance()->childSetText("helperuri", gridInfo->getHelperUri());
179 FloaterGridManager::getInstance()->childSetText("website", gridInfo->getWebSite());
180 FloaterGridManager::getInstance()->childSetText("support", gridInfo->getSupportUrl());
181 FloaterGridManager::getInstance()->childSetText("register", gridInfo->getRegisterUrl());
182 FloaterGridManager::getInstance()->childSetText("password", gridInfo->getPasswordUrl());
183
184 // FloaterGridManager::getInstance()->childSetText("first_name", gridInfo->getFirstName());
185 // FloaterGridManager::getInstance()->childSetText("last_name", gridInfo->getLastName());
186 // if(gridInfo->getAvatarPassword().length() == 32)
187 // FloaterGridManager::getInstance()->childSetText("avatar_password", std::string(PASSWORD_FILLER));
188 // else if(gridInfo->getPasswordUrl().empty())
189 // FloaterGridManager::getInstance()->childSetText("avatar_password", std::string(""));
190
191 // if (gridInfo->getPlatform() == HippoGridInfo::PLATFORM_SECONDLIFE) {
192 // //childSetEnabled("search", false);
193 // //childSetText("search", LLStringExplicit(""));
194 // childSetEnabled("render_compat", false);
195 // childSetValue("render_compat", false);
196 // } else {
197 // //childSetEnabled("search", true);
198 // //childSetText("search", gridInfo->getSearchUrl());
199 // childSetEnabled("render_compat", true);
200 // childSetValue("render_compat", gridInfo->isRenderCompat());
201 // }
202
203 }
204 else
205 {
206 std::string empty = "";
207 FloaterGridManager::getInstance()->childSetText("gridnick", empty);
208 FloaterGridManager::getInstance()->childSetText("gridname", empty);
209 FloaterGridManager::getInstance()->childSetText("loginuri", empty);
210 FloaterGridManager::getInstance()->childSetText("loginpage", empty);
211 FloaterGridManager::getInstance()->childSetText("helperuri", empty);
212 FloaterGridManager::getInstance()->childSetText("website", empty);
213 // FloaterGridManager::getInstance()->childSetText("first_name", empty);
214 // FloaterGridManager::getInstance()->childSetText("last_name", empty);
215 // FloaterGridManager::getInstance()->childSetText("avatar_password", empty);
216 }
217 }
218 else if (FloaterGridManager::getInstance()->getState() == ADD_NEW)
219 {
220 llinfos << "mState == ADD_NEW" << llendl;
221 std::string required = "<required>";
222 std::string empty = "";
223 FloaterGridManager::getInstance()->childSetText("gridnick", required);
224 FloaterGridManager::getInstance()->childSetText("gridname", empty);
225 FloaterGridManager::getInstance()->childSetText("loginuri", required);
226 FloaterGridManager::getInstance()->childSetText("loginpage", empty);
227 FloaterGridManager::getInstance()->childSetText("helperuri", empty);
228 FloaterGridManager::getInstance()->childSetText("website", empty);
229 FloaterGridManager::getInstance()->childSetText("support", empty);
230 FloaterGridManager::getInstance()->childSetText("register", empty);
231 FloaterGridManager::getInstance()->childSetText("password", empty);
232 // FloaterGridManager::getInstance()->childSetText("first_name", empty);
233 // FloaterGridManager::getInstance()->childSetText("last_name", empty);
234 // FloaterGridManager::getInstance()->childSetText("avatar_password", empty);
235 //childSetEnabled("search", true);
236 //childSetText("search", empty);
237 }
238 else if (FloaterGridManager::getInstance()->getState() == ADD_COPY)
239 {
240 llinfos << "mState == ADD_COPY" << llendl;
241 FloaterGridManager::getInstance()->childSetText("gridnick", LLStringExplicit("<required>"));
242 }
243 else
244 {
245 llwarns << "Illegal state " << FloaterGridManager::getInstance()->getState() << llendl;
246 }
247 return;
248}
249
250void FloaterGridManager::update()
251{
252 setState(NORMAL);
253 setCurGrid(gHippoGridManager->getCurrentGridNick());
254 refreshGrids();
255 //KOW gHippoLimits->setLimits();
256}
257
258void FloaterGridManager::applyChanges()
259{
260 HippoGridInfo* gridInfo = gHippoGridManager->getGrid(mCurGrid);
261 if (gridInfo)
262 {
263 if (gridInfo->getGridNick() == childGetValue("gridnick").asString())
264 {
265 gridInfo->setGridName(childGetValue("gridname"));
266 gridInfo->setLoginUri(childGetValue("loginuri"));
267 gridInfo->setLoginPage(childGetValue("loginpage"));
268 gridInfo->setHelperUri(childGetValue("helperuri"));
269 gridInfo->setWebSite(childGetValue("website"));
270 gridInfo->setSupportUrl(childGetValue("support"));
271 gridInfo->setRegisterUrl(childGetValue("register"));
272 gridInfo->setPasswordUrl(childGetValue("password"));
273 //gridInfo->setSearchUrl(childGetValue("search"));
274 gridInfo->setRenderCompat(childGetValue("render_compat"));
275
276 // gridInfo->setFirstName(childGetValue("first_name"));
277 // gridInfo->setLastName(childGetValue("last_name"));
278 // if(childGetValue("avatar_password").asString().empty())
279 // gridInfo->setAvatarPassword(std::string(""));
280 // else if(childGetValue("avatar_password").asString() != std::string(PASSWORD_FILLER))
281 // {
282 // // store account authentication data
283 // std::string auth_password = childGetValue("avatar_password");
284 // std::string hashed_password;
285 // hashPassword(auth_password, hashed_password);
286 // gridInfo->setAvatarPassword(hashed_password);
287 // }
288
289 //this bug was a feature -Patrick Sapinski (Friday, August 21, 2009)
290 //LLPanelLogin::setFields(gridInfo->getFirstName(), gridInfo->getLastName(),
291 // gridInfo->getAvatarPassword(), true);
292 }
293 else
294 {
295 llwarns << "Grid nickname mismatch, ignoring changes." << llendl;
296 }
297 }
298}
299
300
301bool FloaterGridManager::createNewGrid()
302{
303 // check nickname
304 std::string gridnick = childGetValue("gridnick");
305 if (gridnick == "<required>")
306 {
307 gridnick = "";
308 }
309
310 if (gridnick.empty())
311 {
312 //KOW gViewerWindow->alertXml("GridsNoNick");
313 return false;
314 }
315
316 if (gHippoGridManager->getGrid(gridnick))
317 {
318 //LLStringUtil::format_map_t args;
319 //args["[NAME]"] = gridnick;
320 //KOW gViewerWindow->alertXml("GridExists", args);
321 return false;
322 }
323
324 // check login URI
325 std::string loginuri = childGetValue("loginuri");
326 if ((loginuri.empty()) || (loginuri == "<required>"))
327 {
328 //LLStringUtil::format_map_t args;
329 //args["[NAME]"] = gridnick;
330 //KOW gViewerWindow->alertXml("GridsNoLoginUri", args);
331 return false;
332 }
333
334 // create new grid
335 HippoGridInfo* grid = new HippoGridInfo(gridnick);
336 grid->setGridName(childGetValue("gridname"));
337 grid->setLoginUri(loginuri);
338 grid->setLoginPage(childGetValue("loginpage"));
339 grid->setHelperUri(childGetValue("helperuri"));
340 grid->setWebSite(childGetValue("website"));
341 grid->setSupportUrl(childGetValue("support"));
342 grid->setRegisterUrl(childGetValue("register"));
343 grid->setPasswordUrl(childGetValue("password"));
344 //grid->setSearchUrl(childGetValue("search"));
345 grid->setRenderCompat(childGetValue("render_compat"));
346 gHippoGridManager->addGrid(grid);
347
348 // grid->setFirstName(childGetValue("first_name"));
349 // grid->setLastName(childGetValue("last_name"));
350 // if(childGetValue("avatar_password").asString().empty())
351 // grid->setAvatarPassword(std::string(""));
352 // else
353 // {
354 // std::string hashed_password;
355 // hashPassword(childGetValue("avatar_password"), hashed_password);
356 // grid->setAvatarPassword(hashed_password);
357 // }
358
359 setCurGrid(gridnick);
360 return true;
361}
362
363void FloaterGridManager::retrieveGridInfo()
364{
365 std::string loginuri = childGetValue("loginuri");
366 if ((loginuri == "") || (loginuri == "<required>"))
367 {
368 //KOW gViewerWindow->alertXml("GridInfoNoLoginUri");
369 return;
370 }
371
372 HippoGridInfo* grid = 0;
373 bool cleanupGrid = false;
374
375 if (mState == NORMAL)
376 {
377 grid = gHippoGridManager->getGrid(mCurGrid);
378 }
379 else if ((mState == ADD_NEW) || (mState == ADD_COPY))
380 {
381 grid = new HippoGridInfo("");
382 cleanupGrid = true;
383 }
384 else
385 {
386 llerrs << "Illegal state " << mState << '.' << llendl;
387 return;
388 }
389 if (!grid)
390 {
391 llerrs << "Internal error retrieving grid info." << llendl;
392 return;
393 }
394
395 grid->setLoginUri(loginuri);
396 if (grid->retrieveGridInfo())
397 {
398 if (grid->getGridNick() != "") childSetText("gridnick", grid->getGridNick());
399 if (grid->getGridName() != "") childSetText("gridname", grid->getGridName());
400 if (grid->getLoginUri() != "") childSetText("loginuri", grid->getLoginUri());
401 if (grid->getLoginPage() != "") childSetText("loginpage", grid->getLoginPage());
402 if (grid->getHelperUri() != "") childSetText("helperuri", grid->getHelperUri());
403 if (grid->getWebSite() != "") childSetText("website", grid->getWebSite());
404 if (grid->getSupportUrl() != "") childSetText("support", grid->getSupportUrl());
405 if (grid->getRegisterUrl() != "") childSetText("register", grid->getRegisterUrl());
406 if (grid->getPasswordUrl() != "") childSetText("password", grid->getPasswordUrl());
407 //if (grid->getSearchUrl() != "") childSetText("search", grid->getSearchUrl());
408 }
409 else
410 {
411 //KOW gViewerWindow->alertXml("GridInfoError");
412 }
413
414 if (cleanupGrid) delete grid;
415}
416
417void FloaterGridManager::apply()
418{
419 if (mState == NORMAL)
420 {
421 applyChanges();
422 }
423 else if ((mState == ADD_NEW) || (mState == ADD_COPY))
424 {
425 if (!createNewGrid()) return;
426 }
427 else
428 {
429 llwarns << "Illegal state " << mState << '.' << llendl;
430 return;
431 }
432 //gHippoGridManager->setCurrentGrid(mCurGrid);
433 //gHippoGridManager->setDefaultGrid(mCurGrid);
434 gHippoGridManager->saveFile();
435 LLPanelLogin::addServer(LLViewerLogin::getInstance()->getGridLabel());
436}
437
438//void FloaterGridManager::setDefault()
439//{
440// if (mState == NORMAL)
441// {
442// applyChanges();
443// }
444// else if ((mState == ADD_NEW) || (mState == ADD_COPY))
445// {
446// if (!createNewGrid()) return;
447// }
448// else
449// {
450// llwarns << "Illegal state " << mState << '.' << llendl;
451// return;
452// }
453// gHippoGridManager->setCurrentGrid(mCurGrid);
454// gHippoGridManager->setDefaultGrid(mCurGrid);
455// gHippoGridManager->saveFile();
456// LLPanelLogin::addServer(LLViewerLogin::getInstance()->getGridLabel());
457//}
458
459void FloaterGridManager::onSelectGrid(LLUICtrl* ctrl, void* data)
460{
461 FloaterGridManager* self = (FloaterGridManager*)data;
462 if (self->getState() == NORMAL)
463 {
464 self->applyChanges();
465 }
466 else if ((self->getState() == ADD_NEW) || (self->getState() == ADD_COPY))
467 {
468 if (self->createNewGrid())
469 {
470 self->setState(NORMAL);
471 }
472 else
473 {
474 //LLScrollListCtrl *grids = self->getChild<LLScrollListCtrl>("grid_selector");
475 //grids->setCurrentByIndex(grids->getItemCount() - 1);
476 return;
477 }
478 }
479 else
480 {
481 llwarns << "Illegal state " << self->getState() << llendl;
482 return;
483 }
484 self->setCurGrid(ctrl->getValue().asString());
485 self->refreshGrids();
486}
487
488//static
489void FloaterGridManager::onClickDelete(void* data)
490{
491 //llinfos << "onClickDelete" << llendl;
492 FloaterGridManager* self = (FloaterGridManager*)data;
493 if (self->getState() == NORMAL)
494 {
495 gHippoGridManager->deleteGrid(self->getCurGrid());
496 }
497 self->update();
498}
499
500//static
501void FloaterGridManager::onClickAdd(void* data)
502{
503 //llinfos << "onClickAdd" << llendl;
504 FloaterGridManager* self = (FloaterGridManager*)data;
505 self->setState(ADD_NEW);
506 self->refreshGrids();
507}
508
509
510//static
511void FloaterGridManager::onClickCopy(void* data)
512{
513 //llinfos << "onClickCopy" << llendl;
514 FloaterGridManager* self = (FloaterGridManager*)data;
515 self->setState(ADD_COPY);
516 self->refreshGrids();
517}
518
519// static
520void FloaterGridManager::onClickOk(void* data)
521{
522 FloaterGridManager::getInstance()->apply();
523 FloaterGridManager::getInstance()->close();
524}
525
526//static
527void FloaterGridManager::onClickApply(void* data)
528{
529 FloaterGridManager::getInstance()->apply();
530 refreshGrids();
531}
532
533// static
534void FloaterGridManager::onClickClear(void* data)
535{
536 gHippoGridManager->discardAndReload();
537 FloaterGridManager::getInstance()->update();
538}
539
540//static
541//void FloaterGridManager::onClickDefault(void* data)
542//{
543// FloaterGridManager::getInstance()->setDefault();
544// FloaterGridManager::getInstance()->refreshGrids();
545//}
546
547//static
548void FloaterGridManager::onClickGridInfo(void* data)
549{
550 //HippoPanelGrids* self = (HippoPanelGrids*)data;
551 FloaterGridManager::getInstance()->retrieveGridInfo();
552}
553
554//static
555void FloaterGridManager::onClickCancel(void* data)
556{
557 FloaterGridManager::getInstance()->close();
558}
559
560//void FloaterGridManager::setAlwaysRefresh(bool refresh)
561//{
562// // wargames 2: dead code, LLPanelLogin compatibility
563// return;
564//}
565
566//void FloaterGridManager::refreshLocation( bool force_visible )
567//{
568// llinfos << "refreshLocation called" << llendl;
569//
570// if (!FloaterGridManager::getInstance())
571// {
572// return;
573// }
574
575 //LLComboBox* combo = FloaterGridManager::getInstance()->getChild<LLComboBox>("start_location_combo");
576 //
577 //if (LLURLSimString::parse())
578 //{
579 // combo->setCurrentByIndex( 3 ); // BUG? Maybe 2?
580 // combo->setTextEntry(LLURLSimString::FloaterGridManager::getInstance().mSimString);
581 //}
582 //else
583 //{
584 // BOOL login_last = gSavedSettings.getBOOL("LoginLastLocation");
585 // combo->setCurrentByIndex( login_last ? 1 : 0 );
586 //}
587 //
588 //BOOL show_start = TRUE;
589 //
590 //if (!force_visible)
591 // show_start = gSavedSettings.getBOOL("ShowStartLocation");
592 //
593 //FloaterGridManager::getInstance()->childSetVisible("start_location_combo", show_start);
594 //FloaterGridManager::getInstance()->childSetVisible("start_location_text", show_start);
595 //FloaterGridManager::getInstance()->childSetVisible("server_combo", TRUE);
596//}
597
598//void FloaterGridManager::newShow(const std::string &grid, bool initialLogin)
599//{
600// llinfos << "newShow called" << llendl;
601// /*if (!FloaterGridManager::getInstance())
602// {
603// FloaterGridManager::sGrid = grid;
604// FloaterGridManager::sIsInitialLogin = initialLogin;
605// FloaterGridManager::getInstance() = new FloaterGridManager();
606//
607// llinfos << "FloaterGridManager::getInstance() assigned. FloaterGridManager::getInstance()=" << FloaterGridManager::getInstance() << llendl;
608// }*/
609//
610// llinfos << "newshow called" << llendl;
611// FloaterGridManager::getInstance()->setCurGrid(gHippoGridManager->getCurrentGridNick());
612// refreshGrids();
613//
614// FloaterGridManager::getInstance()->open();
615// // we're important
616// //FloaterGridManager::getInstance()->setFrontmost(TRUE);
617// //FloaterGridManager::getInstance()->setFocus(TRUE);
618//
619//}
620
621//void FloaterGridManager::show(const LLRect &rect, BOOL show_server,
622// void (*callback)(S32 option, void* user_data),
623// void* callback_data)
624//{
625// // we don't need a grid passed in because this is old-style login
626// std::string grid = "";
627// newShow(grid, TRUE);
628//}
629
630//void FloaterGridManager::setFocus(BOOL b)
631//{
632// if(b != hasFocus())
633// {
634// if(b)
635// {
636// FloaterGridManager::giveFocus();
637// }
638// else
639// {
640// LLPanel::setFocus(b);
641// }
642// }
643//}
644//
645//void FloaterGridManager::giveFocus()
646//{
647// LLScrollListCtrl *combo = NULL;
648//
649// if (!FloaterGridManager::getInstance())
650// {
651// llinfos << "giveFocus has no FloaterGridManager instance. FloaterGridManager::getInstance()=" << FloaterGridManager::getInstance() << llendl;
652// return;
653// }
654//
655// // for our combo box approach, selecting the combo box is almost always
656// // the right thing to do on the floater receiving focus
657// combo = FloaterGridManager::getInstance()->getChild<LLScrollListCtrl>("grid_selector");
658// combo->setFocus(TRUE);
659//}
660
661BOOL FloaterGridManager::isGridComboDirty()
662{
663 BOOL user_picked = FALSE;
664 if (!FloaterGridManager::getInstance())
665 {
666 llwarns << "Attempted getServer with no login view shown" << llendl;
667 }
668 else
669 {
670 LLComboBox* combo = FloaterGridManager::getInstance()->getChild<LLComboBox>("server_combo");
671 user_picked = combo->isDirty();
672 }
673 return user_picked;
674}
675
676void FloaterGridManager::getLocation(std::string &location)
677{
678 if (!FloaterGridManager::getInstance())
679 {
680 llwarns << "Attempted getLocation with no login view shown" << llendl;
681 return;
682 }
683
684 LLComboBox* combo = FloaterGridManager::getInstance()->getChild<LLComboBox>("start_location_combo");
685 location = combo->getValue().asString();
686}
687
688std::string& FloaterGridManager::getPassword()
689{
690 return mMungedPassword;
691}
692
693void FloaterGridManager::setPassword(std::string &password)
694{
695 mMungedPassword = password;
696}
697
698bool FloaterGridManager::isSamePassword(std::string &password)
699{
700 return mMungedPassword == password;
701}
702
703//void FloaterGridManager::addServer(const std::string& server, S32 domain_name)
704//{
705// if (!FloaterGridManager::getInstance())
706// {
707// llwarns << "Attempted addServer with no login view shown" << llendl;
708// return;
709// }
710//
711// /*LLComboBox* combo = FloaterGridManager::getInstance()->getChild<LLComboBox>("server_combo");
712// combo->add(server, LLSD(domain_name) );
713// combo->setCurrentByIndex(0);*/
714//}
715
716//void FloaterGridManager::cancel_old()
717//{
718// if (!FloaterGridManager::getInstance())
719// {
720// return;
721// }
722//
723// if (FloaterGridManager::getInstance()->sIsInitialLogin)
724// {
725// // send a callback that indicates we're quitting or closing
726// if (FloaterGridManager::getInstance()->mCallback)
727// FloaterGridManager::getInstance()->mCallback(LOGIN_OPTION_QUIT, FloaterGridManager::getInstance()->mCallbackData);
728// return;
729// }
730//
731// FloaterGridManager::getInstance()->close();
732//}
733
734void FloaterGridManager::hashPassword(const std::string& password, std::string& hashedPassword)
735{
736 // Max "actual" password length is 16 characters.
737 // Hex digests are always 32 characters.
738 if (password.length() == 32)
739 {
740 hashedPassword = password;
741 }
742 else
743 {
744 // this is a normal text password
745 LLMD5 pass((unsigned char *)password.c_str());
746 char munged_password[MD5HEX_STR_SIZE];
747 pass.hex_digest(munged_password);
748 hashedPassword = munged_password;
749 }
750}
diff --git a/linden/indra/newview/floatergridmanager.h b/linden/indra/newview/floatergridmanager.h
new file mode 100644
index 0000000..16720bd
--- /dev/null
+++ b/linden/indra/newview/floatergridmanager.h
@@ -0,0 +1,93 @@
1/*
2 * floatergridmanager.h
3 * This is Meerkats grid manager.
4 * -Patrick Sapinski (Monday, August 17, 2009)
5 *
6 * Modified by McCabe Maxsted for Imprudence
7 */
8
9#ifndef PL_floaterlogin_H
10#define PL_floaterlogin_H
11
12#define LOGIN_OPTION_CONNECT 0
13#define LOGIN_OPTION_QUIT 1
14
15#include "llfloater.h"
16
17class LoginController;
18class AuthenticationModel;
19
20class FloaterGridManager : public LLFloater, public LLFloaterSingleton<FloaterGridManager>
21{
22public:
23 FloaterGridManager(const LLSD& key);
24 virtual ~FloaterGridManager();
25
26 /*virtual*/ BOOL postBuild();
27
28 static void refreshGrids();
29 void apply();
30 //void setDefault();
31 void cancel();
32
33 // new-style login methods
34 virtual std::string& getPassword();
35 virtual void setPassword(std::string &password);
36 virtual bool isSamePassword(std::string &password);
37 static void getFields(std::string &loginname, std::string &password,
38 BOOL &remember);
39 static void setFields(const std::string &loginname, const std::string &password,
40 BOOL remember);
41
42 // LLLoginPanel compatibility
43 /*static void setAlwaysRefresh(bool refresh);
44 static void refreshLocation(bool force_visible);
45 virtual void setFocus(BOOL b);
46 static void giveFocus();*/
47 static void getLocation(std::string &location);
48 static BOOL isGridComboDirty();
49 //static void addServer(const std::string& server, S32 domain_name);
50 static void hashPassword(const std::string& password, std::string& hashedPassword);
51protected:
52 static bool sIsInitialLogin;
53 static std::string sGrid;
54private:
55 enum State
56 {
57 NORMAL,
58 ADD_NEW,
59 ADD_COPY
60 };
61
62 State mState;
63 void setState(const State& state) { mState = state; }
64 State getState() { return mState; }
65
66 std::string mCurGrid;
67 void setCurGrid(const std::string& grid) { mCurGrid = grid; }
68 std::string getCurGrid() { return mCurGrid; }
69
70 std::string mIncomingPassword;
71 std::string mMungedPassword;
72
73 void applyChanges();
74 bool createNewGrid();
75 void update();
76 void retrieveGridInfo();
77
78 static void onSelectGrid(LLUICtrl* ctrl, void* data);
79 static void onClickDelete(void* data);
80 static void onClickAdd(void* data);
81 static void onClickCopy(void* data);
82 static void onClickOk(void* data);
83 static void onClickApply(void* data);
84 static void onClickDefault(void* data);
85 static void onClickGridInfo(void* data);
86 static void onClickCancel(void* data);
87 static void onClickClear(void* data);
88
89 static LoginController* sController;
90 static AuthenticationModel* sModel;
91};
92
93#endif // PL_floaterlogin_H
diff --git a/linden/indra/newview/floaterlogin.cpp b/linden/indra/newview/floaterlogin.cpp
deleted file mode 100644
index 78aa0a2..0000000
--- a/linden/indra/newview/floaterlogin.cpp
+++ /dev/null
@@ -1,722 +0,0 @@
1/*
2 * floaterlogin.cpp (floatergridmanager.cpp pls)
3 * This is Meerkats grid manager, and I accidentally finished it with the wrong name :)
4 * -Patrick Sapinski (Monday, August 17, 2009)
5 */
6
7#include "llviewerprecompiledheaders.h"
8
9#include <boost/algorithm/string.hpp>
10#include "llviewercontrol.h"
11#include "llcombobox.h"
12#include "llscrolllistctrl.h"
13#include "llmd5.h"
14#include "llurlsimstring.h"
15#include "lluictrlfactory.h"
16#include "floaterlogin.h"
17#include "hippoGridManager.h"
18#include "llviewernetwork.h"
19#include "llpanellogin.h"
20
21#define PASSWORD_FILLER "123456789!123456"
22
23LoginFloater* LoginFloater::sInstance = NULL;
24LoginController* LoginFloater::sController = NULL;
25bool LoginFloater::sIsInitialLogin;
26std::string LoginFloater::sGrid;
27
28LoginFloater::LoginFloater()
29: LLFloater("floater_login")
30{
31
32 mState = NORMAL;
33 LLUICtrlFactory::getInstance()->buildFloater(this, "floater_login.xml");
34
35
36 llwarns << "LoginFloater called" << llendl;
37
38
39 // configure the floater interface for non-initial login
40 setCanMinimize(!sIsInitialLogin);
41 setCanClose(!sIsInitialLogin);
42 setCanDrag(!sIsInitialLogin);
43 childSetVisible("server_combo", sIsInitialLogin);
44
45 if(!sIsInitialLogin)
46 {
47 LLButton* quit_btn = getChild<LLButton>("quit_btn");
48 quit_btn->setLabel(std::string("Cancel"));
49 setTitle(std::string("Grid Manager"));
50 }
51
52 center();
53 LLLineEditor* edit = getChild<LLLineEditor>("avatar_password_edit");
54 if (edit) edit->setDrawAsterixes(TRUE);
55 LLComboBox* combo = getChild<LLComboBox>("start_location_combo");
56 combo->setAllowTextEntry(TRUE, 128, FALSE);
57
58 BOOL login_last = gSavedSettings.getBOOL("LoginLastLocation");
59 std::string sim_string = LLURLSimString::sInstance.mSimString;
60 if (!sim_string.empty())
61 {
62 // Replace "<Type region name>" with this region name
63 combo->remove(2);
64 combo->add( sim_string );
65 combo->setTextEntry(sim_string);
66 combo->setCurrentByIndex( 2 );
67 }
68 else if (login_last)
69 {
70 combo->setCurrentByIndex( 1 );
71 }
72 else
73 {
74 combo->setCurrentByIndex( 0 );
75 }
76}
77
78
79LoginFloater::~LoginFloater()
80{
81 LoginFloater::sController = NULL;
82 LoginFloater::sInstance = NULL;
83}
84
85void LoginFloater::close()
86{
87 if(sInstance)
88 {
89 delete sInstance;
90 sInstance = NULL;
91 }
92}
93
94BOOL LoginFloater::postBuild()
95{
96 requires<LLScrollListCtrl>("grid_selector");
97 requires<LLLineEditor>("gridnick");
98 requires<LLLineEditor>("gridname");
99 requires<LLLineEditor>("loginuri");
100 requires<LLLineEditor>("loginpage");
101 requires<LLLineEditor>("helperuri");
102 requires<LLLineEditor>("website");
103 requires<LLLineEditor>("support");
104 requires<LLLineEditor>("register");
105 requires<LLLineEditor>("password");
106 requires<LLLineEditor>("first_name");
107 requires<LLLineEditor>("last_name");
108 requires<LLLineEditor>("avatar_password");
109 //requires<LLLineEditor>("search");
110 requires<LLButton>("btn_delete");
111 requires<LLButton>("btn_add");
112 requires<LLButton>("btn_copy");
113 requires<LLButton>("set_default");
114 requires<LLButton>("btn_gridinfo");
115 requires<LLButton>("btn_help_render_compat");
116 if (!checkRequirements()) return false;
117 LLLineEditor* password_edit = getChild<LLLineEditor>("avatar_password");
118 if (password_edit) password_edit->setDrawAsterixes(TRUE);
119
120 childSetAction("btn_delete", onClickDelete, this);
121 childSetAction("btn_add", onClickAdd, this);
122 childSetAction("btn_copy", onClickCopy, this);
123 childSetAction("btn_ok", onClickOk, this);
124 childSetAction("btn_apply", onClickApply, this);
125 // childSetAction("set_default", onClickDefault, this);
126 childSetAction("btn_cancel", onClickCancel, this);
127 childSetAction("btn_gridinfo", onClickGridInfo, this);
128 // childSetAction("btn_help_render_compat", onClickHelpRenderCompat, this);
129
130 childSetCommitCallback("grid_selector", onSelectGrid, this);
131//KOW childSetCommitCallback("platform", onSelectPlatform, this);
132
133 // !!!### server_choice_combo->setFocusLostCallback(onServerComboLostFocus);
134
135//KOW update();
136 return TRUE;
137}
138
139void LoginFloater::refresh_grids()
140{
141 const std::string &defaultGrid = gHippoGridManager->getDefaultGridNick();
142 LLScrollListCtrl *grids = sInstance->getChild<LLScrollListCtrl>("grid_selector");
143 S32 selectIndex = -1, i = 0;
144 grids->deleteAllItems();
145 if (defaultGrid != "") {
146 LLSD value;
147 value["id"] = defaultGrid;
148 value["columns"][0]["column"] = "grid";
149 value["columns"][0]["value"] = defaultGrid;
150 grids->addElement(value);
151 selectIndex = i++;
152 }
153
154 HippoGridManager::GridIterator it, end = gHippoGridManager->endGrid();
155 for (it = gHippoGridManager->beginGrid(); it != end; ++it) {
156 const std::string &grid = it->second->getGridNick();
157 if (grid != defaultGrid) {
158 LLSD value;
159 value["id"] = grid;
160 value["columns"][0]["column"] = "grid";
161 value["columns"][0]["value"] = grid;
162 grids->addElement(value);
163
164 if (grid == sInstance->mCurGrid) selectIndex = i;
165 i++;
166 }
167 }
168 if ((sInstance->mState == ADD_NEW) || (sInstance->mState == ADD_COPY)) {
169 grids->addElement("<new>");
170 selectIndex = i++;
171 }
172 if (selectIndex >= 0) {
173 //grids->setCurrentByIndex(selectIndex);
174 } else {
175 //grids->setLabel(LLStringExplicit("")); // LLComboBox::removeall() does not clear the label
176 }
177
178 // sInstance->childSetTextArg("default_grid", "[DEFAULT]", (defaultGrid != "")? defaultGrid: " ");
179
180 sInstance->childSetEnabled("btn_delete", (selectIndex >= 0));
181 sInstance->childSetEnabled("btn_copy", (sInstance->mState == NORMAL) && (selectIndex >= 0));
182 // sInstance->childSetEnabled("set_default", (sInstance->mState == NORMAL) && (selectIndex > 0));
183 sInstance->childSetEnabled("gridnick", (sInstance->mState == ADD_NEW) || (sInstance->mState == ADD_COPY));
184
185 if (sInstance->mState == NORMAL) {
186 HippoGridInfo *gridInfo = gHippoGridManager->getGrid(sInstance->mCurGrid);
187 if (gridInfo) {
188 sInstance->childSetText("gridnick", gridInfo->getGridNick());
189 //sInstance->childSetText("grid_name", gridInfo->getGridName());
190 sInstance->childSetText("loginuri", gridInfo->getLoginUri());
191 sInstance->childSetText("loginpage", gridInfo->getLoginPage());
192 sInstance->childSetText("helperuri", gridInfo->getHelperUri());
193 sInstance->childSetText("website", gridInfo->getWebSite());
194 sInstance->childSetText("support", gridInfo->getSupportUrl());
195 sInstance->childSetText("register", gridInfo->getRegisterUrl());
196 sInstance->childSetText("password", gridInfo->getPasswordUrl());
197
198 // sInstance->childSetText("first_name", gridInfo->getFirstName());
199 // sInstance->childSetText("last_name", gridInfo->getLastName());
200 // if(gridInfo->getAvatarPassword().length() == 32)
201 // sInstance->childSetText("avatar_password", std::string(PASSWORD_FILLER));
202 // else if(gridInfo->getPasswordUrl().empty())
203 // sInstance->childSetText("avatar_password", std::string(""));
204
205 // if (gridInfo->getPlatform() == HippoGridInfo::PLATFORM_SECONDLIFE) {
206 // //childSetEnabled("search", false);
207 // //childSetText("search", LLStringExplicit(""));
208 // childSetEnabled("render_compat", false);
209 // childSetValue("render_compat", false);
210 // } else {
211 // //childSetEnabled("search", true);
212 // //childSetText("search", gridInfo->getSearchUrl());
213 // childSetEnabled("render_compat", true);
214 // childSetValue("render_compat", gridInfo->isRenderCompat());
215 // }
216
217 } else {
218 std::string empty = "";
219 sInstance->childSetText("gridnick", empty);
220 sInstance->childSetText("gridname", empty);
221 sInstance->childSetText("loginuri", empty);
222 sInstance->childSetText("loginpage", empty);
223 sInstance->childSetText("helperuri", empty);
224 sInstance->childSetText("website", empty);
225 // sInstance->childSetText("first_name", empty);
226 // sInstance->childSetText("last_name", empty);
227 // sInstance->childSetText("avatar_password", empty);
228 }
229 } else if (sInstance->mState == ADD_NEW) {
230 llwarns << "ADD_NEW" << llendl;
231 std::string required = "<required>";
232 std::string empty = "";
233 sInstance->childSetText("gridnick", required);
234 sInstance->childSetText("gridname", empty);
235 sInstance->childSetText("loginuri", required);
236 sInstance->childSetText("loginpage", empty);
237 sInstance->childSetText("helperuri", empty);
238 sInstance->childSetText("website", empty);
239 sInstance->childSetText("support", empty);
240 sInstance->childSetText("register", empty);
241 sInstance->childSetText("password", empty);
242 // sInstance->childSetText("first_name", empty);
243 // sInstance->childSetText("last_name", empty);
244 // sInstance->childSetText("avatar_password", empty);
245 //childSetEnabled("search", true);
246 //childSetText("search", empty);
247 } else if (sInstance->mState == ADD_COPY) {
248 llwarns << "ADD_COPY" << llendl;
249 sInstance->childSetText("gridnick", LLStringExplicit("<required>"));
250 } else {
251 llwarns << "Illegal state " << sInstance->mState << '.' << llendl;
252 }
253 return;
254}
255
256void LoginFloater::update()
257{
258 mState = NORMAL;
259 mCurGrid = gHippoGridManager->getCurrentGridNick();
260 refresh_grids();
261 //KOW gHippoLimits->setLimits();
262}
263
264void LoginFloater::applyChanges()
265{
266 HippoGridInfo *gridInfo = gHippoGridManager->getGrid(mCurGrid);
267 if (gridInfo)
268 {
269 if (gridInfo->getGridNick() == childGetValue("gridnick").asString())
270 {
271 gridInfo->setGridName(childGetValue("gridname"));
272 gridInfo->setLoginUri(childGetValue("loginuri"));
273 gridInfo->setLoginPage(childGetValue("loginpage"));
274 gridInfo->setHelperUri(childGetValue("helperuri"));
275 gridInfo->setWebSite(childGetValue("website"));
276 gridInfo->setSupportUrl(childGetValue("support"));
277 gridInfo->setRegisterUrl(childGetValue("register"));
278 gridInfo->setPasswordUrl(childGetValue("password"));
279 //gridInfo->setSearchUrl(childGetValue("search"));
280 gridInfo->setRenderCompat(childGetValue("render_compat"));
281
282 // gridInfo->setFirstName(childGetValue("first_name"));
283 // gridInfo->setLastName(childGetValue("last_name"));
284 // if(childGetValue("avatar_password").asString().empty())
285 // gridInfo->setAvatarPassword(std::string(""));
286 // else if(childGetValue("avatar_password").asString() != std::string(PASSWORD_FILLER))
287 // {
288 // // store account authentication data
289 // std::string auth_password = childGetValue("avatar_password");
290 // std::string hashed_password;
291 // hashPassword(auth_password, hashed_password);
292 // gridInfo->setAvatarPassword(hashed_password);
293 // }
294
295 //this bug was a feature -Patrick Sapinski (Friday, August 21, 2009)
296 //LLPanelLogin::setFields(gridInfo->getFirstName(), gridInfo->getLastName(),
297 // gridInfo->getAvatarPassword(), true);
298 }
299 else
300 {
301 llwarns << "Grid nickname mismatch, ignoring changes." << llendl;
302 }
303 }
304}
305
306
307bool LoginFloater::createNewGrid()
308{
309 // check nickname
310 std::string gridnick = childGetValue("gridnick");
311 if (gridnick == "<required>") gridnick = "";
312 if (gridnick == "") {
313 //KOW gViewerWindow->alertXml("GridsNoNick");
314 return false;
315 }
316 if (gHippoGridManager->getGrid(gridnick)) {
317 LLStringUtil::format_map_t args;
318 args["[NAME]"] = gridnick;
319 //KOW gViewerWindow->alertXml("GridExists", args);
320 return false;
321 }
322
323 // check login URI
324 std::string loginuri = childGetValue("loginuri");
325 if ((loginuri == "") || (loginuri == "<required>")) {
326 LLStringUtil::format_map_t args;
327 args["[NAME]"] = gridnick;
328 //KOW gViewerWindow->alertXml("GridsNoLoginUri", args);
329 return false;
330 }
331
332 // create new grid
333 HippoGridInfo *grid = new HippoGridInfo(gridnick);
334 grid->setGridName(childGetValue("gridname"));
335 grid->setLoginUri(loginuri);
336 grid->setLoginPage(childGetValue("loginpage"));
337 grid->setHelperUri(childGetValue("helperuri"));
338 grid->setWebSite(childGetValue("website"));
339 grid->setSupportUrl(childGetValue("support"));
340 grid->setRegisterUrl(childGetValue("register"));
341 grid->setPasswordUrl(childGetValue("password"));
342 //grid->setSearchUrl(childGetValue("search"));
343 grid->setRenderCompat(childGetValue("render_compat"));
344 gHippoGridManager->addGrid(grid);
345
346 // grid->setFirstName(childGetValue("first_name"));
347 // grid->setLastName(childGetValue("last_name"));
348 // if(childGetValue("avatar_password").asString().empty())
349 // grid->setAvatarPassword(std::string(""));
350 // else
351 // {
352 // std::string hashed_password;
353 // hashPassword(childGetValue("avatar_password"), hashed_password);
354 // grid->setAvatarPassword(hashed_password);
355 // }
356
357 mCurGrid = gridnick;
358 return true;
359}
360
361void LoginFloater::retrieveGridInfo()
362{
363 std::string loginuri = childGetValue("loginuri");
364 if ((loginuri == "") || (loginuri == "<required>")) {
365 //KOW gViewerWindow->alertXml("GridInfoNoLoginUri");
366 return;
367 }
368
369 HippoGridInfo *grid = 0;
370 bool cleanupGrid = false;
371 if (mState == NORMAL) {
372 grid = gHippoGridManager->getGrid(mCurGrid);
373 } else if ((mState == ADD_NEW) || (mState == ADD_COPY)) {
374 grid = new HippoGridInfo("");
375 cleanupGrid = true;
376 } else {
377 llerrs << "Illegal state " << mState << '.' << llendl;
378 return;
379 }
380 if (!grid) {
381 llerrs << "Internal error retrieving grid info." << llendl;
382 return;
383 }
384
385 grid->setLoginUri(loginuri);
386 if (grid->retrieveGridInfo()) {
387 if (grid->getGridNick() != "") childSetText("gridnick", grid->getGridNick());
388 if (grid->getGridName() != "") childSetText("gridname", grid->getGridName());
389 if (grid->getLoginUri() != "") childSetText("loginuri", grid->getLoginUri());
390 if (grid->getLoginPage() != "") childSetText("loginpage", grid->getLoginPage());
391 if (grid->getHelperUri() != "") childSetText("helperuri", grid->getHelperUri());
392 if (grid->getWebSite() != "") childSetText("website", grid->getWebSite());
393 if (grid->getSupportUrl() != "") childSetText("support", grid->getSupportUrl());
394 if (grid->getRegisterUrl() != "") childSetText("register", grid->getRegisterUrl());
395 if (grid->getPasswordUrl() != "") childSetText("password", grid->getPasswordUrl());
396 //if (grid->getSearchUrl() != "") childSetText("search", grid->getSearchUrl());
397 } else {
398 //KOW gViewerWindow->alertXml("GridInfoError");
399 }
400
401 if (cleanupGrid) delete grid;
402}
403
404void LoginFloater::apply()
405{
406 if (mState == NORMAL) {
407 applyChanges();
408 } else if ((mState == ADD_NEW) || (mState == ADD_COPY)) {
409 if (!createNewGrid()) return;
410 } else {
411 llwarns << "Illegal state " << mState << '.' << llendl;
412 return;
413 }
414 //gHippoGridManager->setCurrentGrid(mCurGrid);
415 //gHippoGridManager->setDefaultGrid(mCurGrid);
416 //LLPanelLogin::refreshLoginPage();
417 gHippoGridManager->saveFile();
418 LLPanelLogin::addServer(LLViewerLogin::getInstance()->getGridLabel());
419}
420
421void LoginFloater::setDefault()
422{
423 if (mState == NORMAL) {
424 applyChanges();
425 } else if ((mState == ADD_NEW) || (mState == ADD_COPY)) {
426 if (!createNewGrid()) return;
427 } else {
428 llwarns << "Illegal state " << mState << '.' << llendl;
429 return;
430 }
431 gHippoGridManager->setCurrentGrid(mCurGrid);
432 gHippoGridManager->setDefaultGrid(mCurGrid);
433 gHippoGridManager->saveFile();
434 LLPanelLogin::addServer(LLViewerLogin::getInstance()->getGridLabel());
435}
436
437void LoginFloater::cancel()
438{
439 gHippoGridManager->discardAndReload();
440 update();
441}
442
443void LoginFloater::onSelectGrid(LLUICtrl* ctrl, void *data)
444{
445 LoginFloater* self = (LoginFloater*)data;
446 if (self->mState == NORMAL) {
447 self->applyChanges();
448 } else if ((self->mState == ADD_NEW) || (self->mState == ADD_COPY)) {
449 if (self->createNewGrid()) {
450 self->mState = NORMAL;
451 } else {
452 //LLScrollListCtrl *grids = self->getChild<LLScrollListCtrl>("grid_selector");
453 //grids->setCurrentByIndex(grids->getItemCount() - 1);
454 return;
455 }
456 } else {
457 llwarns << "Illegal state " << self->mState << '.' << llendl;
458 return;
459 }
460 self->mCurGrid = ctrl->getValue().asString();
461 self->refresh_grids();
462}
463
464//static
465void LoginFloater::onClickDelete(void *data)
466{
467 llwarns << "onclickdelete" << llendl;
468 LoginFloater* self = (LoginFloater*)data;
469 if (self->mState == NORMAL)
470 gHippoGridManager->deleteGrid(self->mCurGrid);
471 self->update();
472}
473
474//static
475void LoginFloater::onClickAdd(void *data)
476{
477 llwarns << "add" << llendl;
478 LoginFloater* self = (LoginFloater*)data;
479 self->mState = ADD_NEW;
480 self->refresh_grids();
481}
482
483
484//static
485void LoginFloater::onClickCopy(void *data)
486{
487 llwarns << "copy" << llendl;
488 LoginFloater* self = (LoginFloater*)data;
489 self->mState = ADD_COPY;
490 self->refresh_grids();
491}
492
493// static
494void LoginFloater::onClickOk(void* data)
495{
496 if(NULL==sInstance)
497 return;
498
499 sInstance->apply();
500 sInstance->close();
501}
502
503//static
504void LoginFloater::onClickApply(void *data)
505{
506 if(NULL==sInstance)
507 return;
508
509 sInstance->apply();
510 refresh_grids();
511}
512
513//static
514void LoginFloater::onClickDefault(void *data)
515{
516 sInstance->setDefault();
517 sInstance->refresh_grids();
518}
519
520//static
521void LoginFloater::onClickGridInfo(void *data)
522{
523 //HippoPanelGrids* self = (HippoPanelGrids*)data;
524 sInstance->retrieveGridInfo();
525}
526
527//static
528void LoginFloater::onClickCancel(void *data)
529{
530 sInstance->cancel();
531}
532
533void LoginFloater::setAlwaysRefresh(bool refresh)
534{
535 // wargames 2: dead code, LLPanelLogin compatibility
536 return;
537}
538
539void LoginFloater::refreshLocation( bool force_visible )
540{
541
542 llwarns << "refreshLocation called" << llendl;
543
544 if (!sInstance) return;
545
546 LLComboBox* combo = sInstance->getChild<LLComboBox>("start_location_combo");
547
548 if (LLURLSimString::parse())
549 {
550 combo->setCurrentByIndex( 3 ); // BUG? Maybe 2?
551 combo->setTextEntry(LLURLSimString::sInstance.mSimString);
552 }
553 else
554 {
555 BOOL login_last = gSavedSettings.getBOOL("LoginLastLocation");
556 combo->setCurrentByIndex( login_last ? 1 : 0 );
557 }
558
559 BOOL show_start = TRUE;
560
561 if ( ! force_visible )
562 show_start = gSavedSettings.getBOOL("ShowStartLocation");
563
564 sInstance->childSetVisible("start_location_combo", show_start);
565 sInstance->childSetVisible("start_location_text", show_start);
566 sInstance->childSetVisible("server_combo", TRUE);
567}
568
569void LoginFloater::newShow(const std::string &grid, bool initialLogin)
570{
571
572 llwarns << "newShow called" << llendl;
573 if(NULL==sInstance)
574 {
575 LoginFloater::sGrid = grid;
576 LoginFloater::sIsInitialLogin = initialLogin;
577 sInstance = new LoginFloater();
578
579 llwarns << "sInstance assigned. sInstance=" << sInstance << llendl;
580 }
581
582 llwarns << "newshow called" << llendl;
583 sInstance->mCurGrid = gHippoGridManager->getCurrentGridNick();
584 refresh_grids();
585
586 sInstance->open(); /*Flawfinder: ignore*/
587 // we're important
588 //sInstance->setFrontmost(TRUE);
589 //sInstance->setFocus(TRUE);
590
591}
592
593void LoginFloater::show(const LLRect &rect, BOOL show_server,
594 void (*callback)(S32 option, void* user_data),
595 void* callback_data)
596{
597 // we don't need a grid passed in because this is old-style login
598 std::string grid = "";
599 newShow(grid, TRUE);
600}
601
602void LoginFloater::setFocus(BOOL b)
603{
604 if(b != hasFocus())
605 {
606 if(b)
607 {
608 LoginFloater::giveFocus();
609 }
610 else
611 {
612 LLPanel::setFocus(b);
613 }
614 }
615}
616
617void LoginFloater::giveFocus()
618{
619 LLScrollListCtrl *combo = NULL;
620
621 if(NULL==sInstance)
622 {
623 llwarns << "giveFocus has no LoginFloater instance. sInstance=" << sInstance << llendl;
624 return;
625 }
626
627 // for our combo box approach, selecting the combo box is almost always
628 // the right thing to do on the floater receiving focus
629 combo = sInstance->getChild<LLScrollListCtrl>("grid_selector");
630 combo->setFocus(TRUE);
631}
632
633BOOL LoginFloater::isGridComboDirty()
634{
635 BOOL user_picked = FALSE;
636 if (!sInstance)
637 {
638 llwarns << "Attempted getServer with no login view shown" << llendl;
639 }
640 else
641 {
642 LLComboBox* combo = sInstance->getChild<LLComboBox>("server_combo");
643 user_picked = combo->isDirty();
644 }
645 return user_picked;
646}
647
648void LoginFloater::getLocation(std::string &location)
649{
650 if (!sInstance)
651 {
652 llwarns << "Attempted getLocation with no login view shown" << llendl;
653 return;
654 }
655
656 LLComboBox* combo = sInstance->getChild<LLComboBox>("start_location_combo");
657 location = combo->getValue().asString();
658}
659
660std::string& LoginFloater::getPassword()
661{
662 return mMungedPassword;
663}
664
665void LoginFloater::setPassword(std::string &password)
666{
667 mMungedPassword = password;
668}
669
670bool LoginFloater::isSamePassword(std::string &password)
671{
672 return mMungedPassword == password;
673}
674
675void LoginFloater::addServer(const std::string& server, S32 domain_name)
676{
677 if (!sInstance)
678 {
679 llwarns << "Attempted addServer with no login view shown" << llendl;
680 return;
681 }
682
683 LLComboBox* combo = sInstance->getChild<LLComboBox>("server_combo");
684 combo->add(server, LLSD(domain_name) );
685 combo->setCurrentByIndex(0);
686}
687
688void LoginFloater::cancel_old()
689{
690 if(NULL==sInstance)
691 return;
692
693 if(sInstance->sIsInitialLogin)
694 {
695 // send a callback that indicates we're quitting or closing
696 if(sInstance->mCallback)
697 sInstance->mCallback(LOGIN_OPTION_QUIT, sInstance->mCallbackData);
698 return;
699 }
700
701 sInstance->close();
702}
703
704void LoginFloater::hashPassword(const std::string& password, std::string& hashedPassword)
705{
706 // Max "actual" password length is 16 characters.
707 // Hex digests are always 32 characters.
708 if (password.length() == 32)
709 {
710 hashedPassword = password;
711 }
712 else
713 {
714 // this is a normal text password
715 LLMD5 pass((unsigned char *)password.c_str());
716 char munged_password[MD5HEX_STR_SIZE];
717 pass.hex_digest(munged_password);
718 hashedPassword = munged_password;
719 }
720
721}
722
diff --git a/linden/indra/newview/floaterlogin.h b/linden/indra/newview/floaterlogin.h
deleted file mode 100644
index cdb60b0..0000000
--- a/linden/indra/newview/floaterlogin.h
+++ /dev/null
@@ -1,90 +0,0 @@
1/*
2 * floaterlogin.h (floatergridmanager.h pls)
3 * This is Meerkats grid manager, and I accidentally finished it with the wrong name :)
4 * -Patrick Sapinski (Monday, August 17, 2009)
5 */
6
7#ifndef PL_floaterlogin_H
8#define PL_floaterlogin_H
9
10#define LOGIN_OPTION_CONNECT 0
11#define LOGIN_OPTION_QUIT 1
12
13#include "llfloater.h"
14
15class LoginController;
16class AuthenticationModel;
17
18class LoginFloater : public LLFloater
19{
20public:
21 LoginFloater();
22 virtual ~LoginFloater();
23
24 virtual BOOL postBuild();
25
26 static void refresh_grids();
27 void apply();
28 void setDefault();
29 void cancel();
30
31 // new-style login methods
32 static void newShow(const std::string &grid, bool initialLogin);
33 virtual std::string& getPassword();
34 virtual void setPassword(std::string &password);
35 virtual bool isSamePassword(std::string &password);
36 static void getFields(std::string &loginname, std::string &password,
37 BOOL &remember);
38 static void setFields(const std::string &loginname, const std::string &password,
39 BOOL remember);
40
41 // LLLoginPanel compatibility
42 //TODO: Make this not suck
43 static void show(const LLRect &rect, BOOL show_server,
44 void (*callback)(S32 option, void *user_data),
45 void *callback_data);
46 static void close();
47 static void setAlwaysRefresh(bool refresh);
48 static void refreshLocation(bool force_visible);
49 virtual void setFocus(BOOL b);
50 static void giveFocus();
51 static void getLocation(std::string &location);
52 static BOOL isGridComboDirty();
53 static void addServer(const std::string& server, S32 domain_name);
54 static void cancel_old();
55 static void hashPassword(const std::string& password, std::string& hashedPassword);
56protected:
57 static bool sIsInitialLogin;
58 static std::string sGrid;
59private:
60 enum State { NORMAL, ADD_NEW, ADD_COPY };
61 State mState;
62 std::string mCurGrid;
63
64 std::string mIncomingPassword;
65 std::string mMungedPassword;
66
67 void applyChanges();
68 bool createNewGrid();
69 void update();
70 void retrieveGridInfo();
71
72 static void onSelectGrid(LLUICtrl *ctrl, void *data);
73 static void onClickDelete(void *data);
74 static void onClickAdd(void *data);
75 static void onClickCopy(void *data);
76 static void onClickOk(void *data);
77 static void onClickApply(void *data);
78 static void onClickDefault(void *data);
79 static void onClickGridInfo(void *data);
80 static void onClickCancel(void *data);
81
82 static LoginFloater *sInstance;
83 static LoginController *sController;
84 static AuthenticationModel *sModel;
85
86 void (*mCallback)(S32 option, void *userdata);
87 void *mCallbackData;
88};
89
90#endif // PL_floaterlogin_H
diff --git a/linden/indra/newview/llpanellogin.cpp b/linden/indra/newview/llpanellogin.cpp
index 8dde683..ea84fee 100644
--- a/linden/indra/newview/llpanellogin.cpp
+++ b/linden/indra/newview/llpanellogin.cpp
@@ -38,8 +38,7 @@
38 38
39#include "hippoGridManager.h" 39#include "hippoGridManager.h"
40#include "hippoLimits.h" 40#include "hippoLimits.h"
41 41#include "floatergridmanager.h"
42#include "floaterlogin.h"
43 42
44#include "indra_constants.h" // for key and mask constants 43#include "indra_constants.h" // for key and mask constants
45#include "llfontgl.h" 44#include "llfontgl.h"
@@ -1006,7 +1005,8 @@ void LLPanelLogin::onClickGrid(void *)
1006{ 1005{
1007 if (sInstance && sInstance->mCallback) 1006 if (sInstance && sInstance->mCallback)
1008 { 1007 {
1009 LoginFloater::newShow(std::string("Test"), false); 1008 FloaterGridManager::getInstance()->open();
1009 FloaterGridManager::getInstance()->center();
1010 } 1010 }
1011} 1011}
1012 1012
diff --git a/linden/indra/newview/skins/default/xui/en-us/floater_login.xml b/linden/indra/newview/skins/default/xui/en-us/floater_grid_manager.xml
index 96e2aa3..401780f 100644
--- a/linden/indra/newview/skins/default/xui/en-us/floater_login.xml
+++ b/linden/indra/newview/skins/default/xui/en-us/floater_grid_manager.xml
@@ -1,7 +1,7 @@
1<?xml version="1.0" encoding="utf-8" standalone="yes" ?> 1<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
2<floater can_close="false" can_drag_on_left="false" can_minimize="false" 2<floater can_close="true" can_drag_on_left="false" can_minimize="false"
3 can_resize="true" height="400" min_height="400" min_width="600" 3 can_resize="true" height="400" min_height="400" min_width="600"
4 name="floater_login" title="plasticwuzhere" width="600"> 4 name="floater_login" title="Grid Manager" width="600">
5 5
6 <!-- Grid Selector --> 6 <!-- Grid Selector -->
7 <text type="string" length="1" enabled="true" name="grid_selector_label" 7 <text type="string" length="1" enabled="true" name="grid_selector_label"
@@ -244,14 +244,17 @@
244 left="280" mouse_opaque="true" name="connect_btn" scale_image="TRUE" 244 left="280" mouse_opaque="true" name="connect_btn" scale_image="TRUE"
245 width="100" /> --> 245 width="100" /> -->
246 <button bottom="8" follows="right|bottom" font="SansSerif" halign="center" 246 <button bottom="8" follows="right|bottom" font="SansSerif" halign="center"
247 height="24" label="Ok" label_selected="Apply" left="280" 247 height="24" label="Apply" label_selected="Apply" left="-108"
248 mouse_opaque="true" name="btn_apply" scale_image="TRUE" width="100" />
249 <button bottom="8" follows="right|bottom" font="SansSerif" halign="center"
250 height="24" label="Cancel" label_selected="Cancel" left_delta="-104"
251 mouse_opaque="true" name="btn_cancel" scale_image="TRUE" width="100" />
252 <button bottom="8" follows="right|bottom" font="SansSerif" halign="center"
253 height="24" label="OK" label_selected="OK" left_delta="-104"
248 mouse_opaque="true" name="btn_ok" scale_image="TRUE" width="100" /> 254 mouse_opaque="true" name="btn_ok" scale_image="TRUE" width="100" />
249 <button bottom="8" follows="right|bottom" font="SansSerif" halign="center" 255 <button bottom="8" follows="right|bottom" font="SansSerif" halign="center"
250 height="24" label="Apply" label_selected="Apply" left="385" 256 height="24" label="Clear" label_selected="Clear" left_delta="-104"
251 mouse_opaque="true" name="btn_apply" scale_image="TRUE" width="100" /> 257 mouse_opaque="true" name="btn_clear" scale_image="TRUE" width="100" />
252 <button bottom="8" follows="right|bottom" font="SansSerif" halign="center"
253 height="24" label="Undo" label_selected="Undo" left="490"
254 mouse_opaque="true" name="btn_cancel" scale_image="TRUE" width="100" />
255 <!-- 258 <!--
256 <combo_box allow_text_entry="true" bottom="32" follows="left|bottom" height="18" 259 <combo_box allow_text_entry="true" bottom="32" follows="left|bottom" height="18"
257 left_delta="135" max_chars="40" mouse_opaque="true" 260 left_delta="135" max_chars="40" mouse_opaque="true"