aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/IPeople.cs2
-rw-r--r--OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs556
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs23
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs17
-rw-r--r--OpenSim/Services/Interfaces/IUserManagement.cs1
5 files changed, 327 insertions, 272 deletions
diff --git a/OpenSim/Framework/IPeople.cs b/OpenSim/Framework/IPeople.cs
index b88e103..8d274d0 100644
--- a/OpenSim/Framework/IPeople.cs
+++ b/OpenSim/Framework/IPeople.cs
@@ -38,6 +38,8 @@ namespace OpenSim.Framework
38 public string LastName { get; set; } 38 public string LastName { get; set; }
39 public string HomeURL { get; set; } 39 public string HomeURL { get; set; }
40 public Dictionary<string, object> ServerURLs { get; set; } 40 public Dictionary<string, object> ServerURLs { get; set; }
41 public bool IsUnknownUser { get; set; }
42 public bool HasGridUserTried { get; set; }
41 } 43 }
42 44
43 public interface IPeople 45 public interface IPeople
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
index 6479430..d3d1246 100644
--- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
@@ -62,6 +62,8 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
62 // The cache 62 // The cache
63 protected Dictionary<UUID, UserData> m_UserCache = new Dictionary<UUID, UserData>(); 63 protected Dictionary<UUID, UserData> m_UserCache = new Dictionary<UUID, UserData>();
64 64
65 protected bool m_DisplayChangingHomeURI = false;
66
65 #region ISharedRegionModule 67 #region ISharedRegionModule
66 68
67 public void Initialise(IConfigSource config) 69 public void Initialise(IConfigSource config)
@@ -73,6 +75,17 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
73 Init(); 75 Init();
74 m_log.DebugFormat("[USER MANAGEMENT MODULE]: {0} is enabled", Name); 76 m_log.DebugFormat("[USER MANAGEMENT MODULE]: {0} is enabled", Name);
75 } 77 }
78
79 if(!m_Enabled)
80 {
81 return;
82 }
83
84 IConfig userManagementConfig = config.Configs["UserManagement"];
85 if (userManagementConfig == null)
86 return;
87
88 m_DisplayChangingHomeURI = userManagementConfig.GetBoolean("DisplayChangingHomeURI", false);
76 } 89 }
77 90
78 public bool IsSharedModule 91 public bool IsSharedModule
@@ -94,7 +107,10 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
94 { 107 {
95 if (m_Enabled) 108 if (m_Enabled)
96 { 109 {
97 m_Scenes.Add(scene); 110 lock (m_Scenes)
111 {
112 m_Scenes.Add(scene);
113 }
98 114
99 scene.RegisterModuleInterface<IUserManagement>(this); 115 scene.RegisterModuleInterface<IUserManagement>(this);
100 scene.RegisterModuleInterface<IPeople>(this); 116 scene.RegisterModuleInterface<IPeople>(this);
@@ -108,7 +124,10 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
108 if (m_Enabled) 124 if (m_Enabled)
109 { 125 {
110 scene.UnregisterModuleInterface<IUserManagement>(this); 126 scene.UnregisterModuleInterface<IUserManagement>(this);
111 m_Scenes.Remove(scene); 127 lock (m_Scenes)
128 {
129 m_Scenes.Remove(scene);
130 }
112 } 131 }
113 } 132 }
114 133
@@ -124,7 +143,10 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
124 143
125 public void Close() 144 public void Close()
126 { 145 {
127 m_Scenes.Clear(); 146 lock (m_Scenes)
147 {
148 m_Scenes.Clear();
149 }
128 150
129 lock (m_UserCache) 151 lock (m_UserCache)
130 m_UserCache.Clear(); 152 m_UserCache.Clear();
@@ -167,11 +189,18 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
167 } 189 }
168 else 190 else
169 { 191 {
170 string[] names = new string[2]; 192 UserData user;
171 if (TryGetUserNamesFromCache(uuid, names)) 193 /* bypass that continuation here when entry is already available */
194 lock (m_UserCache)
172 { 195 {
173 client.SendNameReply(uuid, names[0], names[1]); 196 if (m_UserCache.TryGetValue(uuid, out user))
174 return; 197 {
198 if (!user.IsUnknownUser && user.HasGridUserTried)
199 {
200 client.SendNameReply(uuid, user.FirstName, user.LastName);
201 return;
202 }
203 }
175 } 204 }
176 205
177 // Not found in cache, queue continuation 206 // Not found in cache, queue continuation
@@ -185,8 +214,10 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
185 // So to avoid clients 214 // So to avoid clients
186 // (particularly Hypergrid clients) permanently binding "Unknown User" to a given UUID, we will 215 // (particularly Hypergrid clients) permanently binding "Unknown User" to a given UUID, we will
187 // instead drop the request entirely. 216 // instead drop the request entirely.
188 if (TryGetUserNames(uuid, names)) 217 if (GetUser(uuid, out user))
189 client.SendNameReply(uuid, names[0], names[1]); 218 {
219 client.SendNameReply(uuid, user.FirstName, user.LastName);
220 }
190// else 221// else
191// m_log.DebugFormat( 222// m_log.DebugFormat(
192// "[USER MANAGEMENT MODULE]: No bound name for {0} found, ignoring request from {1}", 223// "[USER MANAGEMENT MODULE]: No bound name for {0} found, ignoring request from {1}",
@@ -269,20 +300,19 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
269 ud.FirstName = acc.FirstName; 300 ud.FirstName = acc.FirstName;
270 ud.LastName = acc.LastName; 301 ud.LastName = acc.LastName;
271 ud.Id = acc.PrincipalID; 302 ud.Id = acc.PrincipalID;
303 ud.HasGridUserTried = true;
304 ud.IsUnknownUser = false;
272 users.Add(ud); 305 users.Add(ud);
273 } 306 }
274 } 307 }
275 308
276 // search the local cache 309 // search the local cache
277 lock (m_UserCache) 310 foreach (UserData data in m_UserCache.Values)
278 { 311 {
279 foreach (UserData data in m_UserCache.Values) 312 if (data.Id != UUID.Zero && !data.IsUnknownUser &&
280 { 313 users.Find(delegate(UserData d) { return d.Id == data.Id; }) == null &&
281 if (data.Id != UUID.Zero && 314 (data.FirstName.ToLower().StartsWith(query.ToLower()) || data.LastName.ToLower().StartsWith(query.ToLower())))
282 users.Find(delegate(UserData d) { return d.Id == data.Id; }) == null && 315 users.Add(data);
283 (data.FirstName.ToLower().StartsWith(query.ToLower()) || data.LastName.ToLower().StartsWith(query.ToLower())))
284 users.Add(data);
285 }
286 } 316 }
287 317
288 AddAdditionalUsers(query, users); 318 AddAdditionalUsers(query, users);
@@ -306,101 +336,6 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
306 } 336 }
307 } 337 }
308 338
309 /// <summary>
310 ///
311 /// </summary>
312 /// <param name="uuid"></param>
313 /// <param name="names">Caller please provide a properly instantiated array for names, string[2]</param>
314 /// <returns></returns>
315 private bool TryGetUserNames(UUID uuid, string[] names)
316 {
317 if (names == null)
318 names = new string[2];
319
320 if (TryGetUserNamesFromCache(uuid, names))
321 return true;
322
323 if (TryGetUserNamesFromServices(uuid, names))
324 return true;
325
326 return false;
327 }
328
329 private bool TryGetUserNamesFromCache(UUID uuid, string[] names)
330 {
331 lock (m_UserCache)
332 {
333 if (m_UserCache.ContainsKey(uuid))
334 {
335 names[0] = m_UserCache[uuid].FirstName;
336 names[1] = m_UserCache[uuid].LastName;
337
338 return true;
339 }
340 }
341
342 return false;
343 }
344
345 /// <summary>
346 /// Try to get the names bound to the given uuid, from the services.
347 /// </summary>
348 /// <returns>True if the name was found, false if not.</returns>
349 /// <param name='uuid'></param>
350 /// <param name='names'>The array of names if found. If not found, then names[0] = "Unknown" and names[1] = "User"</param>
351 private bool TryGetUserNamesFromServices(UUID uuid, string[] names)
352 {
353 UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(UUID.Zero, uuid);
354
355 if (account != null)
356 {
357 names[0] = account.FirstName;
358 names[1] = account.LastName;
359
360 UserData user = new UserData();
361 user.FirstName = account.FirstName;
362 user.LastName = account.LastName;
363
364 lock (m_UserCache)
365 m_UserCache[uuid] = user;
366
367 return true;
368 }
369 else
370 {
371 // Let's try the GridUser service
372 GridUserInfo uInfo = m_Scenes[0].GridUserService.GetGridUserInfo(uuid.ToString());
373 if (uInfo != null)
374 {
375 string url, first, last, tmp;
376 UUID u;
377 if (Util.ParseUniversalUserIdentifier(uInfo.UserID, out u, out url, out first, out last, out tmp))
378 {
379 AddUser(uuid, first, last, url);
380
381 if (m_UserCache.ContainsKey(uuid))
382 {
383 names[0] = m_UserCache[uuid].FirstName;
384 names[1] = m_UserCache[uuid].LastName;
385
386 return true;
387 }
388 }
389 else
390 m_log.DebugFormat("[USER MANAGEMENT MODULE]: Unable to parse UUI {0}", uInfo.UserID);
391 }
392 else
393 {
394 m_log.DebugFormat("[USER MANAGEMENT MODULE]: No grid user found for {0}", uuid);
395 }
396
397 names[0] = "Unknown";
398 names[1] = "UserUMMTGUN9";
399
400 return false;
401 }
402 }
403
404 #region IUserManagement 339 #region IUserManagement
405 340
406 public UUID GetUserIdByName(string name) 341 public UUID GetUserIdByName(string name)
@@ -434,63 +369,56 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
434 369
435 public string GetUserName(UUID uuid) 370 public string GetUserName(UUID uuid)
436 { 371 {
437 string[] names = new string[2]; 372 UserData user;
438 TryGetUserNames(uuid, names); 373 GetUser(uuid, out user);
439 374 return user.FirstName + " " + user.LastName;
440 return names[0] + " " + names[1];
441
442 } 375 }
443 376
444 public string GetUserHomeURL(UUID userID) 377 public string GetUserHomeURL(UUID userID)
445 { 378 {
446 lock (m_UserCache) 379 UserData user;
380 if(GetUser(userID, out user))
447 { 381 {
448 if (m_UserCache.ContainsKey(userID)) 382 return user.HomeURL;
449 return m_UserCache[userID].HomeURL;
450 } 383 }
451
452 return string.Empty; 384 return string.Empty;
453 } 385 }
454 386
455 public string GetUserServerURL(UUID userID, string serverType) 387 public string GetUserServerURL(UUID userID, string serverType)
456 { 388 {
457 UserData userdata; 389 UserData userdata;
458 lock (m_UserCache) 390 if(!GetUser(userID, out userdata))
459 m_UserCache.TryGetValue(userID, out userdata); 391 {
392 return string.Empty;
393 }
460 394
461 if (userdata != null) 395 if (userdata.ServerURLs != null && userdata.ServerURLs.ContainsKey(serverType) && userdata.ServerURLs[serverType] != null)
396 {
397 return userdata.ServerURLs[serverType].ToString();
398 }
399
400 if (!string.IsNullOrEmpty(userdata.HomeURL))
462 { 401 {
463// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Requested url type {0} for {1}", serverType, userID); 402// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Requested url type {0} for {1}", serverType, userID);
464 403
465 if (userdata.ServerURLs != null) 404 UserAgentServiceConnector uConn = new UserAgentServiceConnector(userdata.HomeURL);
405 try
466 { 406 {
467 object url; 407 userdata.ServerURLs = uConn.GetServerURLs(userID);
468
469 if (userdata.ServerURLs.TryGetValue(serverType, out url))
470 return url.ToString();
471 } 408 }
472 else if (!string.IsNullOrEmpty(userdata.HomeURL)) 409 catch(System.Net.WebException e)
473 { 410 {
474 //m_log.DebugFormat( 411 m_log.DebugFormat("[USER MANAGEMENT MODULE]: GetServerURLs call failed {0}", e.Message);
475 // "[USER MANAGEMENT MODULE]: Did not find url type {0} so requesting urls from '{1}' for {2}", 412 userdata.ServerURLs = new Dictionary<string, object>();
476 // serverType, userdata.HomeURL, userID);
477
478 UserAgentServiceConnector uConn = new UserAgentServiceConnector(userdata.HomeURL);
479 try
480 {
481 userdata.ServerURLs = uConn.GetServerURLs(userID);
482 }
483 catch (Exception e)
484 {
485 m_log.Debug("[USER MANAGEMENT MODULE]: GetServerURLs call failed ", e);
486 userdata.ServerURLs = new Dictionary<string, object>();
487 }
488
489 object url;
490
491 if (userdata.ServerURLs.TryGetValue(serverType, out url))
492 return url.ToString();
493 } 413 }
414 catch (Exception e)
415 {
416 m_log.Debug("[USER MANAGEMENT MODULE]: GetServerURLs call failed ", e);
417 userdata.ServerURLs = new Dictionary<string, object>();
418 }
419
420 if (userdata.ServerURLs != null && userdata.ServerURLs.ContainsKey(serverType) && userdata.ServerURLs[serverType] != null)
421 return userdata.ServerURLs[serverType].ToString();
494 } 422 }
495 423
496 return string.Empty; 424 return string.Empty;
@@ -498,19 +426,15 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
498 426
499 public string GetUserUUI(UUID userID) 427 public string GetUserUUI(UUID userID)
500 { 428 {
501 UserData ud; 429 string uui;
502 lock (m_UserCache) 430 GetUserUUI(userID, out uui);
503 m_UserCache.TryGetValue(userID, out ud); 431 return uui;
432 }
504 433
505 if (ud == null) // It's not in the cache 434 public bool GetUserUUI(UUID userID, out string uui)
506 { 435 {
507 string[] names = new string[2]; 436 UserData ud;
508 // This will pull the data from either UserAccounts or GridUser 437 bool result = GetUser(userID, out ud);
509 // and stick it into the cache
510 TryGetUserNamesFromServices(userID, names);
511 lock (m_UserCache)
512 m_UserCache.TryGetValue(userID, out ud);
513 }
514 438
515 if (ud != null) 439 if (ud != null)
516 { 440 {
@@ -524,129 +448,247 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
524 first = parts[0]; 448 first = parts[0];
525 last = parts[1]; 449 last = parts[1];
526 } 450 }
527 return userID + ";" + homeURL + ";" + first + " " + last; 451 uui = userID + ";" + homeURL + ";" + first + " " + last;
528 } 452 }
529 } 453 }
530 454
531 return userID.ToString(); 455 uui = userID.ToString();
456 return result;
532 } 457 }
533 458
534 public void AddUser(UUID uuid, string first, string last) 459 #region Cache Management
460 public bool GetUser(UUID uuid, out UserData userdata)
535 { 461 {
536 lock (m_UserCache) 462 lock (m_UserCache)
537 { 463 {
538 if (m_UserCache.ContainsKey(uuid)) 464 if (m_UserCache.TryGetValue(uuid, out userdata))
539 return; 465 {
466 if (userdata.HasGridUserTried)
467 {
468 return true;
469 }
470 }
471 else
472 {
473 userdata = new UserData();
474 userdata.HasGridUserTried = false;
475 userdata.Id = uuid;
476 userdata.FirstName = "Unknown";
477 userdata.LastName = "UserUMMAU42";
478 userdata.HomeURL = string.Empty;
479 userdata.IsUnknownUser = true;
480 userdata.HasGridUserTried = false;
481 }
482 }
483
484 /* BEGIN: do not wrap this code in any lock here
485 * There are HTTP calls in here.
486 */
487 if (!userdata.HasGridUserTried)
488 {
489 /* rewrite here */
490 UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, uuid);
491 if (account != null)
492 {
493 userdata.FirstName = account.FirstName;
494 userdata.LastName = account.LastName;
495 userdata.HomeURL = string.Empty;
496 userdata.IsUnknownUser = false;
497 userdata.HasGridUserTried = true;
498 }
540 } 499 }
541 500
542 UserData user = new UserData(); 501 if (!userdata.HasGridUserTried)
543 user.Id = uuid; 502 {
544 user.FirstName = first; 503 GridUserInfo uInfo = m_Scenes[0].GridUserService.GetGridUserInfo(uuid.ToString());
545 user.LastName = last; 504 if (uInfo != null)
505 {
506 string url, first, last, tmp;
507 UUID u;
508 if(uInfo.UserID.Length <= 36)
509 {
510 /* not a UUI */
511 }
512 else if (Util.ParseUniversalUserIdentifier(uInfo.UserID, out u, out url, out first, out last, out tmp))
513 {
514 if (url != string.Empty)
515 {
516 userdata.FirstName = first.Replace(" ", ".") + "." + last.Replace(" ", ".");
517 userdata.HomeURL = url;
518 try
519 {
520 userdata.LastName = "@" + new Uri(url).Authority;
521 userdata.IsUnknownUser = false;
522 }
523 catch
524 {
525 userdata.LastName = "@unknown";
526 }
527 userdata.HasGridUserTried = true;
528 }
529 }
530 else
531 m_log.DebugFormat("[USER MANAGEMENT MODULE]: Unable to parse UUI {0}", uInfo.UserID);
532 }
533 }
534 /* END: do not wrap this code in any lock here */
546 535
547 AddUserInternal(user); 536 lock (m_UserCache)
537 {
538 m_UserCache[uuid] = userdata;
539 }
540 return !userdata.IsUnknownUser;
548 } 541 }
549 542
550 public void AddUser(UUID uuid, string first, string last, string homeURL) 543 public void AddUser(UUID uuid, string first, string last)
551 { 544 {
552 //m_log.DebugFormat("[USER MANAGEMENT MODULE]: Adding user with id {0}, first {1}, last {2}, url {3}", uuid, first, last, homeURL); 545 lock(m_UserCache)
553 if (homeURL == string.Empty) 546 {
554 return; 547 if(!m_UserCache.ContainsKey(uuid))
555 548 {
556 AddUser(uuid, homeURL + ";" + first + " " + last); 549 UserData user = new UserData();
550 user.Id = uuid;
551 user.FirstName = first;
552 user.LastName = last;
553 user.IsUnknownUser = false;
554 user.HasGridUserTried = false;
555 m_UserCache.Add(uuid, user);
556 }
557 }
557 } 558 }
558 559
559 public void AddUser(UUID id, string creatorData) 560 public void AddUser(UUID uuid, string first, string last, string homeURL)
560 { 561 {
561 //m_log.DebugFormat("[USER MANAGEMENT MODULE]: Adding user with id {0}, creatorData {1}", id, creatorData); 562 //m_log.DebugFormat("[USER MANAGEMENT MODULE]: Adding user with id {0}, first {1}, last {2}, url {3}", uuid, first, last, homeURL);
562 563
563 UserData oldUser; 564 UserData oldUser;
564 lock (m_UserCache) 565 lock (m_UserCache)
565 m_UserCache.TryGetValue(id, out oldUser);
566
567 if (oldUser != null)
568 { 566 {
569 if (string.IsNullOrEmpty(creatorData)) 567 if (m_UserCache.TryGetValue(uuid, out oldUser))
570 { 568 {
571 //ignore updates without creator data 569 if (!oldUser.IsUnknownUser)
572 return; 570 {
573 } 571 if (homeURL != oldUser.HomeURL && m_DisplayChangingHomeURI)
574 572 {
575 //try update unknown users, but don't update anyone else 573 m_log.DebugFormat("[USER MANAGEMENT MODULE]: Different HomeURI for {0} {1} ({2}): {3} and {4}",
576 if (oldUser.FirstName == "Unknown" && !creatorData.Contains("Unknown")) 574 first, last, uuid.ToString(), homeURL, oldUser.HomeURL);
577 { 575 }
578 lock (m_UserCache) 576 /* no update needed */
579 m_UserCache.Remove(id); 577 return;
580 m_log.DebugFormat("[USER MANAGEMENT MODULE]: Re-adding user with id {0}, creatorData [{1}] and old HomeURL {2}", id, creatorData, oldUser.HomeURL); 578 }
581 } 579 }
582 else 580 else if(!m_UserCache.ContainsKey(uuid))
583 { 581 {
584 //we have already a valid user within the cache 582 oldUser = new UserData();
585 return; 583 oldUser.HasGridUserTried = false;
584 oldUser.IsUnknownUser = false;
585 if (homeURL != string.Empty)
586 {
587 oldUser.FirstName = first.Replace(" ", ".") + "." + last.Replace(" ", ".");
588 try
589 {
590 oldUser.LastName = "@" + new Uri(homeURL).Authority;
591 oldUser.IsUnknownUser = false;
592 }
593 catch
594 {
595 oldUser.LastName = "@unknown";
596 }
597 }
598 else
599 {
600 oldUser.FirstName = first;
601 oldUser.LastName = last;
602 }
603 oldUser.HomeURL = homeURL;
604 oldUser.Id = uuid;
605 m_UserCache.Add(uuid, oldUser);
586 } 606 }
587 } 607 }
608 }
588 609
589 UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, id); 610 public void AddUser(UUID id, string creatorData)
611 {
612 // m_log.InfoFormat("[USER MANAGEMENT MODULE]: Adding user with id {0}, creatorData {1}", id, creatorData);
590 613
591 if (account != null) 614 if(string.IsNullOrEmpty(creatorData))
592 { 615 {
593 AddUser(id, account.FirstName, account.LastName); 616 AddUser(id, string.Empty, string.Empty, string.Empty);
594 } 617 }
595 else 618 else
596 { 619 {
597 UserData user = new UserData(); 620 string homeURL;
598 user.Id = id; 621 string firstname = string.Empty;
599 622 string lastname = string.Empty;
600 if (!string.IsNullOrEmpty(creatorData))
601 {
602 //creatorData = <endpoint>;<name>
603 623
604 string[] parts = creatorData.Split(';'); 624 //creatorData = <endpoint>;<name>
605 625
606 if (parts.Length >= 2) 626 string[] parts = creatorData.Split(';');
607 user.FirstName = parts[1].Replace(' ', '.'); 627 if(parts.Length > 1)
608 628 {
609 if (parts.Length >= 1) 629 string[] nameparts = parts[1].Split(' ');
630 firstname = nameparts[0];
631 for(int xi = 1; xi < nameparts.Length; ++xi)
610 { 632 {
611 user.HomeURL = parts[0]; 633 if(xi != 1)
612 try
613 { 634 {
614 Uri uri = new Uri(parts[0]); 635 lastname += " ";
615 user.LastName = "@" + uri.Authority;
616 } 636 }
617 catch (UriFormatException) 637 lastname += nameparts[xi];
618 { 638 }
619 m_log.DebugFormat( 639 }
620 "[USER MANAGEMENT MODULE]: Unable to parse home URL {0} for user name {1}, ID {2} from original creator data {3} when adding user info.", 640 else
621 parts[0], user.FirstName ?? "Unknown", id, creatorData); 641 {
642 firstname = "Unknown";
643 lastname = "UserUMMAU5";
644 }
645 if (parts.Length >= 1)
646 {
647 homeURL = parts[0];
648 if(Uri.IsWellFormedUriString(homeURL, UriKind.Absolute))
649 {
650 AddUser(id, firstname, lastname, homeURL);
651 }
652 else
653 {
654 m_log.DebugFormat("[SCENE]: Unable to parse Uri {0} for CreatorID {1}", parts[0], creatorData);
622 655
623 user.LastName = "@unknown"; 656 lock (m_UserCache)
657 {
658 if(!m_UserCache.ContainsKey(id))
659 {
660 UserData newUser = new UserData();
661 newUser.Id = id;
662 newUser.FirstName = firstname + "." + lastname.Replace(' ', '.');
663 newUser.LastName = "@unknown";
664 newUser.HomeURL = string.Empty;
665 newUser.HasGridUserTried = false;
666 newUser.IsUnknownUser = true; /* we mark those users as Unknown user so a re-retrieve may be activated */
667 m_UserCache.Add(id, newUser);
668 }
624 } 669 }
625 } 670 }
626 } 671 }
627 else 672 else
628 { 673 {
629 // Temporarily add unknown user entries of this type into the cache so that we can distinguish 674 lock(m_UserCache)
630 // this source from other recent (hopefully resolved) bugs that fail to retrieve a user name binding 675 {
631 // TODO: Can be removed when GUN* unknown users have definitely dropped significantly or 676 if(!m_UserCache.ContainsKey(id))
632 // disappeared. 677 {
633 user.FirstName = "Unknown"; 678 UserData newUser = new UserData();
634 user.LastName = "UserUMMAU4"; 679 newUser.Id = id;
680 newUser.FirstName = "Unknown";
681 newUser.LastName = "UserUMMAU4";
682 newUser.HomeURL = string.Empty;
683 newUser.IsUnknownUser = true;
684 newUser.HasGridUserTried = false;
685 m_UserCache.Add(id, newUser);
686 }
687 }
635 } 688 }
636
637 AddUserInternal(user);
638 } 689 }
639 } 690 }
640 691 #endregion
641 void AddUserInternal(UserData user)
642 {
643 lock (m_UserCache)
644 m_UserCache[user.Id] = user;
645
646 //m_log.DebugFormat(
647 // "[USER MANAGEMENT MODULE]: Added user {0} {1} {2} {3}",
648 // user.Id, user.FirstName, user.LastName, user.HomeURL);
649 }
650 692
651 public bool IsLocalGridUser(UUID uuid) 693 public bool IsLocalGridUser(UUID uuid)
652 { 694 {
@@ -680,21 +722,6 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
680 "Show the bindings between user UUIDs and user names", 722 "Show the bindings between user UUIDs and user names",
681 String.Empty, 723 String.Empty,
682 HandleShowUsers); 724 HandleShowUsers);
683
684 MainConsole.Instance.Commands.AddCommand("Users", true,
685 "reset user cache",
686 "reset user cache",
687 "reset user cache to allow changed settings to be applied",
688 String.Empty,
689 HandleResetUserCache);
690 }
691
692 private void HandleResetUserCache(string module, string[] cmd)
693 {
694 lock(m_UserCache)
695 {
696 m_UserCache.Clear();
697 }
698 } 725 }
699 726
700 private void HandleShowUser(string module, string[] cmd) 727 private void HandleShowUser(string module, string[] cmd)
@@ -711,13 +738,10 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
711 738
712 UserData ud; 739 UserData ud;
713 740
714 lock (m_UserCache) 741 if(!GetUser(userId, out ud))
715 { 742 {
716 if (!m_UserCache.TryGetValue(userId, out ud)) 743 MainConsole.Instance.OutputFormat("No name known for user with id {0}", userId);
717 { 744 return;
718 MainConsole.Instance.OutputFormat("No name known for user with id {0}", userId);
719 return;
720 }
721 } 745 }
722 746
723 ConsoleDisplayTable cdt = new ConsoleDisplayTable(); 747 ConsoleDisplayTable cdt = new ConsoleDisplayTable();
@@ -735,11 +759,17 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
735 cdt.AddColumn("UUID", 36); 759 cdt.AddColumn("UUID", 36);
736 cdt.AddColumn("Name", 30); 760 cdt.AddColumn("Name", 30);
737 cdt.AddColumn("HomeURL", 40); 761 cdt.AddColumn("HomeURL", 40);
762 cdt.AddColumn("Checked", 10);
738 763
739 lock (m_UserCache) 764 Dictionary<UUID, UserData> copyDict;
765 lock(m_UserCache)
766 {
767 copyDict = new Dictionary<UUID, UserData>(m_UserCache);
768 }
769
770 foreach(KeyValuePair<UUID, UserData> kvp in copyDict)
740 { 771 {
741 foreach (KeyValuePair<UUID, UserData> kvp in m_UserCache) 772 cdt.AddRow(kvp.Key, string.Format("{0} {1}", kvp.Value.FirstName, kvp.Value.LastName), kvp.Value.HomeURL, kvp.Value.HasGridUserTried ? "yes" : "no");
742 cdt.AddRow(kvp.Key, string.Format("{0} {1}", kvp.Value.FirstName, kvp.Value.LastName), kvp.Value.HomeURL);
743 } 773 }
744 774
745 MainConsole.Instance.Output(cdt.ToString()); 775 MainConsole.Instance.Output(cdt.ToString());
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs
index e05d186..2238c90 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs
@@ -67,10 +67,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser
67 { 67 {
68 if (sp.PresenceType != PresenceType.Npc) 68 if (sp.PresenceType != PresenceType.Npc)
69 { 69 {
70 string userid = sp.Scene.UserManagementModule.GetUserUUI(sp.UUID); 70 string userid;
71 //m_log.DebugFormat("[ACTIVITY DETECTOR]: Detected root presence {0} in {1}", userid, sp.Scene.RegionInfo.RegionName); 71 //m_log.DebugFormat("[ACTIVITY DETECTOR]: Detected root presence {0} in {1}", userid, sp.Scene.RegionInfo.RegionName);
72 m_GridUserService.SetLastPosition( 72 if (sp.Scene.UserManagementModule.GetUserUUI(sp.UUID, out userid))
73 userid, UUID.Zero, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat); 73 {
74 /* we only setposition on known agents that have a valid lookup */
75 m_GridUserService.SetLastPosition(
76 userid, UUID.Zero, sp.Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat);
77 }
74 } 78 }
75 } 79 }
76 80
@@ -89,17 +93,20 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser
89 if (client.SceneAgent.IsChildAgent) 93 if (client.SceneAgent.IsChildAgent)
90 return; 94 return;
91 95
92 string userId = client.AgentId.ToString(); 96 string userId;
97 /* without scene we cannot logout correctly at all since we do not know how to send the loggedout message then */
93 if (client.Scene is Scene) 98 if (client.Scene is Scene)
94 { 99 {
95 Scene s = (Scene)client.Scene; 100 Scene s = (Scene)client.Scene;
96 userId = s.UserManagementModule.GetUserUUI(client.AgentId); 101 userId = s.UserManagementModule.GetUserUUI(client.AgentId);
102 if(s.UserManagementModule.GetUserUUI(client.AgentId, out userId))
103 {
104 m_GridUserService.LoggedOut(
105 userId, client.SessionId, client.Scene.RegionInfo.RegionID,
106 client.SceneAgent.AbsolutePosition, client.SceneAgent.Lookat);
107 }
97 } 108 }
98 //m_log.DebugFormat("[ACTIVITY DETECTOR]: Detected client logout {0} in {1}", userId, client.Scene.RegionInfo.RegionName);
99 109
100 m_GridUserService.LoggedOut(
101 userId, client.SessionId, client.Scene.RegionInfo.RegionID,
102 client.SceneAgent.AbsolutePosition, client.SceneAgent.Lookat);
103 } 110 }
104 } 111 }
105} 112}
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
index 11b079f..13485bf 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs
@@ -1994,11 +1994,26 @@ namespace OpenSim.Region.CoreModules.World.Land
1994 // (d) parcels with telehubs can be the home of anyone 1994 // (d) parcels with telehubs can be the home of anyone
1995 (telehub != null && land.ContainsPoint((int)telehub.AbsolutePosition.X, (int)telehub.AbsolutePosition.Y)))) 1995 (telehub != null && land.ContainsPoint((int)telehub.AbsolutePosition.X, (int)telehub.AbsolutePosition.Y))))
1996 { 1996 {
1997 if (m_scene.GridUserService.SetHome(remoteClient.AgentId.ToString(), land.RegionUUID, position, lookAt)) 1997 string userId;
1998 UUID test;
1999 if (!m_scene.UserManagementModule.GetUserUUI(remoteClient.AgentId, out userId))
2000 {
2001 /* Do not set a home position in this grid for a HG visitor */
2002 m_Dialog.SendAlertToUser(remoteClient, "Set Home request failed. (User Lookup)");
2003 }
2004 else if (!UUID.TryParse(userId, out test))
2005 {
2006 m_Dialog.SendAlertToUser(remoteClient, "Set Home request failed. (HG visitor)");
2007 }
2008 else if (m_scene.GridUserService.SetHome(userId, land.RegionUUID, position, lookAt))
2009 {
1998 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 2010 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
1999 m_Dialog.SendAlertToUser(remoteClient, "Home position set."); 2011 m_Dialog.SendAlertToUser(remoteClient, "Home position set.");
2012 }
2000 else 2013 else
2014 {
2001 m_Dialog.SendAlertToUser(remoteClient, "Set Home request failed."); 2015 m_Dialog.SendAlertToUser(remoteClient, "Set Home request failed.");
2016 }
2002 } 2017 }
2003 else 2018 else
2004 m_Dialog.SendAlertToUser(remoteClient, "You are not allowed to set your home location in this parcel."); 2019 m_Dialog.SendAlertToUser(remoteClient, "You are not allowed to set your home location in this parcel.");
diff --git a/OpenSim/Services/Interfaces/IUserManagement.cs b/OpenSim/Services/Interfaces/IUserManagement.cs
index b69a63b..9e560d5 100644
--- a/OpenSim/Services/Interfaces/IUserManagement.cs
+++ b/OpenSim/Services/Interfaces/IUserManagement.cs
@@ -40,6 +40,7 @@ namespace OpenSim.Services.Interfaces
40 string GetUserName(UUID uuid); 40 string GetUserName(UUID uuid);
41 string GetUserHomeURL(UUID uuid); 41 string GetUserHomeURL(UUID uuid);
42 string GetUserUUI(UUID uuid); 42 string GetUserUUI(UUID uuid);
43 bool GetUserUUI(UUID userID, out string uui);
43 string GetUserServerURL(UUID uuid, string serverType); 44 string GetUserServerURL(UUID uuid, string serverType);
44 45
45 /// <summary> 46 /// <summary>