diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs | 224 |
1 files changed, 6 insertions, 218 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index b16c37a..3010b59 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs | |||
@@ -54,59 +54,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
54 | 54 | ||
55 | private GatekeeperServiceConnector m_GatekeeperConnector; | 55 | private GatekeeperServiceConnector m_GatekeeperConnector; |
56 | 56 | ||
57 | protected bool m_RestrictAppearanceAbroad; | ||
58 | protected string m_AccountName; | ||
59 | protected List<AvatarAppearance> m_ExportedAppearances; | ||
60 | protected List<AvatarAttachment> m_Attachs; | ||
61 | |||
62 | protected List<AvatarAppearance> ExportedAppearance | ||
63 | { | ||
64 | get | ||
65 | { | ||
66 | if (m_ExportedAppearances != null) | ||
67 | return m_ExportedAppearances; | ||
68 | |||
69 | m_ExportedAppearances = new List<AvatarAppearance>(); | ||
70 | m_Attachs = new List<AvatarAttachment>(); | ||
71 | |||
72 | string[] names = m_AccountName.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); | ||
73 | |||
74 | foreach (string name in names) | ||
75 | { | ||
76 | string[] parts = name.Trim().Split(); | ||
77 | if (parts.Length != 2) | ||
78 | { | ||
79 | m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: Wrong user account name format {0}. Specify 'First Last'", name); | ||
80 | return null; | ||
81 | } | ||
82 | UserAccount account = Scene.UserAccountService.GetUserAccount(UUID.Zero, parts[0], parts[1]); | ||
83 | if (account == null) | ||
84 | { | ||
85 | m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: Unknown account {0}", m_AccountName); | ||
86 | return null; | ||
87 | } | ||
88 | AvatarAppearance a = Scene.AvatarService.GetAppearance(account.PrincipalID); | ||
89 | if (a != null) | ||
90 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Successfully retrieved appearance for {0}", name); | ||
91 | |||
92 | foreach (AvatarAttachment att in a.GetAttachments()) | ||
93 | { | ||
94 | InventoryItemBase item = new InventoryItemBase(att.ItemID, account.PrincipalID); | ||
95 | item = Scene.InventoryService.GetItem(item); | ||
96 | if (item != null) | ||
97 | a.SetAttachment(att.AttachPoint, att.ItemID, item.AssetID); | ||
98 | else | ||
99 | m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: Unable to retrieve item {0} from inventory {1}", att.ItemID, name); | ||
100 | } | ||
101 | |||
102 | m_ExportedAppearances.Add(a); | ||
103 | m_Attachs.AddRange(a.GetAttachments()); | ||
104 | } | ||
105 | |||
106 | return m_ExportedAppearances; | ||
107 | } | ||
108 | } | ||
109 | |||
110 | #region ISharedRegionModule | 57 | #region ISharedRegionModule |
111 | 58 | ||
112 | public override string Name | 59 | public override string Name |
@@ -125,18 +72,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
125 | { | 72 | { |
126 | IConfig transferConfig = source.Configs["EntityTransfer"]; | 73 | IConfig transferConfig = source.Configs["EntityTransfer"]; |
127 | if (transferConfig != null) | 74 | if (transferConfig != null) |
128 | { | ||
129 | m_levelHGTeleport = transferConfig.GetInt("LevelHGTeleport", 0); | 75 | m_levelHGTeleport = transferConfig.GetInt("LevelHGTeleport", 0); |
130 | 76 | ||
131 | m_RestrictAppearanceAbroad = transferConfig.GetBoolean("RestrictAppearanceAbroad", false); | ||
132 | if (m_RestrictAppearanceAbroad) | ||
133 | { | ||
134 | m_AccountName = transferConfig.GetString("AccountForAppearance", string.Empty); | ||
135 | if (m_AccountName == string.Empty) | ||
136 | m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: RestrictAppearanceAbroad is on, but no account has been given for avatar appearance!"); | ||
137 | } | ||
138 | } | ||
139 | |||
140 | InitialiseCommon(source); | 77 | InitialiseCommon(source); |
141 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: {0} enabled.", Name); | 78 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: {0} enabled.", Name); |
142 | } | 79 | } |
@@ -148,36 +85,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
148 | base.AddRegion(scene); | 85 | base.AddRegion(scene); |
149 | 86 | ||
150 | if (m_Enabled) | 87 | if (m_Enabled) |
151 | { | ||
152 | scene.RegisterModuleInterface<IUserAgentVerificationModule>(this); | 88 | scene.RegisterModuleInterface<IUserAgentVerificationModule>(this); |
153 | scene.EventManager.OnIncomingSceneObject += OnIncomingSceneObject; | ||
154 | } | ||
155 | } | ||
156 | |||
157 | void OnIncomingSceneObject(SceneObjectGroup so) | ||
158 | { | ||
159 | if (!so.IsAttachment) | ||
160 | return; | ||
161 | |||
162 | if (so.Scene.UserManagementModule.IsLocalGridUser(so.AttachedAvatar)) | ||
163 | return; | ||
164 | |||
165 | // foreign user | ||
166 | AgentCircuitData aCircuit = so.Scene.AuthenticateHandler.GetAgentCircuitData(so.AttachedAvatar); | ||
167 | if (aCircuit != null && (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0) | ||
168 | { | ||
169 | if (aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("AssetServerURI")) | ||
170 | { | ||
171 | string url = aCircuit.ServiceURLs["AssetServerURI"].ToString(); | ||
172 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Incoming attachement {0} for HG user {1} with asset server {2}", so.Name, so.AttachedAvatar, url); | ||
173 | Dictionary<UUID, AssetType> ids = new Dictionary<UUID, AssetType>(); | ||
174 | HGUuidGatherer uuidGatherer = new HGUuidGatherer(so.Scene.AssetService, url); | ||
175 | uuidGatherer.GatherAssetUuids(so, ids); | ||
176 | |||
177 | foreach (KeyValuePair<UUID, AssetType> kvp in ids) | ||
178 | uuidGatherer.FetchAsset(kvp.Key); | ||
179 | } | ||
180 | } | ||
181 | } | 89 | } |
182 | 90 | ||
183 | protected override void OnNewClient(IClientAPI client) | 91 | protected override void OnNewClient(IClientAPI client) |
@@ -212,7 +120,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
212 | int flags = Scene.GridService.GetRegionFlags(Scene.RegionInfo.ScopeID, region.RegionID); | 120 | int flags = Scene.GridService.GetRegionFlags(Scene.RegionInfo.ScopeID, region.RegionID); |
213 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: region {0} flags: {1}", region.RegionID, flags); | 121 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: region {0} flags: {1}", region.RegionID, flags); |
214 | 122 | ||
215 | if ((flags & (int)OpenSim.Framework.RegionFlags.Hyperlink) != 0) | 123 | if ((flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) |
216 | { | 124 | { |
217 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Destination region {0} is hyperlink", region.RegionID); | 125 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Destination region {0} is hyperlink", region.RegionID); |
218 | GridRegion real_destination = m_GatekeeperConnector.GetHyperlinkRegion(region, region.RegionID); | 126 | GridRegion real_destination = m_GatekeeperConnector.GetHyperlinkRegion(region, region.RegionID); |
@@ -232,7 +140,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
232 | return true; | 140 | return true; |
233 | 141 | ||
234 | int flags = Scene.GridService.GetRegionFlags(Scene.RegionInfo.ScopeID, reg.RegionID); | 142 | int flags = Scene.GridService.GetRegionFlags(Scene.RegionInfo.ScopeID, reg.RegionID); |
235 | if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Framework.RegionFlags.Hyperlink) != 0) | 143 | if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) |
236 | return true; | 144 | return true; |
237 | 145 | ||
238 | return false; | 146 | return false; |
@@ -245,8 +153,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
245 | { | 153 | { |
246 | // Log them out of this grid | 154 | // Log them out of this grid |
247 | Scene.PresenceService.LogoutAgent(sp.ControllingClient.SessionId); | 155 | Scene.PresenceService.LogoutAgent(sp.ControllingClient.SessionId); |
248 | string userId = Scene.UserManagementModule.GetUserUUI(sp.UUID); | ||
249 | Scene.GridUserService.LoggedOut(userId, UUID.Zero, Scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat); | ||
250 | } | 156 | } |
251 | } | 157 | } |
252 | 158 | ||
@@ -256,11 +162,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
256 | reason = string.Empty; | 162 | reason = string.Empty; |
257 | logout = false; | 163 | logout = false; |
258 | int flags = Scene.GridService.GetRegionFlags(Scene.RegionInfo.ScopeID, reg.RegionID); | 164 | int flags = Scene.GridService.GetRegionFlags(Scene.RegionInfo.ScopeID, reg.RegionID); |
259 | if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Framework.RegionFlags.Hyperlink) != 0) | 165 | if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) |
260 | { | 166 | { |
261 | // this user is going to another grid | 167 | // this user is going to another grid |
262 | // for local users, check if HyperGrid teleport is allowed, based on user level | 168 | // check if HyperGrid teleport is allowed, based on user level |
263 | if (Scene.UserManagementModule.IsLocalGridUser(sp.UUID) && sp.UserLevel < m_levelHGTeleport) | 169 | if (sp.UserLevel < m_levelHGTeleport) |
264 | { | 170 | { |
265 | m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: Unable to HG teleport agent due to insufficient UserLevel."); | 171 | m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: Unable to HG teleport agent due to insufficient UserLevel."); |
266 | reason = "Hypergrid teleport not allowed"; | 172 | reason = "Hypergrid teleport not allowed"; |
@@ -294,124 +200,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
294 | TeleportHome(id, client); | 200 | TeleportHome(id, client); |
295 | } | 201 | } |
296 | 202 | ||
297 | protected override bool ValidateGenericConditions(ScenePresence sp, GridRegion reg, GridRegion finalDestination, uint teleportFlags, out string reason) | ||
298 | { | ||
299 | reason = "Please wear your grid's allowed appearance before teleporting to another grid"; | ||
300 | if (!m_RestrictAppearanceAbroad) | ||
301 | return true; | ||
302 | |||
303 | // The rest is only needed for controlling appearance | ||
304 | |||
305 | int flags = Scene.GridService.GetRegionFlags(Scene.RegionInfo.ScopeID, reg.RegionID); | ||
306 | if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Framework.RegionFlags.Hyperlink) != 0) | ||
307 | { | ||
308 | // this user is going to another grid | ||
309 | if (Scene.UserManagementModule.IsLocalGridUser(sp.UUID)) | ||
310 | { | ||
311 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: RestrictAppearanceAbroad is ON. Checking generic appearance"); | ||
312 | |||
313 | // Check wearables | ||
314 | for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++) | ||
315 | { | ||
316 | for (int j = 0; j < sp.Appearance.Wearables[i].Count; j++) | ||
317 | { | ||
318 | if (sp.Appearance.Wearables[i] == null) | ||
319 | continue; | ||
320 | |||
321 | bool found = false; | ||
322 | foreach (AvatarAppearance a in ExportedAppearance) | ||
323 | if (a.Wearables[i] != null) | ||
324 | { | ||
325 | found = true; | ||
326 | break; | ||
327 | } | ||
328 | |||
329 | if (!found) | ||
330 | { | ||
331 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Wearable not allowed to go outside {0}", i); | ||
332 | return false; | ||
333 | } | ||
334 | |||
335 | found = false; | ||
336 | foreach (AvatarAppearance a in ExportedAppearance) | ||
337 | if (sp.Appearance.Wearables[i][j].AssetID == a.Wearables[i][j].AssetID) | ||
338 | { | ||
339 | found = true; | ||
340 | break; | ||
341 | } | ||
342 | |||
343 | if (!found) | ||
344 | { | ||
345 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Wearable not allowed to go outside {0}", i); | ||
346 | return false; | ||
347 | } | ||
348 | } | ||
349 | } | ||
350 | |||
351 | // Check attachments | ||
352 | foreach (AvatarAttachment att in sp.Appearance.GetAttachments()) | ||
353 | { | ||
354 | bool found = false; | ||
355 | foreach (AvatarAttachment att2 in m_Attachs) | ||
356 | { | ||
357 | if (att2.AssetID == att.AssetID) | ||
358 | { | ||
359 | found = true; | ||
360 | break; | ||
361 | } | ||
362 | } | ||
363 | if (!found) | ||
364 | { | ||
365 | m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Attachment not allowed to go outside {0}", att.AttachPoint); | ||
366 | return false; | ||
367 | } | ||
368 | } | ||
369 | } | ||
370 | } | ||
371 | |||
372 | reason = string.Empty; | ||
373 | return true; | ||
374 | } | ||
375 | |||
376 | |||
377 | //protected override bool UpdateAgent(GridRegion reg, GridRegion finalDestination, AgentData agentData, ScenePresence sp) | ||
378 | //{ | ||
379 | // int flags = Scene.GridService.GetRegionFlags(Scene.RegionInfo.ScopeID, reg.RegionID); | ||
380 | // if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Data.RegionFlags.Hyperlink) != 0) | ||
381 | // { | ||
382 | // // this user is going to another grid | ||
383 | // if (m_RestrictAppearanceAbroad && Scene.UserManagementModule.IsLocalGridUser(agentData.AgentID)) | ||
384 | // { | ||
385 | // // We need to strip the agent off its appearance | ||
386 | // m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: RestrictAppearanceAbroad is ON. Sending generic appearance"); | ||
387 | |||
388 | // // Delete existing npc attachments | ||
389 | // Scene.AttachmentsModule.DeleteAttachmentsFromScene(sp, false); | ||
390 | |||
391 | // // XXX: We can't just use IAvatarFactoryModule.SetAppearance() yet since it doesn't transfer attachments | ||
392 | // AvatarAppearance newAppearance = new AvatarAppearance(ExportedAppearance, true); | ||
393 | // sp.Appearance = newAppearance; | ||
394 | |||
395 | // // Rez needed npc attachments | ||
396 | // Scene.AttachmentsModule.RezAttachments(sp); | ||
397 | |||
398 | |||
399 | // IAvatarFactoryModule module = Scene.RequestModuleInterface<IAvatarFactoryModule>(); | ||
400 | // //module.SendAppearance(sp.UUID); | ||
401 | // module.RequestRebake(sp, false); | ||
402 | |||
403 | // Scene.AttachmentsModule.CopyAttachments(sp, agentData); | ||
404 | // agentData.Appearance = sp.Appearance; | ||
405 | // } | ||
406 | // } | ||
407 | |||
408 | // foreach (AvatarAttachment a in agentData.Appearance.GetAttachments()) | ||
409 | // m_log.DebugFormat("[XXX]: {0}-{1}", a.ItemID, a.AssetID); | ||
410 | |||
411 | |||
412 | // return base.UpdateAgent(reg, finalDestination, agentData, sp); | ||
413 | //} | ||
414 | |||
415 | public override bool TeleportHome(UUID id, IClientAPI client) | 203 | public override bool TeleportHome(UUID id, IClientAPI client) |
416 | { | 204 | { |
417 | m_log.DebugFormat( | 205 | m_log.DebugFormat( |
@@ -587,4 +375,4 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
587 | return region; | 375 | return region; |
588 | } | 376 | } |
589 | } | 377 | } |
590 | } | 378 | } \ No newline at end of file |