diff options
Diffstat (limited to '')
4 files changed, 101 insertions, 29 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs index a4861ec..b0b35e4 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs | |||
@@ -186,7 +186,6 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
186 | } | 186 | } |
187 | } | 187 | } |
188 | 188 | ||
189 | |||
190 | private string[] GetUserNames(UUID uuid) | 189 | private string[] GetUserNames(UUID uuid) |
191 | { | 190 | { |
192 | string[] returnstring = new string[2]; | 191 | string[] returnstring = new string[2]; |
@@ -292,6 +291,25 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
292 | return userID.ToString(); | 291 | return userID.ToString(); |
293 | } | 292 | } |
294 | 293 | ||
294 | public void AddUser(UUID uuid, string first, string last) | ||
295 | { | ||
296 | if (m_UserCache.ContainsKey(uuid)) | ||
297 | return; | ||
298 | |||
299 | UserData user = new UserData(); | ||
300 | user.Id = uuid; | ||
301 | user.FirstName = first; | ||
302 | user.LastName = last; | ||
303 | // user.ProfileURL = we should initialize this to the default | ||
304 | |||
305 | AddUserInternal(user); | ||
306 | } | ||
307 | |||
308 | public void AddUser(UUID uuid, string first, string last, string profileURL) | ||
309 | { | ||
310 | AddUser(uuid, profileURL + ";" + first + " " + last); | ||
311 | } | ||
312 | |||
295 | public void AddUser(UUID id, string creatorData) | 313 | public void AddUser(UUID id, string creatorData) |
296 | { | 314 | { |
297 | if (m_UserCache.ContainsKey(id)) | 315 | if (m_UserCache.ContainsKey(id)) |
@@ -299,18 +317,17 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
299 | 317 | ||
300 | // m_log.DebugFormat("[USER MANAGEMENT MODULE]: Adding user with id {0}, craetorData {1}", id, creatorData); | 318 | // m_log.DebugFormat("[USER MANAGEMENT MODULE]: Adding user with id {0}, craetorData {1}", id, creatorData); |
301 | 319 | ||
302 | UserData user = new UserData(); | ||
303 | user.Id = id; | ||
304 | UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, id); | 320 | UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, id); |
305 | 321 | ||
306 | if (account != null) | 322 | if (account != null) |
307 | { | 323 | { |
308 | user.FirstName = account.FirstName; | 324 | AddUser(id, account.FirstName, account.LastName); |
309 | user.LastName = account.LastName; | ||
310 | // user.ProfileURL = we should initialize this to the default | ||
311 | } | 325 | } |
312 | else | 326 | else |
313 | { | 327 | { |
328 | UserData user = new UserData(); | ||
329 | user.Id = id; | ||
330 | |||
314 | if (creatorData != null && creatorData != string.Empty) | 331 | if (creatorData != null && creatorData != string.Empty) |
315 | { | 332 | { |
316 | //creatorData = <endpoint>;<name> | 333 | //creatorData = <endpoint>;<name> |
@@ -338,17 +355,19 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
338 | user.FirstName = "Unknown"; | 355 | user.FirstName = "Unknown"; |
339 | user.LastName = "User"; | 356 | user.LastName = "User"; |
340 | } | 357 | } |
341 | } | ||
342 | 358 | ||
343 | lock (m_UserCache) | 359 | AddUserInternal(user); |
344 | m_UserCache[id] = user; | 360 | } |
345 | |||
346 | m_log.DebugFormat("[USER MANAGEMENT MODULE]: Added user {0} {1} {2} {3}", user.Id, user.FirstName, user.LastName, user.HomeURL); | ||
347 | } | 361 | } |
348 | 362 | ||
349 | public void AddUser(UUID uuid, string first, string last, string profileURL) | 363 | void AddUserInternal(UserData user) |
350 | { | 364 | { |
351 | AddUser(uuid, profileURL + ";" + first + " " + last); | 365 | lock (m_UserCache) |
366 | m_UserCache[user.Id] = user; | ||
367 | |||
368 | m_log.DebugFormat( | ||
369 | "[USER MANAGEMENT MODULE]: Added user {0} {1} {2} {3}", | ||
370 | user.Id, user.FirstName, user.LastName, user.HomeURL); | ||
352 | } | 371 | } |
353 | 372 | ||
354 | //public void AddUser(UUID uuid, string userData) | 373 | //public void AddUser(UUID uuid, string userData) |
diff --git a/OpenSim/Region/Framework/Interfaces/IUserManagement.cs b/OpenSim/Region/Framework/Interfaces/IUserManagement.cs index 5d30aa8..c66e053 100644 --- a/OpenSim/Region/Framework/Interfaces/IUserManagement.cs +++ b/OpenSim/Region/Framework/Interfaces/IUserManagement.cs | |||
@@ -5,13 +5,48 @@ using OpenMetaverse; | |||
5 | 5 | ||
6 | namespace OpenSim.Region.Framework.Interfaces | 6 | namespace OpenSim.Region.Framework.Interfaces |
7 | { | 7 | { |
8 | /// <summary> | ||
9 | /// This maintains the relationship between a UUID and a user name. | ||
10 | /// </summary> | ||
8 | public interface IUserManagement | 11 | public interface IUserManagement |
9 | { | 12 | { |
10 | string GetUserName(UUID uuid); | 13 | string GetUserName(UUID uuid); |
11 | string GetUserHomeURL(UUID uuid); | 14 | string GetUserHomeURL(UUID uuid); |
12 | string GetUserUUI(UUID uuid); | 15 | string GetUserUUI(UUID uuid); |
13 | string GetUserServerURL(UUID uuid, string serverType); | 16 | string GetUserServerURL(UUID uuid, string serverType); |
14 | void AddUser(UUID uuid, string userData); | 17 | |
18 | /// <summary> | ||
19 | /// Add a user. | ||
20 | /// </summary> | ||
21 | /// <remarks> | ||
22 | /// If an account is found for the UUID, then the names in this will be used rather than any information | ||
23 | /// extracted from creatorData. | ||
24 | /// </remarks> | ||
25 | /// <param name="uuid"></param> | ||
26 | /// <param name="creatorData">The creator data for this user.</param> | ||
27 | void AddUser(UUID uuid, string creatorData); | ||
28 | |||
29 | /// <summary> | ||
30 | /// Add a user. | ||
31 | /// </summary> | ||
32 | /// <remarks> | ||
33 | /// The UUID is related to the name without any other checks being performed, such as user account presence. | ||
34 | /// </remarks> | ||
35 | /// <param name="uuid"></param> | ||
36 | /// <param name="firstName"></param> | ||
37 | /// <param name="lastName"></param> | ||
38 | void AddUser(UUID uuid, string firstName, string lastName); | ||
39 | |||
40 | /// <summary> | ||
41 | /// Add a user. | ||
42 | /// </summary> | ||
43 | /// <remarks> | ||
44 | /// The arguments apart from uuid are formed into a creatorData string and processing proceeds as for the | ||
45 | /// AddUser(UUID uuid, string creatorData) method. | ||
46 | /// </remarks> | ||
47 | /// <param name="uuid"></param> | ||
48 | /// <param name="firstName"></param> | ||
49 | /// <param name="profileURL"></param> | ||
15 | void AddUser(UUID uuid, string firstName, string lastName, string profileURL); | 50 | void AddUser(UUID uuid, string firstName, string lastName, string profileURL); |
16 | } | 51 | } |
17 | } | 52 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index ae88a87..513c0ea 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -2582,12 +2582,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2582 | } | 2582 | } |
2583 | } | 2583 | } |
2584 | 2584 | ||
2585 | if (GetScenePresence(client.AgentId) != null) | 2585 | ScenePresence createdSp = GetScenePresence(client.AgentId); |
2586 | if (createdSp != null) | ||
2586 | { | 2587 | { |
2587 | m_LastLogin = Util.EnvironmentTickCount(); | 2588 | m_LastLogin = Util.EnvironmentTickCount(); |
2588 | 2589 | ||
2589 | // Cache the user's name | 2590 | // Cache the user's name |
2590 | CacheUserName(aCircuit); | 2591 | CacheUserName(createdSp, aCircuit); |
2591 | 2592 | ||
2592 | EventManager.TriggerOnNewClient(client); | 2593 | EventManager.TriggerOnNewClient(client); |
2593 | if (vialogin) | 2594 | if (vialogin) |
@@ -2595,28 +2596,41 @@ namespace OpenSim.Region.Framework.Scenes | |||
2595 | } | 2596 | } |
2596 | } | 2597 | } |
2597 | 2598 | ||
2598 | private void CacheUserName(AgentCircuitData aCircuit) | 2599 | /// <summary> |
2600 | /// Cache the user name for later use. | ||
2601 | /// </summary> | ||
2602 | /// <param name="sp"></param> | ||
2603 | /// <param name="aCircuit"></param> | ||
2604 | private void CacheUserName(ScenePresence sp, AgentCircuitData aCircuit) | ||
2599 | { | 2605 | { |
2600 | IUserManagement uMan = RequestModuleInterface<IUserManagement>(); | 2606 | IUserManagement uMan = RequestModuleInterface<IUserManagement>(); |
2601 | if (uMan != null) | 2607 | if (uMan != null) |
2602 | { | 2608 | { |
2603 | string homeURL = string.Empty; | ||
2604 | string first = aCircuit.firstname, last = aCircuit.lastname; | 2609 | string first = aCircuit.firstname, last = aCircuit.lastname; |
2605 | 2610 | ||
2606 | if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) | 2611 | if (sp.PresenceType == PresenceType.Npc) |
2607 | homeURL = aCircuit.ServiceURLs["HomeURI"].ToString(); | 2612 | { |
2608 | 2613 | uMan.AddUser(aCircuit.AgentID, first, last); | |
2609 | if (aCircuit.lastname.StartsWith("@")) | 2614 | } |
2615 | else | ||
2610 | { | 2616 | { |
2611 | string[] parts = aCircuit.firstname.Split('.'); | 2617 | string homeURL = string.Empty; |
2612 | if (parts.Length >= 2) | 2618 | |
2619 | if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) | ||
2620 | homeURL = aCircuit.ServiceURLs["HomeURI"].ToString(); | ||
2621 | |||
2622 | if (aCircuit.lastname.StartsWith("@")) | ||
2613 | { | 2623 | { |
2614 | first = parts[0]; | 2624 | string[] parts = aCircuit.firstname.Split('.'); |
2615 | last = parts[1]; | 2625 | if (parts.Length >= 2) |
2626 | { | ||
2627 | first = parts[0]; | ||
2628 | last = parts[1]; | ||
2629 | } | ||
2616 | } | 2630 | } |
2617 | } | ||
2618 | 2631 | ||
2619 | uMan.AddUser(aCircuit.AgentID, first, last, homeURL); | 2632 | uMan.AddUser(aCircuit.AgentID, first, last, homeURL); |
2633 | } | ||
2620 | } | 2634 | } |
2621 | } | 2635 | } |
2622 | 2636 | ||
diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index f8afc5a..78296a4 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs | |||
@@ -34,6 +34,7 @@ using OpenMetaverse; | |||
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using OpenSim.Framework.Communications; | 35 | using OpenSim.Framework.Communications; |
36 | using OpenSim.Region.CoreModules.Avatar.AvatarFactory; | 36 | using OpenSim.Region.CoreModules.Avatar.AvatarFactory; |
37 | using OpenSim.Region.CoreModules.Framework.UserManagement; | ||
37 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar; | 38 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar; |
38 | using OpenSim.Region.Framework.Interfaces; | 39 | using OpenSim.Region.Framework.Interfaces; |
39 | using OpenSim.Region.Framework.Scenes; | 40 | using OpenSim.Region.Framework.Scenes; |
@@ -57,8 +58,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
57 | config.Configs["NPC"].Set("Enabled", "true"); | 58 | config.Configs["NPC"].Set("Enabled", "true"); |
58 | 59 | ||
59 | AvatarFactoryModule afm = new AvatarFactoryModule(); | 60 | AvatarFactoryModule afm = new AvatarFactoryModule(); |
61 | UserManagementModule umm = new UserManagementModule(); | ||
62 | |||
60 | TestScene scene = SceneHelpers.SetupScene(); | 63 | TestScene scene = SceneHelpers.SetupScene(); |
61 | SceneHelpers.SetupSceneModules(scene, config, afm, new NPCModule()); | 64 | SceneHelpers.SetupSceneModules(scene, config, afm, umm, new NPCModule()); |
62 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); | 65 | ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); |
63 | // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); | 66 | // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); |
64 | 67 | ||
@@ -81,6 +84,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
81 | 84 | ||
82 | Assert.That(npc, Is.Not.Null); | 85 | Assert.That(npc, Is.Not.Null); |
83 | Assert.That(npc.Appearance.Texture.FaceTextures[8].TextureID, Is.EqualTo(originalFace8TextureId)); | 86 | Assert.That(npc.Appearance.Texture.FaceTextures[8].TextureID, Is.EqualTo(originalFace8TextureId)); |
87 | Assert.That(umm.GetUserName(npc.UUID), Is.EqualTo(string.Format("{0} {1}", npc.Firstname, npc.Lastname))); | ||
84 | } | 88 | } |
85 | 89 | ||
86 | [Test] | 90 | [Test] |