aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/UserServer.Modules/UserLoginService.cs
diff options
context:
space:
mode:
authorMW2009-02-24 15:37:03 +0000
committerMW2009-02-24 15:37:03 +0000
commitea26bd415329fb3f030819c9cbaf210825cf5c34 (patch)
treec419cf51b14e33d56532298888c0bec3dfeeaaaa /OpenSim/Grid/UserServer.Modules/UserLoginService.cs
parentDeleted the files from Messagingserver that are now in OpenSim.Grid.Framework (diff)
downloadopensim-SC_OLD-ea26bd415329fb3f030819c9cbaf210825cf5c34.zip
opensim-SC_OLD-ea26bd415329fb3f030819c9cbaf210825cf5c34.tar.gz
opensim-SC_OLD-ea26bd415329fb3f030819c9cbaf210825cf5c34.tar.bz2
opensim-SC_OLD-ea26bd415329fb3f030819c9cbaf210825cf5c34.tar.xz
First step in separating out the Userserver console command handling to a "module".
Added OpenSim.Grid.UserServer.Modules project/dll which now contains the components of the userserver. With the OpenSim.Grid.UserServer being the setup and initiate exe.
Diffstat (limited to 'OpenSim/Grid/UserServer.Modules/UserLoginService.cs')
-rw-r--r--OpenSim/Grid/UserServer.Modules/UserLoginService.cs600
1 files changed, 600 insertions, 0 deletions
diff --git a/OpenSim/Grid/UserServer.Modules/UserLoginService.cs b/OpenSim/Grid/UserServer.Modules/UserLoginService.cs
new file mode 100644
index 0000000..928753f
--- /dev/null
+++ b/OpenSim/Grid/UserServer.Modules/UserLoginService.cs
@@ -0,0 +1,600 @@
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 OpenSim 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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Reflection;
32using System.Text.RegularExpressions;
33using log4net;
34using Nwc.XmlRpc;
35using OpenMetaverse;
36using OpenSim.Data;
37using OpenSim.Framework;
38using OpenSim.Framework.Communications;
39using OpenSim.Framework.Communications.Cache;
40using OpenSim.Framework.Communications.Capabilities;
41using OpenSim.Framework.Servers;
42
43namespace OpenSim.Grid.UserServer.Modules
44{
45 public delegate void UserLoggedInAtLocation(UUID agentID, UUID sessionID, UUID RegionID,
46 ulong regionhandle, float positionX, float positionY, float positionZ,
47 string firstname, string lastname);
48
49 /// <summary>
50 /// Login service used in grid mode.
51 /// </summary>
52 public class UserLoginService : LoginService
53 {
54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55
56 protected IInterServiceInventoryServices m_inventoryService;
57
58 public event UserLoggedInAtLocation OnUserLoggedInAtLocation;
59
60 private UserLoggedInAtLocation handlerUserLoggedInAtLocation;
61
62 public UserConfig m_config;
63 private readonly IRegionProfileService m_regionProfileService;
64
65 protected BaseHttpServer m_httpServer;
66
67 public UserLoginService(
68 UserManagerBase userManager, IInterServiceInventoryServices inventoryService,
69 LibraryRootFolder libraryRootFolder,
70 UserConfig config, string welcomeMess, IRegionProfileService regionProfileService)
71 : base(userManager, libraryRootFolder, welcomeMess)
72 {
73 m_config = config;
74 m_inventoryService = inventoryService;
75 m_regionProfileService = regionProfileService;
76 }
77
78 public void RegisterHandlers(BaseHttpServer httpServer, bool registerLLSDHandler, bool registerOpenIDHandlers)
79 {
80 m_httpServer = httpServer;
81
82 m_httpServer.AddXmlRPCHandler("login_to_simulator", XmlRpcLoginMethod);
83 m_httpServer.AddHTTPHandler("login", ProcessHTMLLogin);
84 m_httpServer.AddXmlRPCHandler("set_login_params", XmlRPCSetLoginParams);
85
86 if (registerLLSDHandler)
87 {
88 m_httpServer.SetDefaultLLSDHandler(LLSDLoginMethod);
89 }
90
91 if (registerOpenIDHandlers)
92 {
93 // Handler for OpenID avatar identity pages
94 m_httpServer.AddStreamHandler(new OpenIdStreamHandler("GET", "/users/", this));
95 // Handlers for the OpenID endpoint server
96 m_httpServer.AddStreamHandler(new OpenIdStreamHandler("POST", "/openid/server/", this));
97 m_httpServer.AddStreamHandler(new OpenIdStreamHandler("GET", "/openid/server/", this));
98 }
99 }
100
101 public void setloginlevel(int level)
102 {
103 m_minLoginLevel = level;
104 m_log.InfoFormat("[GRID]: Login Level set to {0} ", level);
105 }
106 public void setwelcometext(string text)
107 {
108 m_welcomeMessage = text;
109 m_log.InfoFormat("[GRID]: Login text set to {0} ", text);
110 }
111
112 public override void LogOffUser(UserProfileData theUser, string message)
113 {
114 RegionProfileData SimInfo;
115 try
116 {
117 SimInfo = m_regionProfileService.RequestSimProfileData(
118 theUser.CurrentAgent.Handle, m_config.GridServerURL,
119 m_config.GridSendKey, m_config.GridRecvKey);
120
121 if (SimInfo == null)
122 {
123 m_log.Error("[GRID]: Region user was in isn't currently logged in");
124 return;
125 }
126 }
127 catch (Exception)
128 {
129 m_log.Error("[GRID]: Unable to look up region to log user off");
130 return;
131 }
132
133 // Prepare notification
134 Hashtable SimParams = new Hashtable();
135 SimParams["agent_id"] = theUser.ID.ToString();
136 SimParams["region_secret"] = theUser.CurrentAgent.SecureSessionID.ToString();
137 SimParams["region_secret2"] = SimInfo.regionSecret;
138 //m_log.Info(SimInfo.regionSecret);
139 SimParams["regionhandle"] = theUser.CurrentAgent.Handle.ToString();
140 SimParams["message"] = message;
141 ArrayList SendParams = new ArrayList();
142 SendParams.Add(SimParams);
143
144 m_log.InfoFormat(
145 "[ASSUMED CRASH]: Telling region {0} @ {1},{2} ({3}) that their agent is dead: {4}",
146 SimInfo.regionName, SimInfo.regionLocX, SimInfo.regionLocY, SimInfo.httpServerURI,
147 theUser.FirstName + " " + theUser.SurName);
148
149 try
150 {
151 XmlRpcRequest GridReq = new XmlRpcRequest("logoff_user", SendParams);
152 XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000);
153
154 if (GridResp.IsFault)
155 {
156 m_log.ErrorFormat(
157 "[LOGIN]: XMLRPC request for {0} failed, fault code: {1}, reason: {2}, This is likely an old region revision.",
158 SimInfo.httpServerURI, GridResp.FaultCode, GridResp.FaultString);
159 }
160 }
161 catch (Exception)
162 {
163 m_log.Error("[LOGIN]: Error telling region to logout user!");
164 }
165
166 // Prepare notification
167 SimParams = new Hashtable();
168 SimParams["agent_id"] = theUser.ID.ToString();
169 SimParams["region_secret"] = SimInfo.regionSecret;
170 //m_log.Info(SimInfo.regionSecret);
171 SimParams["regionhandle"] = theUser.CurrentAgent.Handle.ToString();
172 SimParams["message"] = message;
173 SendParams = new ArrayList();
174 SendParams.Add(SimParams);
175
176 m_log.InfoFormat(
177 "[ASSUMED CRASH]: Telling region {0} @ {1},{2} ({3}) that their agent is dead: {4}",
178 SimInfo.regionName, SimInfo.regionLocX, SimInfo.regionLocY, SimInfo.httpServerURI,
179 theUser.FirstName + " " + theUser.SurName);
180
181 try
182 {
183 XmlRpcRequest GridReq = new XmlRpcRequest("logoff_user", SendParams);
184 XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000);
185
186 if (GridResp.IsFault)
187 {
188 m_log.ErrorFormat(
189 "[LOGIN]: XMLRPC request for {0} failed, fault code: {1}, reason: {2}, This is likely an old region revision.",
190 SimInfo.httpServerURI, GridResp.FaultCode, GridResp.FaultString);
191 }
192 }
193 catch (Exception)
194 {
195 m_log.Error("[LOGIN]: Error telling region to logout user!");
196 }
197 //base.LogOffUser(theUser);
198 }
199
200 /// <summary>
201 /// Customises the login response and fills in missing values.
202 /// </summary>
203 /// <param name="response">The existing response</param>
204 /// <param name="theUser">The user profile</param>
205 /// <param name="startLocationRequest">The requested start location</param>
206 public override bool CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest)
207 {
208 // add active gestures to login-response
209 AddActiveGestures(response, theUser);
210
211 // HomeLocation
212 RegionProfileData homeInfo = null;
213 // use the homeRegionID if it is stored already. If not, use the regionHandle as before
214 UUID homeRegionId = theUser.HomeRegionID;
215 ulong homeRegionHandle = theUser.HomeRegion;
216 if (homeRegionId != UUID.Zero)
217 {
218 homeInfo = GetRegionInfo(homeRegionId);
219 }
220 else
221 {
222 homeInfo = GetRegionInfo(homeRegionHandle);
223 }
224
225 if (homeInfo != null)
226 {
227 response.Home =
228 string.Format(
229 "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}",
230 (homeInfo.regionLocX*Constants.RegionSize),
231 (homeInfo.regionLocY*Constants.RegionSize),
232 theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z,
233 theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z);
234 }
235 else
236 {
237 // Emergency mode: Home-region isn't available, so we can't request the region info.
238 // Use the stored home regionHandle instead.
239 // NOTE: If the home-region moves, this will be wrong until the users update their user-profile again
240 ulong regionX = homeRegionHandle >> 32;
241 ulong regionY = homeRegionHandle & 0xffffffff;
242 response.Home =
243 string.Format(
244 "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}",
245 regionX, regionY,
246 theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z,
247 theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z);
248 m_log.InfoFormat("[LOGIN] Home region of user {0} {1} is not available; using computed region position {2} {3}",
249 theUser.FirstName, theUser.SurName,
250 regionX, regionY);
251 }
252
253 // StartLocation
254 RegionProfileData regionInfo = null;
255 if (startLocationRequest == "home")
256 {
257 regionInfo = homeInfo;
258 theUser.CurrentAgent.Position = theUser.HomeLocation;
259 response.LookAt = "[r" + theUser.HomeLookAt.X.ToString() + ",r" + theUser.HomeLookAt.Y.ToString() + ",r" + theUser.HomeLookAt.Z.ToString() + "]";
260 }
261 else if (startLocationRequest == "last")
262 {
263 UUID lastRegion = theUser.CurrentAgent.Region;
264 regionInfo = GetRegionInfo(lastRegion);
265 response.LookAt = "[r" + theUser.CurrentAgent.LookAt.X.ToString() + ",r" + theUser.CurrentAgent.LookAt.Y.ToString() + ",r" + theUser.CurrentAgent.LookAt.Z.ToString() + "]";
266 }
267 else
268 {
269 Regex reURI = new Regex(@"^uri:(?<region>[^&]+)&(?<x>\d+)&(?<y>\d+)&(?<z>\d+)$");
270 Match uriMatch = reURI.Match(startLocationRequest);
271 if (uriMatch == null)
272 {
273 m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, but can't process it", startLocationRequest);
274 }
275 else
276 {
277 string region = uriMatch.Groups["region"].ToString();
278 regionInfo = RequestClosestRegion(region);
279 if (regionInfo == null)
280 {
281 m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, can't locate region {1}", startLocationRequest, region);
282 }
283 else
284 {
285 theUser.CurrentAgent.Position = new Vector3(float.Parse(uriMatch.Groups["x"].Value),
286 float.Parse(uriMatch.Groups["y"].Value), float.Parse(uriMatch.Groups["z"].Value));
287 }
288 }
289 response.LookAt = "[r0,r1,r0]";
290 // can be: last, home, safe, url
291 response.StartLocation = "url";
292 }
293
294 if ((regionInfo != null) && (PrepareLoginToRegion(regionInfo, theUser, response)))
295 {
296 return true;
297 }
298
299 // StartLocation not available, send him to a nearby region instead
300 //regionInfo = RegionProfileData.RequestSimProfileData("", m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey);
301 //m_log.InfoFormat("[LOGIN]: StartLocation not available sending to region {0}", regionInfo.regionName);
302
303 // Send him to default region instead
304 // Load information from the gridserver
305 ulong defaultHandle = (((ulong) m_config.DefaultX * Constants.RegionSize) << 32) |
306 ((ulong) m_config.DefaultY * Constants.RegionSize);
307
308 if ((regionInfo != null) && (defaultHandle == regionInfo.regionHandle))
309 {
310 m_log.ErrorFormat("[LOGIN]: Not trying the default region since this is the same as the selected region");
311 return false;
312 }
313
314 m_log.Error("[LOGIN]: Sending user to default region " + defaultHandle + " instead");
315 regionInfo = GetRegionInfo(defaultHandle);
316
317 // Customise the response
318 //response.Home =
319 // string.Format(
320 // "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}",
321 // (SimInfo.regionLocX * Constants.RegionSize),
322 // (SimInfo.regionLocY*Constants.RegionSize),
323 // theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z,
324 // theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z);
325 theUser.CurrentAgent.Position = new Vector3(128,128,0);
326 response.StartLocation = "safe";
327
328 return PrepareLoginToRegion(regionInfo, theUser, response);
329 }
330
331 protected RegionProfileData RequestClosestRegion(string region)
332 {
333 return m_regionProfileService.RequestSimProfileData(region,
334 m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey);
335 }
336
337 protected RegionProfileData GetRegionInfo(ulong homeRegionHandle)
338 {
339 return m_regionProfileService.RequestSimProfileData(homeRegionHandle,
340 m_config.GridServerURL, m_config.GridSendKey,
341 m_config.GridRecvKey);
342 }
343
344 protected RegionProfileData GetRegionInfo(UUID homeRegionId)
345 {
346 return m_regionProfileService.RequestSimProfileData(homeRegionId,
347 m_config.GridServerURL, m_config.GridSendKey,
348 m_config.GridRecvKey);
349 }
350
351 /// <summary>
352 /// Add active gestures of the user to the login response.
353 /// </summary>
354 /// <param name="response">
355 /// A <see cref="LoginResponse"/>
356 /// </param>
357 /// <param name="theUser">
358 /// A <see cref="UserProfileData"/>
359 /// </param>
360 private void AddActiveGestures(LoginResponse response, UserProfileData theUser)
361 {
362 List<InventoryItemBase> gestures = m_inventoryService.GetActiveGestures(theUser.ID);
363 //m_log.DebugFormat("[LOGIN]: AddActiveGestures, found {0}", gestures == null ? 0 : gestures.Count);
364 ArrayList list = new ArrayList();
365 if (gestures != null)
366 {
367 foreach (InventoryItemBase gesture in gestures)
368 {
369 Hashtable item = new Hashtable();
370 item["item_id"] = gesture.ID.ToString();
371 item["asset_id"] = gesture.AssetID.ToString();
372 list.Add(item);
373 }
374 }
375 response.ActiveGestures = list;
376 }
377
378 /// <summary>
379 /// Prepare a login to the given region. This involves both telling the region to expect a connection
380 /// and appropriately customising the response to the user.
381 /// </summary>
382 /// <param name="sim"></param>
383 /// <param name="user"></param>
384 /// <param name="response"></param>
385 /// <returns>true if the region was successfully contacted, false otherwise</returns>
386 private bool PrepareLoginToRegion(RegionProfileData regionInfo, UserProfileData user, LoginResponse response)
387 {
388 try
389 {
390 response.SimAddress = Util.GetHostFromURL(regionInfo.serverURI).ToString();
391 response.SimPort = uint.Parse(regionInfo.serverURI.Split(new char[] { '/', ':' })[4]);
392 response.RegionX = regionInfo.regionLocX;
393 response.RegionY = regionInfo.regionLocY;
394
395 string capsPath = CapsUtil.GetRandomCapsObjectPath();
396
397 // Take off trailing / so that the caps path isn't //CAPS/someUUID
398 if (regionInfo.httpServerURI.EndsWith("/"))
399 regionInfo.httpServerURI = regionInfo.httpServerURI.Substring(0, regionInfo.httpServerURI.Length - 1);
400 response.SeedCapability = regionInfo.httpServerURI + CapsUtil.GetCapsSeedPath(capsPath);
401
402 // Notify the target of an incoming user
403 m_log.InfoFormat(
404 "[LOGIN]: Telling {0} @ {1},{2} ({3}) to prepare for client connection",
405 regionInfo.regionName, response.RegionX, response.RegionY, regionInfo.httpServerURI);
406
407 // Update agent with target sim
408 user.CurrentAgent.Region = regionInfo.UUID;
409 user.CurrentAgent.Handle = regionInfo.regionHandle;
410
411 // Prepare notification
412 Hashtable loginParams = new Hashtable();
413 loginParams["session_id"] = user.CurrentAgent.SessionID.ToString();
414 loginParams["secure_session_id"] = user.CurrentAgent.SecureSessionID.ToString();
415 loginParams["firstname"] = user.FirstName;
416 loginParams["lastname"] = user.SurName;
417 loginParams["agent_id"] = user.ID.ToString();
418 loginParams["circuit_code"] = (Int32) Convert.ToUInt32(response.CircuitCode);
419 loginParams["startpos_x"] = user.CurrentAgent.Position.X.ToString();
420 loginParams["startpos_y"] = user.CurrentAgent.Position.Y.ToString();
421 loginParams["startpos_z"] = user.CurrentAgent.Position.Z.ToString();
422 loginParams["regionhandle"] = user.CurrentAgent.Handle.ToString();
423 loginParams["caps_path"] = capsPath;
424
425 // Get appearance
426 AvatarAppearance appearance = m_userManager.GetUserAppearance(user.ID);
427 if (appearance != null)
428 {
429 loginParams["appearance"] = appearance.ToHashTable();
430 m_log.DebugFormat("[LOGIN]: Found appearance for {0} {1}", user.FirstName, user.SurName);
431 }
432 else
433 {
434 m_log.DebugFormat("[LOGIN]: Appearance not for {0} {1}. Creating default.", user.FirstName, user.SurName);
435 appearance = new AvatarAppearance(user.ID);
436 }
437
438 ArrayList SendParams = new ArrayList();
439 SendParams.Add(loginParams);
440
441 // Send
442 XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams);
443 XmlRpcResponse GridResp = GridReq.Send(regionInfo.httpServerURI, 6000);
444
445 if (!GridResp.IsFault)
446 {
447 bool responseSuccess = true;
448
449 if (GridResp.Value != null)
450 {
451 Hashtable resp = (Hashtable) GridResp.Value;
452 if (resp.ContainsKey("success"))
453 {
454 if ((string) resp["success"] == "FALSE")
455 {
456 responseSuccess = false;
457 }
458 }
459 }
460 if (responseSuccess)
461 {
462 handlerUserLoggedInAtLocation = OnUserLoggedInAtLocation;
463 if (handlerUserLoggedInAtLocation != null)
464 {
465 handlerUserLoggedInAtLocation(user.ID, user.CurrentAgent.SessionID,
466 user.CurrentAgent.Region,
467 user.CurrentAgent.Handle,
468 user.CurrentAgent.Position.X,
469 user.CurrentAgent.Position.Y,
470 user.CurrentAgent.Position.Z,
471 user.FirstName, user.SurName);
472 }
473 }
474 else
475 {
476 m_log.ErrorFormat("[LOGIN]: Region responded that it is not available to receive clients");
477 return false;
478 }
479 }
480 else
481 {
482 m_log.ErrorFormat("[LOGIN]: XmlRpc request to region failed with message {0}, code {1} ", GridResp.FaultString, GridResp.FaultCode);
483 return false;
484 }
485 }
486 catch (Exception e)
487 {
488 m_log.ErrorFormat("[LOGIN]: Region not available for login, {0}", e);
489 return false;
490 }
491
492 return true;
493 }
494
495 // See LoginService
496 protected override InventoryData GetInventorySkeleton(UUID userID)
497 {
498 m_log.DebugFormat(
499 "[LOGIN]: Contacting inventory service at {0} for inventory skeleton of user {1}",
500 m_config.InventoryUrl, userID);
501
502 List<InventoryFolderBase> folders = m_inventoryService.GetInventorySkeleton(userID);
503
504 if (null == folders || folders.Count == 0)
505 {
506 m_log.InfoFormat(
507 "[LOGIN]: A root inventory folder for user {0} was not found. Requesting creation.", userID);
508
509 // Although the create user function creates a new agent inventory along with a new user profile, some
510 // tools are creating the user profile directly in the database without creating the inventory. At
511 // this time we'll accomodate them by lazily creating the user inventory now if it doesn't already
512 // exist.
513 if (!m_inventoryService.CreateNewUserInventory(userID))
514 {
515 throw new Exception(
516 String.Format(
517 "The inventory creation request for user {0} did not succeed."
518 + " Please contact your inventory service provider for more information.",
519 userID));
520 }
521 m_log.InfoFormat("[LOGIN]: A new inventory skeleton was successfully created for user {0}", userID);
522
523 folders = m_inventoryService.GetInventorySkeleton(userID);
524 }
525
526 if (folders != null && folders.Count > 0)
527 {
528 UUID rootID = UUID.Zero;
529 ArrayList AgentInventoryArray = new ArrayList();
530 Hashtable TempHash;
531
532 foreach (InventoryFolderBase InvFolder in folders)
533 {
534// m_log.DebugFormat("[LOGIN]: Received agent inventory folder {0}", InvFolder.name);
535
536 if (InvFolder.ParentID == UUID.Zero)
537 {
538 rootID = InvFolder.ID;
539 }
540 TempHash = new Hashtable();
541 TempHash["name"] = InvFolder.Name;
542 TempHash["parent_id"] = InvFolder.ParentID.ToString();
543 TempHash["version"] = (Int32) InvFolder.Version;
544 TempHash["type_default"] = (Int32) InvFolder.Type;
545 TempHash["folder_id"] = InvFolder.ID.ToString();
546 AgentInventoryArray.Add(TempHash);
547 }
548
549 return new InventoryData(AgentInventoryArray, rootID);
550 }
551 throw new Exception(
552 String.Format(
553 "A root inventory folder for user {0} could not be retrieved from the inventory service",
554 userID));
555 }
556
557 public XmlRpcResponse XmlRPCSetLoginParams(XmlRpcRequest request)
558 {
559 XmlRpcResponse response = new XmlRpcResponse();
560 Hashtable requestData = (Hashtable) request.Params[0];
561 UserProfileData userProfile;
562 Hashtable responseData = new Hashtable();
563
564 UUID uid;
565 string pass = requestData["password"].ToString();
566
567 if (!UUID.TryParse((string) requestData["avatar_uuid"], out uid))
568 {
569 responseData["error"] = "No authorization";
570 response.Value = responseData;
571 return response;
572 }
573
574 userProfile = m_userManager.GetUserProfile(uid);
575
576 if (userProfile == null ||
577 (!AuthenticateUser(userProfile, pass)) ||
578 userProfile.GodLevel < 200)
579 {
580 responseData["error"] = "No authorization";
581 response.Value = responseData;
582 return response;
583 }
584
585 if (requestData.ContainsKey("login_level"))
586 {
587 m_minLoginLevel = Convert.ToInt32(requestData["login_level"]);
588 }
589
590 if (requestData.ContainsKey("login_motd"))
591 {
592 m_welcomeMessage = requestData["login_motd"].ToString();
593 }
594
595 response.Value = responseData;
596 return response;
597 }
598
599 }
600}