diff options
Diffstat (limited to 'linden/indra/newview/llviewernetwork.cpp')
-rw-r--r-- | linden/indra/newview/llviewernetwork.cpp | 201 |
1 files changed, 28 insertions, 173 deletions
diff --git a/linden/indra/newview/llviewernetwork.cpp b/linden/indra/newview/llviewernetwork.cpp index f4e3bb7..de9addf 100644 --- a/linden/indra/newview/llviewernetwork.cpp +++ b/linden/indra/newview/llviewernetwork.cpp | |||
@@ -5,7 +5,7 @@ | |||
5 | * | 5 | * |
6 | * $LicenseInfo:firstyear=2006&license=viewergpl$ | 6 | * $LicenseInfo:firstyear=2006&license=viewergpl$ |
7 | * | 7 | * |
8 | * Copyright (c) 2006-2009, Linden Research, Inc. | 8 | * Copyright (c) 2006-2008, Linden Research, Inc. |
9 | * | 9 | * |
10 | * Second Life Viewer Source Code | 10 | * Second Life Viewer Source Code |
11 | * The source code in this file ("Source Code") is provided by Linden Lab | 11 | * The source code in this file ("Source Code") is provided by Linden Lab |
@@ -34,158 +34,19 @@ | |||
34 | 34 | ||
35 | #include "llviewernetwork.h" | 35 | #include "llviewernetwork.h" |
36 | #include "llviewercontrol.h" | 36 | #include "llviewercontrol.h" |
37 | #include "llstartup.h" | ||
37 | 38 | ||
38 | struct LLGridData | 39 | #include "hippoGridManager.h" |
39 | { | ||
40 | const char* mLabel; | ||
41 | const char* mCodeName; | ||
42 | const char* mName; | ||
43 | const char* mLoginURI; | ||
44 | const char* mHelperURI; | ||
45 | }; | ||
46 | |||
47 | static LLGridData gGridInfo[GRID_INFO_COUNT] = | ||
48 | { | ||
49 | { "None", "", "", "", "" }, | ||
50 | { "SL Main Grid", | ||
51 | "Agni", | ||
52 | "util.agni.lindenlab.com", | ||
53 | "https://login.agni.lindenlab.com/cgi-bin/login.cgi", | ||
54 | "https://secondlife.com/helpers/" }, | ||
55 | { "SL Beta Grid", | ||
56 | "Aditi", | ||
57 | "util.aditi.lindenlab.com", | ||
58 | "https://login.aditi.lindenlab.com/cgi-bin/login.cgi", | ||
59 | "http://aditi-secondlife.webdev.lindenlab.com/helpers/" }, | ||
60 | { "Local OpenSim", | ||
61 | "", | ||
62 | "localhost", | ||
63 | "http://127.0.0.1:9000", | ||
64 | "" }, | ||
65 | { "Other", "", "", "", "" } | ||
66 | }; | ||
67 | |||
68 | const EGridInfo DEFAULT_GRID_CHOICE = GRID_INFO_AGNI; | ||
69 | 40 | ||
70 | 41 | ||
71 | unsigned char gMACAddress[MAC_ADDRESS_BYTES]; /* Flawfinder: ignore */ | 42 | unsigned char gMACAddress[MAC_ADDRESS_BYTES]; /* Flawfinder: ignore */ |
72 | 43 | ||
73 | LLViewerLogin::LLViewerLogin() : | ||
74 | mGridChoice(DEFAULT_GRID_CHOICE) | ||
75 | { | ||
76 | } | ||
77 | |||
78 | void LLViewerLogin::setGridChoice(EGridInfo grid) | ||
79 | { | ||
80 | if(grid < 0 || grid >= GRID_INFO_COUNT) | ||
81 | { | ||
82 | llerrs << "Invalid grid index specified." << llendl; | ||
83 | } | ||
84 | |||
85 | if(mGridChoice != grid || gSavedSettings.getS32("ServerChoice") != grid) | ||
86 | { | ||
87 | mGridChoice = grid; | ||
88 | if(GRID_INFO_LOCAL == mGridChoice) | ||
89 | { | ||
90 | mGridName = LOOPBACK_ADDRESS_STRING; | ||
91 | } | ||
92 | else if(GRID_INFO_OTHER == mGridChoice) | ||
93 | { | ||
94 | // *FIX:Mani - could this possibly be valid? | ||
95 | mGridName = "other"; | ||
96 | } | ||
97 | else | ||
98 | { | ||
99 | mGridName = gGridInfo[mGridChoice].mLabel; | ||
100 | } | ||
101 | |||
102 | gSavedSettings.setS32("ServerChoice", mGridChoice); | ||
103 | gSavedSettings.setString("CustomServer", ""); | ||
104 | } | ||
105 | } | ||
106 | |||
107 | void LLViewerLogin::setGridChoice(const std::string& grid_name) | ||
108 | { | ||
109 | // Set the grid choice based on a string. | ||
110 | // The string can be: | ||
111 | // - a grid label from the gGridInfo table | ||
112 | // - an ip address | ||
113 | if(!grid_name.empty()) | ||
114 | { | ||
115 | // find the grid choice from the user setting. | ||
116 | int grid_index = GRID_INFO_NONE; | ||
117 | for(;grid_index < GRID_INFO_OTHER; ++grid_index) | ||
118 | { | ||
119 | if(0 == LLStringUtil::compareInsensitive(gGridInfo[grid_index].mLabel, grid_name)) | ||
120 | { | ||
121 | // Founding a matching label in the list... | ||
122 | setGridChoice((EGridInfo)grid_index); | ||
123 | break; | ||
124 | } | ||
125 | } | ||
126 | |||
127 | if(GRID_INFO_OTHER == grid_index) | ||
128 | { | ||
129 | // *FIX:MEP Can and should we validate that this is an IP address? | ||
130 | mGridChoice = GRID_INFO_OTHER; | ||
131 | mGridName = grid_name; | ||
132 | gSavedSettings.setS32("ServerChoice", mGridChoice); | ||
133 | gSavedSettings.setString("CustomServer", mGridName); | ||
134 | } | ||
135 | } | ||
136 | } | ||
137 | |||
138 | void LLViewerLogin::resetURIs() | ||
139 | { | ||
140 | // Clear URIs when picking a new server | ||
141 | gSavedSettings.setValue("CmdLineLoginURI", LLSD::emptyArray()); | ||
142 | gSavedSettings.setString("CmdLineHelperURI", ""); | ||
143 | } | ||
144 | |||
145 | EGridInfo LLViewerLogin::getGridChoice() const | ||
146 | { | ||
147 | return mGridChoice; | ||
148 | } | ||
149 | |||
150 | std::string LLViewerLogin::getGridLabel() const | ||
151 | { | ||
152 | if(mGridChoice == GRID_INFO_NONE) | ||
153 | { | ||
154 | return "None"; | ||
155 | } | ||
156 | else if(mGridChoice < GRID_INFO_OTHER) | ||
157 | { | ||
158 | return gGridInfo[mGridChoice].mLabel; | ||
159 | } | ||
160 | |||
161 | return mGridName; | ||
162 | } | ||
163 | |||
164 | std::string LLViewerLogin::getGridCodeName() const | ||
165 | { | ||
166 | // Fall back to grid label if code name is empty. | ||
167 | if( strcmp(gGridInfo[mGridChoice].mCodeName, "") == 0 ) | ||
168 | { | ||
169 | return getGridLabel(); | ||
170 | } | ||
171 | |||
172 | return gGridInfo[mGridChoice].mCodeName; | ||
173 | } | ||
174 | |||
175 | std::string LLViewerLogin::getKnownGridLabel(EGridInfo grid_index) const | ||
176 | { | ||
177 | if(grid_index > GRID_INFO_NONE && grid_index < GRID_INFO_OTHER) | ||
178 | { | ||
179 | return gGridInfo[grid_index].mLabel; | ||
180 | } | ||
181 | return gGridInfo[GRID_INFO_NONE].mLabel; | ||
182 | } | ||
183 | 44 | ||
184 | void LLViewerLogin::getLoginURIs(std::vector<std::string>& uris) const | 45 | void LLViewerLogin::getLoginURIs(std::vector<std::string>& uris) const |
185 | { | 46 | { |
186 | // return the login uri set on the command line. | 47 | // return the login uri set on the command line. |
187 | LLControlVariable* c = gSavedSettings.getControl("CmdLineLoginURI"); | 48 | LLControlVariable* c = gSavedSettings.getControl("CmdLineLoginURI"); |
188 | if(c) | 49 | if(c && !LLStartUp::shouldAutoLogin()) |
189 | { | 50 | { |
190 | LLSD v = c->getValue(); | 51 | LLSD v = c->getValue(); |
191 | if(v.isArray()) | 52 | if(v.isArray()) |
@@ -209,10 +70,12 @@ void LLViewerLogin::getLoginURIs(std::vector<std::string>& uris) const | |||
209 | } | 70 | } |
210 | } | 71 | } |
211 | } | 72 | } |
212 | 73 | ||
213 | // If there was no command line uri... | 74 | // If there was no command line uri... |
214 | if(uris.empty()) | 75 | if(uris.empty()) |
215 | { | 76 | { |
77 | uris.push_back(gHippoGridManager->getConnectedGrid()->getLoginUri()); | ||
78 | /* | ||
216 | // If its a known grid choice, get the uri from the table, | 79 | // If its a known grid choice, get the uri from the table, |
217 | // else try the grid name. | 80 | // else try the grid name. |
218 | if(mGridChoice > GRID_INFO_NONE && mGridChoice < GRID_INFO_OTHER) | 81 | if(mGridChoice > GRID_INFO_NONE && mGridChoice < GRID_INFO_OTHER) |
@@ -222,44 +85,36 @@ void LLViewerLogin::getLoginURIs(std::vector<std::string>& uris) const | |||
222 | else | 85 | else |
223 | { | 86 | { |
224 | uris.push_back(mGridName); | 87 | uris.push_back(mGridName); |
225 | } | 88 | } */ |
226 | } | 89 | } |
227 | } | 90 | } |
228 | 91 | ||
229 | std::string LLViewerLogin::getHelperURI() const | 92 | const std::string &LLViewerLogin::getGridLabel() const |
230 | { | 93 | { |
231 | std::string helper_uri = gSavedSettings.getString("CmdLineHelperURI"); | 94 | return gHippoGridManager->getConnectedGrid()->getGridNick(); |
232 | if (helper_uri.empty()) | 95 | } |
233 | { | ||
234 | // grab URI from selected grid | ||
235 | if(mGridChoice > GRID_INFO_NONE && mGridChoice < GRID_INFO_OTHER) | ||
236 | { | ||
237 | helper_uri = gGridInfo[mGridChoice].mHelperURI; | ||
238 | } | ||
239 | 96 | ||
240 | if (helper_uri.empty()) | 97 | const std::string &LLViewerLogin::getLoginPage() const |
241 | { | 98 | { |
242 | // what do we do with unnamed/miscellaneous grids? | 99 | return gHippoGridManager->getConnectedGrid()->getLoginPage(); |
243 | // for now, operations that rely on the helper URI (currency/land purchasing) will fail | ||
244 | } | ||
245 | } | ||
246 | return helper_uri; | ||
247 | } | 100 | } |
248 | 101 | ||
249 | bool LLViewerLogin::isInProductionGrid() | 102 | const std::string &LLViewerLogin::getHelperURI() const |
250 | { | 103 | { |
251 | // *NOTE:Mani This used to compare GRID_INFO_AGNI to gGridChoice, | 104 | return gHippoGridManager->getConnectedGrid()->getHelperUri(); |
252 | // but it seems that loginURI trumps that. | 105 | } |
253 | std::vector<std::string> uris; | 106 | |
254 | getLoginURIs(uris); | 107 | bool LLViewerLogin::isOpenSimulator() |
255 | LLStringUtil::toLower(uris[0]); | 108 | { |
109 | return gHippoGridManager->getConnectedGrid()->isOpenSimulator(); | ||
110 | } | ||
256 | 111 | ||
257 | // Returns true for every grid but Aditi now, | 112 | bool LLViewerLogin::isSecondLife() |
258 | // because opensim grids have feelings too! -- McCabe | 113 | { |
259 | if((uris[0].find("aditi") != std::string::npos)) | 114 | return gHippoGridManager->getConnectedGrid()->isSecondLife(); |
260 | { | 115 | } |
261 | return false; | ||
262 | } | ||
263 | 116 | ||
117 | bool LLViewerLogin::isInProductionGrid() | ||
118 | { | ||
264 | return true; | 119 | return true; |
265 | } | 120 | } |