diff options
author | lbsa71 | 2009-03-11 19:19:48 +0000 |
---|---|---|
committer | lbsa71 | 2009-03-11 19:19:48 +0000 |
commit | 2133d358317f28fe54020207ed8fa59562e1d6eb (patch) | |
tree | df648eee35bf347a7ba66a15bdec6a1b4082840b /OpenSim/Grid/UserServer.Modules/UserLoginService.cs | |
parent | Thanks rtomita for a patch to fix inventory listings for clients using libomv... (diff) | |
download | opensim-SC-2133d358317f28fe54020207ed8fa59562e1d6eb.zip opensim-SC-2133d358317f28fe54020207ed8fa59562e1d6eb.tar.gz opensim-SC-2133d358317f28fe54020207ed8fa59562e1d6eb.tar.bz2 opensim-SC-2133d358317f28fe54020207ed8fa59562e1d6eb.tar.xz |
* Reverted r8750 to do another round of debugging on mantis #3287
Diffstat (limited to 'OpenSim/Grid/UserServer.Modules/UserLoginService.cs')
-rw-r--r-- | OpenSim/Grid/UserServer.Modules/UserLoginService.cs | 183 |
1 files changed, 155 insertions, 28 deletions
diff --git a/OpenSim/Grid/UserServer.Modules/UserLoginService.cs b/OpenSim/Grid/UserServer.Modules/UserLoginService.cs index b695ff5..4e672f6 100644 --- a/OpenSim/Grid/UserServer.Modules/UserLoginService.cs +++ b/OpenSim/Grid/UserServer.Modules/UserLoginService.cs | |||
@@ -99,11 +99,11 @@ namespace OpenSim.Grid.UserServer.Modules | |||
99 | m_httpServer.AddStreamHandler(new OpenIdStreamHandler("GET", "/openid/server/", this)); | 99 | m_httpServer.AddStreamHandler(new OpenIdStreamHandler("GET", "/openid/server/", this)); |
100 | } | 100 | } |
101 | } | 101 | } |
102 | 102 | ||
103 | public void setloginlevel(int level) | 103 | public void setloginlevel(int level) |
104 | { | 104 | { |
105 | m_minLoginLevel = level; | 105 | m_minLoginLevel = level; |
106 | m_log.InfoFormat("[GRID]: Login Level set to {0} ", level); | 106 | m_log.InfoFormat("[GRID]: Login Level set to {0} ", level); |
107 | } | 107 | } |
108 | public void setwelcometext(string text) | 108 | public void setwelcometext(string text) |
109 | { | 109 | { |
@@ -199,24 +199,155 @@ namespace OpenSim.Grid.UserServer.Modules | |||
199 | //base.LogOffUser(theUser); | 199 | //base.LogOffUser(theUser); |
200 | } | 200 | } |
201 | 201 | ||
202 | protected override RegionInfo RequestClosestRegion(string region) | 202 | /// <summary> |
203 | /// Customises the login response and fills in missing values. | ||
204 | /// </summary> | ||
205 | /// <param name="response">The existing response</param> | ||
206 | /// <param name="theUser">The user profile</param> | ||
207 | /// <param name="startLocationRequest">The requested start location</param> | ||
208 | public override bool CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest) | ||
209 | { | ||
210 | // add active gestures to login-response | ||
211 | AddActiveGestures(response, theUser); | ||
212 | |||
213 | // HomeLocation | ||
214 | RegionProfileData homeInfo = null; | ||
215 | // use the homeRegionID if it is stored already. If not, use the regionHandle as before | ||
216 | UUID homeRegionId = theUser.HomeRegionID; | ||
217 | ulong homeRegionHandle = theUser.HomeRegion; | ||
218 | if (homeRegionId != UUID.Zero) | ||
219 | { | ||
220 | homeInfo = GetRegionInfo(homeRegionId); | ||
221 | } | ||
222 | else | ||
223 | { | ||
224 | homeInfo = GetRegionInfo(homeRegionHandle); | ||
225 | } | ||
226 | |||
227 | if (homeInfo != null) | ||
228 | { | ||
229 | response.Home = | ||
230 | string.Format( | ||
231 | "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", | ||
232 | (homeInfo.regionLocX*Constants.RegionSize), | ||
233 | (homeInfo.regionLocY*Constants.RegionSize), | ||
234 | theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, | ||
235 | theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); | ||
236 | } | ||
237 | else | ||
238 | { | ||
239 | // Emergency mode: Home-region isn't available, so we can't request the region info. | ||
240 | // Use the stored home regionHandle instead. | ||
241 | // NOTE: If the home-region moves, this will be wrong until the users update their user-profile again | ||
242 | ulong regionX = homeRegionHandle >> 32; | ||
243 | ulong regionY = homeRegionHandle & 0xffffffff; | ||
244 | response.Home = | ||
245 | string.Format( | ||
246 | "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", | ||
247 | regionX, regionY, | ||
248 | theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, | ||
249 | theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); | ||
250 | m_log.InfoFormat("[LOGIN] Home region of user {0} {1} is not available; using computed region position {2} {3}", | ||
251 | theUser.FirstName, theUser.SurName, | ||
252 | regionX, regionY); | ||
253 | } | ||
254 | |||
255 | // StartLocation | ||
256 | RegionProfileData regionInfo = null; | ||
257 | if (startLocationRequest == "home") | ||
258 | { | ||
259 | regionInfo = homeInfo; | ||
260 | theUser.CurrentAgent.Position = theUser.HomeLocation; | ||
261 | response.LookAt = "[r" + theUser.HomeLookAt.X.ToString() + ",r" + theUser.HomeLookAt.Y.ToString() + ",r" + theUser.HomeLookAt.Z.ToString() + "]"; | ||
262 | } | ||
263 | else if (startLocationRequest == "last") | ||
264 | { | ||
265 | UUID lastRegion = theUser.CurrentAgent.Region; | ||
266 | regionInfo = GetRegionInfo(lastRegion); | ||
267 | response.LookAt = "[r" + theUser.CurrentAgent.LookAt.X.ToString() + ",r" + theUser.CurrentAgent.LookAt.Y.ToString() + ",r" + theUser.CurrentAgent.LookAt.Z.ToString() + "]"; | ||
268 | } | ||
269 | else | ||
270 | { | ||
271 | Regex reURI = new Regex(@"^uri:(?<region>[^&]+)&(?<x>\d+)&(?<y>\d+)&(?<z>\d+)$"); | ||
272 | Match uriMatch = reURI.Match(startLocationRequest); | ||
273 | if (uriMatch == null) | ||
274 | { | ||
275 | m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, but can't process it", startLocationRequest); | ||
276 | } | ||
277 | else | ||
278 | { | ||
279 | string region = uriMatch.Groups["region"].ToString(); | ||
280 | regionInfo = RequestClosestRegion(region); | ||
281 | if (regionInfo == null) | ||
282 | { | ||
283 | m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, can't locate region {1}", startLocationRequest, region); | ||
284 | } | ||
285 | else | ||
286 | { | ||
287 | theUser.CurrentAgent.Position = new Vector3(float.Parse(uriMatch.Groups["x"].Value), | ||
288 | float.Parse(uriMatch.Groups["y"].Value), float.Parse(uriMatch.Groups["z"].Value)); | ||
289 | } | ||
290 | } | ||
291 | response.LookAt = "[r0,r1,r0]"; | ||
292 | // can be: last, home, safe, url | ||
293 | response.StartLocation = "url"; | ||
294 | } | ||
295 | |||
296 | if ((regionInfo != null) && (PrepareLoginToRegion(regionInfo, theUser, response))) | ||
297 | { | ||
298 | return true; | ||
299 | } | ||
300 | |||
301 | // StartLocation not available, send him to a nearby region instead | ||
302 | //regionInfo = RegionProfileData.RequestSimProfileData("", m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey); | ||
303 | //m_log.InfoFormat("[LOGIN]: StartLocation not available sending to region {0}", regionInfo.regionName); | ||
304 | |||
305 | // Send him to default region instead | ||
306 | // Load information from the gridserver | ||
307 | ulong defaultHandle = (((ulong) m_defaultHomeX * Constants.RegionSize) << 32) | | ||
308 | ((ulong) m_defaultHomeY * Constants.RegionSize); | ||
309 | |||
310 | if ((regionInfo != null) && (defaultHandle == regionInfo.regionHandle)) | ||
311 | { | ||
312 | m_log.ErrorFormat("[LOGIN]: Not trying the default region since this is the same as the selected region"); | ||
313 | return false; | ||
314 | } | ||
315 | |||
316 | m_log.Error("[LOGIN]: Sending user to default region " + defaultHandle + " instead"); | ||
317 | regionInfo = GetRegionInfo(defaultHandle); | ||
318 | |||
319 | // Customise the response | ||
320 | //response.Home = | ||
321 | // string.Format( | ||
322 | // "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", | ||
323 | // (SimInfo.regionLocX * Constants.RegionSize), | ||
324 | // (SimInfo.regionLocY*Constants.RegionSize), | ||
325 | // theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, | ||
326 | // theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); | ||
327 | theUser.CurrentAgent.Position = new Vector3(128,128,0); | ||
328 | response.StartLocation = "safe"; | ||
329 | |||
330 | return PrepareLoginToRegion(regionInfo, theUser, response); | ||
331 | } | ||
332 | |||
333 | protected RegionProfileData RequestClosestRegion(string region) | ||
203 | { | 334 | { |
204 | return m_regionProfileService.RequestSimProfileData(region, | 335 | return m_regionProfileService.RequestSimProfileData(region, |
205 | m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey).ToRegionInfo(); | 336 | m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey); |
206 | } | 337 | } |
207 | 338 | ||
208 | protected override RegionInfo GetRegionInfo(ulong homeRegionHandle) | 339 | protected RegionProfileData GetRegionInfo(ulong homeRegionHandle) |
209 | { | 340 | { |
210 | return m_regionProfileService.RequestSimProfileData(homeRegionHandle, | 341 | return m_regionProfileService.RequestSimProfileData(homeRegionHandle, |
211 | m_config.GridServerURL, m_config.GridSendKey, | 342 | m_config.GridServerURL, m_config.GridSendKey, |
212 | m_config.GridRecvKey).ToRegionInfo(); | 343 | m_config.GridRecvKey); |
213 | } | 344 | } |
214 | 345 | ||
215 | protected override RegionInfo GetRegionInfo(UUID homeRegionId) | 346 | protected RegionProfileData GetRegionInfo(UUID homeRegionId) |
216 | { | 347 | { |
217 | return m_regionProfileService.RequestSimProfileData(homeRegionId, | 348 | return m_regionProfileService.RequestSimProfileData(homeRegionId, |
218 | m_config.GridServerURL, m_config.GridSendKey, | 349 | m_config.GridServerURL, m_config.GridSendKey, |
219 | m_config.GridRecvKey).ToRegionInfo(); | 350 | m_config.GridRecvKey); |
220 | } | 351 | } |
221 | 352 | ||
222 | /// <summary> | 353 | /// <summary> |
@@ -228,7 +359,7 @@ namespace OpenSim.Grid.UserServer.Modules | |||
228 | /// <param name="theUser"> | 359 | /// <param name="theUser"> |
229 | /// A <see cref="UserProfileData"/> | 360 | /// A <see cref="UserProfileData"/> |
230 | /// </param> | 361 | /// </param> |
231 | protected override void AddActiveGestures(LoginResponse response, UserProfileData theUser) | 362 | private void AddActiveGestures(LoginResponse response, UserProfileData theUser) |
232 | { | 363 | { |
233 | List<InventoryItemBase> gestures = m_inventoryService.GetActiveGestures(theUser.ID); | 364 | List<InventoryItemBase> gestures = m_inventoryService.GetActiveGestures(theUser.ID); |
234 | //m_log.DebugFormat("[LOGIN]: AddActiveGestures, found {0}", gestures == null ? 0 : gestures.Count); | 365 | //m_log.DebugFormat("[LOGIN]: AddActiveGestures, found {0}", gestures == null ? 0 : gestures.Count); |
@@ -246,23 +377,18 @@ namespace OpenSim.Grid.UserServer.Modules | |||
246 | response.ActiveGestures = list; | 377 | response.ActiveGestures = list; |
247 | } | 378 | } |
248 | 379 | ||
249 | protected override bool PrepareLoginToRegion(RegionInfo regionInfo, UserProfileData user, LoginResponse response) | ||
250 | { | ||
251 | return PrepareLoginToRegion(RegionProfileData.FromRegionInfo(regionInfo), user, response); | ||
252 | } | ||
253 | |||
254 | /// <summary> | 380 | /// <summary> |
255 | /// Prepare a login to the given region. This involves both telling the region to expect a connection | 381 | /// Prepare a login to the given region. This involves both telling the region to expect a connection |
256 | /// and appropriately customising the response to the user. | 382 | /// and appropriately customising the response to the user. |
257 | /// </summary> | 383 | /// </summary> |
258 | /// <param name="regionInfo"></param> | 384 | /// <param name="sim"></param> |
259 | /// <param name="user"></param> | 385 | /// <param name="user"></param> |
260 | /// <param name="response"></param> | 386 | /// <param name="response"></param> |
261 | /// <returns>true if the region was successfully contacted, false otherwise</returns> | 387 | /// <returns>true if the region was successfully contacted, false otherwise</returns> |
262 | private bool PrepareLoginToRegion(RegionProfileData regionInfo, UserProfileData user, LoginResponse response) | 388 | private bool PrepareLoginToRegion(RegionProfileData regionInfo, UserProfileData user, LoginResponse response) |
263 | { | 389 | { |
264 | try | 390 | try |
265 | { | 391 | { |
266 | response.SimAddress = Util.GetHostFromURL(regionInfo.serverURI).ToString(); | 392 | response.SimAddress = Util.GetHostFromURL(regionInfo.serverURI).ToString(); |
267 | response.SimPort = uint.Parse(regionInfo.serverURI.Split(new char[] { '/', ':' })[4]); | 393 | response.SimPort = uint.Parse(regionInfo.serverURI.Split(new char[] { '/', ':' })[4]); |
268 | response.RegionX = regionInfo.regionLocX; | 394 | response.RegionX = regionInfo.regionLocX; |
@@ -279,11 +405,11 @@ namespace OpenSim.Grid.UserServer.Modules | |||
279 | m_log.InfoFormat( | 405 | m_log.InfoFormat( |
280 | "[LOGIN]: Telling {0} @ {1},{2} ({3}) to prepare for client connection", | 406 | "[LOGIN]: Telling {0} @ {1},{2} ({3}) to prepare for client connection", |
281 | regionInfo.regionName, response.RegionX, response.RegionY, regionInfo.httpServerURI); | 407 | regionInfo.regionName, response.RegionX, response.RegionY, regionInfo.httpServerURI); |
282 | 408 | ||
283 | // Update agent with target sim | 409 | // Update agent with target sim |
284 | user.CurrentAgent.Region = regionInfo.UUID; | 410 | user.CurrentAgent.Region = regionInfo.UUID; |
285 | user.CurrentAgent.Handle = regionInfo.regionHandle; | 411 | user.CurrentAgent.Handle = regionInfo.regionHandle; |
286 | 412 | ||
287 | // Prepare notification | 413 | // Prepare notification |
288 | Hashtable loginParams = new Hashtable(); | 414 | Hashtable loginParams = new Hashtable(); |
289 | loginParams["session_id"] = user.CurrentAgent.SessionID.ToString(); | 415 | loginParams["session_id"] = user.CurrentAgent.SessionID.ToString(); |
@@ -291,7 +417,7 @@ namespace OpenSim.Grid.UserServer.Modules | |||
291 | loginParams["firstname"] = user.FirstName; | 417 | loginParams["firstname"] = user.FirstName; |
292 | loginParams["lastname"] = user.SurName; | 418 | loginParams["lastname"] = user.SurName; |
293 | loginParams["agent_id"] = user.ID.ToString(); | 419 | loginParams["agent_id"] = user.ID.ToString(); |
294 | loginParams["circuit_code"] = (Int32)Convert.ToUInt32(response.CircuitCode); | 420 | loginParams["circuit_code"] = (Int32) Convert.ToUInt32(response.CircuitCode); |
295 | loginParams["startpos_x"] = user.CurrentAgent.Position.X.ToString(); | 421 | loginParams["startpos_x"] = user.CurrentAgent.Position.X.ToString(); |
296 | loginParams["startpos_y"] = user.CurrentAgent.Position.Y.ToString(); | 422 | loginParams["startpos_y"] = user.CurrentAgent.Position.Y.ToString(); |
297 | loginParams["startpos_z"] = user.CurrentAgent.Position.Z.ToString(); | 423 | loginParams["startpos_z"] = user.CurrentAgent.Position.Z.ToString(); |
@@ -324,10 +450,10 @@ namespace OpenSim.Grid.UserServer.Modules | |||
324 | 450 | ||
325 | if (GridResp.Value != null) | 451 | if (GridResp.Value != null) |
326 | { | 452 | { |
327 | Hashtable resp = (Hashtable)GridResp.Value; | 453 | Hashtable resp = (Hashtable) GridResp.Value; |
328 | if (resp.ContainsKey("success")) | 454 | if (resp.ContainsKey("success")) |
329 | { | 455 | { |
330 | if ((string)resp["success"] == "FALSE") | 456 | if ((string) resp["success"] == "FALSE") |
331 | { | 457 | { |
332 | responseSuccess = false; | 458 | responseSuccess = false; |
333 | } | 459 | } |
@@ -407,7 +533,7 @@ namespace OpenSim.Grid.UserServer.Modules | |||
407 | 533 | ||
408 | foreach (InventoryFolderBase InvFolder in folders) | 534 | foreach (InventoryFolderBase InvFolder in folders) |
409 | { | 535 | { |
410 | // m_log.DebugFormat("[LOGIN]: Received agent inventory folder {0}", InvFolder.name); | 536 | // m_log.DebugFormat("[LOGIN]: Received agent inventory folder {0}", InvFolder.name); |
411 | 537 | ||
412 | if (InvFolder.ParentID == UUID.Zero) | 538 | if (InvFolder.ParentID == UUID.Zero) |
413 | { | 539 | { |
@@ -416,8 +542,8 @@ namespace OpenSim.Grid.UserServer.Modules | |||
416 | TempHash = new Hashtable(); | 542 | TempHash = new Hashtable(); |
417 | TempHash["name"] = InvFolder.Name; | 543 | TempHash["name"] = InvFolder.Name; |
418 | TempHash["parent_id"] = InvFolder.ParentID.ToString(); | 544 | TempHash["parent_id"] = InvFolder.ParentID.ToString(); |
419 | TempHash["version"] = (Int32)InvFolder.Version; | 545 | TempHash["version"] = (Int32) InvFolder.Version; |
420 | TempHash["type_default"] = (Int32)InvFolder.Type; | 546 | TempHash["type_default"] = (Int32) InvFolder.Type; |
421 | TempHash["folder_id"] = InvFolder.ID.ToString(); | 547 | TempHash["folder_id"] = InvFolder.ID.ToString(); |
422 | AgentInventoryArray.Add(TempHash); | 548 | AgentInventoryArray.Add(TempHash); |
423 | } | 549 | } |
@@ -433,14 +559,14 @@ namespace OpenSim.Grid.UserServer.Modules | |||
433 | public XmlRpcResponse XmlRPCSetLoginParams(XmlRpcRequest request) | 559 | public XmlRpcResponse XmlRPCSetLoginParams(XmlRpcRequest request) |
434 | { | 560 | { |
435 | XmlRpcResponse response = new XmlRpcResponse(); | 561 | XmlRpcResponse response = new XmlRpcResponse(); |
436 | Hashtable requestData = (Hashtable)request.Params[0]; | 562 | Hashtable requestData = (Hashtable) request.Params[0]; |
437 | UserProfileData userProfile; | 563 | UserProfileData userProfile; |
438 | Hashtable responseData = new Hashtable(); | 564 | Hashtable responseData = new Hashtable(); |
439 | 565 | ||
440 | UUID uid; | 566 | UUID uid; |
441 | string pass = requestData["password"].ToString(); | 567 | string pass = requestData["password"].ToString(); |
442 | 568 | ||
443 | if (!UUID.TryParse((string)requestData["avatar_uuid"], out uid)) | 569 | if (!UUID.TryParse((string) requestData["avatar_uuid"], out uid)) |
444 | { | 570 | { |
445 | responseData["error"] = "No authorization"; | 571 | responseData["error"] = "No authorization"; |
446 | response.Value = responseData; | 572 | response.Value = responseData; |
@@ -471,5 +597,6 @@ namespace OpenSim.Grid.UserServer.Modules | |||
471 | response.Value = responseData; | 597 | response.Value = responseData; |
472 | return response; | 598 | return response; |
473 | } | 599 | } |
600 | |||
474 | } | 601 | } |
475 | } | 602 | } |