diff options
author | Diva Canto | 2011-06-08 16:01:33 -0700 |
---|---|---|
committer | Diva Canto | 2011-06-08 16:01:33 -0700 |
commit | 80fc607d7536d4f375da4d01280a00fe656654c4 (patch) | |
tree | 0604dc00577818655490304c1bd92041a19a159f /OpenSim/Region/CoreModules | |
parent | Added EventManager.OnPrimsLoaded, an event that modules can hook up onto so t... (diff) | |
download | opensim-SC_OLD-80fc607d7536d4f375da4d01280a00fe656654c4.zip opensim-SC_OLD-80fc607d7536d4f375da4d01280a00fe656654c4.tar.gz opensim-SC_OLD-80fc607d7536d4f375da4d01280a00fe656654c4.tar.bz2 opensim-SC_OLD-80fc607d7536d4f375da4d01280a00fe656654c4.tar.xz |
Fixed "Unknown User" listed as creator/owner on prims created with the Build button by foreign visitors. Added command to the UserManagementModule to list all the known bindings between user UUIDs and their names: show user-names.
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs | 74 |
1 files changed, 66 insertions, 8 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs index 9051194..ae4336c 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs | |||
@@ -30,6 +30,7 @@ using System.IO; | |||
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | 31 | ||
32 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
33 | using OpenSim.Framework.Console; | ||
33 | 34 | ||
34 | using OpenSim.Region.Framework; | 35 | using OpenSim.Region.Framework; |
35 | using OpenSim.Region.Framework.Interfaces; | 36 | using OpenSim.Region.Framework.Interfaces; |
@@ -80,6 +81,14 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
80 | // } | 81 | // } |
81 | // } | 82 | // } |
82 | //} | 83 | //} |
84 | MainConsole.Instance.Commands.AddCommand("grid", true, | ||
85 | "show user-names", | ||
86 | "show user-names", | ||
87 | "Show the bindings between user UUIDs and user names", | ||
88 | String.Empty, | ||
89 | HandleShowUsers); | ||
90 | |||
91 | |||
83 | } | 92 | } |
84 | 93 | ||
85 | public bool IsSharedModule | 94 | public bool IsSharedModule |
@@ -103,6 +112,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
103 | 112 | ||
104 | scene.RegisterModuleInterface<IUserManagement>(this); | 113 | scene.RegisterModuleInterface<IUserManagement>(this); |
105 | scene.EventManager.OnNewClient += new EventManager.OnNewClientDelegate(EventManager_OnNewClient); | 114 | scene.EventManager.OnNewClient += new EventManager.OnNewClientDelegate(EventManager_OnNewClient); |
115 | scene.EventManager.OnPrimsLoaded += new EventManager.PrimsLoaded(EventManager_OnPrimsLoaded); | ||
106 | } | 116 | } |
107 | 117 | ||
108 | public void RemoveRegion(Scene scene) | 118 | public void RemoveRegion(Scene scene) |
@@ -111,18 +121,12 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
111 | m_Scenes.Remove(scene); | 121 | m_Scenes.Remove(scene); |
112 | } | 122 | } |
113 | 123 | ||
114 | public void RegionLoaded(Scene scene) | 124 | public void RegionLoaded(Scene s) |
115 | { | 125 | { |
116 | } | 126 | } |
117 | 127 | ||
118 | public void PostInitialise() | 128 | public void PostInitialise() |
119 | { | 129 | { |
120 | foreach (Scene s in m_Scenes) | ||
121 | { | ||
122 | // let's sniff all the user names referenced by objects in the scene | ||
123 | m_log.DebugFormat("[USER MANAGEMENT MODULE]: Caching creators' data from {0} ({1} objects)...", s.RegionInfo.RegionName, s.GetEntities().Length); | ||
124 | s.ForEachSOG(delegate(SceneObjectGroup sog) { CacheCreators(sog); }); | ||
125 | } | ||
126 | } | 130 | } |
127 | 131 | ||
128 | public void Close() | 132 | public void Close() |
@@ -136,6 +140,14 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
136 | 140 | ||
137 | #region Event Handlers | 141 | #region Event Handlers |
138 | 142 | ||
143 | void EventManager_OnPrimsLoaded(Scene s) | ||
144 | { | ||
145 | // let's sniff all the user names referenced by objects in the scene | ||
146 | m_log.DebugFormat("[USER MANAGEMENT MODULE]: Caching creators' data from {0} ({1} objects)...", s.RegionInfo.RegionName, s.GetEntities().Length); | ||
147 | s.ForEachSOG(delegate(SceneObjectGroup sog) { CacheCreators(sog); }); | ||
148 | } | ||
149 | |||
150 | |||
139 | void EventManager_OnNewClient(IClientAPI client) | 151 | void EventManager_OnNewClient(IClientAPI client) |
140 | { | 152 | { |
141 | client.OnNameFromUUIDRequest += new UUIDNameRequest(HandleUUIDNameRequest); | 153 | client.OnNameFromUUIDRequest += new UUIDNameRequest(HandleUUIDNameRequest); |
@@ -143,7 +155,6 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
143 | 155 | ||
144 | void HandleUUIDNameRequest(UUID uuid, IClientAPI remote_client) | 156 | void HandleUUIDNameRequest(UUID uuid, IClientAPI remote_client) |
145 | { | 157 | { |
146 | //m_log.DebugFormat("[XXX] HandleUUIDNameRequest {0}", uuid); | ||
147 | if (m_Scenes[0].LibraryService != null && (m_Scenes[0].LibraryService.LibraryRootFolder.Owner == uuid)) | 158 | if (m_Scenes[0].LibraryService != null && (m_Scenes[0].LibraryService.LibraryRootFolder.Owner == uuid)) |
148 | { | 159 | { |
149 | remote_client.SendNameReply(uuid, "Mr", "OpenSim"); | 160 | remote_client.SendNameReply(uuid, "Mr", "OpenSim"); |
@@ -153,6 +164,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
153 | string[] names = GetUserNames(uuid); | 164 | string[] names = GetUserNames(uuid); |
154 | if (names.Length == 2) | 165 | if (names.Length == 2) |
155 | { | 166 | { |
167 | //m_log.DebugFormat("[XXX] HandleUUIDNameRequest {0} is {1} {2}", uuid, names[0], names[1]); | ||
156 | remote_client.SendNameReply(uuid, names[0], names[1]); | 168 | remote_client.SendNameReply(uuid, names[0], names[1]); |
157 | } | 169 | } |
158 | 170 | ||
@@ -254,6 +266,32 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
254 | return string.Empty; | 266 | return string.Empty; |
255 | } | 267 | } |
256 | 268 | ||
269 | public string GetUserUUI(UUID userID) | ||
270 | { | ||
271 | UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, userID); | ||
272 | if (account != null) | ||
273 | return userID.ToString(); | ||
274 | |||
275 | if (m_UserCache.ContainsKey(userID)) | ||
276 | { | ||
277 | UserData ud = m_UserCache[userID]; | ||
278 | string homeURL = ud.HomeURL; | ||
279 | string first = ud.FirstName, last = ud.LastName; | ||
280 | if (ud.LastName.StartsWith("@")) | ||
281 | { | ||
282 | string[] parts = ud.FirstName.Split('.'); | ||
283 | if (parts.Length >= 2) | ||
284 | { | ||
285 | first = parts[0]; | ||
286 | last = parts[1]; | ||
287 | } | ||
288 | return userID + ";" + homeURL + ";" + first + " " + last; | ||
289 | } | ||
290 | } | ||
291 | |||
292 | return userID.ToString(); | ||
293 | } | ||
294 | |||
257 | public void AddUser(UUID id, string creatorData) | 295 | public void AddUser(UUID id, string creatorData) |
258 | { | 296 | { |
259 | if (m_UserCache.ContainsKey(id)) | 297 | if (m_UserCache.ContainsKey(id)) |
@@ -343,5 +381,25 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
343 | //} | 381 | //} |
344 | 382 | ||
345 | #endregion IUserManagement | 383 | #endregion IUserManagement |
384 | |||
385 | private void HandleShowUsers(string module, string[] cmd) | ||
386 | { | ||
387 | if (m_UserCache.Count == 0) | ||
388 | { | ||
389 | MainConsole.Instance.Output("No users not found"); | ||
390 | return; | ||
391 | } | ||
392 | |||
393 | MainConsole.Instance.Output("UUID User Name"); | ||
394 | MainConsole.Instance.Output("-----------------------------------------------------------------------------"); | ||
395 | foreach (KeyValuePair<UUID, UserData> kvp in m_UserCache) | ||
396 | { | ||
397 | MainConsole.Instance.Output(String.Format("{0} {1} {2}", | ||
398 | kvp.Key, kvp.Value.FirstName, kvp.Value.LastName)); | ||
399 | } | ||
400 | return; | ||
401 | } | ||
402 | |||
403 | |||
346 | } | 404 | } |
347 | } | 405 | } |