aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Framework
diff options
context:
space:
mode:
authorJonathan Freedman2010-11-21 20:01:48 -0800
committerJonathan Freedman2010-11-21 20:01:48 -0800
commitb7f5e8284360f92e0e102b9546076573c57d9397 (patch)
tree132663da8c1882e524241b55a739ef2758ef8958 /OpenSim/Region/CoreModules/Framework
parentMerge https://github.com/opensim/opensim into mantis5110 (diff)
parentMerge branch 'master' of /var/git/opensim/ (diff)
downloadopensim-SC_OLD-b7f5e8284360f92e0e102b9546076573c57d9397.zip
opensim-SC_OLD-b7f5e8284360f92e0e102b9546076573c57d9397.tar.gz
opensim-SC_OLD-b7f5e8284360f92e0e102b9546076573c57d9397.tar.bz2
opensim-SC_OLD-b7f5e8284360f92e0e102b9546076573c57d9397.tar.xz
Merge branch 'master-core' into mantis5110
Diffstat (limited to 'OpenSim/Region/CoreModules/Framework')
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs9
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs19
-rw-r--r--OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs310
3 files changed, 331 insertions, 7 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index 9ba144d..56aefa5 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -1200,11 +1200,16 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1200 } 1200 }
1201 1201
1202 m_log.Debug("[ENTITY TRANSFER MODULE]: Completed inform client about neighbour " + endPoint.ToString()); 1202 m_log.Debug("[ENTITY TRANSFER MODULE]: Completed inform client about neighbour " + endPoint.ToString());
1203
1204 } 1203 }
1205
1206 } 1204 }
1207 1205
1206 /// <summary>
1207 /// Return the list of regions that are considered to be neighbours to the given scene.
1208 /// </summary>
1209 /// <param name="pScene"></param>
1210 /// <param name="pRegionLocX"></param>
1211 /// <param name="pRegionLocY"></param>
1212 /// <returns></returns>
1208 protected List<GridRegion> RequestNeighbours(Scene pScene, uint pRegionLocX, uint pRegionLocY) 1213 protected List<GridRegion> RequestNeighbours(Scene pScene, uint pRegionLocX, uint pRegionLocY)
1209 { 1214 {
1210 RegionInfo m_regionInfo = pScene.RegionInfo; 1215 RegionInfo m_regionInfo = pScene.RegionInfo;
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
index 7a175ea..67732ff 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
@@ -370,6 +370,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
370 370
371 item = new InventoryItemBase(); 371 item = new InventoryItemBase();
372 item.CreatorId = objectGroup.RootPart.CreatorID.ToString(); 372 item.CreatorId = objectGroup.RootPart.CreatorID.ToString();
373 item.CreatorData = objectGroup.RootPart.CreatorData;
373 item.ID = UUID.Random(); 374 item.ID = UUID.Random();
374 item.InvType = (int)InventoryType.Object; 375 item.InvType = (int)InventoryType.Object;
375 item.Folder = folder.ID; 376 item.Folder = folder.ID;
@@ -569,12 +570,20 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
569 { 570 {
570 group.RootPart.Flags |= PrimFlags.Phantom; 571 group.RootPart.Flags |= PrimFlags.Phantom;
571 group.RootPart.IsAttachment = true; 572 group.RootPart.IsAttachment = true;
572 }
573 573
574 // If we're rezzing an attachment then don't ask AddNewSceneObject() to update the client since 574 // If we're rezzing an attachment then don't ask
575 // we'll be doing that later on. Scheduling more than one full update during the attachment 575 // AddNewSceneObject() to update the client since
576 // process causes some clients to fail to display the attachment properly. 576 // we'll be doing that later on. Scheduling more
577 m_Scene.AddNewSceneObject(group, true, false); 577 // than one full update during the attachment
578 // process causes some clients to fail to display
579 // the attachment properly.
580 // Also, don't persist attachments.
581 m_Scene.AddNewSceneObject(group, false, false);
582 }
583 else
584 {
585 m_Scene.AddNewSceneObject(group, true, false);
586 }
578 587
579 // m_log.InfoFormat("ray end point for inventory rezz is {0} {1} {2} ", RayEnd.X, RayEnd.Y, RayEnd.Z); 588 // m_log.InfoFormat("ray end point for inventory rezz is {0} {1} {2} ", RayEnd.X, RayEnd.Y, RayEnd.Z);
580 // if attachment we set it's asset id so object updates can reflect that 589 // if attachment we set it's asset id so object updates can reflect that
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
new file mode 100644
index 0000000..0d94baa
--- /dev/null
+++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
@@ -0,0 +1,310 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27using System;
28using System.Collections.Generic;
29using System.IO;
30using System.Reflection;
31
32using OpenSim.Framework;
33
34using OpenSim.Region.Framework;
35using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes;
37using OpenSim.Services.Interfaces;
38
39using OpenMetaverse;
40using log4net;
41using Nini.Config;
42
43namespace OpenSim.Region.CoreModules.Framework.UserManagement
44{
45 struct UserData
46 {
47 public UUID Id;
48 public string FirstName;
49 public string LastName;
50 public string ProfileURL;
51 }
52
53 public class UserManagementModule : ISharedRegionModule, IUserManagement
54 {
55 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
56
57 private List<Scene> m_Scenes = new List<Scene>();
58
59 // The cache
60 Dictionary<UUID, UserData> m_UserCache = new Dictionary<UUID, UserData>();
61
62 #region ISharedRegionModule
63
64 public void Initialise(IConfigSource config)
65 {
66 //m_Enabled = config.Configs["Modules"].GetBoolean("LibraryModule", m_Enabled);
67 //if (m_Enabled)
68 //{
69 // IConfig libConfig = config.Configs["LibraryService"];
70 // if (libConfig != null)
71 // {
72 // string dllName = libConfig.GetString("LocalServiceModule", string.Empty);
73 // m_log.Debug("[LIBRARY MODULE]: Library service dll is " + dllName);
74 // if (dllName != string.Empty)
75 // {
76 // Object[] args = new Object[] { config };
77 // m_Library = ServerUtils.LoadPlugin<ILibraryService>(dllName, args);
78 // }
79 // }
80 //}
81 }
82
83 public bool IsSharedModule
84 {
85 get { return true; }
86 }
87
88 public string Name
89 {
90 get { return "UserManagement Module"; }
91 }
92
93 public Type ReplaceableInterface
94 {
95 get { return null; }
96 }
97
98 public void AddRegion(Scene scene)
99 {
100 m_Scenes.Add(scene);
101
102 scene.RegisterModuleInterface<IUserManagement>(this);
103 scene.EventManager.OnNewClient += new EventManager.OnNewClientDelegate(EventManager_OnNewClient);
104 }
105
106 public void RemoveRegion(Scene scene)
107 {
108 scene.UnregisterModuleInterface<IUserManagement>(this);
109 m_Scenes.Remove(scene);
110 }
111
112 public void RegionLoaded(Scene scene)
113 {
114 }
115
116 public void PostInitialise()
117 {
118 foreach (Scene s in m_Scenes)
119 {
120 // let's sniff all the user names referenced by objects in the scene
121 m_log.DebugFormat("[USER MANAGEMENT MODULE]: Caching creators' data from {0} ({1} objects)...", s.RegionInfo.RegionName, s.GetEntities().Length);
122 s.ForEachSOG(delegate(SceneObjectGroup sog) { CacheCreators(sog); });
123 }
124 }
125
126 public void Close()
127 {
128 m_Scenes.Clear();
129 m_UserCache.Clear();
130 }
131
132 #endregion ISharedRegionModule
133
134
135 #region Event Handlers
136
137 void EventManager_OnNewClient(IClientAPI client)
138 {
139 client.OnNameFromUUIDRequest += new UUIDNameRequest(HandleUUIDNameRequest);
140 }
141
142 void HandleUUIDNameRequest(UUID uuid, IClientAPI remote_client)
143 {
144 if (m_Scenes[0].LibraryService != null && (m_Scenes[0].LibraryService.LibraryRootFolder.Owner == uuid))
145 {
146 remote_client.SendNameReply(uuid, "Mr", "OpenSim");
147 }
148 else
149 {
150 string[] names = GetUserNames(uuid);
151 if (names.Length == 2)
152 {
153 remote_client.SendNameReply(uuid, names[0], names[1]);
154 }
155
156 }
157 }
158
159 #endregion Event Handlers
160
161 private void CacheCreators(SceneObjectGroup sog)
162 {
163 //m_log.DebugFormat("[USER MANAGEMENT MODULE]: processing {0} {1}; {2}", sog.RootPart.Name, sog.RootPart.CreatorData, sog.RootPart.CreatorIdentification);
164 AddUser(sog.RootPart.CreatorID, sog.RootPart.CreatorData);
165
166 foreach (SceneObjectPart sop in sog.Parts)
167 {
168 AddUser(sop.CreatorID, sop.CreatorData);
169 foreach (TaskInventoryItem item in sop.TaskInventory.Values)
170 AddUser(item.CreatorID, item.CreatorData);
171 }
172 }
173
174
175 private string[] GetUserNames(UUID uuid)
176 {
177 string[] returnstring = new string[2];
178
179 if (m_UserCache.ContainsKey(uuid))
180 {
181 returnstring[0] = m_UserCache[uuid].FirstName;
182 returnstring[1] = m_UserCache[uuid].LastName;
183 return returnstring;
184 }
185
186 UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, uuid);
187
188 if (account != null)
189 {
190 returnstring[0] = account.FirstName;
191 returnstring[1] = account.LastName;
192
193 UserData user = new UserData();
194 user.FirstName = account.FirstName;
195 user.LastName = account.LastName;
196
197 lock (m_UserCache)
198 m_UserCache[uuid] = user;
199 }
200 else
201 {
202 returnstring[0] = "Unknown";
203 returnstring[1] = "User";
204 }
205
206 return returnstring;
207 }
208
209 #region IUserManagement
210
211 public string GetUserName(UUID uuid)
212 {
213 string[] names = GetUserNames(uuid);
214 if (names.Length == 2)
215 {
216 string firstname = names[0];
217 string lastname = names[1];
218
219 return firstname + " " + lastname;
220
221 }
222 return "(hippos)";
223 }
224
225 public void AddUser(UUID id, string creatorData)
226 {
227 if (m_UserCache.ContainsKey(id))
228 return;
229
230 UserData user = new UserData();
231 user.Id = id;
232
233 UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(m_Scenes[0].RegionInfo.ScopeID, id);
234
235 if (account != null)
236 {
237 user.FirstName = account.FirstName;
238 user.LastName = account.LastName;
239 // user.ProfileURL = we should initialize this to the default
240 }
241 else
242 {
243 if (creatorData != null && creatorData != string.Empty)
244 {
245 //creatorData = <endpoint>;<name>
246
247 string[] parts = creatorData.Split(';');
248 if (parts.Length >= 1)
249 {
250 user.ProfileURL = parts[0];
251 try
252 {
253 Uri uri = new Uri(parts[0]);
254 user.LastName = "@" + uri.Authority;
255 }
256 catch
257 {
258 m_log.DebugFormat("[SCENE]: Unable to parse Uri {0}", parts[0]);
259 user.LastName = "@unknown";
260 }
261 }
262 if (parts.Length >= 2)
263 user.FirstName = parts[1].Replace(' ', '.');
264 }
265 else
266 {
267 user.FirstName = "Unknown";
268 user.LastName = "User";
269 }
270 }
271
272 lock (m_UserCache)
273 m_UserCache[id] = user;
274
275 m_log.DebugFormat("[USER MANAGEMENT MODULE]: Added user {0} {1} {2} {3}", user.Id, user.FirstName, user.LastName, user.ProfileURL);
276 }
277
278 //public void AddUser(UUID uuid, string userData)
279 //{
280 // if (m_UserCache.ContainsKey(uuid))
281 // return;
282
283 // UserData user = new UserData();
284 // user.Id = uuid;
285
286 // // userData = <profile url>;<name>
287 // string[] parts = userData.Split(';');
288 // if (parts.Length >= 1)
289 // user.ProfileURL = parts[0].Trim();
290 // if (parts.Length >= 2)
291 // {
292 // string[] name = parts[1].Trim().Split(' ');
293 // if (name.Length >= 1)
294 // user.FirstName = name[0];
295 // if (name.Length >= 2)
296 // user.LastName = name[1];
297 // else
298 // user.LastName = "?";
299 // }
300
301 // lock (m_UserCache)
302 // m_UserCache.Add(uuid, user);
303
304 // m_log.DebugFormat("[USER MANAGEMENT MODULE]: Added user {0} {1} {2} {3}", user.Id, user.FirstName, user.LastName, user.ProfileURL);
305
306 //}
307
308 #endregion IUserManagement
309 }
310}