aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorBo Iwu2012-01-12 17:43:20 +0100
committerMelanie2012-01-12 17:51:13 +0000
commit6214e6a217cfe206e127739b141bdcceb253c98d (patch)
tree5cf6964b7775d44e29c28fffe7d5aa6a05ff8341
parentHG: normalize all externalized user ULRs to be the Home URL, i.e. the locatio... (diff)
downloadopensim-SC_OLD-6214e6a217cfe206e127739b141bdcceb253c98d.zip
opensim-SC_OLD-6214e6a217cfe206e127739b141bdcceb253c98d.tar.gz
opensim-SC_OLD-6214e6a217cfe206e127739b141bdcceb253c98d.tar.bz2
opensim-SC_OLD-6214e6a217cfe206e127739b141bdcceb253c98d.tar.xz
Allow update of stored entries within User Management Module-this is needed for proper work of HG friends.
See http://opensimulator.org/mantis/view.php?id=5847
-rw-r--r--OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs100
1 files changed, 52 insertions, 48 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
index 37292d6..2ad30a0 100644
--- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
@@ -423,58 +423,62 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
423 AddUser(uuid, profileURL + ";" + first + " " + last); 423 AddUser(uuid, profileURL + ";" + first + " " + last);
424 } 424 }
425 425
426 public void AddUser(UUID id, string creatorData) 426 public void AddUser (UUID id, string creatorData)
427 { 427 {
428 lock (m_UserCache) 428 UserData oldUser;
429 { 429 //lock the whole block - prevent concurrent update
430 if (m_UserCache.ContainsKey(id)) 430 lock (m_UserCache) {
431 return; 431 m_UserCache.TryGetValue (id, out oldUser);
432 } 432 if (oldUser != null) {
433 433 if (creatorData == null || creatorData == String.Empty) {
434// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Adding user with id {0}, craetorData {1}", id, creatorData); 434 //ignore updates without creator data
435 435 return;
436 UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, id); 436 }
437 437 //try update unknown users
438 if (account != null) 438 //and creator's home URL's
439 { 439 if ((oldUser.FirstName == "Unknown" && !creatorData.Contains ("Unknown")) || (oldUser.HomeURL != null && !creatorData.StartsWith (oldUser.HomeURL))) {
440 AddUser(id, account.FirstName, account.LastName); 440 m_UserCache.Remove (id);
441 } 441// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Re-adding user with id {0}, creatorData [{1}] and old HomeURL {2}", id, creatorData,oldUser.HomeURL);
442 else 442 } else {
443 { 443 //we have already a valid user within the cache
444 UserData user = new UserData(); 444 return;
445 user.Id = id;
446 user.Flags = -1;
447 user.Created = -1;
448
449 if (creatorData != null && creatorData != string.Empty)
450 {
451 //creatorData = <endpoint>;<name>
452
453 string[] parts = creatorData.Split(';');
454 if (parts.Length >= 1)
455 {
456 user.HomeURL = parts[0];
457 try
458 {
459 Uri uri = new Uri(parts[0]);
460 user.LastName = "@" + uri.Authority;
461 }
462 catch (UriFormatException)
463 {
464 m_log.DebugFormat("[SCENE]: Unable to parse Uri {0}", parts[0]);
465 user.LastName = "@unknown";
466 }
467 } 445 }
468 if (parts.Length >= 2)
469 user.FirstName = parts[1].Replace(' ', '.');
470 } 446 }
471 else 447// m_log.DebugFormat("[USER MANAGEMENT MODULE]: Adding user with id {0}, creatorData {1}", id, creatorData);
472 { 448
473 user.FirstName = "Unknown"; 449 UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount (m_Scenes[0].RegionInfo.ScopeID, id);
474 user.LastName = "User"; 450
451 if (account != null) {
452 AddUser (id, account.FirstName, account.LastName);
453 } else {
454 UserData user = new UserData ();
455 user.Id = id;
456 user.Flags = -1;
457 user.Created = -1;
458
459 if (creatorData != null && creatorData != string.Empty) {
460 //creatorData = <endpoint>;<name>
461
462 string[] parts = creatorData.Split (';');
463 if (parts.Length >= 1) {
464 user.HomeURL = parts[0];
465 try {
466 Uri uri = new Uri (parts[0]);
467 user.LastName = "@" + uri.Authority;
468 } catch (UriFormatException) {
469 m_log.DebugFormat ("[SCENE]: Unable to parse Uri {0}", parts[0]);
470 user.LastName = "@unknown";
471 }
472 }
473 if (parts.Length >= 2)
474 user.FirstName = parts[1].Replace (' ', '.');
475 } else {
476 user.FirstName = "Unknown";
477 user.LastName = "User";
478 }
479
480 AddUserInternal (user);
475 } 481 }
476
477 AddUserInternal(user);
478 } 482 }
479 } 483 }
480 484