diff options
Diffstat (limited to '')
-rw-r--r-- | linden/indra/newview/floatergridmanager.cpp | 893 |
1 files changed, 415 insertions, 478 deletions
diff --git a/linden/indra/newview/floatergridmanager.cpp b/linden/indra/newview/floatergridmanager.cpp index 298fe35..257c210 100644 --- a/linden/indra/newview/floatergridmanager.cpp +++ b/linden/indra/newview/floatergridmanager.cpp | |||
@@ -1,54 +1,66 @@ | |||
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 | |||
26 | LoginController* FloaterGridManager::sController = NULL; | ||
27 | bool FloaterGridManager::sIsInitialLogin; | ||
28 | std::string FloaterGridManager::sGrid; | ||
29 | 50 | ||
30 | FloaterGridManager::FloaterGridManager(const LLSD& key) | 51 | FloaterGridManager::FloaterGridManager(const LLSD& key) |
31 | : mState(NORMAL), | 52 | : |
32 | mCurGrid(gHippoGridManager->getCurrentGridNick()), | 53 | mState(GRID_STATE_NORMAL), |
33 | mIncomingPassword(""), | 54 | mCurGrid("") |
34 | mMungedPassword("") | ||
35 | { | 55 | { |
36 | llinfos << "Opening grid manager" << llendl; | 56 | llinfos << "Opening grid manager" << llendl; |
37 | 57 | ||
38 | LLUICtrlFactory::getInstance()->buildFloater(this, "floater_grid_manager.xml"); | 58 | LLUICtrlFactory::getInstance()->buildFloater(this, "floater_grid_manager.xml"); |
39 | center(); | 59 | center(); |
40 | |||
41 | LLLineEditor* edit = getChild<LLLineEditor>("avatar_password_edit"); | ||
42 | if (edit) | ||
43 | { | ||
44 | edit->setDrawAsterixes(TRUE); | ||
45 | } | ||
46 | } | 60 | } |
47 | 61 | ||
48 | |||
49 | FloaterGridManager::~FloaterGridManager() | 62 | FloaterGridManager::~FloaterGridManager() |
50 | { | 63 | { |
51 | FloaterGridManager::sController = NULL; | ||
52 | } | 64 | } |
53 | 65 | ||
54 | BOOL FloaterGridManager::postBuild() | 66 | BOOL FloaterGridManager::postBuild() |
@@ -64,105 +76,117 @@ BOOL FloaterGridManager::postBuild() | |||
64 | childSetAction("btn_copy", onClickCopy, this); | 76 | childSetAction("btn_copy", onClickCopy, this); |
65 | childSetAction("btn_ok", onClickOk, this); | 77 | childSetAction("btn_ok", onClickOk, this); |
66 | childSetAction("btn_apply", onClickApply, this); | 78 | 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); | 79 | childSetAction("btn_cancel", onClickCancel, this); |
69 | childSetAction("btn_clear", onClickClear, this); | 80 | childSetAction("btn_clear", onClickClear, this); |
70 | childSetAction("btn_gridinfo", onClickGridInfo, this); | 81 | childSetAction("btn_gridinfo", onClickGridInfo, this); |
71 | // childSetAction("btn_help_render_compat", onClickHelpRenderCompat, this); // Ugly ugly ugly | ||
72 | 82 | ||
73 | childSetCommitCallback("grid_selector", onSelectGrid, this); | 83 | childSetCommitCallback("grid_selector", onSelectGrid, this); |
74 | LLScrollListCtrl* combo = getChild<LLScrollListCtrl>("grid_selector"); | 84 | LLScrollListCtrl* combo = getChild<LLScrollListCtrl>("grid_selector"); |
75 | combo->setFocus(TRUE); | 85 | combo->setFocus(TRUE); |
76 | 86 | ||
87 | clearGridInfo(true); | ||
88 | |||
77 | refreshGrids(); | 89 | refreshGrids(); |
78 | 90 | ||
79 | return TRUE; | 91 | // We use the last selected grid as the default |
80 | } | 92 | HippoGridInfo* first_selected = gHippoGridManager->getGrid(mCurGrid); |
93 | if (first_selected) | ||
94 | { | ||
95 | getChild<LLLineEditor>("first_name")->setVisible(!first_selected->isUsernameCompat()); | ||
96 | getChild<LLLineEditor>("last_name")->setVisible(!first_selected->isUsernameCompat()); | ||
97 | getChild<LLLineEditor>("username")->setVisible(first_selected->isUsernameCompat()); | ||
98 | } | ||
99 | getChild<LLLineEditor>("gridnick")->setEnabled(false); | ||
81 | 100 | ||
82 | void FloaterGridManager::clearInfo() | 101 | 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 | } | 102 | } |
106 | 103 | ||
107 | void FloaterGridManager::draw() | 104 | void FloaterGridManager::draw() |
108 | { | 105 | { |
109 | refresh(); | 106 | refresh(); |
110 | |||
111 | LLFloater::draw(); | 107 | LLFloater::draw(); |
112 | } | 108 | } |
113 | 109 | ||
114 | void FloaterGridManager::refresh() | 110 | void FloaterGridManager::refresh() |
115 | { | 111 | { |
116 | //TODO: these should just be set in a prompt | 112 | //TODO: new grid creation should just be set in a popup |
117 | bool can_edit = (!getChild<LLLineEditor>("gridnick")->getText().empty() && | 113 | bool can_edit = (!(getChild<LLLineEditor>("gridnick")->getText().empty()) && |
118 | !getChild<LLLineEditor>("loginuri")->getText().empty() && | 114 | !(getChild<LLLineEditor>("gridname")->getText().empty()) && |
119 | getChild<LLLineEditor>("gridnick")->getText() != "<required>" && | 115 | !(getChild<LLLineEditor>("loginuri")->getText().empty())); |
120 | getChild<LLLineEditor>("loginuri")->getText() != "<required>"); | ||
121 | 116 | ||
122 | //getChild<LLLineEditor>("gridname"); | ||
123 | getChild<LLLineEditor>("loginpage")->setEnabled(can_edit); | 117 | getChild<LLLineEditor>("loginpage")->setEnabled(can_edit); |
124 | getChild<LLLineEditor>("helperuri")->setEnabled(can_edit); | 118 | getChild<LLLineEditor>("helperuri")->setEnabled(can_edit); |
125 | getChild<LLLineEditor>("website")->setEnabled(can_edit); | 119 | getChild<LLLineEditor>("website")->setEnabled(can_edit); |
126 | getChild<LLLineEditor>("support")->setEnabled(can_edit); | 120 | getChild<LLLineEditor>("support")->setEnabled(can_edit); |
127 | getChild<LLLineEditor>("register")->setEnabled(can_edit); | 121 | getChild<LLLineEditor>("register")->setEnabled(can_edit); |
128 | getChild<LLLineEditor>("password")->setEnabled(can_edit); | 122 | getChild<LLLineEditor>("password")->setEnabled(can_edit); |
129 | //getChild<LLLineEditor>("first_name")->setEnabled(can_edit); | 123 | getChild<LLLineEditor>("first_name")->setEnabled(can_edit); |
130 | //getChild<LLLineEditor>("last_name")->setEnabled(can_edit); | 124 | getChild<LLLineEditor>("last_name")->setEnabled(can_edit); |
131 | //getChild<LLLineEditor>("avatar_password")->setEnabled(can_edit); | 125 | getChild<LLLineEditor>("username")->setEnabled(can_edit); |
126 | getChild<LLLineEditor>("avatar_password")->setEnabled(can_edit); | ||
132 | getChild<LLLineEditor>("search")->setEnabled(can_edit); | 127 | getChild<LLLineEditor>("search")->setEnabled(can_edit); |
133 | getChild<LLButton>("btn_delete")->setEnabled(can_edit); | 128 | getChild<LLButton>("btn_delete")->setEnabled(can_edit); |
134 | //getChild<LLButton>("btn_add") | ||
135 | //getChild<LLButton>("btn_copy")->setEnabled(can_edit); | 129 | //getChild<LLButton>("btn_copy")->setEnabled(can_edit); |
136 | //getChild<LLButton>("set_default")->setEnabled(can_dit); | ||
137 | getChild<LLButton>("btn_gridinfo")->setEnabled(can_edit); | 130 | getChild<LLButton>("btn_gridinfo")->setEnabled(can_edit); |
138 | getChild<LLButton>("btn_clear")->setEnabled(can_edit); | 131 | getChild<LLButton>("btn_clear")->setEnabled(can_edit); |
139 | //getChild<LLButton>("btn_help_render_compat")->setEnabled(can_edit); | 132 | |
133 | getChild<LLTextBox>("loginpage_text")->setEnabled(can_edit); | ||
134 | getChild<LLTextBox>("helperuri_text")->setEnabled(can_edit); | ||
135 | getChild<LLTextBox>("website_text")->setEnabled(can_edit); | ||
136 | getChild<LLTextBox>("support_text")->setEnabled(can_edit); | ||
137 | getChild<LLTextBox>("register_text")->setEnabled(can_edit); | ||
138 | getChild<LLTextBox>("password_text")->setEnabled(can_edit); | ||
139 | getChild<LLTextBox>("first_name_text")->setEnabled(can_edit); | ||
140 | getChild<LLTextBox>("last_name_text")->setEnabled(can_edit); | ||
141 | getChild<LLTextBox>("username_text")->setEnabled(can_edit); | ||
142 | getChild<LLTextBox>("avatar_password_text")->setEnabled(can_edit); | ||
143 | getChild<LLTextBox>("search_text")->setEnabled(can_edit); | ||
140 | } | 144 | } |
141 | 145 | ||
142 | void FloaterGridManager::refreshGrids() | 146 | void FloaterGridManager::refreshGrids() |
143 | { | 147 | { |
144 | LLScrollListCtrl *grids = FloaterGridManager::getInstance()->getChild<LLScrollListCtrl>("grid_selector"); | 148 | // no need to update the list while editing |
149 | if (FloaterGridManager::getInstance()->getGridState() >= GRID_STATE_NEW) | ||
150 | { | ||
151 | return; | ||
152 | } | ||
153 | |||
154 | LLScrollListCtrl* grid_list = FloaterGridManager::getInstance()->getChild<LLScrollListCtrl>("grid_selector"); | ||
145 | std::string lastSelectedItem; | 155 | std::string lastSelectedItem; |
146 | LLSD element; | 156 | LLSD element; |
147 | 157 | ||
148 | if (grids->getFirstSelected()) | 158 | if (grid_list->getFirstSelected()) |
149 | { | 159 | { |
150 | lastSelectedItem = grids->getFirstSelected()->getValue().asString(); | 160 | // grid NICK |
161 | lastSelectedItem = grid_list->getFirstSelected()->getColumn(0)->getValue().asString(); | ||
151 | } | 162 | } |
152 | 163 | ||
153 | grids->deleteAllItems(); | 164 | grid_list->deleteAllItems(); |
154 | 165 | ||
155 | for (HippoGridManager::GridIterator it = gHippoGridManager->beginGrid(); it != gHippoGridManager->endGrid(); ++it) | 166 | // Grids should really have UUIDs, but we'll use their nicks to keep track of 'em instead |
167 | for (HippoGridManager::GridIterator it = gHippoGridManager->beginGrid(); | ||
168 | it != gHippoGridManager->endGrid(); ++it) | ||
156 | { | 169 | { |
157 | std::string grid_nick = it->second->getGridNick(); | 170 | std::string grid_nick = it->second->getGridNick(); |
158 | // There's no reason why empty grids nicks should be in this list, ugh | 171 | |
159 | if (!grid_nick.empty() && grid_nick != gHippoGridManager->getCurrentGridNick()) | 172 | if (grid_nick.empty()) |
173 | { | ||
174 | // shouldn't ever happen | ||
175 | continue; | ||
176 | } | ||
177 | |||
178 | // Note: default sorted by grid NAME in the XUI | ||
179 | if (grid_nick != gHippoGridManager->getCurrentGridNick()) | ||
160 | { | 180 | { |
161 | element["id"] = grid_nick; | 181 | element["id"] = grid_nick; |
162 | element["columns"][0]["column"] = "grid"; | 182 | element["columns"][0]["column"] = "grid_nick"; |
163 | element["columns"][0]["type"] = "text"; | 183 | element["columns"][0]["type"] = "text"; |
164 | element["columns"][0]["value"] = grid_nick; | 184 | element["columns"][0]["value"] = grid_nick; |
165 | grids->addElement(element, ADD_BOTTOM); | 185 | element["columns"][1]["column"] = "grid_name"; |
186 | element["columns"][1]["type"] = "text"; | ||
187 | element["columns"][1]["value"] = it->second->getGridName(); | ||
188 | |||
189 | grid_list->addElement(element, ADD_BOTTOM); | ||
166 | } | 190 | } |
167 | } | 191 | } |
168 | 192 | ||
@@ -172,368 +196,367 @@ void FloaterGridManager::refreshGrids() | |||
172 | if (!gHippoGridManager->getCurrentGridNick().empty()) | 196 | if (!gHippoGridManager->getCurrentGridNick().empty()) |
173 | { | 197 | { |
174 | element["id"] = gHippoGridManager->getCurrentGridNick(); | 198 | element["id"] = gHippoGridManager->getCurrentGridNick(); |
175 | element["columns"][0]["column"] = "grid"; | 199 | element["columns"][0]["column"] = "grid_nick"; |
176 | element["columns"][0]["type"] = "text"; | 200 | element["columns"][0]["type"] = "text"; |
177 | element["columns"][0]["font-style"] = "BOLD"; | 201 | element["columns"][0]["font-style"] = "BOLD"; |
178 | element["columns"][0]["value"] = gHippoGridManager->getCurrentGridNick(); | 202 | element["columns"][0]["value"] = gHippoGridManager->getCurrentGridNick(); |
179 | grids->addElement(element, ADD_TOP); | 203 | element["columns"][1]["column"] = "grid_name"; |
204 | element["columns"][1]["type"] = "text"; | ||
205 | element["columns"][1]["value"] = gHippoGridManager->getCurrentGrid()->getGridName(); | ||
206 | |||
207 | grid_list->addElement(element, ADD_TOP); | ||
180 | } | 208 | } |
181 | 209 | ||
182 | // Reselect the item if we had one selected | 210 | // Reselect the item if we had one selected |
183 | if (lastSelectedItem.empty()) | 211 | if (lastSelectedItem.empty()) |
184 | { | 212 | { |
185 | grids->selectItemByLabel(gHippoGridManager->getCurrentGridNick()); | 213 | grid_list->selectItemByLabel(gHippoGridManager->getCurrentGridNick()); |
214 | FloaterGridManager::getInstance()->setCurGrid(gHippoGridManager->getCurrentGridNick()); | ||
186 | } | 215 | } |
187 | else | 216 | else |
188 | { | 217 | { |
189 | grids->selectItemByLabel(lastSelectedItem); | 218 | grid_list->selectItemByLabel(lastSelectedItem); |
190 | } | 219 | 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 | } | 220 | } |
197 | 221 | ||
198 | //if (selectIndex >= 0) | 222 | //if (selectIndex >= 0) |
199 | //{ | 223 | //{ |
200 | // grids->setCurrentByIndex(selectIndex); | 224 | // grid_list->setCurrentByIndex(selectIndex); |
201 | //} | 225 | //} |
202 | //else | 226 | //else |
203 | //{ | 227 | //{ |
204 | // grids->setLabel(LLStringExplicit("")); // LLComboBox::removeall() does not clear the label | 228 | // grid_list->setLabel(LLStringExplicit("")); // LLComboBox::removeall() does not clear the label |
205 | //} | 229 | //} |
206 | |||
207 | // FloaterGridManager::getInstance()->childSetTextArg("default_grid", "[DEFAULT]", (defaultGrid != "")? defaultGrid: " "); | ||
208 | 230 | ||
209 | FloaterGridManager::getInstance()->childSetEnabled("btn_delete", grids->getItemCount() > 0); | 231 | FloaterGridManager::getInstance()->childSetEnabled("btn_delete", grid_list->getItemCount() > 0); |
232 | FloaterGridManager::getInstance()->childSetEnabled("btn_copy", grid_list->getItemCount() > 0); | ||
210 | 233 | ||
211 | FloaterGridManager::getInstance()->childSetEnabled("btn_copy", (FloaterGridManager::getInstance()->getState() == NORMAL) && (grids->getItemCount() > 0)); | 234 | HippoGridInfo *gridInfo = gHippoGridManager->getGrid(FloaterGridManager::getInstance()->mCurGrid); |
212 | // FloaterGridManager::getInstance()->childSetEnabled("set_default", (FloaterGridManager::getInstance()->getState() == NORMAL) && (grids->getItemCount() > 0)); | 235 | 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 | { | 236 | { |
217 | HippoGridInfo *gridInfo = gHippoGridManager->getGrid(FloaterGridManager::getInstance()->getCurGrid()); | 237 | // Remember: NEVER let users change an existing grid's nick. Bad juju awaits if you do |
218 | if (gridInfo) | 238 | FloaterGridManager::getInstance()->getChild<LLLineEditor>("gridnick")->setText(gridInfo->getGridNick()); |
239 | FloaterGridManager::getInstance()->getChild<LLLineEditor>("gridname")->setText(gridInfo->getGridName()); | ||
240 | |||
241 | FloaterGridManager::getInstance()->getChild<LLLineEditor>("loginuri")->setText(gridInfo->getLoginURI()); | ||
242 | FloaterGridManager::getInstance()->getChild<LLLineEditor>("loginpage")->setText(gridInfo->getLoginPage()); | ||
243 | FloaterGridManager::getInstance()->getChild<LLLineEditor>("helperuri")->setText(gridInfo->getHelperURI()); | ||
244 | FloaterGridManager::getInstance()->getChild<LLLineEditor>("website")->setText(gridInfo->getWebSite()); | ||
245 | FloaterGridManager::getInstance()->getChild<LLLineEditor>("support")->setText(gridInfo->getSupportURL()); | ||
246 | FloaterGridManager::getInstance()->getChild<LLLineEditor>("register")->setText(gridInfo->getRegisterURL()); | ||
247 | FloaterGridManager::getInstance()->getChild<LLLineEditor>("password")->setText(gridInfo->getPasswordURL()); | ||
248 | FloaterGridManager::getInstance()->getChild<LLLineEditor>("first_name")->setText(gridInfo->getFirstName()); | ||
249 | FloaterGridManager::getInstance()->getChild<LLLineEditor>("last_name")->setText(gridInfo->getLastName()); | ||
250 | FloaterGridManager::getInstance()->getChild<LLLineEditor>("username")->setText(gridInfo->getUsername()); | ||
251 | |||
252 | if (gridInfo->getPassword().empty()) | ||
219 | { | 253 | { |
220 | FloaterGridManager::getInstance()->childSetText("gridnick", gridInfo->getGridNick()); | 254 | FloaterGridManager::getInstance()->getChild<LLLineEditor>("avatar_password")->setText(LLStringExplicit("")); |
221 | //FloaterGridManager::getInstance()->childSetText("grid_name", gridInfo->getGridName()); | 255 | } |
222 | FloaterGridManager::getInstance()->childSetText("loginuri", gridInfo->getLoginUri()); | 256 | else |
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 | ||
254 | { | 257 | { |
255 | FloaterGridManager::getInstance()->childSetText("gridnick", LLStringUtil::null); | 258 | FloaterGridManager::getInstance()->getChild<LLLineEditor>("avatar_password")->setText(PASSWORD_FILLER); |
256 | FloaterGridManager::getInstance()->childSetText("gridname", LLStringUtil::null); | ||
257 | FloaterGridManager::getInstance()->childSetText("loginuri", LLStringUtil::null); | ||
258 | FloaterGridManager::getInstance()->childSetText("loginpage", LLStringUtil::null); | ||
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 | } | 259 | } |
269 | } | 260 | |
270 | else if (FloaterGridManager::getInstance()->getState() == ADD_NEW) | 261 | FloaterGridManager::getInstance()->getChild<LLLineEditor>("first_name")->setVisible(!gridInfo->isUsernameCompat()); |
271 | { | 262 | FloaterGridManager::getInstance()->getChild<LLTextBox>("first_name_text")->setVisible(!gridInfo->isUsernameCompat()); |
272 | llinfos << "mState == ADD_NEW" << llendl; | 263 | FloaterGridManager::getInstance()->getChild<LLLineEditor>("last_name")->setVisible(!gridInfo->isUsernameCompat()); |
273 | std::string required = "<required>"; | 264 | FloaterGridManager::getInstance()->getChild<LLTextBox>("last_name_text")->setVisible(!gridInfo->isUsernameCompat()); |
274 | FloaterGridManager::getInstance()->childSetText("gridnick", required); | 265 | FloaterGridManager::getInstance()->getChild<LLLineEditor>("username")->setVisible(gridInfo->isUsernameCompat()); |
275 | FloaterGridManager::getInstance()->childSetText("gridname", LLStringUtil::null); | 266 | FloaterGridManager::getInstance()->getChild<LLTextBox>("username_text")->setVisible(gridInfo->isUsernameCompat()); |
276 | FloaterGridManager::getInstance()->childSetText("loginuri", required); | 267 | |
277 | FloaterGridManager::getInstance()->childSetText("loginpage", LLStringUtil::null); | 268 | if (gridInfo->getPlatform() == HippoGridInfo::PLATFORM_SECONDLIFE) |
278 | FloaterGridManager::getInstance()->childSetText("helperuri", LLStringUtil::null); | 269 | { |
279 | FloaterGridManager::getInstance()->childSetText("website", LLStringUtil::null); | 270 | FloaterGridManager::getInstance()->childSetEnabled("search", false); |
280 | FloaterGridManager::getInstance()->childSetText("support", LLStringUtil::null); | 271 | FloaterGridManager::getInstance()->getChild<LLLineEditor>("search")->setText(LLStringExplicit("")); |
281 | FloaterGridManager::getInstance()->childSetText("register", LLStringUtil::null); | 272 | } |
282 | FloaterGridManager::getInstance()->childSetText("password", LLStringUtil::null); | 273 | else |
283 | // FloaterGridManager::getInstance()->childSetText("first_name", LLStringUtil::null); | 274 | { |
284 | // FloaterGridManager::getInstance()->childSetText("last_name", LLStringUtil::null); | 275 | FloaterGridManager::getInstance()->childSetEnabled("search", true); |
285 | // FloaterGridManager::getInstance()->childSetText("avatar_password", LLStringUtil::null); | 276 | FloaterGridManager::getInstance()->getChild<LLLineEditor>("search")->setText(gridInfo->getSearchURL()); |
286 | //childSetEnabled("search", true); | 277 | } |
287 | FloaterGridManager::getInstance()->childSetText("search", LLStringUtil::null); | 278 | } |
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 | 279 | else |
295 | { | 280 | { |
296 | llwarns << "Illegal state " << FloaterGridManager::getInstance()->getState() << llendl; | 281 | // should never happen, but if so default to creating a new entry |
282 | FloaterGridManager::getInstance()->setupNewGridEntry(); | ||
297 | } | 283 | } |
298 | return; | 284 | } |
299 | } | ||
300 | 285 | ||
301 | void FloaterGridManager::update() | 286 | void FloaterGridManager::update() |
302 | { | 287 | { |
303 | setState(NORMAL); | 288 | // no need to update the list until we need to |
304 | setCurGrid(gHippoGridManager->getCurrentGridNick()); | 289 | if (getGridState() >= GRID_STATE_NEW) |
290 | { | ||
291 | return; | ||
292 | } | ||
305 | refreshGrids(); | 293 | refreshGrids(); |
306 | //KOW gHippoLimits->setLimits(); | ||
307 | } | 294 | } |
308 | 295 | ||
309 | void FloaterGridManager::applyChanges() | 296 | void FloaterGridManager::applyChanges() |
310 | { | 297 | { |
311 | HippoGridInfo* gridInfo = gHippoGridManager->getGrid(mCurGrid); | 298 | // When we apply changes, we update based on the state |
312 | if (gridInfo) | 299 | // of the UI. This is ugly and could really be improved |
300 | |||
301 | // Note: nick and loginuri are required | ||
302 | std::string grid_nick = childGetValue("gridnick").asString(); | ||
303 | if (grid_nick.empty()) | ||
304 | { | ||
305 | LLNotifications::instance().add("GridsNoNick"); | ||
306 | return; | ||
307 | } | ||
308 | |||
309 | if (childGetValue("loginuri").asString().empty()) | ||
313 | { | 310 | { |
314 | if (gridInfo->getGridNick() == childGetValue("gridnick").asString()) | 311 | LLSD args; |
312 | args["[NAME]"] = grid_nick; | ||
313 | LLNotifications::instance().add("GridsNoLoginURI", args); | ||
314 | return ; | ||
315 | } | ||
316 | |||
317 | HippoGridInfo* grid = NULL; | ||
318 | |||
319 | // Note: we disable the scroll list during grid creation to prevent conflicts | ||
320 | if (getGridState() == GRID_STATE_NEW || getGridState() == GRID_STATE_COPY) | ||
321 | { | ||
322 | if (gHippoGridManager->hasGridNick(grid_nick)) | ||
315 | { | 323 | { |
316 | gridInfo->setGridName(childGetValue("gridname")); | 324 | LLSD args; |
317 | gridInfo->setLoginUri(childGetValue("loginuri")); | 325 | args["[NAME]"] = grid_nick; |
318 | gridInfo->setLoginPage(childGetValue("loginpage")); | 326 | LLNotifications::instance().add("GridExists", args); |
319 | gridInfo->setHelperUri(childGetValue("helperuri")); | 327 | return; |
320 | gridInfo->setWebSite(childGetValue("website")); | 328 | } |
321 | gridInfo->setSupportUrl(childGetValue("support")); | 329 | 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 | { | 330 | { |
346 | llwarns << "Grid nickname mismatch, ignoring changes." << llendl; | 331 | grid = new HippoGridInfo(grid_nick); |
332 | } | ||
333 | } | ||
334 | else // updating grid | ||
335 | { | ||
336 | if (!gHippoGridManager->hasGridNick(grid_nick)) | ||
337 | { | ||
338 | llwarns << "Can't update info for a grid we don't know, ignoring changes." << llendl; | ||
339 | return; | ||
340 | } | ||
341 | else | ||
342 | { | ||
343 | grid = gHippoGridManager->getGrid(grid_nick); | ||
347 | } | 344 | } |
348 | } | 345 | } |
349 | } | ||
350 | 346 | ||
347 | grid->setGridName(childGetValue("gridname")); | ||
348 | grid->setLoginURI(childGetValue("loginuri")); | ||
349 | grid->setLoginPage(childGetValue("loginpage")); | ||
350 | grid->setHelperURI(childGetValue("helperuri")); | ||
351 | grid->setWebSite(childGetValue("website")); | ||
352 | grid->setSupportURL(childGetValue("support")); | ||
353 | grid->setRegisterURL(childGetValue("register")); | ||
354 | grid->setPasswordURL(childGetValue("password")); | ||
355 | grid->setSearchURL(childGetValue("search")); | ||
356 | grid->setFirstName(childGetValue("first_name")); | ||
357 | grid->setLastName(childGetValue("last_name")); | ||
358 | grid->setUsername(childGetValue("username")); | ||
359 | |||
360 | // don't allow users to set their password as PASSWORD_FILLER | ||
361 | // would be nice to get grid-specific rules on password formatting, too | ||
362 | // passwords are remembered by default when entered in the grid manager (good default?) | ||
363 | std::string password_new = childGetValue("avatar_password").asString(); | ||
364 | std::string password_old = grid->getPassword(); // initialized to "" | ||
365 | if (password_new != PASSWORD_FILLER && password_new != password_old) | ||
366 | { | ||
367 | // store account authentication data | ||
368 | grid->setPassword(password_new); | ||
369 | } | ||
351 | 370 | ||
352 | bool FloaterGridManager::createNewGrid() | 371 | FloaterGridManager::getInstance()->getChild<LLScrollListCtrl>("grid_selector")->setEnabled(true); |
353 | { | 372 | FloaterGridManager::getInstance()->getChild<LLLineEditor>("gridnick")->setEnabled(false); |
354 | // check nickname | 373 | |
355 | std::string gridnick = childGetValue("gridnick"); | 374 | if (getGridState() == GRID_STATE_NEW || getGridState() == GRID_STATE_COPY) |
356 | if (gridnick == "<required>") | ||
357 | { | 375 | { |
358 | gridnick = ""; | 376 | gHippoGridManager->addGrid(grid); |
377 | refreshGrids(); | ||
378 | FloaterGridManager::getInstance()->getChild<LLScrollListCtrl>("grid_selector")->selectByValue(LLSD(grid_nick)); | ||
359 | } | 379 | } |
360 | 380 | ||
361 | if (gridnick.empty()) | 381 | // just in case |
382 | gHippoGridManager->setCurrentGrid(grid_nick); | ||
383 | |||
384 | // should this be settable? | ||
385 | if (grid->isUsernameCompat()) | ||
362 | { | 386 | { |
363 | LLNotifications::instance().add("GridsNoNick"); | 387 | LLPanelLogin::setFields(grid->getUsername(), grid->getPassword()); |
364 | return false; | ||
365 | } | 388 | } |
366 | 389 | else | |
367 | if (gHippoGridManager->getGrid(gridnick)) | ||
368 | { | 390 | { |
369 | LLSD args; | 391 | LLPanelLogin::setFields(grid->getFirstName(), grid->getLastName(), grid->getPassword()); |
370 | args["[NAME]"] = gridnick; | ||
371 | LLNotifications::instance().add("GridExists", args); | ||
372 | return false; | ||
373 | } | 392 | } |
374 | 393 | ||
375 | // check login URI | 394 | if (FloaterGridDefault::instanceVisible()) |
376 | std::string loginuri = childGetValue("loginuri"); | ||
377 | if ((loginuri.empty()) || (loginuri == "<required>")) | ||
378 | { | 395 | { |
379 | LLSD args; | 396 | FloaterGridDefault::getInstance()->refreshGridList(); |
380 | args["[NAME]"] = gridnick; | ||
381 | LLNotifications::instance().add("GridsNoLoginUri", args); | ||
382 | return false; | ||
383 | } | 397 | } |
384 | 398 | ||
385 | // create new grid | 399 | 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 | } | 400 | } |
413 | 401 | ||
414 | void FloaterGridManager::retrieveGridInfo() | 402 | void FloaterGridManager::clearGridInfo(bool clear_all) |
415 | { | 403 | { |
416 | std::string loginuri = childGetValue("loginuri"); | 404 | if (clear_all) |
417 | if ((loginuri == "") || (loginuri == "<required>")) | 405 | { |
418 | { | 406 | getChild<LLLineEditor>("gridnick")->clear(); |
419 | LLNotifications::instance().add("GridInfoNoLoginUri"); | 407 | getChild<LLLineEditor>("gridname")->clear(); |
420 | return; | 408 | getChild<LLLineEditor>("loginuri")->clear(); |
409 | getChild<LLLineEditor>("password")->clear(); | ||
410 | getChild<LLLineEditor>("first_name")->clear(); | ||
411 | getChild<LLLineEditor>("last_name")->clear(); | ||
412 | getChild<LLLineEditor>("username")->clear(); | ||
413 | getChild<LLLineEditor>("avatar_password")->clear(); | ||
421 | } | 414 | } |
422 | 415 | ||
423 | HippoGridInfo* grid = 0; | 416 | getChild<LLLineEditor>("loginpage")->clear(); |
424 | bool cleanupGrid = false; | 417 | getChild<LLLineEditor>("helperuri")->clear(); |
418 | getChild<LLLineEditor>("website")->clear(); | ||
419 | getChild<LLLineEditor>("support")->clear(); | ||
420 | getChild<LLLineEditor>("register")->clear(); | ||
421 | getChild<LLLineEditor>("search")->clear(); | ||
422 | |||
423 | getChild<LLButton>("btn_gridinfo")->setEnabled(TRUE); | ||
424 | } | ||
425 | 425 | ||
426 | if (mState == NORMAL) | 426 | void FloaterGridManager::createNewGrid() |
427 | { | ||
428 | // warn us if anything's dirty | ||
429 | if (getChild<LLLineEditor>("gridnick")->isDirty() || | ||
430 | getChild<LLLineEditor>("gridname")->isDirty() || | ||
431 | getChild<LLLineEditor>("loginuri")->isDirty() || | ||
432 | getChild<LLLineEditor>("loginpage")->isDirty() || | ||
433 | getChild<LLLineEditor>("helperuri")->isDirty() || | ||
434 | getChild<LLLineEditor>("website")->isDirty() || | ||
435 | getChild<LLLineEditor>("support")->isDirty() || | ||
436 | getChild<LLLineEditor>("register")->isDirty() || | ||
437 | getChild<LLLineEditor>("password")->isDirty() || | ||
438 | getChild<LLLineEditor>("first_name")->isDirty() || | ||
439 | getChild<LLLineEditor>("last_name")->isDirty() || | ||
440 | getChild<LLLineEditor>("username")->isDirty() || | ||
441 | getChild<LLLineEditor>("avatar_password")->isDirty() || | ||
442 | getChild<LLLineEditor>("search")->isDirty()) | ||
443 | { | ||
444 | LLNotifications::instance().add("GridInfoDirty", LLSD(), LLSD(), newGridCreationCallback); | ||
445 | } | ||
446 | else | ||
427 | { | 447 | { |
428 | grid = gHippoGridManager->getGrid(mCurGrid); | 448 | // This clears the form. Until an entry is entered, we keep the UI open and blank |
429 | } | 449 | // This is clearly undesirable if you want to cancel, but redoing this window is |
430 | else if ((mState == ADD_NEW) || (mState == ADD_COPY)) | 450 | // a WIP -- MC |
451 | setupNewGridEntry(); | ||
452 | } | ||
453 | } | ||
454 | |||
455 | void FloaterGridManager::setupNewGridEntry() | ||
456 | { | ||
457 | // disable scroll list until we can use it again | ||
458 | getChild<LLScrollListCtrl>("grid_selector")->setEnabled(false); | ||
459 | |||
460 | getChild<LLLineEditor>("gridnick")->setEnabled(true); | ||
461 | clearGridInfo(true); | ||
462 | |||
463 | setGridState(GRID_STATE_NEW); | ||
464 | } | ||
465 | |||
466 | bool FloaterGridManager::newGridCreationCallback(const LLSD& notification, const LLSD& response) | ||
467 | { | ||
468 | S32 option = LLNotification::getSelectedOption(notification, response); | ||
469 | if (option == 0) | ||
431 | { | 470 | { |
432 | grid = new HippoGridInfo(""); | 471 | FloaterGridManager::getInstance()->setupNewGridEntry(); |
433 | cleanupGrid = true; | 472 | } |
434 | } | 473 | return false; |
435 | else | 474 | } |
475 | |||
476 | void FloaterGridManager::setupCopyGridEntry() | ||
477 | { | ||
478 | // disable scroll list until we can use it again | ||
479 | getChild<LLScrollListCtrl>("grid_selector")->setEnabled(false); | ||
480 | |||
481 | getChild<LLLineEditor>("gridnick")->setEnabled(true); | ||
482 | getChild<LLLineEditor>("gridnick")->clear(); | ||
483 | getChild<LLLineEditor>("gridname")->clear(); | ||
484 | getChild<LLLineEditor>("loginuri")->clear(); | ||
485 | |||
486 | setGridState(GRID_STATE_COPY); | ||
487 | } | ||
488 | |||
489 | void FloaterGridManager::retrieveGridInfo() | ||
490 | { | ||
491 | std::string loginuri = childGetValue("loginuri"); | ||
492 | if (loginuri.empty()) | ||
436 | { | 493 | { |
437 | llerrs << "Illegal state " << mState << '.' << llendl; | 494 | LLNotifications::instance().add("GridInfoNoLoginURI"); |
438 | return; | 495 | return; |
439 | } | 496 | } |
497 | |||
498 | // this can be clicked even for grids we haven't saved yet | ||
499 | HippoGridInfo* grid = gHippoGridManager->getGrid(childGetValue("gridnick")); | ||
500 | bool del_temp_grid = false; | ||
440 | if (!grid) | 501 | if (!grid) |
441 | { | 502 | { |
442 | llerrs << "Internal error retrieving grid info." << llendl; | 503 | // easier than fixing the hippo grid manager |
443 | return; | 504 | HippoGridInfo* temp = new HippoGridInfo(""); |
505 | if (temp) | ||
506 | { | ||
507 | del_temp_grid = true; | ||
508 | grid = temp; | ||
509 | } | ||
444 | } | 510 | } |
445 | 511 | ||
446 | grid->setLoginUri(loginuri); | 512 | grid->setLoginURI(loginuri); |
447 | if (grid->retrieveGridInfo()) | 513 | if (grid->retrieveGridInfo()) |
448 | { | 514 | { |
449 | if (grid->getGridNick() != "") childSetText("gridnick", grid->getGridNick()); | 515 | // just in case |
450 | if (grid->getGridName() != "") childSetText("gridname", grid->getGridName()); | 516 | if (!(grid->getGridNick().empty())) |
451 | if (grid->getLoginUri() != "") childSetText("loginuri", grid->getLoginUri()); | 517 | getChild<LLLineEditor>("gridnick")->setText(grid->getGridNick()); |
452 | if (grid->getLoginPage() != "") childSetText("loginpage", grid->getLoginPage()); | 518 | if (!(grid->getLoginURI().empty())) |
453 | if (grid->getHelperUri() != "") childSetText("helperuri", grid->getHelperUri()); | 519 | getChild<LLLineEditor>("loginuri")->setText(grid->getLoginURI()); |
454 | if (grid->getWebSite() != "") childSetText("website", grid->getWebSite()); | 520 | getChild<LLLineEditor>("gridname")->setText(grid->getGridName()); |
455 | if (grid->getSupportUrl() != "") childSetText("support", grid->getSupportUrl()); | 521 | getChild<LLLineEditor>("loginpage")->setText(grid->getLoginPage()); |
456 | if (grid->getRegisterUrl() != "") childSetText("register", grid->getRegisterUrl()); | 522 | getChild<LLLineEditor>("helperuri")->setText(grid->getHelperURI()); |
457 | if (grid->getPasswordUrl() != "") childSetText("password", grid->getPasswordUrl()); | 523 | getChild<LLLineEditor>("website")->setText(grid->getWebSite()); |
458 | if (grid->getSearchUrl() != "") childSetText("search", grid->getSearchUrl()); | 524 | getChild<LLLineEditor>("support")->setText(grid->getSupportURL()); |
459 | } | 525 | getChild<LLLineEditor>("register")->setText(grid->getRegisterURL()); |
460 | else | 526 | getChild<LLLineEditor>("password")->setText(grid->getPasswordURL()); |
527 | getChild<LLLineEditor>("search")->setText(grid->getSearchURL()); | ||
528 | } | ||
529 | else | ||
461 | { | 530 | { |
462 | LLNotifications::instance().add("GridInfoError"); | 531 | LLNotifications::instance().add("GridInfoError"); |
463 | } | 532 | } |
464 | 533 | ||
465 | if (cleanupGrid) delete grid; | 534 | if (del_temp_grid) |
535 | { | ||
536 | delete grid; | ||
537 | } | ||
466 | } | 538 | } |
467 | 539 | ||
468 | void FloaterGridManager::apply() | 540 | void FloaterGridManager::apply() |
469 | { | 541 | { |
470 | if (mState == NORMAL) | 542 | // where all the magic happens! |
471 | { | 543 | applyChanges(); |
472 | applyChanges(); | 544 | |
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(); | 545 | gHippoGridManager->saveFile(); |
486 | LLPanelLogin::addServer(LLViewerLogin::getInstance()->getGridLabel()); | 546 | LLPanelLogin::addServer(LLViewerLogin::getInstance()->getGridLabel()); |
547 | LLPanelLogin::loadLoginForm(); | ||
548 | LLPanelLogin::loadLoginPage(); | ||
487 | } | 549 | } |
488 | 550 | ||
489 | //void FloaterGridManager::setDefault() | 551 | // 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) | 552 | void FloaterGridManager::onSelectGrid(LLUICtrl* ctrl, void* data) |
511 | { | 553 | { |
512 | FloaterGridManager* self = (FloaterGridManager*)data; | 554 | FloaterGridManager* self = (FloaterGridManager*)data; |
513 | if (self->getState() == NORMAL) | 555 | if (self) |
514 | { | ||
515 | self->applyChanges(); | ||
516 | } | ||
517 | else if ((self->getState() == ADD_NEW) || (self->getState() == ADD_COPY)) | ||
518 | { | 556 | { |
519 | if (self->createNewGrid()) | 557 | self->setCurGrid(ctrl->getValue().asString()); |
520 | { | 558 | self->refreshGrids(); |
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 | { | ||
532 | llwarns << "Illegal state " << self->getState() << llendl; | ||
533 | return; | ||
534 | } | 559 | } |
535 | self->setCurGrid(ctrl->getValue().asString()); | ||
536 | self->refreshGrids(); | ||
537 | } | 560 | } |
538 | 561 | ||
539 | //static | 562 | //static |
@@ -541,7 +564,7 @@ void FloaterGridManager::onClickDelete(void* data) | |||
541 | { | 564 | { |
542 | //llinfos << "onClickDelete" << llendl; | 565 | //llinfos << "onClickDelete" << llendl; |
543 | FloaterGridManager* self = (FloaterGridManager*)data; | 566 | FloaterGridManager* self = (FloaterGridManager*)data; |
544 | if (self->getState() == NORMAL) | 567 | if (self) |
545 | { | 568 | { |
546 | gHippoGridManager->deleteGrid(self->getCurGrid()); | 569 | gHippoGridManager->deleteGrid(self->getCurGrid()); |
547 | } | 570 | } |
@@ -553,71 +576,80 @@ void FloaterGridManager::onClickAdd(void* data) | |||
553 | { | 576 | { |
554 | //llinfos << "onClickAdd" << llendl; | 577 | //llinfos << "onClickAdd" << llendl; |
555 | FloaterGridManager* self = (FloaterGridManager*)data; | 578 | FloaterGridManager* self = (FloaterGridManager*)data; |
556 | self->setState(ADD_NEW); | 579 | if (self) |
557 | self->refreshGrids(); | 580 | { |
581 | self->createNewGrid(); | ||
582 | } | ||
558 | } | 583 | } |
559 | 584 | ||
560 | 585 | ||
561 | //static | 586 | //static |
562 | void FloaterGridManager::onClickCopy(void* data) | 587 | void FloaterGridManager::onClickCopy(void* data) |
563 | { | 588 | { |
564 | //llinfos << "onClickCopy" << llendl; | ||
565 | FloaterGridManager* self = (FloaterGridManager*)data; | 589 | FloaterGridManager* self = (FloaterGridManager*)data; |
566 | self->setState(ADD_COPY); | 590 | if (self) |
567 | self->refreshGrids(); | 591 | { |
592 | self->setupCopyGridEntry(); | ||
593 | } | ||
568 | } | 594 | } |
569 | 595 | ||
570 | // static | 596 | // static |
571 | void FloaterGridManager::onClickOk(void* data) | 597 | void FloaterGridManager::onClickOk(void* data) |
572 | { | 598 | { |
573 | FloaterGridManager::getInstance()->apply(); | 599 | FloaterGridManager* self = (FloaterGridManager*)data; |
574 | FloaterGridManager::getInstance()->close(); | 600 | if (self) |
601 | { | ||
602 | self->apply(); | ||
603 | self->close(); | ||
604 | } | ||
575 | } | 605 | } |
576 | 606 | ||
577 | //static | 607 | //static |
578 | void FloaterGridManager::onClickApply(void* data) | 608 | void FloaterGridManager::onClickApply(void* data) |
579 | { | 609 | { |
580 | FloaterGridManager::getInstance()->apply(); | 610 | FloaterGridManager* self = (FloaterGridManager*)data; |
611 | if (self) | ||
612 | { | ||
613 | self->apply(); | ||
614 | } | ||
581 | refreshGrids(); | 615 | refreshGrids(); |
582 | } | 616 | } |
583 | 617 | ||
584 | // static | 618 | // static |
585 | void FloaterGridManager::onClickClear(void* data) | 619 | void FloaterGridManager::onClickClear(void* data) |
586 | { | 620 | { |
587 | FloaterGridManager::getInstance()->clearInfo(); | 621 | FloaterGridManager* self = (FloaterGridManager*)data; |
622 | if (self) | ||
623 | { | ||
624 | self->clearGridInfo(false); | ||
625 | } | ||
588 | } | 626 | } |
589 | 627 | ||
590 | //static | 628 | //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) | 629 | void FloaterGridManager::onClickGridInfo(void* data) |
599 | { | 630 | { |
600 | //HippoPanelGrids* self = (HippoPanelGrids*)data; | 631 | FloaterGridManager* self = (FloaterGridManager*)data; |
601 | FloaterGridManager::getInstance()->retrieveGridInfo(); | 632 | if (self) |
633 | { | ||
634 | self->retrieveGridInfo(); | ||
635 | } | ||
602 | } | 636 | } |
603 | 637 | ||
604 | //static | 638 | //static |
605 | void FloaterGridManager::onClickCancel(void* data) | 639 | void FloaterGridManager::onClickCancel(void* data) |
606 | { | 640 | { |
607 | FloaterGridManager::getInstance()->close(); | 641 | FloaterGridManager* self = (FloaterGridManager*)data; |
642 | if (self) | ||
643 | { | ||
644 | self->close(); | ||
645 | } | ||
608 | } | 646 | } |
609 | 647 | ||
610 | //void FloaterGridManager::setAlwaysRefresh(bool refresh) | 648 | //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 | //{ | 649 | //{ |
618 | // llinfos << "refreshLocation called" << llendl; | 650 | // llinfos << "refreshLocation called" << llendl; |
619 | // | 651 | // |
620 | // if (!FloaterGridManager::getInstance()) | 652 | // if (!FloaterGridManager::instanceVisible()) |
621 | // { | 653 | // { |
622 | // return; | 654 | // return; |
623 | // } | 655 | // } |
@@ -645,41 +677,10 @@ void FloaterGridManager::onClickCancel(void* data) | |||
645 | //FloaterGridManager::getInstance()->childSetVisible("server_combo", TRUE); | 677 | //FloaterGridManager::getInstance()->childSetVisible("server_combo", TRUE); |
646 | //} | 678 | //} |
647 | 679 | ||
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() | 680 | BOOL FloaterGridManager::isGridComboDirty() |
680 | { | 681 | { |
681 | BOOL user_picked = FALSE; | 682 | BOOL user_picked = FALSE; |
682 | if (!FloaterGridManager::getInstance()) | 683 | if (!FloaterGridManager::instanceVisible()) |
683 | { | 684 | { |
684 | llwarns << "Attempted getServer with no login view shown" << llendl; | 685 | llwarns << "Attempted getServer with no login view shown" << llendl; |
685 | } | 686 | } |
@@ -691,78 +692,14 @@ BOOL FloaterGridManager::isGridComboDirty() | |||
691 | return user_picked; | 692 | return user_picked; |
692 | } | 693 | } |
693 | 694 | ||
694 | void FloaterGridManager::getLocation(std::string &location) | 695 | //void FloaterGridManager::getLocation(std::string& location) |
695 | { | ||
696 | if (!FloaterGridManager::getInstance()) | ||
697 | { | ||
698 | llwarns << "Attempted getLocation with no login view shown" << llendl; | ||
699 | return; | ||
700 | } | ||
701 | |||
702 | LLComboBox* combo = FloaterGridManager::getInstance()->getChild<LLComboBox>("start_location_combo"); | ||
703 | location = combo->getValue().asString(); | ||
704 | } | ||
705 | |||
706 | std::string& FloaterGridManager::getPassword() | ||
707 | { | ||
708 | return mMungedPassword; | ||
709 | } | ||
710 | |||
711 | void FloaterGridManager::setPassword(std::string &password) | ||
712 | { | ||
713 | mMungedPassword = password; | ||
714 | } | ||
715 | |||
716 | bool FloaterGridManager::isSamePassword(std::string &password) | ||
717 | { | ||
718 | return mMungedPassword == password; | ||
719 | } | ||
720 | |||
721 | //void FloaterGridManager::addServer(const std::string& server, S32 domain_name) | ||
722 | //{ | 696 | //{ |
723 | // if (!FloaterGridManager::getInstance()) | 697 | // if (!FloaterGridManager::instanceVisible()) |
724 | // { | 698 | // { |
725 | // llwarns << "Attempted addServer with no login view shown" << llendl; | 699 | // llwarns << "Attempted getLocation with no login view shown" << llendl; |
726 | // return; | 700 | // return; |
727 | // } | 701 | // } |
728 | // | 702 | // |
729 | // /*LLComboBox* combo = FloaterGridManager::getInstance()->getChild<LLComboBox>("server_combo"); | 703 | // LLComboBox* combo = FloaterGridManager::getInstance()->getChild<LLComboBox>("start_location_combo"); |
730 | // combo->add(server, LLSD(domain_name) ); | 704 | // location = combo->getValue().asString(); |
731 | // combo->setCurrentByIndex(0);*/ | ||
732 | //} | 705 | //} |
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) | ||
753 | { | ||
754 | // Max "actual" password length is 16 characters. | ||
755 | // Hex digests are always 32 characters. | ||
756 | if (password.length() == 32) | ||
757 | { | ||
758 | hashedPassword = password; | ||
759 | } | ||
760 | else | ||
761 | { | ||
762 | // this is a normal text password | ||
763 | LLMD5 pass((unsigned char *)password.c_str()); | ||
764 | char munged_password[MD5HEX_STR_SIZE]; | ||
765 | pass.hex_digest(munged_password); | ||
766 | hashedPassword = munged_password; | ||
767 | } | ||
768 | } | ||