diff options
author | McCabe Maxsted | 2011-04-15 21:07:29 -0700 |
---|---|---|
committer | McCabe Maxsted | 2011-04-15 21:07:29 -0700 |
commit | f7df6f323e4746abae0a0858cb7ef56bedbb94ca (patch) | |
tree | 7a4a9e3be1ca658c0d72c78f413946249a38ad21 /linden/indra/newview/floatergridmanager.cpp | |
parent | test commit - slviewer-0-v12500-DeadObjectsFixes_v2.patch (diff) | |
download | meta-impy-f7df6f323e4746abae0a0858cb7ef56bedbb94ca.zip meta-impy-f7df6f323e4746abae0a0858cb7ef56bedbb94ca.tar.gz meta-impy-f7df6f323e4746abae0a0858cb7ef56bedbb94ca.tar.bz2 meta-impy-f7df6f323e4746abae0a0858cb7ef56bedbb94ca.tar.xz |
Updated the grid manager to save names and passwords along with grid info. This commit includes the following:
* Fixed missing GPL headers from hippo grid manager
* Fixed grids named <required> or "" being saved in the list
* Fixed grid manager list only showing grid nicks, not grid names
* Fixed grid names not settable in the grid manager
* Grid manager now remembers avatar names and passwords
* Usernames can now be set in the grid manager for SL (needs work)
* Fixed grid manager being stuck in an updating state
* Some general code cleanup
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/floatergridmanager.cpp | 864 |
1 files changed, 414 insertions, 450 deletions
diff --git a/linden/indra/newview/floatergridmanager.cpp b/linden/indra/newview/floatergridmanager.cpp index 298fe35..ad6ea05 100644 --- a/linden/indra/newview/floatergridmanager.cpp +++ b/linden/indra/newview/floatergridmanager.cpp | |||
@@ -1,54 +1,68 @@ | |||
1 | /* | 1 | /** |
2 | * floatergridmanager.cpp | 2 | * @file floatergridmanager.cpp |
3 | * This is Meerkats grid manager. | 3 | * @brief UI for managing grid information |
4 | * -Patrick Sapinski (Monday, August 17, 2009) | 4 | * |
5 | * | 5 | * $LicenseInfo:firstyear=2011&license=viewergpl$ |
6 | * Modified by McCabe Maxsted for Imprudence | 6 | * |
7 | */ | 7 | * Copyright (c) 2011, McCabe Maxsted |
8 | * based on Meerkat's grid manager by Patrick Sapinski | ||
9 | * | ||
10 | * Imprudence Viewer Source Code | ||
11 | * The source code in this file ("Source Code") is provided to you | ||
12 | * under the terms of the GNU General Public License, version 2.0 | ||
13 | * ("GPL"). Terms of the GPL can be found in doc/GPL-license.txt in | ||
14 | * this distribution, or online at | ||
15 | * http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
16 | * | ||
17 | * There are special exceptions to the terms and conditions of the GPL as | ||
18 | * it is applied to this Source Code. View the full text of the exception | ||
19 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
20 | * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
21 | * | ||
22 | * By copying, modifying or distributing this software, you acknowledge | ||
23 | * that you have read and understood your obligations described above, | ||
24 | * and agree to abide by those obligations. | ||
25 | * | ||
26 | * ALL SOURCE CODE IS PROVIDED "AS IS." THE AUTHOR MAKES NO | ||
27 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
28 | * COMPLETENESS OR PERFORMANCE. | ||
29 | * $/LicenseInfo$ | ||
30 | */ | ||
8 | 31 | ||
9 | #include "llviewerprecompiledheaders.h" | 32 | #include "llviewerprecompiledheaders.h" |
10 | 33 | ||
11 | #include "floatergridmanager.h" | 34 | #include "floatergridmanager.h" |
12 | 35 | ||
13 | #include <boost/algorithm/string.hpp> | 36 | #include <boost/algorithm/string.hpp> |
37 | #include "floatergriddefault.h" | ||
14 | #include "llviewercontrol.h" | 38 | #include "llviewercontrol.h" |
15 | #include "llcombobox.h" | 39 | #include "llcombobox.h" |
16 | #include "llscrolllistctrl.h" | 40 | #include "llscrolllistctrl.h" |
17 | #include "llmd5.h" | 41 | #include "llmd5.h" |
42 | #include "llnotifications.h" | ||
18 | #include "llurlsimstring.h" | 43 | #include "llurlsimstring.h" |
19 | #include "lluictrlfactory.h" | 44 | #include "lluictrlfactory.h" |
20 | #include "hippogridmanager.h" | 45 | #include "hippogridmanager.h" |
21 | #include "llviewernetwork.h" | 46 | #include "llviewernetwork.h" |
22 | #include "llpanellogin.h" | 47 | #include "llpanellogin.h" |
23 | 48 | ||
24 | #define PASSWORD_FILLER "123456789!123456" | 49 | const std::string PASSWORD_FILLER = "123456789!123456"; |
25 | 50 | //bool FloaterGridManager::sIsInitialLogin; | |
26 | LoginController* FloaterGridManager::sController = NULL; | ||
27 | bool FloaterGridManager::sIsInitialLogin; | ||
28 | std::string FloaterGridManager::sGrid; | ||
29 | 51 | ||
30 | FloaterGridManager::FloaterGridManager(const LLSD& key) | 52 | FloaterGridManager::FloaterGridManager(const LLSD& key) |
31 | : mState(NORMAL), | 53 | : |
32 | mCurGrid(gHippoGridManager->getCurrentGridNick()), | 54 | mState(GRID_STATE_NORMAL), |
33 | mIncomingPassword(""), | 55 | mCurGrid(""), |
34 | mMungedPassword("") | 56 | mMungedPassword("") |
35 | { | 57 | { |
36 | llinfos << "Opening grid manager" << llendl; | 58 | llinfos << "Opening grid manager" << llendl; |
37 | 59 | ||
38 | LLUICtrlFactory::getInstance()->buildFloater(this, "floater_grid_manager.xml"); | 60 | LLUICtrlFactory::getInstance()->buildFloater(this, "floater_grid_manager.xml"); |
39 | center(); | 61 | center(); |
40 | |||
41 | LLLineEditor* edit = getChild<LLLineEditor>("avatar_password_edit"); | ||
42 | if (edit) | ||
43 | { | ||
44 | edit->setDrawAsterixes(TRUE); | ||
45 | } | ||
46 | } | 62 | } |
47 | 63 | ||
48 | |||
49 | FloaterGridManager::~FloaterGridManager() | 64 | FloaterGridManager::~FloaterGridManager() |
50 | { | 65 | { |
51 | FloaterGridManager::sController = NULL; | ||
52 | } | 66 | } |
53 | 67 | ||
54 | BOOL FloaterGridManager::postBuild() | 68 | BOOL FloaterGridManager::postBuild() |
@@ -64,105 +78,117 @@ BOOL FloaterGridManager::postBuild() | |||
64 | childSetAction("btn_copy", onClickCopy, this); | 78 | childSetAction("btn_copy", onClickCopy, this); |
65 | childSetAction("btn_ok", onClickOk, this); | 79 | childSetAction("btn_ok", onClickOk, this); |
66 | childSetAction("btn_apply", onClickApply, this); | 80 | childSetAction("btn_apply", onClickApply, this); |
67 | // childSetAction("set_default", onClickDefault, this); // We use the last selected grid as the default | ||
68 | childSetAction("btn_cancel", onClickCancel, this); | 81 | childSetAction("btn_cancel", onClickCancel, this); |
69 | childSetAction("btn_clear", onClickClear, this); | 82 | childSetAction("btn_clear", onClickClear, this); |
70 | childSetAction("btn_gridinfo", onClickGridInfo, this); | 83 | childSetAction("btn_gridinfo", onClickGridInfo, this); |
71 | // childSetAction("btn_help_render_compat", onClickHelpRenderCompat, this); // Ugly ugly ugly | ||
72 | 84 | ||
73 | childSetCommitCallback("grid_selector", onSelectGrid, this); | 85 | childSetCommitCallback("grid_selector", onSelectGrid, this); |
74 | LLScrollListCtrl* combo = getChild<LLScrollListCtrl>("grid_selector"); | 86 | LLScrollListCtrl* combo = getChild<LLScrollListCtrl>("grid_selector"); |
75 | combo->setFocus(TRUE); | 87 | combo->setFocus(TRUE); |
76 | 88 | ||
89 | clearGridInfo(true); | ||
90 | |||
77 | refreshGrids(); | 91 | refreshGrids(); |
78 | 92 | ||
79 | return TRUE; | 93 | // We use the last selected grid as the default |
80 | } | 94 | HippoGridInfo* first_selected = gHippoGridManager->getGrid(mCurGrid); |
95 | if (first_selected) | ||
96 | { | ||
97 | getChild<LLLineEditor>("first_name")->setVisible(!first_selected->isUsernameCompat()); | ||
98 | getChild<LLLineEditor>("last_name")->setVisible(!first_selected->isUsernameCompat()); | ||
99 | getChild<LLLineEditor>("username")->setVisible(first_selected->isUsernameCompat()); | ||
100 | } | ||
101 | getChild<LLLineEditor>("gridnick")->setEnabled(false); | ||
81 | 102 | ||
82 | void FloaterGridManager::clearInfo() | 103 | return TRUE; |
83 | { | ||
84 | //getChild<LLScrollListCtrl>("grid_selector")->clear(); | ||
85 | //getChild<LLLineEditor>("gridnick")->clear(); | ||
86 | //getChild<LLLineEditor>("gridname")->clear(); | ||
87 | //getChild<LLLineEditor>("loginuri")->clear(); | ||
88 | getChild<LLLineEditor>("loginpage")->clear(); | ||
89 | getChild<LLLineEditor>("helperuri")->clear(); | ||
90 | getChild<LLLineEditor>("website")->clear(); | ||
91 | getChild<LLLineEditor>("support")->clear(); | ||
92 | getChild<LLLineEditor>("register")->clear(); | ||
93 | getChild<LLLineEditor>("password")->clear(); | ||
94 | //getChild<LLLineEditor>("first_name")->clear(); | ||
95 | //getChild<LLLineEditor>("last_name")->clear(); | ||
96 | //getChild<LLLineEditor>("avatar_password")->clear(); | ||
97 | getChild<LLLineEditor>("search")->clear(); | ||
98 | //getChild<LLButton>("btn_delete"); | ||
99 | //getChild<LLButton>("btn_add") | ||
100 | //getChild<LLButton>("btn_copy"); | ||
101 | //getChild<LLButton>("set_default")->setEnabled(FALSE); | ||
102 | getChild<LLButton>("btn_gridinfo")->setEnabled(TRUE); | ||
103 | //getChild<LLButton>("btn_clear"); | ||
104 | //getChild<LLButton>("btn_help_render_compat")->setEnabled(FALSE); | ||
105 | } | 104 | } |
106 | 105 | ||
107 | void FloaterGridManager::draw() | 106 | void FloaterGridManager::draw() |
108 | { | 107 | { |
109 | refresh(); | 108 | refresh(); |
110 | |||
111 | LLFloater::draw(); | 109 | LLFloater::draw(); |
112 | } | 110 | } |
113 | 111 | ||
114 | void FloaterGridManager::refresh() | 112 | void FloaterGridManager::refresh() |
115 | { | 113 | { |
116 | //TODO: these should just be set in a prompt | 114 | //TODO: new grid creation should just be set in a popup |
117 | bool can_edit = (!getChild<LLLineEditor>("gridnick")->getText().empty() && | 115 | bool can_edit = (!(getChild<LLLineEditor>("gridnick")->getText().empty()) && |
118 | !getChild<LLLineEditor>("loginuri")->getText().empty() && | 116 | !(getChild<LLLineEditor>("gridname")->getText().empty()) && |
119 | getChild<LLLineEditor>("gridnick")->getText() != "<required>" && | 117 | !(getChild<LLLineEditor>("loginuri")->getText().empty())); |
120 | getChild<LLLineEditor>("loginuri")->getText() != "<required>"); | ||
121 | 118 | ||
122 | //getChild<LLLineEditor>("gridname"); | ||
123 | getChild<LLLineEditor>("loginpage")->setEnabled(can_edit); | 119 | getChild<LLLineEditor>("loginpage")->setEnabled(can_edit); |
124 | getChild<LLLineEditor>("helperuri")->setEnabled(can_edit); | 120 | getChild<LLLineEditor>("helperuri")->setEnabled(can_edit); |
125 | getChild<LLLineEditor>("website")->setEnabled(can_edit); | 121 | getChild<LLLineEditor>("website")->setEnabled(can_edit); |
126 | getChild<LLLineEditor>("support")->setEnabled(can_edit); | 122 | getChild<LLLineEditor>("support")->setEnabled(can_edit); |
127 | getChild<LLLineEditor>("register")->setEnabled(can_edit); | 123 | getChild<LLLineEditor>("register")->setEnabled(can_edit); |
128 | getChild<LLLineEditor>("password")->setEnabled(can_edit); | 124 | getChild<LLLineEditor>("password")->setEnabled(can_edit); |
129 | //getChild<LLLineEditor>("first_name")->setEnabled(can_edit); | 125 | getChild<LLLineEditor>("first_name")->setEnabled(can_edit); |
130 | //getChild<LLLineEditor>("last_name")->setEnabled(can_edit); | 126 | getChild<LLLineEditor>("last_name")->setEnabled(can_edit); |
131 | //getChild<LLLineEditor>("avatar_password")->setEnabled(can_edit); | 127 | getChild<LLLineEditor>("username")->setEnabled(can_edit); |
128 | getChild<LLLineEditor>("avatar_password")->setEnabled(can_edit); | ||
132 | getChild<LLLineEditor>("search")->setEnabled(can_edit); | 129 | getChild<LLLineEditor>("search")->setEnabled(can_edit); |
133 | getChild<LLButton>("btn_delete")->setEnabled(can_edit); | 130 | getChild<LLButton>("btn_delete")->setEnabled(can_edit); |
134 | //getChild<LLButton>("btn_add") | ||
135 | //getChild<LLButton>("btn_copy")->setEnabled(can_edit); | 131 | //getChild<LLButton>("btn_copy")->setEnabled(can_edit); |
136 | //getChild<LLButton>("set_default")->setEnabled(can_dit); | ||
137 | getChild<LLButton>("btn_gridinfo")->setEnabled(can_edit); | 132 | getChild<LLButton>("btn_gridinfo")->setEnabled(can_edit); |
138 | getChild<LLButton>("btn_clear")->setEnabled(can_edit); | 133 | getChild<LLButton>("btn_clear")->setEnabled(can_edit); |
139 | //getChild<LLButton>("btn_help_render_compat")->setEnabled(can_edit); | 134 | |
135 | getChild<LLTextBox>("loginpage_text")->setEnabled(can_edit); | ||
136 | getChild<LLTextBox>("helperuri_text")->setEnabled(can_edit); | ||
137 | getChild<LLTextBox>("website_text")->setEnabled(can_edit); | ||
138 | getChild<LLTextBox>("support_text")->setEnabled(can_edit); | ||
139 | getChild<LLTextBox>("register_text")->setEnabled(can_edit); | ||
140 | getChild<LLTextBox>("password_text")->setEnabled(can_edit); | ||
141 | getChild<LLTextBox>("first_name_text")->setEnabled(can_edit); | ||
142 | getChild<LLTextBox>("last_name_text")->setEnabled(can_edit); | ||
143 | getChild<LLTextBox>("username_text")->setEnabled(can_edit); | ||
144 | getChild<LLTextBox>("avatar_password_text")->setEnabled(can_edit); | ||
145 | getChild<LLTextBox>("search_text")->setEnabled(can_edit); | ||
140 | } | 146 | } |
141 | 147 | ||
142 | void FloaterGridManager::refreshGrids() | 148 | void FloaterGridManager::refreshGrids() |
143 | { | 149 | { |
144 | LLScrollListCtrl *grids = FloaterGridManager::getInstance()->getChild<LLScrollListCtrl>("grid_selector"); | 150 | // no need to update the list while editing |
151 | if (FloaterGridManager::getInstance()->getGridState() >= GRID_STATE_NEW) | ||
152 | { | ||
153 | return; | ||
154 | } | ||
155 | |||
156 | LLScrollListCtrl* grid_list = FloaterGridManager::getInstance()->getChild<LLScrollListCtrl>("grid_selector"); | ||
145 | std::string lastSelectedItem; | 157 | std::string lastSelectedItem; |
146 | LLSD element; | 158 | LLSD element; |
147 | 159 | ||
148 | if (grids->getFirstSelected()) | 160 | if (grid_list->getFirstSelected()) |
149 | { | 161 | { |
150 | lastSelectedItem = grids->getFirstSelected()->getValue().asString(); | 162 | // grid NICK |
163 | lastSelectedItem = grid_list->getFirstSelected()->getColumn(0)->getValue().asString(); | ||
151 | } | 164 | } |
152 | 165 | ||
153 | grids->deleteAllItems(); | 166 | grid_list->deleteAllItems(); |
154 | 167 | ||
155 | for (HippoGridManager::GridIterator it = gHippoGridManager->beginGrid(); it != gHippoGridManager->endGrid(); ++it) | 168 | // Grids should really have UUIDs, but we'll use their nicks to keep track of 'em instead |
169 | for (HippoGridManager::GridIterator it = gHippoGridManager->beginGrid(); | ||
170 | it != gHippoGridManager->endGrid(); ++it) | ||
156 | { | 171 | { |
157 | std::string grid_nick = it->second->getGridNick(); | 172 | std::string grid_nick = it->second->getGridNick(); |
158 | // There's no reason why empty grids nicks should be in this list, ugh | 173 | |
159 | if (!grid_nick.empty() && grid_nick != gHippoGridManager->getCurrentGridNick()) | 174 | if (grid_nick.empty()) |
175 | { | ||
176 | // shouldn't ever happen | ||
177 | continue; | ||
178 | } | ||
179 | |||
180 | // Note: default sorted by grid NAME in the XUI | ||
181 | if (grid_nick != gHippoGridManager->getCurrentGridNick()) | ||
160 | { | 182 | { |
161 | element["id"] = grid_nick; | 183 | element["id"] = grid_nick; |
162 | element["columns"][0]["column"] = "grid"; | 184 | element["columns"][0]["column"] = "grid_nick"; |
163 | element["columns"][0]["type"] = "text"; | 185 | element["columns"][0]["type"] = "text"; |
164 | element["columns"][0]["value"] = grid_nick; | 186 | element["columns"][0]["value"] = grid_nick; |
165 | grids->addElement(element, ADD_BOTTOM); | 187 | element["columns"][1]["column"] = "grid_name"; |
188 | element["columns"][1]["type"] = "text"; | ||
189 | element["columns"][1]["value"] = it->second->getGridName(); | ||
190 | |||
191 | grid_list->addElement(element, ADD_BOTTOM); | ||
166 | } | 192 | } |
167 | } | 193 | } |
168 | 194 | ||
@@ -172,368 +198,359 @@ void FloaterGridManager::refreshGrids() | |||
172 | if (!gHippoGridManager->getCurrentGridNick().empty()) | 198 | if (!gHippoGridManager->getCurrentGridNick().empty()) |
173 | { | 199 | { |
174 | element["id"] = gHippoGridManager->getCurrentGridNick(); | 200 | element["id"] = gHippoGridManager->getCurrentGridNick(); |
175 | element["columns"][0]["column"] = "grid"; | 201 | element["columns"][0]["column"] = "grid_nick"; |
176 | element["columns"][0]["type"] = "text"; | 202 | element["columns"][0]["type"] = "text"; |
177 | element["columns"][0]["font-style"] = "BOLD"; | 203 | element["columns"][0]["font-style"] = "BOLD"; |
178 | element["columns"][0]["value"] = gHippoGridManager->getCurrentGridNick(); | 204 | element["columns"][0]["value"] = gHippoGridManager->getCurrentGridNick(); |
179 | grids->addElement(element, ADD_TOP); | 205 | element["columns"][1]["column"] = "grid_name"; |
206 | element["columns"][1]["type"] = "text"; | ||
207 | element["columns"][1]["value"] = gHippoGridManager->getCurrentGrid()->getGridName(); | ||
208 | |||
209 | grid_list->addElement(element, ADD_TOP); | ||
180 | } | 210 | } |
181 | 211 | ||
182 | // Reselect the item if we had one selected | 212 | // Reselect the item if we had one selected |
183 | if (lastSelectedItem.empty()) | 213 | if (lastSelectedItem.empty()) |
184 | { | 214 | { |
185 | grids->selectItemByLabel(gHippoGridManager->getCurrentGridNick()); | 215 | grid_list->selectItemByLabel(gHippoGridManager->getCurrentGridNick()); |
216 | FloaterGridManager::getInstance()->setCurGrid(gHippoGridManager->getCurrentGridNick()); | ||
186 | } | 217 | } |
187 | else | 218 | else |
188 | { | 219 | { |
189 | grids->selectItemByLabel(lastSelectedItem); | 220 | grid_list->selectItemByLabel(lastSelectedItem); |
190 | } | 221 | FloaterGridManager::getInstance()->setCurGrid(lastSelectedItem); |
191 | |||
192 | // TODO: get rid of all this state junk | ||
193 | if ((FloaterGridManager::getInstance()->getState() == ADD_NEW) || (FloaterGridManager::getInstance()->getState() == ADD_COPY)) | ||
194 | { | ||
195 | grids->addElement("<new>", ADD_BOTTOM); | ||
196 | } | 222 | } |
197 | 223 | ||
198 | //if (selectIndex >= 0) | 224 | //if (selectIndex >= 0) |
199 | //{ | 225 | //{ |
200 | // grids->setCurrentByIndex(selectIndex); | 226 | // grid_list->setCurrentByIndex(selectIndex); |
201 | //} | 227 | //} |
202 | //else | 228 | //else |
203 | //{ | 229 | //{ |
204 | // grids->setLabel(LLStringExplicit("")); // LLComboBox::removeall() does not clear the label | 230 | // grid_list->setLabel(LLStringExplicit("")); // LLComboBox::removeall() does not clear the label |
205 | //} | 231 | //} |
206 | |||
207 | // FloaterGridManager::getInstance()->childSetTextArg("default_grid", "[DEFAULT]", (defaultGrid != "")? defaultGrid: " "); | ||
208 | 232 | ||
209 | FloaterGridManager::getInstance()->childSetEnabled("btn_delete", grids->getItemCount() > 0); | 233 | FloaterGridManager::getInstance()->childSetEnabled("btn_delete", grid_list->getItemCount() > 0); |
234 | FloaterGridManager::getInstance()->childSetEnabled("btn_copy", grid_list->getItemCount() > 0); | ||
210 | 235 | ||
211 | FloaterGridManager::getInstance()->childSetEnabled("btn_copy", (FloaterGridManager::getInstance()->getState() == NORMAL) && (grids->getItemCount() > 0)); | 236 | HippoGridInfo *gridInfo = gHippoGridManager->getGrid(FloaterGridManager::getInstance()->mCurGrid); |
212 | // FloaterGridManager::getInstance()->childSetEnabled("set_default", (FloaterGridManager::getInstance()->getState() == NORMAL) && (grids->getItemCount() > 0)); | 237 | if (gridInfo) |
213 | FloaterGridManager::getInstance()->childSetEnabled("gridnick", (FloaterGridManager::getInstance()->getState() == ADD_NEW) || (FloaterGridManager::getInstance()->getState() == ADD_COPY)); | ||
214 | |||
215 | if (FloaterGridManager::getInstance()->getState() == NORMAL) | ||
216 | { | 238 | { |
217 | HippoGridInfo *gridInfo = gHippoGridManager->getGrid(FloaterGridManager::getInstance()->getCurGrid()); | 239 | // Remember: NEVER let users change an existing grid's nick. Bad juju awaits if you do |
218 | if (gridInfo) | 240 | FloaterGridManager::getInstance()->getChild<LLLineEditor>("gridnick")->setText(gridInfo->getGridNick()); |
241 | FloaterGridManager::getInstance()->getChild<LLLineEditor>("gridname")->setText(gridInfo->getGridName()); | ||
242 | |||
243 | FloaterGridManager::getInstance()->getChild<LLLineEditor>("loginuri")->setText(gridInfo->getLoginURI()); | ||
244 | FloaterGridManager::getInstance()->getChild<LLLineEditor>("loginpage")->setText(gridInfo->getLoginPage()); | ||
245 | FloaterGridManager::getInstance()->getChild<LLLineEditor>("helperuri")->setText(gridInfo->getHelperURI()); | ||
246 | FloaterGridManager::getInstance()->getChild<LLLineEditor>("website")->setText(gridInfo->getWebSite()); | ||
247 | FloaterGridManager::getInstance()->getChild<LLLineEditor>("support")->setText(gridInfo->getSupportURL()); | ||
248 | FloaterGridManager::getInstance()->getChild<LLLineEditor>("register")->setText(gridInfo->getRegisterURL()); | ||
249 | FloaterGridManager::getInstance()->getChild<LLLineEditor>("password")->setText(gridInfo->getPasswordURL()); | ||
250 | FloaterGridManager::getInstance()->getChild<LLLineEditor>("first_name")->setText(gridInfo->getFirstName()); | ||
251 | FloaterGridManager::getInstance()->getChild<LLLineEditor>("last_name")->setText(gridInfo->getLastName()); | ||
252 | FloaterGridManager::getInstance()->getChild<LLLineEditor>("username")->setText(gridInfo->getUsername()); | ||
253 | FloaterGridManager::getInstance()->getChild<LLLineEditor>("avatar_password")->setText(gridInfo->getAvatarPassword()); | ||
254 | |||
255 | FloaterGridManager::getInstance()->getChild<LLLineEditor>("first_name")->setVisible(!gridInfo->isUsernameCompat()); | ||
256 | FloaterGridManager::getInstance()->getChild<LLTextBox>("first_name_text")->setVisible(!gridInfo->isUsernameCompat()); | ||
257 | FloaterGridManager::getInstance()->getChild<LLLineEditor>("last_name")->setVisible(!gridInfo->isUsernameCompat()); | ||
258 | FloaterGridManager::getInstance()->getChild<LLTextBox>("last_name_text")->setVisible(!gridInfo->isUsernameCompat()); | ||
259 | FloaterGridManager::getInstance()->getChild<LLLineEditor>("username")->setVisible(gridInfo->isUsernameCompat()); | ||
260 | FloaterGridManager::getInstance()->getChild<LLTextBox>("username_text")->setVisible(gridInfo->isUsernameCompat()); | ||
261 | |||
262 | if (gridInfo->getPlatform() == HippoGridInfo::PLATFORM_SECONDLIFE) | ||
219 | { | 263 | { |
220 | FloaterGridManager::getInstance()->childSetText("gridnick", gridInfo->getGridNick()); | 264 | FloaterGridManager::getInstance()->childSetEnabled("search", false); |
221 | //FloaterGridManager::getInstance()->childSetText("grid_name", gridInfo->getGridName()); | 265 | FloaterGridManager::getInstance()->getChild<LLLineEditor>("search")->setText(LLStringExplicit("")); |
222 | FloaterGridManager::getInstance()->childSetText("loginuri", gridInfo->getLoginUri()); | 266 | } |
223 | FloaterGridManager::getInstance()->childSetText("loginpage", gridInfo->getLoginPage()); | ||
224 | FloaterGridManager::getInstance()->childSetText("helperuri", gridInfo->getHelperUri()); | ||
225 | FloaterGridManager::getInstance()->childSetText("website", gridInfo->getWebSite()); | ||
226 | FloaterGridManager::getInstance()->childSetText("support", gridInfo->getSupportUrl()); | ||
227 | FloaterGridManager::getInstance()->childSetText("register", gridInfo->getRegisterUrl()); | ||
228 | FloaterGridManager::getInstance()->childSetText("password", gridInfo->getPasswordUrl()); | ||
229 | |||
230 | // FloaterGridManager::getInstance()->childSetText("first_name", gridInfo->getFirstName()); | ||
231 | // FloaterGridManager::getInstance()->childSetText("last_name", gridInfo->getLastName()); | ||
232 | // if(gridInfo->getAvatarPassword().length() == 32) | ||
233 | // FloaterGridManager::getInstance()->childSetText("avatar_password", std::string(PASSWORD_FILLER)); | ||
234 | // else if(gridInfo->getPasswordUrl().empty()) | ||
235 | // FloaterGridManager::getInstance()->childSetText("avatar_password", std::string("")); | ||
236 | |||
237 | if (gridInfo->getPlatform() == HippoGridInfo::PLATFORM_SECONDLIFE) | ||
238 | { | ||
239 | FloaterGridManager::getInstance()->childSetEnabled("search", false); | ||
240 | FloaterGridManager::getInstance()->childSetText("search", LLStringUtil::null); | ||
241 | //childSetEnabled("render_compat", false); | ||
242 | //childSetValue("render_compat", false); | ||
243 | } | ||
244 | else | ||
245 | { | ||
246 | FloaterGridManager::getInstance()->childSetEnabled("search", true); | ||
247 | FloaterGridManager::getInstance()->childSetText("search", gridInfo->getSearchUrl()); | ||
248 | //childSetEnabled("render_compat", true); | ||
249 | //childSetValue("render_compat", gridInfo->isRenderCompat()); | ||
250 | } | ||
251 | |||
252 | } | ||
253 | else | 267 | else |
254 | { | 268 | { |
255 | FloaterGridManager::getInstance()->childSetText("gridnick", LLStringUtil::null); | 269 | FloaterGridManager::getInstance()->childSetEnabled("search", true); |
256 | FloaterGridManager::getInstance()->childSetText("gridname", LLStringUtil::null); | 270 | FloaterGridManager::getInstance()->getChild<LLLineEditor>("search")->setText(gridInfo->getSearchURL()); |
257 | FloaterGridManager::getInstance()->childSetText("loginuri", LLStringUtil::null); | 271 | } |
258 | FloaterGridManager::getInstance()->childSetText("loginpage", LLStringUtil::null); | 272 | } |
259 | FloaterGridManager::getInstance()->childSetText("helperuri", LLStringUtil::null); | ||
260 | FloaterGridManager::getInstance()->childSetText("website", LLStringUtil::null); | ||
261 | FloaterGridManager::getInstance()->childSetText("support", LLStringUtil::null); | ||
262 | FloaterGridManager::getInstance()->childSetText("register", LLStringUtil::null); | ||
263 | FloaterGridManager::getInstance()->childSetText("password", LLStringUtil::null); | ||
264 | // FloaterGridManager::getInstance()->childSetText("first_name", LLStringUtil::null); | ||
265 | // FloaterGridManager::getInstance()->childSetText("last_name", LLStringUtil::null); | ||
266 | // FloaterGridManager::getInstance()->childSetText("avatar_password", LLStringUtil::null); | ||
267 | FloaterGridManager::getInstance()->childSetText("search", LLStringUtil::null); | ||
268 | } | ||
269 | } | ||
270 | else if (FloaterGridManager::getInstance()->getState() == ADD_NEW) | ||
271 | { | ||
272 | llinfos << "mState == ADD_NEW" << llendl; | ||
273 | std::string required = "<required>"; | ||
274 | FloaterGridManager::getInstance()->childSetText("gridnick", required); | ||
275 | FloaterGridManager::getInstance()->childSetText("gridname", LLStringUtil::null); | ||
276 | FloaterGridManager::getInstance()->childSetText("loginuri", required); | ||
277 | FloaterGridManager::getInstance()->childSetText("loginpage", LLStringUtil::null); | ||
278 | FloaterGridManager::getInstance()->childSetText("helperuri", LLStringUtil::null); | ||
279 | FloaterGridManager::getInstance()->childSetText("website", LLStringUtil::null); | ||
280 | FloaterGridManager::getInstance()->childSetText("support", LLStringUtil::null); | ||
281 | FloaterGridManager::getInstance()->childSetText("register", LLStringUtil::null); | ||
282 | FloaterGridManager::getInstance()->childSetText("password", LLStringUtil::null); | ||
283 | // FloaterGridManager::getInstance()->childSetText("first_name", LLStringUtil::null); | ||
284 | // FloaterGridManager::getInstance()->childSetText("last_name", LLStringUtil::null); | ||
285 | // FloaterGridManager::getInstance()->childSetText("avatar_password", LLStringUtil::null); | ||
286 | //childSetEnabled("search", true); | ||
287 | FloaterGridManager::getInstance()->childSetText("search", LLStringUtil::null); | ||
288 | } | ||
289 | else if (FloaterGridManager::getInstance()->getState() == ADD_COPY) | ||
290 | { | ||
291 | llinfos << "mState == ADD_COPY" << llendl; | ||
292 | FloaterGridManager::getInstance()->childSetText("gridnick", LLStringExplicit("<required>")); | ||
293 | } | ||
294 | else | 273 | else |
295 | { | 274 | { |
296 | llwarns << "Illegal state " << FloaterGridManager::getInstance()->getState() << llendl; | 275 | // should never happen, but if so default to creating a new entry |
276 | FloaterGridManager::getInstance()->setupNewGridEntry(); | ||
297 | } | 277 | } |
298 | return; | 278 | } |
299 | } | ||
300 | 279 | ||
301 | void FloaterGridManager::update() | 280 | void FloaterGridManager::update() |
302 | { | 281 | { |
303 | setState(NORMAL); | 282 | // no need to update the list until we need to |
304 | setCurGrid(gHippoGridManager->getCurrentGridNick()); | 283 | if (getGridState() >= GRID_STATE_NEW) |
284 | { | ||
285 | return; | ||
286 | } | ||
305 | refreshGrids(); | 287 | refreshGrids(); |
306 | //KOW gHippoLimits->setLimits(); | ||
307 | } | 288 | } |
308 | 289 | ||
309 | void FloaterGridManager::applyChanges() | 290 | void FloaterGridManager::applyChanges() |
310 | { | 291 | { |
311 | HippoGridInfo* gridInfo = gHippoGridManager->getGrid(mCurGrid); | 292 | // When we apply changes, we update based on the state |
312 | if (gridInfo) | 293 | // of the UI. This is ugly and could really be improved |
294 | |||
295 | // Note: nick and loginuri are required | ||
296 | std::string grid_nick = childGetValue("gridnick").asString(); | ||
297 | if (grid_nick.empty()) | ||
298 | { | ||
299 | LLNotifications::instance().add("GridsNoNick"); | ||
300 | return; | ||
301 | } | ||
302 | |||
303 | if (childGetValue("loginuri").asString().empty()) | ||
304 | { | ||
305 | LLSD args; | ||
306 | args["[NAME]"] = grid_nick; | ||
307 | LLNotifications::instance().add("GridsNoLoginURI", args); | ||
308 | return ; | ||
309 | } | ||
310 | |||
311 | HippoGridInfo* grid = NULL; | ||
312 | |||
313 | // Note: we disable the scroll list during grid creation to prevent conflicts | ||
314 | if (getGridState() == GRID_STATE_NEW || getGridState() == GRID_STATE_COPY) | ||
313 | { | 315 | { |
314 | if (gridInfo->getGridNick() == childGetValue("gridnick").asString()) | 316 | if (gHippoGridManager->hasGridNick(grid_nick)) |
315 | { | 317 | { |
316 | gridInfo->setGridName(childGetValue("gridname")); | 318 | LLSD args; |
317 | gridInfo->setLoginUri(childGetValue("loginuri")); | 319 | args["[NAME]"] = grid_nick; |
318 | gridInfo->setLoginPage(childGetValue("loginpage")); | 320 | LLNotifications::instance().add("GridExists", args); |
319 | gridInfo->setHelperUri(childGetValue("helperuri")); | 321 | return; |
320 | gridInfo->setWebSite(childGetValue("website")); | 322 | } |
321 | gridInfo->setSupportUrl(childGetValue("support")); | 323 | else |
322 | gridInfo->setRegisterUrl(childGetValue("register")); | ||
323 | gridInfo->setPasswordUrl(childGetValue("password")); | ||
324 | gridInfo->setSearchUrl(childGetValue("search")); | ||
325 | gridInfo->setRenderCompat(childGetValue("render_compat")); | ||
326 | |||
327 | // gridInfo->setFirstName(childGetValue("first_name")); | ||
328 | // gridInfo->setLastName(childGetValue("last_name")); | ||
329 | // if(childGetValue("avatar_password").asString().empty()) | ||
330 | // gridInfo->setAvatarPassword(std::string("")); | ||
331 | // else if(childGetValue("avatar_password").asString() != std::string(PASSWORD_FILLER)) | ||
332 | // { | ||
333 | // // store account authentication data | ||
334 | // std::string auth_password = childGetValue("avatar_password"); | ||
335 | // std::string hashed_password; | ||
336 | // hashPassword(auth_password, hashed_password); | ||
337 | // gridInfo->setAvatarPassword(hashed_password); | ||
338 | // } | ||
339 | |||
340 | //this bug was a feature -Patrick Sapinski (Friday, August 21, 2009) | ||
341 | //LLPanelLogin::setFields(gridInfo->getFirstName(), gridInfo->getLastName(), | ||
342 | // gridInfo->getAvatarPassword(), true); | ||
343 | } | ||
344 | else | ||
345 | { | 324 | { |
346 | llwarns << "Grid nickname mismatch, ignoring changes." << llendl; | 325 | grid = new HippoGridInfo(grid_nick); |
326 | } | ||
327 | } | ||
328 | else // updating grid | ||
329 | { | ||
330 | if (!gHippoGridManager->hasGridNick(grid_nick)) | ||
331 | { | ||
332 | llwarns << "Can't update info for a grid we don't know, ignoring changes." << llendl; | ||
333 | return; | ||
334 | } | ||
335 | else | ||
336 | { | ||
337 | grid = gHippoGridManager->getGrid(grid_nick); | ||
347 | } | 338 | } |
348 | } | 339 | } |
349 | } | ||
350 | 340 | ||
341 | grid->setGridName(childGetValue("gridname")); | ||
342 | grid->setLoginURI(childGetValue("loginuri")); | ||
343 | grid->setLoginPage(childGetValue("loginpage")); | ||
344 | grid->setHelperURI(childGetValue("helperuri")); | ||
345 | grid->setWebSite(childGetValue("website")); | ||
346 | grid->setSupportURL(childGetValue("support")); | ||
347 | grid->setRegisterURL(childGetValue("register")); | ||
348 | grid->setPasswordURL(childGetValue("password")); | ||
349 | grid->setSearchURL(childGetValue("search")); | ||
350 | grid->setFirstName(childGetValue("first_name")); | ||
351 | grid->setLastName(childGetValue("last_name")); | ||
352 | grid->setUsername(childGetValue("username")); | ||
353 | |||
354 | // don't allow users to set their password as PASSWORD_FILLER | ||
355 | // would be nice to get grid-specific rules on password formatting, too | ||
356 | // passwords are remembered by default | ||
357 | std::string password_new = childGetValue("avatar_password").asString(); | ||
358 | std::string password_old = grid->getAvatarPassword(); // initialized to "" | ||
359 | if (!password_new.empty() && password_new != PASSWORD_FILLER && password_new != password_old) | ||
360 | { | ||
361 | // store account authentication data | ||
362 | std::string hashed_password; | ||
363 | hashPassword(password_new, hashed_password); | ||
364 | grid->setAvatarPassword(hashed_password); | ||
365 | } | ||
351 | 366 | ||
352 | bool FloaterGridManager::createNewGrid() | 367 | FloaterGridManager::getInstance()->getChild<LLScrollListCtrl>("grid_selector")->setEnabled(true); |
353 | { | 368 | FloaterGridManager::getInstance()->getChild<LLLineEditor>("gridnick")->setEnabled(false); |
354 | // check nickname | 369 | |
355 | std::string gridnick = childGetValue("gridnick"); | 370 | if (getGridState() == GRID_STATE_NEW || getGridState() == GRID_STATE_COPY) |
356 | if (gridnick == "<required>") | ||
357 | { | 371 | { |
358 | gridnick = ""; | 372 | gHippoGridManager->addGrid(grid); |
373 | refreshGrids(); | ||
374 | FloaterGridManager::getInstance()->getChild<LLScrollListCtrl>("grid_selector")->selectByValue(LLSD(grid_nick)); | ||
359 | } | 375 | } |
360 | 376 | ||
361 | if (gridnick.empty()) | 377 | // just in case |
378 | gHippoGridManager->setCurrentGrid(grid_nick); | ||
379 | |||
380 | // should this be settable? | ||
381 | if (grid->isUsernameCompat()) | ||
362 | { | 382 | { |
363 | LLNotifications::instance().add("GridsNoNick"); | 383 | LLPanelLogin::setFields(grid->getUsername(), grid->getAvatarPassword()); |
364 | return false; | ||
365 | } | 384 | } |
366 | 385 | else | |
367 | if (gHippoGridManager->getGrid(gridnick)) | ||
368 | { | 386 | { |
369 | LLSD args; | 387 | LLPanelLogin::setFields(grid->getFirstName(), grid->getLastName(), grid->getAvatarPassword()); |
370 | args["[NAME]"] = gridnick; | ||
371 | LLNotifications::instance().add("GridExists", args); | ||
372 | return false; | ||
373 | } | 388 | } |
374 | 389 | ||
375 | // check login URI | 390 | if (FloaterGridDefault::instanceVisible()) |
376 | std::string loginuri = childGetValue("loginuri"); | ||
377 | if ((loginuri.empty()) || (loginuri == "<required>")) | ||
378 | { | 391 | { |
379 | LLSD args; | 392 | FloaterGridDefault::getInstance()->refreshGridList(); |
380 | args["[NAME]"] = gridnick; | ||
381 | LLNotifications::instance().add("GridsNoLoginUri", args); | ||
382 | return false; | ||
383 | } | 393 | } |
384 | 394 | ||
385 | // create new grid | 395 | setGridState(GRID_STATE_NORMAL); |
386 | HippoGridInfo* grid = new HippoGridInfo(gridnick); | ||
387 | grid->setGridName(childGetValue("gridname")); | ||
388 | grid->setLoginUri(loginuri); | ||
389 | grid->setLoginPage(childGetValue("loginpage")); | ||
390 | grid->setHelperUri(childGetValue("helperuri")); | ||
391 | grid->setWebSite(childGetValue("website")); | ||
392 | grid->setSupportUrl(childGetValue("support")); | ||
393 | grid->setRegisterUrl(childGetValue("register")); | ||
394 | grid->setPasswordUrl(childGetValue("password")); | ||
395 | grid->setSearchUrl(childGetValue("search")); | ||
396 | grid->setRenderCompat(childGetValue("render_compat")); | ||
397 | gHippoGridManager->addGrid(grid); | ||
398 | |||
399 | // grid->setFirstName(childGetValue("first_name")); | ||
400 | // grid->setLastName(childGetValue("last_name")); | ||
401 | // if(childGetValue("avatar_password").asString().empty()) | ||
402 | // grid->setAvatarPassword(std::string("")); | ||
403 | // else | ||
404 | // { | ||
405 | // std::string hashed_password; | ||
406 | // hashPassword(childGetValue("avatar_password"), hashed_password); | ||
407 | // grid->setAvatarPassword(hashed_password); | ||
408 | // } | ||
409 | |||
410 | setCurGrid(gridnick); | ||
411 | return true; | ||
412 | } | 396 | } |
413 | 397 | ||
414 | void FloaterGridManager::retrieveGridInfo() | 398 | void FloaterGridManager::clearGridInfo(bool clear_all) |
415 | { | 399 | { |
416 | std::string loginuri = childGetValue("loginuri"); | 400 | if (clear_all) |
417 | if ((loginuri == "") || (loginuri == "<required>")) | 401 | { |
418 | { | 402 | getChild<LLLineEditor>("gridnick")->clear(); |
419 | LLNotifications::instance().add("GridInfoNoLoginUri"); | 403 | getChild<LLLineEditor>("gridname")->clear(); |
420 | return; | 404 | getChild<LLLineEditor>("loginuri")->clear(); |
405 | getChild<LLLineEditor>("password")->clear(); | ||
406 | getChild<LLLineEditor>("first_name")->clear(); | ||
407 | getChild<LLLineEditor>("last_name")->clear(); | ||
408 | getChild<LLLineEditor>("username")->clear(); | ||
409 | getChild<LLLineEditor>("avatar_password")->clear(); | ||
421 | } | 410 | } |
422 | 411 | ||
423 | HippoGridInfo* grid = 0; | 412 | getChild<LLLineEditor>("loginpage")->clear(); |
424 | bool cleanupGrid = false; | 413 | getChild<LLLineEditor>("helperuri")->clear(); |
414 | getChild<LLLineEditor>("website")->clear(); | ||
415 | getChild<LLLineEditor>("support")->clear(); | ||
416 | getChild<LLLineEditor>("register")->clear(); | ||
417 | getChild<LLLineEditor>("search")->clear(); | ||
418 | |||
419 | getChild<LLButton>("btn_gridinfo")->setEnabled(TRUE); | ||
420 | } | ||
425 | 421 | ||
426 | if (mState == NORMAL) | 422 | void FloaterGridManager::createNewGrid() |
423 | { | ||
424 | // warn us if anything's dirty | ||
425 | if (getChild<LLLineEditor>("gridnick")->isDirty() || | ||
426 | getChild<LLLineEditor>("gridname")->isDirty() || | ||
427 | getChild<LLLineEditor>("loginuri")->isDirty() || | ||
428 | getChild<LLLineEditor>("loginpage")->isDirty() || | ||
429 | getChild<LLLineEditor>("helperuri")->isDirty() || | ||
430 | getChild<LLLineEditor>("website")->isDirty() || | ||
431 | getChild<LLLineEditor>("support")->isDirty() || | ||
432 | getChild<LLLineEditor>("register")->isDirty() || | ||
433 | getChild<LLLineEditor>("password")->isDirty() || | ||
434 | getChild<LLLineEditor>("first_name")->isDirty() || | ||
435 | getChild<LLLineEditor>("last_name")->isDirty() || | ||
436 | getChild<LLLineEditor>("username")->isDirty() || | ||
437 | getChild<LLLineEditor>("avatar_password")->isDirty() || | ||
438 | getChild<LLLineEditor>("search")->isDirty()) | ||
439 | { | ||
440 | LLNotifications::instance().add("GridInfoDirty", LLSD(), LLSD(), newGridCreationCallback); | ||
441 | } | ||
442 | else | ||
427 | { | 443 | { |
428 | grid = gHippoGridManager->getGrid(mCurGrid); | 444 | // This clears the form. Until an entry is entered, we keep the UI open and blank |
429 | } | 445 | // This is clearly undesirable if you want to cancel, but redoing this window is |
430 | else if ((mState == ADD_NEW) || (mState == ADD_COPY)) | 446 | // a WIP -- MC |
447 | setupNewGridEntry(); | ||
448 | } | ||
449 | } | ||
450 | |||
451 | void FloaterGridManager::setupNewGridEntry() | ||
452 | { | ||
453 | // disable scroll list until we can use it again | ||
454 | getChild<LLScrollListCtrl>("grid_selector")->setEnabled(false); | ||
455 | |||
456 | getChild<LLLineEditor>("gridnick")->setEnabled(true); | ||
457 | clearGridInfo(true); | ||
458 | |||
459 | setGridState(GRID_STATE_NEW); | ||
460 | } | ||
461 | |||
462 | bool FloaterGridManager::newGridCreationCallback(const LLSD& notification, const LLSD& response) | ||
463 | { | ||
464 | S32 option = LLNotification::getSelectedOption(notification, response); | ||
465 | if (option == 0) | ||
431 | { | 466 | { |
432 | grid = new HippoGridInfo(""); | 467 | FloaterGridManager::getInstance()->setupNewGridEntry(); |
433 | cleanupGrid = true; | 468 | } |
434 | } | 469 | return false; |
435 | else | 470 | } |
471 | |||
472 | void FloaterGridManager::setupCopyGridEntry() | ||
473 | { | ||
474 | // disable scroll list until we can use it again | ||
475 | getChild<LLScrollListCtrl>("grid_selector")->setEnabled(false); | ||
476 | |||
477 | getChild<LLLineEditor>("gridnick")->setEnabled(true); | ||
478 | getChild<LLLineEditor>("gridnick")->clear(); | ||
479 | getChild<LLLineEditor>("gridname")->clear(); | ||
480 | getChild<LLLineEditor>("loginuri")->clear(); | ||
481 | |||
482 | setGridState(GRID_STATE_COPY); | ||
483 | } | ||
484 | |||
485 | void FloaterGridManager::retrieveGridInfo() | ||
486 | { | ||
487 | std::string loginuri = childGetValue("loginuri"); | ||
488 | if (loginuri.empty()) | ||
436 | { | 489 | { |
437 | llerrs << "Illegal state " << mState << '.' << llendl; | 490 | LLNotifications::instance().add("GridInfoNoLoginURI"); |
438 | return; | 491 | return; |
439 | } | 492 | } |
493 | |||
494 | // this can be clicked even for grids we haven't saved yet | ||
495 | HippoGridInfo* grid = gHippoGridManager->getGrid(childGetValue("gridnick")); | ||
496 | bool del_temp_grid = false; | ||
440 | if (!grid) | 497 | if (!grid) |
441 | { | 498 | { |
442 | llerrs << "Internal error retrieving grid info." << llendl; | 499 | // easier than fixing the hippo grid manager |
443 | return; | 500 | HippoGridInfo* temp = new HippoGridInfo(""); |
501 | if (temp) | ||
502 | { | ||
503 | del_temp_grid = true; | ||
504 | grid = temp; | ||
505 | } | ||
444 | } | 506 | } |
445 | 507 | ||
446 | grid->setLoginUri(loginuri); | 508 | grid->setLoginURI(loginuri); |
447 | if (grid->retrieveGridInfo()) | 509 | if (grid->retrieveGridInfo()) |
448 | { | 510 | { |
449 | if (grid->getGridNick() != "") childSetText("gridnick", grid->getGridNick()); | 511 | // just in case |
450 | if (grid->getGridName() != "") childSetText("gridname", grid->getGridName()); | 512 | if (!(grid->getGridNick().empty())) |
451 | if (grid->getLoginUri() != "") childSetText("loginuri", grid->getLoginUri()); | 513 | getChild<LLLineEditor>("gridnick")->setText(grid->getGridNick()); |
452 | if (grid->getLoginPage() != "") childSetText("loginpage", grid->getLoginPage()); | 514 | if (!(grid->getLoginURI().empty())) |
453 | if (grid->getHelperUri() != "") childSetText("helperuri", grid->getHelperUri()); | 515 | getChild<LLLineEditor>("loginuri")->setText(grid->getLoginURI()); |
454 | if (grid->getWebSite() != "") childSetText("website", grid->getWebSite()); | 516 | getChild<LLLineEditor>("gridname")->setText(grid->getGridName()); |
455 | if (grid->getSupportUrl() != "") childSetText("support", grid->getSupportUrl()); | 517 | getChild<LLLineEditor>("loginpage")->setText(grid->getLoginPage()); |
456 | if (grid->getRegisterUrl() != "") childSetText("register", grid->getRegisterUrl()); | 518 | getChild<LLLineEditor>("helperuri")->setText(grid->getHelperURI()); |
457 | if (grid->getPasswordUrl() != "") childSetText("password", grid->getPasswordUrl()); | 519 | getChild<LLLineEditor>("website")->setText(grid->getWebSite()); |
458 | if (grid->getSearchUrl() != "") childSetText("search", grid->getSearchUrl()); | 520 | getChild<LLLineEditor>("support")->setText(grid->getSupportURL()); |
459 | } | 521 | getChild<LLLineEditor>("register")->setText(grid->getRegisterURL()); |
460 | else | 522 | getChild<LLLineEditor>("password")->setText(grid->getPasswordURL()); |
523 | getChild<LLLineEditor>("search")->setText(grid->getSearchURL()); | ||
524 | } | ||
525 | else | ||
461 | { | 526 | { |
462 | LLNotifications::instance().add("GridInfoError"); | 527 | LLNotifications::instance().add("GridInfoError"); |
463 | } | 528 | } |
464 | 529 | ||
465 | if (cleanupGrid) delete grid; | 530 | if (del_temp_grid) |
531 | { | ||
532 | delete grid; | ||
533 | } | ||
466 | } | 534 | } |
467 | 535 | ||
468 | void FloaterGridManager::apply() | 536 | void FloaterGridManager::apply() |
469 | { | 537 | { |
470 | if (mState == NORMAL) | 538 | // where all the magic happens! |
471 | { | 539 | applyChanges(); |
472 | applyChanges(); | 540 | |
473 | } | ||
474 | else if ((mState == ADD_NEW) || (mState == ADD_COPY)) | ||
475 | { | ||
476 | if (!createNewGrid()) return; | ||
477 | } | ||
478 | else | ||
479 | { | ||
480 | llwarns << "Illegal state " << mState << '.' << llendl; | ||
481 | return; | ||
482 | } | ||
483 | //gHippoGridManager->setCurrentGrid(mCurGrid); | ||
484 | //gHippoGridManager->setDefaultGrid(mCurGrid); | ||
485 | gHippoGridManager->saveFile(); | 541 | gHippoGridManager->saveFile(); |
486 | LLPanelLogin::addServer(LLViewerLogin::getInstance()->getGridLabel()); | 542 | LLPanelLogin::addServer(LLViewerLogin::getInstance()->getGridLabel()); |
487 | } | 543 | } |
488 | 544 | ||
489 | //void FloaterGridManager::setDefault() | 545 | // static |
490 | //{ | ||
491 | // if (mState == NORMAL) | ||
492 | // { | ||
493 | // applyChanges(); | ||
494 | // } | ||
495 | // else if ((mState == ADD_NEW) || (mState == ADD_COPY)) | ||
496 | // { | ||
497 | // if (!createNewGrid()) return; | ||
498 | // } | ||
499 | // else | ||
500 | // { | ||
501 | // llwarns << "Illegal state " << mState << '.' << llendl; | ||
502 | // return; | ||
503 | // } | ||
504 | // gHippoGridManager->setCurrentGrid(mCurGrid); | ||
505 | // gHippoGridManager->setDefaultGrid(mCurGrid); | ||
506 | // gHippoGridManager->saveFile(); | ||
507 | // LLPanelLogin::addServer(LLViewerLogin::getInstance()->getGridLabel()); | ||
508 | //} | ||
509 | |||
510 | void FloaterGridManager::onSelectGrid(LLUICtrl* ctrl, void* data) | 546 | void FloaterGridManager::onSelectGrid(LLUICtrl* ctrl, void* data) |
511 | { | 547 | { |
512 | FloaterGridManager* self = (FloaterGridManager*)data; | 548 | FloaterGridManager* self = (FloaterGridManager*)data; |
513 | if (self->getState() == NORMAL) | 549 | if (self) |
514 | { | ||
515 | self->applyChanges(); | ||
516 | } | ||
517 | else if ((self->getState() == ADD_NEW) || (self->getState() == ADD_COPY)) | ||
518 | { | ||
519 | if (self->createNewGrid()) | ||
520 | { | ||
521 | self->setState(NORMAL); | ||
522 | } | ||
523 | else | ||
524 | { | ||
525 | //LLScrollListCtrl *grids = self->getChild<LLScrollListCtrl>("grid_selector"); | ||
526 | //grids->setCurrentByIndex(grids->getItemCount() - 1); | ||
527 | return; | ||
528 | } | ||
529 | } | ||
530 | else | ||
531 | { | 550 | { |
532 | llwarns << "Illegal state " << self->getState() << llendl; | 551 | self->setCurGrid(ctrl->getValue().asString()); |
533 | return; | 552 | self->refreshGrids(); |
534 | } | 553 | } |
535 | self->setCurGrid(ctrl->getValue().asString()); | ||
536 | self->refreshGrids(); | ||
537 | } | 554 | } |
538 | 555 | ||
539 | //static | 556 | //static |
@@ -541,7 +558,7 @@ void FloaterGridManager::onClickDelete(void* data) | |||
541 | { | 558 | { |
542 | //llinfos << "onClickDelete" << llendl; | 559 | //llinfos << "onClickDelete" << llendl; |
543 | FloaterGridManager* self = (FloaterGridManager*)data; | 560 | FloaterGridManager* self = (FloaterGridManager*)data; |
544 | if (self->getState() == NORMAL) | 561 | if (self) |
545 | { | 562 | { |
546 | gHippoGridManager->deleteGrid(self->getCurGrid()); | 563 | gHippoGridManager->deleteGrid(self->getCurGrid()); |
547 | } | 564 | } |
@@ -553,71 +570,80 @@ void FloaterGridManager::onClickAdd(void* data) | |||
553 | { | 570 | { |
554 | //llinfos << "onClickAdd" << llendl; | 571 | //llinfos << "onClickAdd" << llendl; |
555 | FloaterGridManager* self = (FloaterGridManager*)data; | 572 | FloaterGridManager* self = (FloaterGridManager*)data; |
556 | self->setState(ADD_NEW); | 573 | if (self) |
557 | self->refreshGrids(); | 574 | { |
575 | self->createNewGrid(); | ||
576 | } | ||
558 | } | 577 | } |
559 | 578 | ||
560 | 579 | ||
561 | //static | 580 | //static |
562 | void FloaterGridManager::onClickCopy(void* data) | 581 | void FloaterGridManager::onClickCopy(void* data) |
563 | { | 582 | { |
564 | //llinfos << "onClickCopy" << llendl; | ||
565 | FloaterGridManager* self = (FloaterGridManager*)data; | 583 | FloaterGridManager* self = (FloaterGridManager*)data; |
566 | self->setState(ADD_COPY); | 584 | if (self) |
567 | self->refreshGrids(); | 585 | { |
586 | self->setupCopyGridEntry(); | ||
587 | } | ||
568 | } | 588 | } |
569 | 589 | ||
570 | // static | 590 | // static |
571 | void FloaterGridManager::onClickOk(void* data) | 591 | void FloaterGridManager::onClickOk(void* data) |
572 | { | 592 | { |
573 | FloaterGridManager::getInstance()->apply(); | 593 | FloaterGridManager* self = (FloaterGridManager*)data; |
574 | FloaterGridManager::getInstance()->close(); | 594 | if (self) |
595 | { | ||
596 | self->apply(); | ||
597 | self->close(); | ||
598 | } | ||
575 | } | 599 | } |
576 | 600 | ||
577 | //static | 601 | //static |
578 | void FloaterGridManager::onClickApply(void* data) | 602 | void FloaterGridManager::onClickApply(void* data) |
579 | { | 603 | { |
580 | FloaterGridManager::getInstance()->apply(); | 604 | FloaterGridManager* self = (FloaterGridManager*)data; |
605 | if (self) | ||
606 | { | ||
607 | self->apply(); | ||
608 | } | ||
581 | refreshGrids(); | 609 | refreshGrids(); |
582 | } | 610 | } |
583 | 611 | ||
584 | // static | 612 | // static |
585 | void FloaterGridManager::onClickClear(void* data) | 613 | void FloaterGridManager::onClickClear(void* data) |
586 | { | 614 | { |
587 | FloaterGridManager::getInstance()->clearInfo(); | 615 | FloaterGridManager* self = (FloaterGridManager*)data; |
616 | if (self) | ||
617 | { | ||
618 | self->clearGridInfo(false); | ||
619 | } | ||
588 | } | 620 | } |
589 | 621 | ||
590 | //static | 622 | //static |
591 | //void FloaterGridManager::onClickDefault(void* data) | ||
592 | //{ | ||
593 | // FloaterGridManager::getInstance()->setDefault(); | ||
594 | // FloaterGridManager::getInstance()->refreshGrids(); | ||
595 | //} | ||
596 | |||
597 | //static | ||
598 | void FloaterGridManager::onClickGridInfo(void* data) | 623 | void FloaterGridManager::onClickGridInfo(void* data) |
599 | { | 624 | { |
600 | //HippoPanelGrids* self = (HippoPanelGrids*)data; | 625 | FloaterGridManager* self = (FloaterGridManager*)data; |
601 | FloaterGridManager::getInstance()->retrieveGridInfo(); | 626 | if (self) |
627 | { | ||
628 | self->retrieveGridInfo(); | ||
629 | } | ||
602 | } | 630 | } |
603 | 631 | ||
604 | //static | 632 | //static |
605 | void FloaterGridManager::onClickCancel(void* data) | 633 | void FloaterGridManager::onClickCancel(void* data) |
606 | { | 634 | { |
607 | FloaterGridManager::getInstance()->close(); | 635 | FloaterGridManager* self = (FloaterGridManager*)data; |
636 | if (self) | ||
637 | { | ||
638 | self->close(); | ||
639 | } | ||
608 | } | 640 | } |
609 | 641 | ||
610 | //void FloaterGridManager::setAlwaysRefresh(bool refresh) | 642 | //void FloaterGridManager::refreshLocation(bool force_visible) |
611 | //{ | ||
612 | // // wargames 2: dead code, LLPanelLogin compatibility | ||
613 | // return; | ||
614 | //} | ||
615 | |||
616 | //void FloaterGridManager::refreshLocation( bool force_visible ) | ||
617 | //{ | 643 | //{ |
618 | // llinfos << "refreshLocation called" << llendl; | 644 | // llinfos << "refreshLocation called" << llendl; |
619 | // | 645 | // |
620 | // if (!FloaterGridManager::getInstance()) | 646 | // if (!FloaterGridManager::instanceVisible()) |
621 | // { | 647 | // { |
622 | // return; | 648 | // return; |
623 | // } | 649 | // } |
@@ -645,41 +671,10 @@ void FloaterGridManager::onClickCancel(void* data) | |||
645 | //FloaterGridManager::getInstance()->childSetVisible("server_combo", TRUE); | 671 | //FloaterGridManager::getInstance()->childSetVisible("server_combo", TRUE); |
646 | //} | 672 | //} |
647 | 673 | ||
648 | //void FloaterGridManager::setFocus(BOOL b) | ||
649 | //{ | ||
650 | // if(b != hasFocus()) | ||
651 | // { | ||
652 | // if(b) | ||
653 | // { | ||
654 | // FloaterGridManager::giveFocus(); | ||
655 | // } | ||
656 | // else | ||
657 | // { | ||
658 | // LLPanel::setFocus(b); | ||
659 | // } | ||
660 | // } | ||
661 | //} | ||
662 | // | ||
663 | //void FloaterGridManager::giveFocus() | ||
664 | //{ | ||
665 | // LLScrollListCtrl *combo = NULL; | ||
666 | // | ||
667 | // if (!FloaterGridManager::getInstance()) | ||
668 | // { | ||
669 | // llinfos << "giveFocus has no FloaterGridManager instance. FloaterGridManager::getInstance()=" << FloaterGridManager::getInstance() << llendl; | ||
670 | // return; | ||
671 | // } | ||
672 | // | ||
673 | // // for our combo box approach, selecting the combo box is almost always | ||
674 | // // the right thing to do on the floater receiving focus | ||
675 | // combo = FloaterGridManager::getInstance()->getChild<LLScrollListCtrl>("grid_selector"); | ||
676 | // combo->setFocus(TRUE); | ||
677 | //} | ||
678 | |||
679 | BOOL FloaterGridManager::isGridComboDirty() | 674 | BOOL FloaterGridManager::isGridComboDirty() |
680 | { | 675 | { |
681 | BOOL user_picked = FALSE; | 676 | BOOL user_picked = FALSE; |
682 | if (!FloaterGridManager::getInstance()) | 677 | if (!FloaterGridManager::instanceVisible()) |
683 | { | 678 | { |
684 | llwarns << "Attempted getServer with no login view shown" << llendl; | 679 | llwarns << "Attempted getServer with no login view shown" << llendl; |
685 | } | 680 | } |
@@ -691,17 +686,17 @@ BOOL FloaterGridManager::isGridComboDirty() | |||
691 | return user_picked; | 686 | return user_picked; |
692 | } | 687 | } |
693 | 688 | ||
694 | void FloaterGridManager::getLocation(std::string &location) | 689 | //void FloaterGridManager::getLocation(std::string& location) |
695 | { | 690 | //{ |
696 | if (!FloaterGridManager::getInstance()) | 691 | // if (!FloaterGridManager::instanceVisible()) |
697 | { | 692 | // { |
698 | llwarns << "Attempted getLocation with no login view shown" << llendl; | 693 | // llwarns << "Attempted getLocation with no login view shown" << llendl; |
699 | return; | 694 | // return; |
700 | } | 695 | // } |
701 | 696 | // | |
702 | LLComboBox* combo = FloaterGridManager::getInstance()->getChild<LLComboBox>("start_location_combo"); | 697 | // LLComboBox* combo = FloaterGridManager::getInstance()->getChild<LLComboBox>("start_location_combo"); |
703 | location = combo->getValue().asString(); | 698 | // location = combo->getValue().asString(); |
704 | } | 699 | //} |
705 | 700 | ||
706 | std::string& FloaterGridManager::getPassword() | 701 | std::string& FloaterGridManager::getPassword() |
707 | { | 702 | { |
@@ -718,37 +713,6 @@ bool FloaterGridManager::isSamePassword(std::string &password) | |||
718 | return mMungedPassword == password; | 713 | return mMungedPassword == password; |
719 | } | 714 | } |
720 | 715 | ||
721 | //void FloaterGridManager::addServer(const std::string& server, S32 domain_name) | ||
722 | //{ | ||
723 | // if (!FloaterGridManager::getInstance()) | ||
724 | // { | ||
725 | // llwarns << "Attempted addServer with no login view shown" << llendl; | ||
726 | // return; | ||
727 | // } | ||
728 | // | ||
729 | // /*LLComboBox* combo = FloaterGridManager::getInstance()->getChild<LLComboBox>("server_combo"); | ||
730 | // combo->add(server, LLSD(domain_name) ); | ||
731 | // combo->setCurrentByIndex(0);*/ | ||
732 | //} | ||
733 | |||
734 | //void FloaterGridManager::cancel_old() | ||
735 | //{ | ||
736 | // if (!FloaterGridManager::getInstance()) | ||
737 | // { | ||
738 | // return; | ||
739 | // } | ||
740 | // | ||
741 | // if (FloaterGridManager::getInstance()->sIsInitialLogin) | ||
742 | // { | ||
743 | // // send a callback that indicates we're quitting or closing | ||
744 | // if (FloaterGridManager::getInstance()->mCallback) | ||
745 | // FloaterGridManager::getInstance()->mCallback(LOGIN_OPTION_QUIT, FloaterGridManager::getInstance()->mCallbackData); | ||
746 | // return; | ||
747 | // } | ||
748 | // | ||
749 | // FloaterGridManager::getInstance()->close(); | ||
750 | //} | ||
751 | |||
752 | void FloaterGridManager::hashPassword(const std::string& password, std::string& hashedPassword) | 716 | void FloaterGridManager::hashPassword(const std::string& password, std::string& hashedPassword) |
753 | { | 717 | { |
754 | // Max "actual" password length is 16 characters. | 718 | // Max "actual" password length is 16 characters. |