diff options
Diffstat (limited to 'OpenSim/Services/LLLoginService')
-rw-r--r-- | OpenSim/Services/LLLoginService/LLLoginResponse.cs | 972 | ||||
-rw-r--r-- | OpenSim/Services/LLLoginService/LLLoginService.cs | 650 |
2 files changed, 1622 insertions, 0 deletions
diff --git a/OpenSim/Services/LLLoginService/LLLoginResponse.cs b/OpenSim/Services/LLLoginService/LLLoginResponse.cs new file mode 100644 index 0000000..05f5b4c --- /dev/null +++ b/OpenSim/Services/LLLoginService/LLLoginResponse.cs | |||
@@ -0,0 +1,972 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Net; | ||
32 | using System.Reflection; | ||
33 | |||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Framework.Capabilities; | ||
36 | using OpenSim.Services.Interfaces; | ||
37 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
38 | using FriendInfo = OpenSim.Services.Interfaces.FriendInfo; | ||
39 | |||
40 | using log4net; | ||
41 | using OpenMetaverse; | ||
42 | using OpenMetaverse.StructuredData; | ||
43 | using OSDArray = OpenMetaverse.StructuredData.OSDArray; | ||
44 | using OSDMap = OpenMetaverse.StructuredData.OSDMap; | ||
45 | |||
46 | namespace OpenSim.Services.LLLoginService | ||
47 | { | ||
48 | public class LLFailedLoginResponse : OpenSim.Services.Interfaces.FailedLoginResponse | ||
49 | { | ||
50 | string m_key; | ||
51 | string m_value; | ||
52 | string m_login; | ||
53 | |||
54 | public static LLFailedLoginResponse UserProblem; | ||
55 | public static LLFailedLoginResponse AuthorizationProblem; | ||
56 | public static LLFailedLoginResponse GridProblem; | ||
57 | public static LLFailedLoginResponse InventoryProblem; | ||
58 | public static LLFailedLoginResponse DeadRegionProblem; | ||
59 | public static LLFailedLoginResponse LoginBlockedProblem; | ||
60 | public static LLFailedLoginResponse AlreadyLoggedInProblem; | ||
61 | public static LLFailedLoginResponse InternalError; | ||
62 | |||
63 | static LLFailedLoginResponse() | ||
64 | { | ||
65 | UserProblem = new LLFailedLoginResponse("key", | ||
66 | "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.", | ||
67 | "false"); | ||
68 | AuthorizationProblem = new LLFailedLoginResponse("key", | ||
69 | "Error connecting to grid. Unable to authorize your session into the region.", | ||
70 | "false"); | ||
71 | GridProblem = new LLFailedLoginResponse("key", | ||
72 | "Error connecting to the desired location. Try connecting to another region.", | ||
73 | "false"); | ||
74 | InventoryProblem = new LLFailedLoginResponse("key", | ||
75 | "The inventory service is not responding. Please notify your login region operator.", | ||
76 | "false"); | ||
77 | DeadRegionProblem = new LLFailedLoginResponse("key", | ||
78 | "The region you are attempting to log into is not responding. Please select another region and try again.", | ||
79 | "false"); | ||
80 | LoginBlockedProblem = new LLFailedLoginResponse("presence", | ||
81 | "Logins are currently restricted. Please try again later.", | ||
82 | "false"); | ||
83 | AlreadyLoggedInProblem = new LLFailedLoginResponse("presence", | ||
84 | "You appear to be already logged in. " + | ||
85 | "If this is not the case please wait for your session to timeout. " + | ||
86 | "If this takes longer than a few minutes please contact the grid owner. " + | ||
87 | "Please wait 5 minutes if you are going to connect to a region nearby to the region you were at previously.", | ||
88 | "false"); | ||
89 | InternalError = new LLFailedLoginResponse("Internal Error", "Error generating Login Response", "false"); | ||
90 | } | ||
91 | |||
92 | public LLFailedLoginResponse(string key, string value, string login) | ||
93 | { | ||
94 | m_key = key; | ||
95 | m_value = value; | ||
96 | m_login = login; | ||
97 | } | ||
98 | |||
99 | public override Hashtable ToHashtable() | ||
100 | { | ||
101 | Hashtable loginError = new Hashtable(); | ||
102 | loginError["reason"] = m_key; | ||
103 | loginError["message"] = m_value; | ||
104 | loginError["login"] = m_login; | ||
105 | return loginError; | ||
106 | } | ||
107 | |||
108 | public override OSD ToOSDMap() | ||
109 | { | ||
110 | OSDMap map = new OSDMap(); | ||
111 | |||
112 | map["reason"] = OSD.FromString(m_key); | ||
113 | map["message"] = OSD.FromString(m_value); | ||
114 | map["login"] = OSD.FromString(m_login); | ||
115 | |||
116 | return map; | ||
117 | } | ||
118 | } | ||
119 | |||
120 | /// <summary> | ||
121 | /// A class to handle LL login response. | ||
122 | /// </summary> | ||
123 | public class LLLoginResponse : OpenSim.Services.Interfaces.LoginResponse | ||
124 | { | ||
125 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
126 | private static Hashtable globalTexturesHash; | ||
127 | // Global Textures | ||
128 | private static string sunTexture = "cce0f112-878f-4586-a2e2-a8f104bba271"; | ||
129 | private static string cloudTexture = "dc4b9f0b-d008-45c6-96a4-01dd947ac621"; | ||
130 | private static string moonTexture = "ec4b9f0b-d008-45c6-96a4-01dd947ac621"; | ||
131 | |||
132 | private Hashtable loginFlagsHash; | ||
133 | private Hashtable uiConfigHash; | ||
134 | |||
135 | private ArrayList loginFlags; | ||
136 | private ArrayList globalTextures; | ||
137 | private ArrayList eventCategories; | ||
138 | private ArrayList uiConfig; | ||
139 | private ArrayList classifiedCategories; | ||
140 | private ArrayList inventoryRoot; | ||
141 | private ArrayList initialOutfit; | ||
142 | private ArrayList agentInventory; | ||
143 | private ArrayList inventoryLibraryOwner; | ||
144 | private ArrayList inventoryLibRoot; | ||
145 | private ArrayList inventoryLibrary; | ||
146 | private ArrayList activeGestures; | ||
147 | |||
148 | private UserInfo userProfile; | ||
149 | |||
150 | private UUID agentID; | ||
151 | private UUID sessionID; | ||
152 | private UUID secureSessionID; | ||
153 | |||
154 | // Login Flags | ||
155 | private string dst; | ||
156 | private string stipendSinceLogin; | ||
157 | private string gendered; | ||
158 | private string everLoggedIn; | ||
159 | private string login; | ||
160 | private uint simPort; | ||
161 | private uint simHttpPort; | ||
162 | private string simAddress; | ||
163 | private string agentAccess; | ||
164 | private string agentAccessMax; | ||
165 | private Int32 circuitCode; | ||
166 | private uint regionX; | ||
167 | private uint regionY; | ||
168 | |||
169 | // Login | ||
170 | private string firstname; | ||
171 | private string lastname; | ||
172 | |||
173 | // Error Flags | ||
174 | private string errorReason; | ||
175 | private string errorMessage; | ||
176 | |||
177 | private string welcomeMessage; | ||
178 | private string startLocation; | ||
179 | private string allowFirstLife; | ||
180 | private string home; | ||
181 | private string seedCapability; | ||
182 | private string lookAt; | ||
183 | |||
184 | private BuddyList m_buddyList = null; | ||
185 | |||
186 | static LLLoginResponse() | ||
187 | { | ||
188 | // This is being set, but it's not used | ||
189 | // not sure why. | ||
190 | globalTexturesHash = new Hashtable(); | ||
191 | globalTexturesHash["sun_texture_id"] = sunTexture; | ||
192 | globalTexturesHash["cloud_texture_id"] = cloudTexture; | ||
193 | globalTexturesHash["moon_texture_id"] = moonTexture; | ||
194 | } | ||
195 | |||
196 | public LLLoginResponse() | ||
197 | { | ||
198 | loginFlags = new ArrayList(); | ||
199 | globalTextures = new ArrayList(); | ||
200 | eventCategories = new ArrayList(); | ||
201 | uiConfig = new ArrayList(); | ||
202 | classifiedCategories = new ArrayList(); | ||
203 | |||
204 | uiConfigHash = new Hashtable(); | ||
205 | |||
206 | // defaultXmlRpcResponse = new XmlRpcResponse(); | ||
207 | userProfile = new UserInfo(); | ||
208 | inventoryRoot = new ArrayList(); | ||
209 | initialOutfit = new ArrayList(); | ||
210 | agentInventory = new ArrayList(); | ||
211 | inventoryLibrary = new ArrayList(); | ||
212 | inventoryLibraryOwner = new ArrayList(); | ||
213 | activeGestures = new ArrayList(); | ||
214 | |||
215 | SetDefaultValues(); | ||
216 | } | ||
217 | |||
218 | public LLLoginResponse(UserAccount account, AgentCircuitData aCircuit, PresenceInfo pinfo, | ||
219 | GridRegion destination, List<InventoryFolderBase> invSkel, FriendInfo[] friendsList, ILibraryService libService, | ||
220 | string where, string startlocation, Vector3 position, Vector3 lookAt, string message, | ||
221 | GridRegion home, IPEndPoint clientIP) | ||
222 | : this() | ||
223 | { | ||
224 | FillOutInventoryData(invSkel, libService); | ||
225 | |||
226 | CircuitCode = (int)aCircuit.circuitcode; | ||
227 | Lastname = account.LastName; | ||
228 | Firstname = account.FirstName; | ||
229 | AgentID = account.PrincipalID; | ||
230 | SessionID = aCircuit.SessionID; | ||
231 | SecureSessionID = aCircuit.SecureSessionID; | ||
232 | Message = message; | ||
233 | BuddList = ConvertFriendListItem(friendsList); | ||
234 | StartLocation = where; | ||
235 | |||
236 | FillOutHomeData(pinfo, home); | ||
237 | LookAt = String.Format("[r{0},r{1},r{2}]", lookAt.X, lookAt.Y, lookAt.Z); | ||
238 | |||
239 | FillOutRegionData(destination); | ||
240 | |||
241 | FillOutSeedCap(aCircuit, destination, clientIP); | ||
242 | |||
243 | } | ||
244 | |||
245 | private void FillOutInventoryData(List<InventoryFolderBase> invSkel, ILibraryService libService) | ||
246 | { | ||
247 | InventoryData inventData = null; | ||
248 | |||
249 | try | ||
250 | { | ||
251 | inventData = GetInventorySkeleton(invSkel); | ||
252 | } | ||
253 | catch (Exception e) | ||
254 | { | ||
255 | m_log.WarnFormat( | ||
256 | "[LLLOGIN SERVICE]: Error processing inventory skeleton of agent {0} - {1}", | ||
257 | agentID, e); | ||
258 | |||
259 | // ignore and continue | ||
260 | } | ||
261 | |||
262 | if (inventData != null) | ||
263 | { | ||
264 | ArrayList AgentInventoryArray = inventData.InventoryArray; | ||
265 | |||
266 | Hashtable InventoryRootHash = new Hashtable(); | ||
267 | InventoryRootHash["folder_id"] = inventData.RootFolderID.ToString(); | ||
268 | InventoryRoot = new ArrayList(); | ||
269 | InventoryRoot.Add(InventoryRootHash); | ||
270 | InventorySkeleton = AgentInventoryArray; | ||
271 | } | ||
272 | |||
273 | // Inventory Library Section | ||
274 | if (libService != null && libService.LibraryRootFolder != null) | ||
275 | { | ||
276 | Hashtable InventoryLibRootHash = new Hashtable(); | ||
277 | InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; | ||
278 | InventoryLibRoot = new ArrayList(); | ||
279 | InventoryLibRoot.Add(InventoryLibRootHash); | ||
280 | |||
281 | InventoryLibraryOwner = GetLibraryOwner(libService.LibraryRootFolder); | ||
282 | InventoryLibrary = GetInventoryLibrary(libService); | ||
283 | } | ||
284 | } | ||
285 | |||
286 | private void FillOutHomeData(PresenceInfo pinfo, GridRegion home) | ||
287 | { | ||
288 | int x = 1000 * (int)Constants.RegionSize, y = 1000 * (int)Constants.RegionSize; | ||
289 | if (home != null) | ||
290 | { | ||
291 | x = home.RegionLocX; | ||
292 | y = home.RegionLocY; | ||
293 | } | ||
294 | |||
295 | Home = string.Format( | ||
296 | "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", | ||
297 | x, | ||
298 | y, | ||
299 | pinfo.HomePosition.X, pinfo.HomePosition.Y, pinfo.HomePosition.Z, | ||
300 | pinfo.HomeLookAt.X, pinfo.HomeLookAt.Y, pinfo.HomeLookAt.Z); | ||
301 | |||
302 | } | ||
303 | |||
304 | private void FillOutRegionData(GridRegion destination) | ||
305 | { | ||
306 | IPEndPoint endPoint = destination.ExternalEndPoint; | ||
307 | SimAddress = endPoint.Address.ToString(); | ||
308 | SimPort = (uint)endPoint.Port; | ||
309 | RegionX = (uint)destination.RegionLocX; | ||
310 | RegionY = (uint)destination.RegionLocY; | ||
311 | } | ||
312 | |||
313 | private void FillOutSeedCap(AgentCircuitData aCircuit, GridRegion destination, IPEndPoint ipepClient) | ||
314 | { | ||
315 | string capsSeedPath = String.Empty; | ||
316 | |||
317 | // Don't use the following! It Fails for logging into any region not on the same port as the http server! | ||
318 | // Kept here so it doesn't happen again! | ||
319 | // response.SeedCapability = regionInfo.ServerURI + capsSeedPath; | ||
320 | |||
321 | #region IP Translation for NAT | ||
322 | if (ipepClient != null) | ||
323 | { | ||
324 | capsSeedPath | ||
325 | = "http://" | ||
326 | + NetworkUtil.GetHostFor(ipepClient.Address, destination.ExternalHostName) | ||
327 | + ":" | ||
328 | + destination.HttpPort | ||
329 | + CapsUtil.GetCapsSeedPath(aCircuit.CapsPath); | ||
330 | } | ||
331 | else | ||
332 | { | ||
333 | capsSeedPath | ||
334 | = "http://" | ||
335 | + destination.ExternalHostName | ||
336 | + ":" | ||
337 | + destination.HttpPort | ||
338 | + CapsUtil.GetCapsSeedPath(aCircuit.CapsPath); | ||
339 | } | ||
340 | #endregion | ||
341 | |||
342 | SeedCapability = capsSeedPath; | ||
343 | } | ||
344 | |||
345 | private void SetDefaultValues() | ||
346 | { | ||
347 | DST = TimeZone.CurrentTimeZone.IsDaylightSavingTime(DateTime.Now) ? "Y" : "N"; | ||
348 | StipendSinceLogin = "N"; | ||
349 | Gendered = "Y"; | ||
350 | EverLoggedIn = "Y"; | ||
351 | login = "false"; | ||
352 | firstname = "Test"; | ||
353 | lastname = "User"; | ||
354 | agentAccess = "M"; | ||
355 | agentAccessMax = "A"; | ||
356 | startLocation = "last"; | ||
357 | allowFirstLife = "Y"; | ||
358 | |||
359 | ErrorMessage = "You have entered an invalid name/password combination. Check Caps/lock."; | ||
360 | ErrorReason = "key"; | ||
361 | welcomeMessage = "Welcome to OpenSim!"; | ||
362 | seedCapability = String.Empty; | ||
363 | home = "{'region_handle':[r" + (1000*Constants.RegionSize).ToString() + ",r" + (1000*Constants.RegionSize).ToString() + "], 'position':[r" + | ||
364 | userProfile.homepos.X.ToString() + ",r" + userProfile.homepos.Y.ToString() + ",r" + | ||
365 | userProfile.homepos.Z.ToString() + "], 'look_at':[r" + userProfile.homelookat.X.ToString() + ",r" + | ||
366 | userProfile.homelookat.Y.ToString() + ",r" + userProfile.homelookat.Z.ToString() + "]}"; | ||
367 | lookAt = "[r0.99949799999999999756,r0.03166859999999999814,r0]"; | ||
368 | RegionX = (uint) 255232; | ||
369 | RegionY = (uint) 254976; | ||
370 | |||
371 | // Classifieds; | ||
372 | AddClassifiedCategory((Int32) 1, "Shopping"); | ||
373 | AddClassifiedCategory((Int32) 2, "Land Rental"); | ||
374 | AddClassifiedCategory((Int32) 3, "Property Rental"); | ||
375 | AddClassifiedCategory((Int32) 4, "Special Attraction"); | ||
376 | AddClassifiedCategory((Int32) 5, "New Products"); | ||
377 | AddClassifiedCategory((Int32) 6, "Employment"); | ||
378 | AddClassifiedCategory((Int32) 7, "Wanted"); | ||
379 | AddClassifiedCategory((Int32) 8, "Service"); | ||
380 | AddClassifiedCategory((Int32) 9, "Personal"); | ||
381 | |||
382 | SessionID = UUID.Random(); | ||
383 | SecureSessionID = UUID.Random(); | ||
384 | AgentID = UUID.Random(); | ||
385 | |||
386 | Hashtable InitialOutfitHash = new Hashtable(); | ||
387 | InitialOutfitHash["folder_name"] = "Nightclub Female"; | ||
388 | InitialOutfitHash["gender"] = "female"; | ||
389 | initialOutfit.Add(InitialOutfitHash); | ||
390 | } | ||
391 | |||
392 | |||
393 | public override Hashtable ToHashtable() | ||
394 | { | ||
395 | try | ||
396 | { | ||
397 | Hashtable responseData = new Hashtable(); | ||
398 | |||
399 | loginFlagsHash = new Hashtable(); | ||
400 | loginFlagsHash["daylight_savings"] = DST; | ||
401 | loginFlagsHash["stipend_since_login"] = StipendSinceLogin; | ||
402 | loginFlagsHash["gendered"] = Gendered; | ||
403 | loginFlagsHash["ever_logged_in"] = EverLoggedIn; | ||
404 | loginFlags.Add(loginFlagsHash); | ||
405 | |||
406 | responseData["first_name"] = Firstname; | ||
407 | responseData["last_name"] = Lastname; | ||
408 | responseData["agent_access"] = agentAccess; | ||
409 | responseData["agent_access_max"] = agentAccessMax; | ||
410 | |||
411 | globalTextures.Add(globalTexturesHash); | ||
412 | // this.eventCategories.Add(this.eventCategoriesHash); | ||
413 | |||
414 | AddToUIConfig("allow_first_life", allowFirstLife); | ||
415 | uiConfig.Add(uiConfigHash); | ||
416 | |||
417 | responseData["sim_port"] = (Int32) SimPort; | ||
418 | responseData["sim_ip"] = SimAddress; | ||
419 | responseData["http_port"] = (Int32)SimHttpPort; | ||
420 | |||
421 | responseData["agent_id"] = AgentID.ToString(); | ||
422 | responseData["session_id"] = SessionID.ToString(); | ||
423 | responseData["secure_session_id"] = SecureSessionID.ToString(); | ||
424 | responseData["circuit_code"] = CircuitCode; | ||
425 | responseData["seconds_since_epoch"] = (Int32) (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; | ||
426 | responseData["login-flags"] = loginFlags; | ||
427 | responseData["global-textures"] = globalTextures; | ||
428 | responseData["seed_capability"] = seedCapability; | ||
429 | |||
430 | responseData["event_categories"] = eventCategories; | ||
431 | responseData["event_notifications"] = new ArrayList(); // todo | ||
432 | responseData["classified_categories"] = classifiedCategories; | ||
433 | responseData["ui-config"] = uiConfig; | ||
434 | |||
435 | if (agentInventory != null) | ||
436 | { | ||
437 | responseData["inventory-skeleton"] = agentInventory; | ||
438 | responseData["inventory-root"] = inventoryRoot; | ||
439 | } | ||
440 | responseData["inventory-skel-lib"] = inventoryLibrary; | ||
441 | responseData["inventory-lib-root"] = inventoryLibRoot; | ||
442 | responseData["gestures"] = activeGestures; | ||
443 | responseData["inventory-lib-owner"] = inventoryLibraryOwner; | ||
444 | responseData["initial-outfit"] = initialOutfit; | ||
445 | responseData["start_location"] = startLocation; | ||
446 | responseData["seed_capability"] = seedCapability; | ||
447 | responseData["home"] = home; | ||
448 | responseData["look_at"] = lookAt; | ||
449 | responseData["message"] = welcomeMessage; | ||
450 | responseData["region_x"] = (Int32)(RegionX); | ||
451 | responseData["region_y"] = (Int32)(RegionY); | ||
452 | |||
453 | if (m_buddyList != null) | ||
454 | { | ||
455 | responseData["buddy-list"] = m_buddyList.ToArray(); | ||
456 | } | ||
457 | |||
458 | responseData["login"] = "true"; | ||
459 | |||
460 | return responseData; | ||
461 | } | ||
462 | catch (Exception e) | ||
463 | { | ||
464 | m_log.Warn("[CLIENT]: LoginResponse: Error creating Hashtable Response: " + e.Message); | ||
465 | |||
466 | return LLFailedLoginResponse.InternalError.ToHashtable(); | ||
467 | } | ||
468 | } | ||
469 | |||
470 | public override OSD ToOSDMap() | ||
471 | { | ||
472 | try | ||
473 | { | ||
474 | OSDMap map = new OSDMap(); | ||
475 | |||
476 | map["first_name"] = OSD.FromString(Firstname); | ||
477 | map["last_name"] = OSD.FromString(Lastname); | ||
478 | map["agent_access"] = OSD.FromString(agentAccess); | ||
479 | map["agent_access_max"] = OSD.FromString(agentAccessMax); | ||
480 | |||
481 | map["sim_port"] = OSD.FromInteger(SimPort); | ||
482 | map["sim_ip"] = OSD.FromString(SimAddress); | ||
483 | |||
484 | map["agent_id"] = OSD.FromUUID(AgentID); | ||
485 | map["session_id"] = OSD.FromUUID(SessionID); | ||
486 | map["secure_session_id"] = OSD.FromUUID(SecureSessionID); | ||
487 | map["circuit_code"] = OSD.FromInteger(CircuitCode); | ||
488 | map["seconds_since_epoch"] = OSD.FromInteger((int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds); | ||
489 | |||
490 | #region Login Flags | ||
491 | |||
492 | OSDMap loginFlagsLLSD = new OSDMap(); | ||
493 | loginFlagsLLSD["daylight_savings"] = OSD.FromString(DST); | ||
494 | loginFlagsLLSD["stipend_since_login"] = OSD.FromString(StipendSinceLogin); | ||
495 | loginFlagsLLSD["gendered"] = OSD.FromString(Gendered); | ||
496 | loginFlagsLLSD["ever_logged_in"] = OSD.FromString(EverLoggedIn); | ||
497 | map["login-flags"] = WrapOSDMap(loginFlagsLLSD); | ||
498 | |||
499 | #endregion Login Flags | ||
500 | |||
501 | #region Global Textures | ||
502 | |||
503 | OSDMap globalTexturesLLSD = new OSDMap(); | ||
504 | globalTexturesLLSD["sun_texture_id"] = OSD.FromString(SunTexture); | ||
505 | globalTexturesLLSD["cloud_texture_id"] = OSD.FromString(CloudTexture); | ||
506 | globalTexturesLLSD["moon_texture_id"] = OSD.FromString(MoonTexture); | ||
507 | |||
508 | map["global-textures"] = WrapOSDMap(globalTexturesLLSD); | ||
509 | |||
510 | #endregion Global Textures | ||
511 | |||
512 | map["seed_capability"] = OSD.FromString(seedCapability); | ||
513 | |||
514 | map["event_categories"] = ArrayListToOSDArray(eventCategories); | ||
515 | //map["event_notifications"] = new OSDArray(); // todo | ||
516 | map["classified_categories"] = ArrayListToOSDArray(classifiedCategories); | ||
517 | |||
518 | #region UI Config | ||
519 | |||
520 | OSDMap uiConfigLLSD = new OSDMap(); | ||
521 | uiConfigLLSD["allow_first_life"] = OSD.FromString(allowFirstLife); | ||
522 | map["ui-config"] = WrapOSDMap(uiConfigLLSD); | ||
523 | |||
524 | #endregion UI Config | ||
525 | |||
526 | #region Inventory | ||
527 | |||
528 | map["inventory-skeleton"] = ArrayListToOSDArray(agentInventory); | ||
529 | |||
530 | map["inventory-skel-lib"] = ArrayListToOSDArray(inventoryLibrary); | ||
531 | map["inventory-root"] = ArrayListToOSDArray(inventoryRoot); ; | ||
532 | map["inventory-lib-root"] = ArrayListToOSDArray(inventoryLibRoot); | ||
533 | map["inventory-lib-owner"] = ArrayListToOSDArray(inventoryLibraryOwner); | ||
534 | |||
535 | #endregion Inventory | ||
536 | |||
537 | map["gestures"] = ArrayListToOSDArray(activeGestures); | ||
538 | |||
539 | map["initial-outfit"] = ArrayListToOSDArray(initialOutfit); | ||
540 | map["start_location"] = OSD.FromString(startLocation); | ||
541 | |||
542 | map["seed_capability"] = OSD.FromString(seedCapability); | ||
543 | map["home"] = OSD.FromString(home); | ||
544 | map["look_at"] = OSD.FromString(lookAt); | ||
545 | map["message"] = OSD.FromString(welcomeMessage); | ||
546 | map["region_x"] = OSD.FromInteger(RegionX); | ||
547 | map["region_y"] = OSD.FromInteger(RegionY); | ||
548 | |||
549 | if (m_buddyList != null) | ||
550 | { | ||
551 | map["buddy-list"] = ArrayListToOSDArray(m_buddyList.ToArray()); | ||
552 | } | ||
553 | |||
554 | map["login"] = OSD.FromString("true"); | ||
555 | |||
556 | return map; | ||
557 | } | ||
558 | catch (Exception e) | ||
559 | { | ||
560 | m_log.Warn("[CLIENT]: LoginResponse: Error creating LLSD Response: " + e.Message); | ||
561 | |||
562 | return LLFailedLoginResponse.InternalError.ToOSDMap(); | ||
563 | } | ||
564 | } | ||
565 | |||
566 | public OSDArray ArrayListToOSDArray(ArrayList arrlst) | ||
567 | { | ||
568 | OSDArray llsdBack = new OSDArray(); | ||
569 | foreach (Hashtable ht in arrlst) | ||
570 | { | ||
571 | OSDMap mp = new OSDMap(); | ||
572 | foreach (DictionaryEntry deHt in ht) | ||
573 | { | ||
574 | mp.Add((string)deHt.Key, OSDString.FromObject(deHt.Value)); | ||
575 | } | ||
576 | llsdBack.Add(mp); | ||
577 | } | ||
578 | return llsdBack; | ||
579 | } | ||
580 | |||
581 | private static OSDArray WrapOSDMap(OSDMap wrapMe) | ||
582 | { | ||
583 | OSDArray array = new OSDArray(); | ||
584 | array.Add(wrapMe); | ||
585 | return array; | ||
586 | } | ||
587 | |||
588 | public void SetEventCategories(string category, string value) | ||
589 | { | ||
590 | // this.eventCategoriesHash[category] = value; | ||
591 | //TODO | ||
592 | } | ||
593 | |||
594 | public void AddToUIConfig(string itemName, string item) | ||
595 | { | ||
596 | uiConfigHash[itemName] = item; | ||
597 | } | ||
598 | |||
599 | public void AddClassifiedCategory(Int32 ID, string categoryName) | ||
600 | { | ||
601 | Hashtable hash = new Hashtable(); | ||
602 | hash["category_name"] = categoryName; | ||
603 | hash["category_id"] = ID; | ||
604 | classifiedCategories.Add(hash); | ||
605 | // this.classifiedCategoriesHash.Clear(); | ||
606 | } | ||
607 | |||
608 | |||
609 | private static LLLoginResponse.BuddyList ConvertFriendListItem(FriendInfo[] friendsList) | ||
610 | { | ||
611 | LLLoginResponse.BuddyList buddylistreturn = new LLLoginResponse.BuddyList(); | ||
612 | foreach (FriendInfo finfo in friendsList) | ||
613 | { | ||
614 | if (finfo.TheirFlags == -1) | ||
615 | continue; | ||
616 | LLLoginResponse.BuddyList.BuddyInfo buddyitem = new LLLoginResponse.BuddyList.BuddyInfo(finfo.Friend); | ||
617 | buddyitem.BuddyID = finfo.Friend; | ||
618 | buddyitem.BuddyRightsHave = (int)finfo.TheirFlags; | ||
619 | buddyitem.BuddyRightsGiven = (int)finfo.MyFlags; | ||
620 | buddylistreturn.AddNewBuddy(buddyitem); | ||
621 | } | ||
622 | return buddylistreturn; | ||
623 | } | ||
624 | |||
625 | private InventoryData GetInventorySkeleton(List<InventoryFolderBase> folders) | ||
626 | { | ||
627 | UUID rootID = UUID.Zero; | ||
628 | ArrayList AgentInventoryArray = new ArrayList(); | ||
629 | Hashtable TempHash; | ||
630 | foreach (InventoryFolderBase InvFolder in folders) | ||
631 | { | ||
632 | if (InvFolder.ParentID == UUID.Zero) | ||
633 | { | ||
634 | rootID = InvFolder.ID; | ||
635 | } | ||
636 | TempHash = new Hashtable(); | ||
637 | TempHash["name"] = InvFolder.Name; | ||
638 | TempHash["parent_id"] = InvFolder.ParentID.ToString(); | ||
639 | TempHash["version"] = (Int32)InvFolder.Version; | ||
640 | TempHash["type_default"] = (Int32)InvFolder.Type; | ||
641 | TempHash["folder_id"] = InvFolder.ID.ToString(); | ||
642 | AgentInventoryArray.Add(TempHash); | ||
643 | } | ||
644 | |||
645 | return new InventoryData(AgentInventoryArray, rootID); | ||
646 | |||
647 | } | ||
648 | |||
649 | /// <summary> | ||
650 | /// Converts the inventory library skeleton into the form required by the rpc request. | ||
651 | /// </summary> | ||
652 | /// <returns></returns> | ||
653 | protected virtual ArrayList GetInventoryLibrary(ILibraryService library) | ||
654 | { | ||
655 | Dictionary<UUID, InventoryFolderImpl> rootFolders = library.GetAllFolders(); | ||
656 | m_log.DebugFormat("[LLOGIN]: Library has {0} folders", rootFolders.Count); | ||
657 | //Dictionary<UUID, InventoryFolderImpl> rootFolders = new Dictionary<UUID,InventoryFolderImpl>(); | ||
658 | ArrayList folderHashes = new ArrayList(); | ||
659 | |||
660 | foreach (InventoryFolderBase folder in rootFolders.Values) | ||
661 | { | ||
662 | Hashtable TempHash = new Hashtable(); | ||
663 | TempHash["name"] = folder.Name; | ||
664 | TempHash["parent_id"] = folder.ParentID.ToString(); | ||
665 | TempHash["version"] = (Int32)folder.Version; | ||
666 | TempHash["type_default"] = (Int32)folder.Type; | ||
667 | TempHash["folder_id"] = folder.ID.ToString(); | ||
668 | folderHashes.Add(TempHash); | ||
669 | } | ||
670 | |||
671 | return folderHashes; | ||
672 | } | ||
673 | |||
674 | /// <summary> | ||
675 | /// | ||
676 | /// </summary> | ||
677 | /// <returns></returns> | ||
678 | protected virtual ArrayList GetLibraryOwner(InventoryFolderImpl libFolder) | ||
679 | { | ||
680 | //for now create random inventory library owner | ||
681 | Hashtable TempHash = new Hashtable(); | ||
682 | TempHash["agent_id"] = "11111111-1111-0000-0000-000100bba000"; // libFolder.Owner | ||
683 | ArrayList inventoryLibOwner = new ArrayList(); | ||
684 | inventoryLibOwner.Add(TempHash); | ||
685 | return inventoryLibOwner; | ||
686 | } | ||
687 | |||
688 | public class InventoryData | ||
689 | { | ||
690 | public ArrayList InventoryArray = null; | ||
691 | public UUID RootFolderID = UUID.Zero; | ||
692 | |||
693 | public InventoryData(ArrayList invList, UUID rootID) | ||
694 | { | ||
695 | InventoryArray = invList; | ||
696 | RootFolderID = rootID; | ||
697 | } | ||
698 | } | ||
699 | |||
700 | #region Properties | ||
701 | |||
702 | public string Login | ||
703 | { | ||
704 | get { return login; } | ||
705 | set { login = value; } | ||
706 | } | ||
707 | |||
708 | public string DST | ||
709 | { | ||
710 | get { return dst; } | ||
711 | set { dst = value; } | ||
712 | } | ||
713 | |||
714 | public string StipendSinceLogin | ||
715 | { | ||
716 | get { return stipendSinceLogin; } | ||
717 | set { stipendSinceLogin = value; } | ||
718 | } | ||
719 | |||
720 | public string Gendered | ||
721 | { | ||
722 | get { return gendered; } | ||
723 | set { gendered = value; } | ||
724 | } | ||
725 | |||
726 | public string EverLoggedIn | ||
727 | { | ||
728 | get { return everLoggedIn; } | ||
729 | set { everLoggedIn = value; } | ||
730 | } | ||
731 | |||
732 | public uint SimPort | ||
733 | { | ||
734 | get { return simPort; } | ||
735 | set { simPort = value; } | ||
736 | } | ||
737 | |||
738 | public uint SimHttpPort | ||
739 | { | ||
740 | get { return simHttpPort; } | ||
741 | set { simHttpPort = value; } | ||
742 | } | ||
743 | |||
744 | public string SimAddress | ||
745 | { | ||
746 | get { return simAddress; } | ||
747 | set { simAddress = value; } | ||
748 | } | ||
749 | |||
750 | public UUID AgentID | ||
751 | { | ||
752 | get { return agentID; } | ||
753 | set { agentID = value; } | ||
754 | } | ||
755 | |||
756 | public UUID SessionID | ||
757 | { | ||
758 | get { return sessionID; } | ||
759 | set { sessionID = value; } | ||
760 | } | ||
761 | |||
762 | public UUID SecureSessionID | ||
763 | { | ||
764 | get { return secureSessionID; } | ||
765 | set { secureSessionID = value; } | ||
766 | } | ||
767 | |||
768 | public Int32 CircuitCode | ||
769 | { | ||
770 | get { return circuitCode; } | ||
771 | set { circuitCode = value; } | ||
772 | } | ||
773 | |||
774 | public uint RegionX | ||
775 | { | ||
776 | get { return regionX; } | ||
777 | set { regionX = value; } | ||
778 | } | ||
779 | |||
780 | public uint RegionY | ||
781 | { | ||
782 | get { return regionY; } | ||
783 | set { regionY = value; } | ||
784 | } | ||
785 | |||
786 | public string SunTexture | ||
787 | { | ||
788 | get { return sunTexture; } | ||
789 | set { sunTexture = value; } | ||
790 | } | ||
791 | |||
792 | public string CloudTexture | ||
793 | { | ||
794 | get { return cloudTexture; } | ||
795 | set { cloudTexture = value; } | ||
796 | } | ||
797 | |||
798 | public string MoonTexture | ||
799 | { | ||
800 | get { return moonTexture; } | ||
801 | set { moonTexture = value; } | ||
802 | } | ||
803 | |||
804 | public string Firstname | ||
805 | { | ||
806 | get { return firstname; } | ||
807 | set { firstname = value; } | ||
808 | } | ||
809 | |||
810 | public string Lastname | ||
811 | { | ||
812 | get { return lastname; } | ||
813 | set { lastname = value; } | ||
814 | } | ||
815 | |||
816 | public string AgentAccess | ||
817 | { | ||
818 | get { return agentAccess; } | ||
819 | set { agentAccess = value; } | ||
820 | } | ||
821 | |||
822 | public string AgentAccessMax | ||
823 | { | ||
824 | get { return agentAccessMax; } | ||
825 | set { agentAccessMax = value; } | ||
826 | } | ||
827 | |||
828 | public string StartLocation | ||
829 | { | ||
830 | get { return startLocation; } | ||
831 | set { startLocation = value; } | ||
832 | } | ||
833 | |||
834 | public string LookAt | ||
835 | { | ||
836 | get { return lookAt; } | ||
837 | set { lookAt = value; } | ||
838 | } | ||
839 | |||
840 | public string SeedCapability | ||
841 | { | ||
842 | get { return seedCapability; } | ||
843 | set { seedCapability = value; } | ||
844 | } | ||
845 | |||
846 | public string ErrorReason | ||
847 | { | ||
848 | get { return errorReason; } | ||
849 | set { errorReason = value; } | ||
850 | } | ||
851 | |||
852 | public string ErrorMessage | ||
853 | { | ||
854 | get { return errorMessage; } | ||
855 | set { errorMessage = value; } | ||
856 | } | ||
857 | |||
858 | public ArrayList InventoryRoot | ||
859 | { | ||
860 | get { return inventoryRoot; } | ||
861 | set { inventoryRoot = value; } | ||
862 | } | ||
863 | |||
864 | public ArrayList InventorySkeleton | ||
865 | { | ||
866 | get { return agentInventory; } | ||
867 | set { agentInventory = value; } | ||
868 | } | ||
869 | |||
870 | public ArrayList InventoryLibrary | ||
871 | { | ||
872 | get { return inventoryLibrary; } | ||
873 | set { inventoryLibrary = value; } | ||
874 | } | ||
875 | |||
876 | public ArrayList InventoryLibraryOwner | ||
877 | { | ||
878 | get { return inventoryLibraryOwner; } | ||
879 | set { inventoryLibraryOwner = value; } | ||
880 | } | ||
881 | |||
882 | public ArrayList InventoryLibRoot | ||
883 | { | ||
884 | get { return inventoryLibRoot; } | ||
885 | set { inventoryLibRoot = value; } | ||
886 | } | ||
887 | |||
888 | public ArrayList ActiveGestures | ||
889 | { | ||
890 | get { return activeGestures; } | ||
891 | set { activeGestures = value; } | ||
892 | } | ||
893 | |||
894 | public string Home | ||
895 | { | ||
896 | get { return home; } | ||
897 | set { home = value; } | ||
898 | } | ||
899 | |||
900 | public string Message | ||
901 | { | ||
902 | get { return welcomeMessage; } | ||
903 | set { welcomeMessage = value; } | ||
904 | } | ||
905 | |||
906 | public BuddyList BuddList | ||
907 | { | ||
908 | get { return m_buddyList; } | ||
909 | set { m_buddyList = value; } | ||
910 | } | ||
911 | |||
912 | #endregion | ||
913 | |||
914 | public class UserInfo | ||
915 | { | ||
916 | public string firstname; | ||
917 | public string lastname; | ||
918 | public ulong homeregionhandle; | ||
919 | public Vector3 homepos; | ||
920 | public Vector3 homelookat; | ||
921 | } | ||
922 | |||
923 | public class BuddyList | ||
924 | { | ||
925 | public List<BuddyInfo> Buddies = new List<BuddyInfo>(); | ||
926 | |||
927 | public void AddNewBuddy(BuddyInfo buddy) | ||
928 | { | ||
929 | if (!Buddies.Contains(buddy)) | ||
930 | { | ||
931 | Buddies.Add(buddy); | ||
932 | } | ||
933 | } | ||
934 | |||
935 | public ArrayList ToArray() | ||
936 | { | ||
937 | ArrayList buddyArray = new ArrayList(); | ||
938 | foreach (BuddyInfo buddy in Buddies) | ||
939 | { | ||
940 | buddyArray.Add(buddy.ToHashTable()); | ||
941 | } | ||
942 | return buddyArray; | ||
943 | } | ||
944 | |||
945 | public class BuddyInfo | ||
946 | { | ||
947 | public int BuddyRightsHave = 1; | ||
948 | public int BuddyRightsGiven = 1; | ||
949 | public string BuddyID; | ||
950 | |||
951 | public BuddyInfo(string buddyID) | ||
952 | { | ||
953 | BuddyID = buddyID; | ||
954 | } | ||
955 | |||
956 | public BuddyInfo(UUID buddyID) | ||
957 | { | ||
958 | BuddyID = buddyID.ToString(); | ||
959 | } | ||
960 | |||
961 | public Hashtable ToHashTable() | ||
962 | { | ||
963 | Hashtable hTable = new Hashtable(); | ||
964 | hTable["buddy_rights_has"] = BuddyRightsHave; | ||
965 | hTable["buddy_rights_given"] = BuddyRightsGiven; | ||
966 | hTable["buddy_id"] = BuddyID; | ||
967 | return hTable; | ||
968 | } | ||
969 | } | ||
970 | } | ||
971 | } | ||
972 | } | ||
diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs new file mode 100644 index 0000000..143e5f1 --- /dev/null +++ b/OpenSim/Services/LLLoginService/LLLoginService.cs | |||
@@ -0,0 +1,650 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Net; | ||
4 | using System.Reflection; | ||
5 | using System.Text.RegularExpressions; | ||
6 | |||
7 | using log4net; | ||
8 | using Nini.Config; | ||
9 | using OpenMetaverse; | ||
10 | |||
11 | using OpenSim.Framework; | ||
12 | using OpenSim.Framework.Capabilities; | ||
13 | using OpenSim.Framework.Console; | ||
14 | using OpenSim.Server.Base; | ||
15 | using OpenSim.Services.Interfaces; | ||
16 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
17 | using FriendInfo = OpenSim.Services.Interfaces.FriendInfo; | ||
18 | using OpenSim.Services.Connectors.Hypergrid; | ||
19 | |||
20 | namespace OpenSim.Services.LLLoginService | ||
21 | { | ||
22 | public class LLLoginService : ILoginService | ||
23 | { | ||
24 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
25 | private static bool Initialized = false; | ||
26 | |||
27 | private IUserAccountService m_UserAccountService; | ||
28 | private IAuthenticationService m_AuthenticationService; | ||
29 | private IInventoryService m_InventoryService; | ||
30 | private IGridService m_GridService; | ||
31 | private IPresenceService m_PresenceService; | ||
32 | private ISimulationService m_LocalSimulationService; | ||
33 | private ISimulationService m_RemoteSimulationService; | ||
34 | private ILibraryService m_LibraryService; | ||
35 | private IFriendsService m_FriendsService; | ||
36 | private IAvatarService m_AvatarService; | ||
37 | private IUserAgentService m_UserAgentService; | ||
38 | |||
39 | private GatekeeperServiceConnector m_GatekeeperConnector; | ||
40 | |||
41 | private string m_DefaultRegionName; | ||
42 | private string m_WelcomeMessage; | ||
43 | private bool m_RequireInventory; | ||
44 | private int m_MinLoginLevel; | ||
45 | private string m_GatekeeperURL; | ||
46 | |||
47 | IConfig m_LoginServerConfig; | ||
48 | |||
49 | public LLLoginService(IConfigSource config, ISimulationService simService, ILibraryService libraryService) | ||
50 | { | ||
51 | m_LoginServerConfig = config.Configs["LoginService"]; | ||
52 | if (m_LoginServerConfig == null) | ||
53 | throw new Exception(String.Format("No section LoginService in config file")); | ||
54 | |||
55 | string accountService = m_LoginServerConfig.GetString("UserAccountService", String.Empty); | ||
56 | string agentService = m_LoginServerConfig.GetString("UserAgentService", String.Empty); | ||
57 | string authService = m_LoginServerConfig.GetString("AuthenticationService", String.Empty); | ||
58 | string invService = m_LoginServerConfig.GetString("InventoryService", String.Empty); | ||
59 | string gridService = m_LoginServerConfig.GetString("GridService", String.Empty); | ||
60 | string presenceService = m_LoginServerConfig.GetString("PresenceService", String.Empty); | ||
61 | string libService = m_LoginServerConfig.GetString("LibraryService", String.Empty); | ||
62 | string friendsService = m_LoginServerConfig.GetString("FriendsService", String.Empty); | ||
63 | string avatarService = m_LoginServerConfig.GetString("AvatarService", String.Empty); | ||
64 | string simulationService = m_LoginServerConfig.GetString("SimulationService", String.Empty); | ||
65 | |||
66 | m_DefaultRegionName = m_LoginServerConfig.GetString("DefaultRegion", String.Empty); | ||
67 | m_WelcomeMessage = m_LoginServerConfig.GetString("WelcomeMessage", "Welcome to OpenSim!"); | ||
68 | m_RequireInventory = m_LoginServerConfig.GetBoolean("RequireInventory", true); | ||
69 | m_GatekeeperURL = m_LoginServerConfig.GetString("GatekeeperURI", string.Empty); | ||
70 | |||
71 | // These are required; the others aren't | ||
72 | if (accountService == string.Empty || authService == string.Empty) | ||
73 | throw new Exception("LoginService is missing service specifications"); | ||
74 | |||
75 | Object[] args = new Object[] { config }; | ||
76 | m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(accountService, args); | ||
77 | m_AuthenticationService = ServerUtils.LoadPlugin<IAuthenticationService>(authService, args); | ||
78 | m_InventoryService = ServerUtils.LoadPlugin<IInventoryService>(invService, args); | ||
79 | if (gridService != string.Empty) | ||
80 | m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args); | ||
81 | if (presenceService != string.Empty) | ||
82 | m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(presenceService, args); | ||
83 | if (avatarService != string.Empty) | ||
84 | m_AvatarService = ServerUtils.LoadPlugin<IAvatarService>(avatarService, args); | ||
85 | if (friendsService != string.Empty) | ||
86 | m_FriendsService = ServerUtils.LoadPlugin<IFriendsService>(friendsService, args); | ||
87 | if (simulationService != string.Empty) | ||
88 | m_RemoteSimulationService = ServerUtils.LoadPlugin<ISimulationService>(simulationService, args); | ||
89 | if (agentService != string.Empty) | ||
90 | m_UserAgentService = ServerUtils.LoadPlugin<IUserAgentService>(agentService, args); | ||
91 | |||
92 | // | ||
93 | // deal with the services given as argument | ||
94 | // | ||
95 | m_LocalSimulationService = simService; | ||
96 | if (libraryService != null) | ||
97 | { | ||
98 | m_log.DebugFormat("[LLOGIN SERVICE]: Using LibraryService given as argument"); | ||
99 | m_LibraryService = libraryService; | ||
100 | } | ||
101 | else if (libService != string.Empty) | ||
102 | { | ||
103 | m_log.DebugFormat("[LLOGIN SERVICE]: Using instantiated LibraryService"); | ||
104 | m_LibraryService = ServerUtils.LoadPlugin<ILibraryService>(libService, args); | ||
105 | } | ||
106 | |||
107 | m_GatekeeperConnector = new GatekeeperServiceConnector(); | ||
108 | |||
109 | if (!Initialized) | ||
110 | { | ||
111 | Initialized = true; | ||
112 | RegisterCommands(); | ||
113 | } | ||
114 | |||
115 | m_log.DebugFormat("[LLOGIN SERVICE]: Starting..."); | ||
116 | |||
117 | } | ||
118 | |||
119 | public LLLoginService(IConfigSource config) : this(config, null, null) | ||
120 | { | ||
121 | } | ||
122 | |||
123 | public LoginResponse Login(string firstName, string lastName, string passwd, string startLocation, IPEndPoint clientIP) | ||
124 | { | ||
125 | bool success = false; | ||
126 | UUID session = UUID.Random(); | ||
127 | |||
128 | try | ||
129 | { | ||
130 | // | ||
131 | // Get the account and check that it exists | ||
132 | // | ||
133 | UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, firstName, lastName); | ||
134 | if (account == null) | ||
135 | { | ||
136 | m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: user not found"); | ||
137 | return LLFailedLoginResponse.UserProblem; | ||
138 | } | ||
139 | |||
140 | if (account.UserLevel < m_MinLoginLevel) | ||
141 | { | ||
142 | m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: login is blocked for user level {0}", account.UserLevel); | ||
143 | return LLFailedLoginResponse.LoginBlockedProblem; | ||
144 | } | ||
145 | |||
146 | // | ||
147 | // Authenticate this user | ||
148 | // | ||
149 | if (!passwd.StartsWith("$1$")) | ||
150 | passwd = "$1$" + Util.Md5Hash(passwd); | ||
151 | passwd = passwd.Remove(0, 3); //remove $1$ | ||
152 | string token = m_AuthenticationService.Authenticate(account.PrincipalID, passwd, 30); | ||
153 | UUID secureSession = UUID.Zero; | ||
154 | if ((token == string.Empty) || (token != string.Empty && !UUID.TryParse(token, out secureSession))) | ||
155 | { | ||
156 | m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: authentication failed"); | ||
157 | return LLFailedLoginResponse.UserProblem; | ||
158 | } | ||
159 | |||
160 | // | ||
161 | // Get the user's inventory | ||
162 | // | ||
163 | if (m_RequireInventory && m_InventoryService == null) | ||
164 | { | ||
165 | m_log.WarnFormat("[LLOGIN SERVICE]: Login failed, reason: inventory service not set up"); | ||
166 | return LLFailedLoginResponse.InventoryProblem; | ||
167 | } | ||
168 | List<InventoryFolderBase> inventorySkel = m_InventoryService.GetInventorySkeleton(account.PrincipalID); | ||
169 | if (m_RequireInventory && ((inventorySkel == null) || (inventorySkel != null && inventorySkel.Count == 0))) | ||
170 | { | ||
171 | m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: unable to retrieve user inventory"); | ||
172 | return LLFailedLoginResponse.InventoryProblem; | ||
173 | } | ||
174 | |||
175 | // | ||
176 | // Login the presence | ||
177 | // | ||
178 | PresenceInfo presence = null; | ||
179 | GridRegion home = null; | ||
180 | if (m_PresenceService != null) | ||
181 | { | ||
182 | success = m_PresenceService.LoginAgent(account.PrincipalID.ToString(), session, secureSession); | ||
183 | if (!success) | ||
184 | { | ||
185 | m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: could not login presence"); | ||
186 | return LLFailedLoginResponse.GridProblem; | ||
187 | } | ||
188 | |||
189 | // Get the updated presence info | ||
190 | presence = m_PresenceService.GetAgent(session); | ||
191 | |||
192 | // Get the home region | ||
193 | if ((presence.HomeRegionID != UUID.Zero) && m_GridService != null) | ||
194 | { | ||
195 | home = m_GridService.GetRegionByUUID(account.ScopeID, presence.HomeRegionID); | ||
196 | } | ||
197 | } | ||
198 | |||
199 | // | ||
200 | // Find the destination region/grid | ||
201 | // | ||
202 | string where = string.Empty; | ||
203 | Vector3 position = Vector3.Zero; | ||
204 | Vector3 lookAt = Vector3.Zero; | ||
205 | GridRegion gatekeeper = null; | ||
206 | GridRegion destination = FindDestination(account, presence, session, startLocation, out gatekeeper, out where, out position, out lookAt); | ||
207 | if (destination == null) | ||
208 | { | ||
209 | m_PresenceService.LogoutAgent(session, presence.Position, presence.LookAt); | ||
210 | m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: destination not found"); | ||
211 | return LLFailedLoginResponse.GridProblem; | ||
212 | } | ||
213 | |||
214 | // | ||
215 | // Get the avatar | ||
216 | // | ||
217 | AvatarData avatar = null; | ||
218 | if (m_AvatarService != null) | ||
219 | { | ||
220 | avatar = m_AvatarService.GetAvatar(account.PrincipalID); | ||
221 | } | ||
222 | |||
223 | // | ||
224 | // Instantiate/get the simulation interface and launch an agent at the destination | ||
225 | // | ||
226 | string reason = string.Empty; | ||
227 | AgentCircuitData aCircuit = LaunchAgentAtGrid(gatekeeper, destination, account, avatar, session, secureSession, position, where, out where, out reason); | ||
228 | |||
229 | if (aCircuit == null) | ||
230 | { | ||
231 | m_PresenceService.LogoutAgent(session, presence.Position, presence.LookAt); | ||
232 | m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: {0}", reason); | ||
233 | return LLFailedLoginResponse.AuthorizationProblem; | ||
234 | |||
235 | } | ||
236 | // Get Friends list | ||
237 | FriendInfo[] friendsList = new FriendInfo[0]; | ||
238 | if (m_FriendsService != null) | ||
239 | { | ||
240 | friendsList = m_FriendsService.GetFriends(account.PrincipalID); | ||
241 | m_log.DebugFormat("[LLOGIN SERVICE]: Retrieved {0} friends", friendsList.Length); | ||
242 | } | ||
243 | |||
244 | // | ||
245 | // Finally, fill out the response and return it | ||
246 | // | ||
247 | LLLoginResponse response = new LLLoginResponse(account, aCircuit, presence, destination, inventorySkel, friendsList, m_LibraryService, | ||
248 | where, startLocation, position, lookAt, m_WelcomeMessage, home, clientIP); | ||
249 | |||
250 | return response; | ||
251 | } | ||
252 | catch (Exception e) | ||
253 | { | ||
254 | m_log.WarnFormat("[LLOGIN SERVICE]: Exception processing login for {0} {1}: {2}", firstName, lastName, e.ToString()); | ||
255 | if (m_PresenceService != null) | ||
256 | m_PresenceService.LogoutAgent(session, new Vector3(128, 128, 0), new Vector3(0, 1, 0)); | ||
257 | return LLFailedLoginResponse.InternalError; | ||
258 | } | ||
259 | } | ||
260 | |||
261 | private GridRegion FindDestination(UserAccount account, PresenceInfo pinfo, UUID sessionID, string startLocation, out GridRegion gatekeeper, out string where, out Vector3 position, out Vector3 lookAt) | ||
262 | { | ||
263 | m_log.DebugFormat("[LLOGIN SERVICE]: FindDestination for start location {0}", startLocation); | ||
264 | |||
265 | gatekeeper = null; | ||
266 | where = "home"; | ||
267 | position = new Vector3(128, 128, 0); | ||
268 | lookAt = new Vector3(0, 1, 0); | ||
269 | |||
270 | if (m_GridService == null) | ||
271 | return null; | ||
272 | |||
273 | if (startLocation.Equals("home")) | ||
274 | { | ||
275 | // logging into home region | ||
276 | if (pinfo == null) | ||
277 | return null; | ||
278 | |||
279 | GridRegion region = null; | ||
280 | |||
281 | if (pinfo.HomeRegionID.Equals(UUID.Zero) || (region = m_GridService.GetRegionByUUID(account.ScopeID, pinfo.HomeRegionID)) == null) | ||
282 | { | ||
283 | List<GridRegion> defaults = m_GridService.GetDefaultRegions(account.ScopeID); | ||
284 | if (defaults != null && defaults.Count > 0) | ||
285 | { | ||
286 | region = defaults[0]; | ||
287 | where = "safe"; | ||
288 | } | ||
289 | else | ||
290 | m_log.WarnFormat("[LLOGIN SERVICE]: User {0} {1} does not have a home set and this grid does not have default locations.", | ||
291 | account.FirstName, account.LastName); | ||
292 | } | ||
293 | |||
294 | return region; | ||
295 | } | ||
296 | else if (startLocation.Equals("last")) | ||
297 | { | ||
298 | // logging into last visited region | ||
299 | where = "last"; | ||
300 | |||
301 | if (pinfo == null) | ||
302 | return null; | ||
303 | |||
304 | GridRegion region = null; | ||
305 | |||
306 | if (pinfo.RegionID.Equals(UUID.Zero) || (region = m_GridService.GetRegionByUUID(account.ScopeID, pinfo.RegionID)) == null) | ||
307 | { | ||
308 | List<GridRegion> defaults = m_GridService.GetDefaultRegions(account.ScopeID); | ||
309 | if (defaults != null && defaults.Count > 0) | ||
310 | { | ||
311 | region = defaults[0]; | ||
312 | where = "safe"; | ||
313 | } | ||
314 | } | ||
315 | else | ||
316 | { | ||
317 | position = pinfo.Position; | ||
318 | lookAt = pinfo.LookAt; | ||
319 | } | ||
320 | return region; | ||
321 | |||
322 | } | ||
323 | else | ||
324 | { | ||
325 | // free uri form | ||
326 | // e.g. New Moon&135&46 New Moon@osgrid.org:8002&153&34 | ||
327 | where = "url"; | ||
328 | Regex reURI = new Regex(@"^uri:(?<region>[^&]+)&(?<x>\d+)&(?<y>\d+)&(?<z>\d+)$"); | ||
329 | Match uriMatch = reURI.Match(startLocation); | ||
330 | if (uriMatch == null) | ||
331 | { | ||
332 | m_log.InfoFormat("[LLLOGIN SERVICE]: Got Custom Login URI {0}, but can't process it", startLocation); | ||
333 | return null; | ||
334 | } | ||
335 | else | ||
336 | { | ||
337 | position = new Vector3(float.Parse(uriMatch.Groups["x"].Value), | ||
338 | float.Parse(uriMatch.Groups["y"].Value), | ||
339 | float.Parse(uriMatch.Groups["z"].Value)); | ||
340 | |||
341 | string regionName = uriMatch.Groups["region"].ToString(); | ||
342 | if (regionName != null) | ||
343 | { | ||
344 | if (!regionName.Contains("@")) | ||
345 | { | ||
346 | |||
347 | List<GridRegion> regions = m_GridService.GetRegionsByName(account.ScopeID, regionName, 1); | ||
348 | if ((regions == null) || (regions != null && regions.Count == 0)) | ||
349 | { | ||
350 | m_log.InfoFormat("[LLLOGIN SERVICE]: Got Custom Login URI {0}, can't locate region {1}. Trying defaults.", startLocation, regionName); | ||
351 | regions = m_GridService.GetDefaultRegions(UUID.Zero); | ||
352 | if (regions != null && regions.Count > 0) | ||
353 | { | ||
354 | where = "safe"; | ||
355 | return regions[0]; | ||
356 | } | ||
357 | else | ||
358 | { | ||
359 | m_log.InfoFormat("[LLLOGIN SERVICE]: Got Custom Login URI {0}, Grid does not provide default regions.", startLocation); | ||
360 | return null; | ||
361 | } | ||
362 | } | ||
363 | return regions[0]; | ||
364 | } | ||
365 | else | ||
366 | { | ||
367 | if (m_UserAgentService == null) | ||
368 | { | ||
369 | m_log.WarnFormat("[LLLOGIN SERVICE]: This llogin service is not running a user agent service, as such it can't lauch agents at foreign grids"); | ||
370 | return null; | ||
371 | } | ||
372 | string[] parts = regionName.Split(new char[] { '@' }); | ||
373 | if (parts.Length < 2) | ||
374 | { | ||
375 | m_log.InfoFormat("[LLLOGIN SERVICE]: Got Custom Login URI {0}, can't locate region {1}", startLocation, regionName); | ||
376 | return null; | ||
377 | } | ||
378 | // Valid specification of a remote grid | ||
379 | regionName = parts[0]; | ||
380 | string domainLocator = parts[1]; | ||
381 | parts = domainLocator.Split(new char[] {':'}); | ||
382 | string domainName = parts[0]; | ||
383 | uint port = 0; | ||
384 | if (parts.Length > 1) | ||
385 | UInt32.TryParse(parts[1], out port); | ||
386 | GridRegion region = FindForeignRegion(domainName, port, regionName, out gatekeeper); | ||
387 | return region; | ||
388 | } | ||
389 | } | ||
390 | else | ||
391 | { | ||
392 | List<GridRegion> defaults = m_GridService.GetDefaultRegions(account.ScopeID); | ||
393 | if (defaults != null && defaults.Count > 0) | ||
394 | { | ||
395 | where = "safe"; | ||
396 | return defaults[0]; | ||
397 | } | ||
398 | else | ||
399 | return null; | ||
400 | } | ||
401 | } | ||
402 | //response.LookAt = "[r0,r1,r0]"; | ||
403 | //// can be: last, home, safe, url | ||
404 | //response.StartLocation = "url"; | ||
405 | |||
406 | } | ||
407 | |||
408 | } | ||
409 | |||
410 | private GridRegion FindForeignRegion(string domainName, uint port, string regionName, out GridRegion gatekeeper) | ||
411 | { | ||
412 | gatekeeper = new GridRegion(); | ||
413 | gatekeeper.ExternalHostName = domainName; | ||
414 | gatekeeper.HttpPort = port; | ||
415 | gatekeeper.RegionName = regionName; | ||
416 | gatekeeper.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0); | ||
417 | |||
418 | UUID regionID; | ||
419 | ulong handle; | ||
420 | string imageURL = string.Empty, reason = string.Empty; | ||
421 | if (m_GatekeeperConnector.LinkRegion(gatekeeper, out regionID, out handle, out domainName, out imageURL, out reason)) | ||
422 | { | ||
423 | GridRegion destination = m_GatekeeperConnector.GetHyperlinkRegion(gatekeeper, regionID); | ||
424 | return destination; | ||
425 | } | ||
426 | |||
427 | return null; | ||
428 | } | ||
429 | |||
430 | private string hostName = string.Empty; | ||
431 | private int port = 0; | ||
432 | |||
433 | private void SetHostAndPort(string url) | ||
434 | { | ||
435 | try | ||
436 | { | ||
437 | Uri uri = new Uri(url); | ||
438 | hostName = uri.Host; | ||
439 | port = uri.Port; | ||
440 | } | ||
441 | catch | ||
442 | { | ||
443 | m_log.WarnFormat("[LLLogin SERVICE]: Unable to parse GatekeeperURL {0}", url); | ||
444 | } | ||
445 | } | ||
446 | |||
447 | private AgentCircuitData LaunchAgentAtGrid(GridRegion gatekeeper, GridRegion destination, UserAccount account, AvatarData avatar, | ||
448 | UUID session, UUID secureSession, Vector3 position, string currentWhere, out string where, out string reason) | ||
449 | { | ||
450 | where = currentWhere; | ||
451 | ISimulationService simConnector = null; | ||
452 | reason = string.Empty; | ||
453 | uint circuitCode = 0; | ||
454 | AgentCircuitData aCircuit = null; | ||
455 | |||
456 | if (m_UserAgentService == null) | ||
457 | { | ||
458 | // HG standalones have both a localSimulatonDll and a remoteSimulationDll | ||
459 | // non-HG standalones have just a localSimulationDll | ||
460 | // independent login servers have just a remoteSimulationDll | ||
461 | if (m_LocalSimulationService != null) | ||
462 | simConnector = m_LocalSimulationService; | ||
463 | else if (m_RemoteSimulationService != null) | ||
464 | simConnector = m_RemoteSimulationService; | ||
465 | } | ||
466 | else // User Agent Service is on | ||
467 | { | ||
468 | if (gatekeeper == null) // login to local grid | ||
469 | { | ||
470 | if (hostName == string.Empty) | ||
471 | SetHostAndPort(m_GatekeeperURL); | ||
472 | |||
473 | gatekeeper = new GridRegion(destination); | ||
474 | gatekeeper.ExternalHostName = hostName; | ||
475 | gatekeeper.HttpPort = (uint)port; | ||
476 | |||
477 | } | ||
478 | else // login to foreign grid | ||
479 | { | ||
480 | } | ||
481 | } | ||
482 | |||
483 | bool success = false; | ||
484 | |||
485 | if (m_UserAgentService == null && simConnector != null) | ||
486 | { | ||
487 | circuitCode = (uint)Util.RandomClass.Next(); ; | ||
488 | aCircuit = MakeAgent(destination, account, avatar, session, secureSession, circuitCode, position); | ||
489 | success = LaunchAgentDirectly(simConnector, destination, aCircuit, out reason); | ||
490 | if (!success && m_GridService != null) | ||
491 | { | ||
492 | // Try the fallback regions | ||
493 | List<GridRegion> fallbacks = m_GridService.GetFallbackRegions(account.ScopeID, destination.RegionLocX, destination.RegionLocY); | ||
494 | if (fallbacks != null) | ||
495 | { | ||
496 | foreach (GridRegion r in fallbacks) | ||
497 | { | ||
498 | success = LaunchAgentDirectly(simConnector, r, aCircuit, out reason); | ||
499 | if (success) | ||
500 | { | ||
501 | where = "safe"; | ||
502 | destination = r; | ||
503 | break; | ||
504 | } | ||
505 | } | ||
506 | } | ||
507 | } | ||
508 | } | ||
509 | |||
510 | if (m_UserAgentService != null) | ||
511 | { | ||
512 | circuitCode = (uint)Util.RandomClass.Next(); ; | ||
513 | aCircuit = MakeAgent(destination, account, avatar, session, secureSession, circuitCode, position); | ||
514 | success = LaunchAgentIndirectly(gatekeeper, destination, aCircuit, out reason); | ||
515 | if (!success && m_GridService != null) | ||
516 | { | ||
517 | // Try the fallback regions | ||
518 | List<GridRegion> fallbacks = m_GridService.GetFallbackRegions(account.ScopeID, destination.RegionLocX, destination.RegionLocY); | ||
519 | if (fallbacks != null) | ||
520 | { | ||
521 | foreach (GridRegion r in fallbacks) | ||
522 | { | ||
523 | success = LaunchAgentIndirectly(gatekeeper, r, aCircuit, out reason); | ||
524 | if (success) | ||
525 | { | ||
526 | where = "safe"; | ||
527 | destination = r; | ||
528 | break; | ||
529 | } | ||
530 | } | ||
531 | } | ||
532 | } | ||
533 | } | ||
534 | |||
535 | if (success) | ||
536 | return aCircuit; | ||
537 | else | ||
538 | return null; | ||
539 | } | ||
540 | |||
541 | private AgentCircuitData MakeAgent(GridRegion region, UserAccount account, | ||
542 | AvatarData avatar, UUID session, UUID secureSession, uint circuit, Vector3 position) | ||
543 | { | ||
544 | AgentCircuitData aCircuit = new AgentCircuitData(); | ||
545 | |||
546 | aCircuit.AgentID = account.PrincipalID; | ||
547 | if (avatar != null) | ||
548 | aCircuit.Appearance = avatar.ToAvatarAppearance(account.PrincipalID); | ||
549 | else | ||
550 | aCircuit.Appearance = new AvatarAppearance(account.PrincipalID); | ||
551 | |||
552 | //aCircuit.BaseFolder = irrelevant | ||
553 | aCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath(); | ||
554 | aCircuit.child = false; // the first login agent is root | ||
555 | aCircuit.ChildrenCapSeeds = new Dictionary<ulong, string>(); | ||
556 | aCircuit.circuitcode = circuit; | ||
557 | aCircuit.firstname = account.FirstName; | ||
558 | //aCircuit.InventoryFolder = irrelevant | ||
559 | aCircuit.lastname = account.LastName; | ||
560 | aCircuit.SecureSessionID = secureSession; | ||
561 | aCircuit.SessionID = session; | ||
562 | aCircuit.startpos = position; | ||
563 | SetServiceURLs(aCircuit, account); | ||
564 | |||
565 | return aCircuit; | ||
566 | |||
567 | //m_UserAgentService.LoginAgentToGrid(aCircuit, GatekeeperServiceConnector, region, out reason); | ||
568 | //if (simConnector.CreateAgent(region, aCircuit, 0, out reason)) | ||
569 | // return aCircuit; | ||
570 | |||
571 | //return null; | ||
572 | |||
573 | } | ||
574 | |||
575 | private void SetServiceURLs(AgentCircuitData aCircuit, UserAccount account) | ||
576 | { | ||
577 | aCircuit.ServiceURLs = new Dictionary<string, object>(); | ||
578 | if (account.ServiceURLs == null) | ||
579 | return; | ||
580 | |||
581 | foreach (KeyValuePair<string, object> kvp in account.ServiceURLs) | ||
582 | { | ||
583 | if (kvp.Value == null || (kvp.Value != null && kvp.Value.ToString() == string.Empty)) | ||
584 | { | ||
585 | aCircuit.ServiceURLs[kvp.Key] = m_LoginServerConfig.GetString(kvp.Key, string.Empty); | ||
586 | } | ||
587 | else | ||
588 | { | ||
589 | aCircuit.ServiceURLs[kvp.Key] = kvp.Value; | ||
590 | } | ||
591 | } | ||
592 | } | ||
593 | |||
594 | private bool LaunchAgentDirectly(ISimulationService simConnector, GridRegion region, AgentCircuitData aCircuit, out string reason) | ||
595 | { | ||
596 | return simConnector.CreateAgent(region, aCircuit, (int)Constants.TeleportFlags.ViaLogin, out reason); | ||
597 | } | ||
598 | |||
599 | private bool LaunchAgentIndirectly(GridRegion gatekeeper, GridRegion destination, AgentCircuitData aCircuit, out string reason) | ||
600 | { | ||
601 | m_log.Debug("[LLOGIN SERVICE] Launching agent at " + destination.RegionName); | ||
602 | return m_UserAgentService.LoginAgentToGrid(aCircuit, gatekeeper, destination, out reason); | ||
603 | } | ||
604 | |||
605 | #region Console Commands | ||
606 | private void RegisterCommands() | ||
607 | { | ||
608 | //MainConsole.Instance.Commands.AddCommand | ||
609 | MainConsole.Instance.Commands.AddCommand("loginservice", false, "login level", | ||
610 | "login level <level>", | ||
611 | "Set the minimum user level to log in", HandleLoginCommand); | ||
612 | |||
613 | MainConsole.Instance.Commands.AddCommand("loginservice", false, "login reset", | ||
614 | "login reset", | ||
615 | "Reset the login level to allow all users", | ||
616 | HandleLoginCommand); | ||
617 | |||
618 | MainConsole.Instance.Commands.AddCommand("loginservice", false, "login text", | ||
619 | "login text <text>", | ||
620 | "Set the text users will see on login", HandleLoginCommand); | ||
621 | |||
622 | } | ||
623 | |||
624 | private void HandleLoginCommand(string module, string[] cmd) | ||
625 | { | ||
626 | string subcommand = cmd[1]; | ||
627 | |||
628 | switch (subcommand) | ||
629 | { | ||
630 | case "level": | ||
631 | // Set the minimum level to allow login | ||
632 | // Useful to allow grid update without worrying about users. | ||
633 | // or fixing critical issues | ||
634 | // | ||
635 | if (cmd.Length > 2) | ||
636 | Int32.TryParse(cmd[2], out m_MinLoginLevel); | ||
637 | break; | ||
638 | case "reset": | ||
639 | m_MinLoginLevel = 0; | ||
640 | break; | ||
641 | case "text": | ||
642 | if (cmd.Length > 2) | ||
643 | m_WelcomeMessage = cmd[2]; | ||
644 | break; | ||
645 | } | ||
646 | } | ||
647 | } | ||
648 | |||
649 | #endregion | ||
650 | } | ||