diff options
Diffstat (limited to 'linden/indra/newview/llviewernetwork.cpp')
-rw-r--r-- | linden/indra/newview/llviewernetwork.cpp | 186 |
1 files changed, 182 insertions, 4 deletions
diff --git a/linden/indra/newview/llviewernetwork.cpp b/linden/indra/newview/llviewernetwork.cpp index d6e92c2..3224c00 100644 --- a/linden/indra/newview/llviewernetwork.cpp +++ b/linden/indra/newview/llviewernetwork.cpp | |||
@@ -33,8 +33,17 @@ | |||
33 | #include "llviewerprecompiledheaders.h" | 33 | #include "llviewerprecompiledheaders.h" |
34 | 34 | ||
35 | #include "llviewernetwork.h" | 35 | #include "llviewernetwork.h" |
36 | #include "llviewercontrol.h" | ||
36 | 37 | ||
37 | LLGridData gGridInfo[GRID_INFO_COUNT] = | 38 | struct LLGridData |
39 | { | ||
40 | const char* mLabel; | ||
41 | const char* mName; | ||
42 | const char* mLoginURI; | ||
43 | const char* mHelperURI; | ||
44 | }; | ||
45 | |||
46 | static LLGridData gGridInfo[GRID_INFO_COUNT] = | ||
38 | { | 47 | { |
39 | { "None", "", "", ""}, | 48 | { "None", "", "", ""}, |
40 | { "Aditi", | 49 | { "Aditi", |
@@ -111,8 +120,177 @@ LLGridData gGridInfo[GRID_INFO_COUNT] = | |||
111 | "" } | 120 | "" } |
112 | }; | 121 | }; |
113 | 122 | ||
114 | // Use this to figure out which domain name and login URI to use. | 123 | #if LL_RELEASE_FOR_DOWNLOAD |
124 | // Default userserver for production builds is agni | ||
125 | const EGridInfo DEFAULT_GRID_CHOICE = GRID_INFO_AGNI; | ||
126 | #else | ||
127 | // Default userserver for development builds is none | ||
128 | const EGridInfo DEFAULT_GRID_CHOICE = GRID_INFO_NONE; | ||
129 | #endif | ||
115 | 130 | ||
116 | EGridInfo gGridChoice = GRID_INFO_NONE; | ||
117 | LLString gGridName; /* Flawfinder: ignore */ | ||
118 | unsigned char gMACAddress[MAC_ADDRESS_BYTES]; /* Flawfinder: ignore */ | 131 | unsigned char gMACAddress[MAC_ADDRESS_BYTES]; /* Flawfinder: ignore */ |
132 | |||
133 | LLViewerLogin::LLViewerLogin() : | ||
134 | mGridChoice(DEFAULT_GRID_CHOICE) | ||
135 | { | ||
136 | } | ||
137 | |||
138 | void LLViewerLogin::setGridChoice(EGridInfo grid) | ||
139 | { | ||
140 | if(grid < 0 || grid >= GRID_INFO_COUNT) | ||
141 | { | ||
142 | llerrs << "Invalid grid index specified." << llendl; | ||
143 | } | ||
144 | |||
145 | if(mGridChoice != grid) | ||
146 | { | ||
147 | mGridChoice = grid; | ||
148 | if(GRID_INFO_LOCAL == mGridChoice) | ||
149 | { | ||
150 | mGridName = LOOPBACK_ADDRESS_STRING; | ||
151 | } | ||
152 | else if(GRID_INFO_OTHER == mGridChoice) | ||
153 | { | ||
154 | // *FIX:Mani - could this possibly be valid? | ||
155 | mGridName = "other"; | ||
156 | } | ||
157 | else | ||
158 | { | ||
159 | mGridName = gGridInfo[mGridChoice].mLabel; | ||
160 | } | ||
161 | |||
162 | gSavedSettings.setS32("ServerChoice", mGridChoice); | ||
163 | gSavedSettings.setString("CustomServer", ""); | ||
164 | } | ||
165 | } | ||
166 | |||
167 | void LLViewerLogin::setGridChoice(const std::string& grid_name) | ||
168 | { | ||
169 | // Set the grid choice based on a string. | ||
170 | // The string can be: | ||
171 | // - a grid label from the gGridInfo table | ||
172 | // - an ip address | ||
173 | if(!grid_name.empty()) | ||
174 | { | ||
175 | // find the grid choice from the user setting. | ||
176 | int grid_index = GRID_INFO_NONE; | ||
177 | for(;grid_index < GRID_INFO_OTHER; ++grid_index) | ||
178 | { | ||
179 | if(0 == LLString::compareInsensitive(gGridInfo[grid_index].mLabel, grid_name.c_str())) | ||
180 | { | ||
181 | // Founding a matching label in the list... | ||
182 | setGridChoice((EGridInfo)grid_index); | ||
183 | break; | ||
184 | } | ||
185 | } | ||
186 | |||
187 | if(GRID_INFO_OTHER == grid_index) | ||
188 | { | ||
189 | // *FIX:MEP Can and should we validate that this is an IP address? | ||
190 | mGridChoice = GRID_INFO_OTHER; | ||
191 | mGridName = grid_name; | ||
192 | gSavedSettings.setS32("ServerChoice", mGridChoice); | ||
193 | gSavedSettings.setString("CustomServer", mGridName); | ||
194 | } | ||
195 | } | ||
196 | } | ||
197 | |||
198 | void LLViewerLogin::resetURIs() | ||
199 | { | ||
200 | // Clear URIs when picking a new server | ||
201 | gSavedSettings.setValue("CmdLineLoginURI", LLSD::emptyArray()); | ||
202 | gSavedSettings.setString("CmdLineHelperURI", ""); | ||
203 | } | ||
204 | |||
205 | EGridInfo LLViewerLogin::getGridChoice() const | ||
206 | { | ||
207 | return mGridChoice; | ||
208 | } | ||
209 | |||
210 | std::string LLViewerLogin::getGridLabel() const | ||
211 | { | ||
212 | if(mGridChoice == GRID_INFO_NONE) | ||
213 | { | ||
214 | return "None"; | ||
215 | } | ||
216 | else if(mGridChoice < GRID_INFO_OTHER) | ||
217 | { | ||
218 | return gGridInfo[mGridChoice].mLabel; | ||
219 | } | ||
220 | |||
221 | return mGridName; | ||
222 | } | ||
223 | |||
224 | std::string LLViewerLogin::getKnownGridLabel(EGridInfo grid_index) const | ||
225 | { | ||
226 | if(grid_index > GRID_INFO_NONE && grid_index < GRID_INFO_OTHER) | ||
227 | { | ||
228 | return gGridInfo[grid_index].mLabel; | ||
229 | } | ||
230 | return gGridInfo[GRID_INFO_NONE].mLabel; | ||
231 | } | ||
232 | |||
233 | void LLViewerLogin::getLoginURIs(std::vector<std::string>& uris) const | ||
234 | { | ||
235 | // return the login uri set on the command line. | ||
236 | LLControlVariable* c = gSavedSettings.getControl("CmdLineLoginURI"); | ||
237 | if(c) | ||
238 | { | ||
239 | LLSD v = c->getValue(); | ||
240 | if(v.isArray()) | ||
241 | { | ||
242 | for(LLSD::array_const_iterator itr = v.beginArray(); | ||
243 | itr != v.endArray(); ++itr) | ||
244 | { | ||
245 | std::string uri = itr->asString(); | ||
246 | if(!uri.empty()) | ||
247 | { | ||
248 | uris.push_back(uri); | ||
249 | } | ||
250 | } | ||
251 | } | ||
252 | else | ||
253 | { | ||
254 | std::string uri = v.asString(); | ||
255 | if(!uri.empty()) | ||
256 | { | ||
257 | uris.push_back(uri); | ||
258 | } | ||
259 | } | ||
260 | } | ||
261 | |||
262 | // If there was no command line uri... | ||
263 | if(uris.empty()) | ||
264 | { | ||
265 | // If its a known grid choice, get the uri from the table, | ||
266 | // else try the grid name. | ||
267 | if(mGridChoice > GRID_INFO_NONE && mGridChoice < GRID_INFO_OTHER) | ||
268 | { | ||
269 | uris.push_back(gGridInfo[mGridChoice].mLoginURI); | ||
270 | } | ||
271 | else | ||
272 | { | ||
273 | uris.push_back(mGridName); | ||
274 | } | ||
275 | } | ||
276 | } | ||
277 | |||
278 | std::string LLViewerLogin::getHelperURI() const | ||
279 | { | ||
280 | return gSavedSettings.getString("CmdLineHelperURI"); | ||
281 | } | ||
282 | |||
283 | bool LLViewerLogin::isInProductionGrid() | ||
284 | { | ||
285 | // *NOTE:Mani This used to compare GRID_INFO_AGNI to gGridChoice, | ||
286 | // but it seems that loginURI trumps that. | ||
287 | std::vector<std::string> uris; | ||
288 | getLoginURIs(uris); | ||
289 | LLString::toLower(uris[0]); | ||
290 | if((uris[0].find("agni") != std::string::npos)) | ||
291 | { | ||
292 | return true; | ||
293 | } | ||
294 | |||
295 | return false; | ||
296 | } | ||