diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar')
13 files changed, 686 insertions, 220 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index f107be1..88ca9db 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | |||
@@ -40,6 +40,7 @@ using OpenSim.Region.Framework; | |||
40 | using OpenSim.Region.Framework.Interfaces; | 40 | using OpenSim.Region.Framework.Interfaces; |
41 | using OpenSim.Region.Framework.Scenes; | 41 | using OpenSim.Region.Framework.Scenes; |
42 | using OpenSim.Region.Framework.Scenes.Serialization; | 42 | using OpenSim.Region.Framework.Scenes.Serialization; |
43 | using OpenSim.Services.Interfaces; | ||
43 | 44 | ||
44 | namespace OpenSim.Region.CoreModules.Avatar.Attachments | 45 | namespace OpenSim.Region.CoreModules.Avatar.Attachments |
45 | { | 46 | { |
@@ -169,6 +170,40 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
169 | 170 | ||
170 | // m_log.DebugFormat("[ATTACHMENTS MODULE]: Rezzing any attachments for {0}", sp.Name); | 171 | // m_log.DebugFormat("[ATTACHMENTS MODULE]: Rezzing any attachments for {0}", sp.Name); |
171 | 172 | ||
173 | XmlDocument doc = new XmlDocument(); | ||
174 | string stateData = String.Empty; | ||
175 | |||
176 | IAttachmentsService attServ = m_scene.RequestModuleInterface<IAttachmentsService>(); | ||
177 | if (attServ != null) | ||
178 | { | ||
179 | m_log.DebugFormat("[ATTACHMENT]: Loading attachment data from attachment service"); | ||
180 | stateData = attServ.Get(sp.UUID.ToString()); | ||
181 | if (stateData != String.Empty) | ||
182 | { | ||
183 | try | ||
184 | { | ||
185 | doc.LoadXml(stateData); | ||
186 | } | ||
187 | catch { } | ||
188 | } | ||
189 | } | ||
190 | |||
191 | Dictionary<UUID, string> itemData = new Dictionary<UUID, string>(); | ||
192 | |||
193 | XmlNodeList nodes = doc.GetElementsByTagName("Attachment"); | ||
194 | if (nodes.Count > 0) | ||
195 | { | ||
196 | foreach (XmlNode n in nodes) | ||
197 | { | ||
198 | XmlElement elem = (XmlElement)n; | ||
199 | string itemID = elem.GetAttribute("ItemID"); | ||
200 | string xml = elem.InnerXml; | ||
201 | |||
202 | itemData[new UUID(itemID)] = xml; | ||
203 | } | ||
204 | } | ||
205 | |||
206 | |||
172 | List<AvatarAttachment> attachments = sp.Appearance.GetAttachments(); | 207 | List<AvatarAttachment> attachments = sp.Appearance.GetAttachments(); |
173 | foreach (AvatarAttachment attach in attachments) | 208 | foreach (AvatarAttachment attach in attachments) |
174 | { | 209 | { |
@@ -188,12 +223,22 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
188 | 223 | ||
189 | try | 224 | try |
190 | { | 225 | { |
226 | string xmlData; | ||
227 | XmlDocument d = null; | ||
228 | UUID asset; | ||
229 | if (itemData.TryGetValue(attach.ItemID, out xmlData)) | ||
230 | { | ||
231 | d = new XmlDocument(); | ||
232 | d.LoadXml(xmlData); | ||
233 | m_log.InfoFormat("[ATTACHMENT]: Found saved state for item {0}, loading it", attach.ItemID); | ||
234 | } | ||
235 | |||
191 | // If we're an NPC then skip all the item checks and manipulations since we don't have an | 236 | // If we're an NPC then skip all the item checks and manipulations since we don't have an |
192 | // inventory right now. | 237 | // inventory right now. |
193 | if (sp.PresenceType == PresenceType.Npc) | 238 | if (sp.PresenceType == PresenceType.Npc) |
194 | RezSingleAttachmentFromInventoryInternal(sp, UUID.Zero, attach.AssetID, p); | 239 | RezSingleAttachmentFromInventoryInternal(sp, UUID.Zero, attach.AssetID, p, null); |
195 | else | 240 | else |
196 | RezSingleAttachmentFromInventory(sp, attach.ItemID, p); | 241 | RezSingleAttachmentFromInventory(sp, attach.ItemID, p, d); |
197 | } | 242 | } |
198 | catch (Exception e) | 243 | catch (Exception e) |
199 | { | 244 | { |
@@ -239,7 +284,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
239 | sp.ClearAttachments(); | 284 | sp.ClearAttachments(); |
240 | } | 285 | } |
241 | 286 | ||
242 | public bool AttachObject(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool temp) | 287 | public bool AttachObject(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool useAttachData, bool temp) |
243 | { | 288 | { |
244 | lock (sp.AttachmentsSyncLock) | 289 | lock (sp.AttachmentsSyncLock) |
245 | { | 290 | { |
@@ -294,6 +339,24 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
294 | attachPos = Vector3.Zero; | 339 | attachPos = Vector3.Zero; |
295 | } | 340 | } |
296 | 341 | ||
342 | if (useAttachData) | ||
343 | { | ||
344 | group.RootPart.RotationOffset = group.RootPart.AttachRotation; | ||
345 | attachPos = group.RootPart.AttachOffset; | ||
346 | if (attachmentPt == 0) | ||
347 | { | ||
348 | attachmentPt = group.RootPart.AttachPoint; | ||
349 | if (attachmentPt == 0) | ||
350 | { | ||
351 | attachmentPt = (uint)AttachmentPoint.LeftHand; | ||
352 | attachPos = Vector3.Zero; | ||
353 | } | ||
354 | } | ||
355 | else if (group.RootPart.AttachPoint != attachmentPt) | ||
356 | { | ||
357 | attachPos = Vector3.Zero; | ||
358 | } | ||
359 | } | ||
297 | group.AttachmentPoint = attachmentPt; | 360 | group.AttachmentPoint = attachmentPt; |
298 | group.AbsolutePosition = attachPos; | 361 | group.AbsolutePosition = attachPos; |
299 | 362 | ||
@@ -334,7 +397,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
334 | } | 397 | } |
335 | } | 398 | } |
336 | 399 | ||
337 | public SceneObjectGroup RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt) | 400 | public ISceneEntity RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt) |
401 | { | ||
402 | return RezSingleAttachmentFromInventory(sp, itemID, AttachmentPt, null); | ||
403 | } | ||
404 | |||
405 | public ISceneEntity RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt, XmlDocument doc) | ||
338 | { | 406 | { |
339 | if (!Enabled) | 407 | if (!Enabled) |
340 | return null; | 408 | return null; |
@@ -373,7 +441,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
373 | return null; | 441 | return null; |
374 | } | 442 | } |
375 | 443 | ||
376 | return RezSingleAttachmentFromInventoryInternal(sp, itemID, UUID.Zero, AttachmentPt); | 444 | return RezSingleAttachmentFromInventoryInternal(sp, itemID, UUID.Zero, AttachmentPt, doc); |
377 | } | 445 | } |
378 | 446 | ||
379 | public void RezMultipleAttachmentsFromInventory(IScenePresence sp, List<KeyValuePair<UUID, uint>> rezlist) | 447 | public void RezMultipleAttachmentsFromInventory(IScenePresence sp, List<KeyValuePair<UUID, uint>> rezlist) |
@@ -438,7 +506,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
438 | so.AttachedAvatar = UUID.Zero; | 506 | so.AttachedAvatar = UUID.Zero; |
439 | rootPart.SetParentLocalId(0); | 507 | rootPart.SetParentLocalId(0); |
440 | so.ClearPartAttachmentData(); | 508 | so.ClearPartAttachmentData(); |
441 | rootPart.ApplyPhysics(rootPart.GetEffectiveObjectFlags(), rootPart.VolumeDetectActive); | 509 | rootPart.ApplyPhysics(rootPart.GetEffectiveObjectFlags(), rootPart.VolumeDetectActive,false); |
442 | so.HasGroupChanged = true; | 510 | so.HasGroupChanged = true; |
443 | rootPart.Rezzed = DateTime.Now; | 511 | rootPart.Rezzed = DateTime.Now; |
444 | rootPart.RemFlag(PrimFlags.TemporaryOnRez); | 512 | rootPart.RemFlag(PrimFlags.TemporaryOnRez); |
@@ -759,8 +827,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
759 | UpdateDetachedObject(sp, so); | 827 | UpdateDetachedObject(sp, so); |
760 | } | 828 | } |
761 | 829 | ||
762 | private SceneObjectGroup RezSingleAttachmentFromInventoryInternal( | 830 | protected SceneObjectGroup RezSingleAttachmentFromInventoryInternal( |
763 | IScenePresence sp, UUID itemID, UUID assetID, uint attachmentPt) | 831 | IScenePresence sp, UUID itemID, UUID assetID, uint attachmentPt, XmlDocument doc) |
764 | { | 832 | { |
765 | if (m_invAccessModule == null) | 833 | if (m_invAccessModule == null) |
766 | return null; | 834 | return null; |
@@ -798,7 +866,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
798 | // This will throw if the attachment fails | 866 | // This will throw if the attachment fails |
799 | try | 867 | try |
800 | { | 868 | { |
801 | AttachObject(sp, objatt, attachmentPt, false, false); | 869 | AttachObject(sp, objatt, attachmentPt, false, false, false); |
802 | } | 870 | } |
803 | catch (Exception e) | 871 | catch (Exception e) |
804 | { | 872 | { |
@@ -811,10 +879,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
811 | m_scene.DeleteSceneObject(objatt, false); | 879 | m_scene.DeleteSceneObject(objatt, false); |
812 | return null; | 880 | return null; |
813 | } | 881 | } |
814 | 882 | ||
815 | if (tainted) | 883 | if (tainted) |
816 | objatt.HasGroupChanged = true; | 884 | objatt.HasGroupChanged = true; |
817 | 885 | ||
886 | if (doc != null) | ||
887 | { | ||
888 | objatt.LoadScriptState(doc); | ||
889 | objatt.ResetOwnerChangeFlag(); | ||
890 | } | ||
891 | |||
818 | // Fire after attach, so we don't get messy perms dialogs | 892 | // Fire after attach, so we don't get messy perms dialogs |
819 | // 4 == AttachedRez | 893 | // 4 == AttachedRez |
820 | objatt.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 4); | 894 | objatt.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 4); |
@@ -832,7 +906,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
832 | itemID, sp.Name, attachmentPt); | 906 | itemID, sp.Name, attachmentPt); |
833 | } | 907 | } |
834 | } | 908 | } |
835 | 909 | ||
836 | return null; | 910 | return null; |
837 | } | 911 | } |
838 | 912 | ||
@@ -952,7 +1026,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
952 | AttachmentPt &= 0x7f; | 1026 | AttachmentPt &= 0x7f; |
953 | 1027 | ||
954 | // Calls attach with a Zero position | 1028 | // Calls attach with a Zero position |
955 | if (AttachObject(sp, part.ParentGroup, AttachmentPt, false, false)) | 1029 | if (AttachObject(sp, part.ParentGroup, AttachmentPt, false, true, false)) |
956 | { | 1030 | { |
957 | // m_log.Debug( | 1031 | // m_log.Debug( |
958 | // "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId | 1032 | // "[ATTACHMENTS MODULE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId |
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs index 1d13f75..d9a619d 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs | |||
@@ -189,7 +189,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
189 | 189 | ||
190 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID); | 190 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID); |
191 | 191 | ||
192 | scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false); | 192 | scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false, false); |
193 | 193 | ||
194 | // Check status on scene presence | 194 | // Check status on scene presence |
195 | Assert.That(sp.HasAttachments(), Is.True); | 195 | Assert.That(sp.HasAttachments(), Is.True); |
@@ -243,7 +243,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
243 | sp2.AbsolutePosition = new Vector3(0, 0, 0); | 243 | sp2.AbsolutePosition = new Vector3(0, 0, 0); |
244 | sp2.HandleAgentRequestSit(sp2.ControllingClient, sp2.UUID, so.UUID, Vector3.Zero); | 244 | sp2.HandleAgentRequestSit(sp2.ControllingClient, sp2.UUID, so.UUID, Vector3.Zero); |
245 | 245 | ||
246 | scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false); | 246 | scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false, false); |
247 | 247 | ||
248 | Assert.That(sp.HasAttachments(), Is.False); | 248 | Assert.That(sp.HasAttachments(), Is.False); |
249 | Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); | 249 | Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1)); |
@@ -410,7 +410,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
410 | scene.EventManager.OnChatFromWorld += OnChatFromWorld; | 410 | scene.EventManager.OnChatFromWorld += OnChatFromWorld; |
411 | 411 | ||
412 | SceneObjectGroup rezzedSo | 412 | SceneObjectGroup rezzedSo |
413 | = scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest); | 413 | = (SceneObjectGroup)(scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest)); |
414 | 414 | ||
415 | // Wait for chat to signal rezzed script has been started. | 415 | // Wait for chat to signal rezzed script has been started. |
416 | m_chatEvent.WaitOne(60000); | 416 | m_chatEvent.WaitOne(60000); |
@@ -429,7 +429,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests | |||
429 | Assert.That(scriptStateNodes.Count, Is.EqualTo(1)); | 429 | Assert.That(scriptStateNodes.Count, Is.EqualTo(1)); |
430 | 430 | ||
431 | // Re-rez the attachment to check script running state | 431 | // Re-rez the attachment to check script running state |
432 | SceneObjectGroup reRezzedSo = scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest); | 432 | SceneObjectGroup reRezzedSo = (SceneObjectGroup)(scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, userItem.ID, (uint)AttachmentPoint.Chest)); |
433 | 433 | ||
434 | // Wait for chat to signal rezzed script has been started. | 434 | // Wait for chat to signal rezzed script has been started. |
435 | m_chatEvent.WaitOne(60000); | 435 | m_chatEvent.WaitOne(60000); |
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index 1d6e522..bd7bd82 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs | |||
@@ -566,12 +566,17 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
566 | /// <param name="client"></param> | 566 | /// <param name="client"></param> |
567 | private void Client_OnRequestWearables(IClientAPI client) | 567 | private void Client_OnRequestWearables(IClientAPI client) |
568 | { | 568 | { |
569 | // m_log.DebugFormat("[AVFACTORY]: Client_OnRequestWearables called for {0} ({1})", client.Name, client.AgentId); | 569 | Util.FireAndForget(delegate(object x) |
570 | ScenePresence sp = m_scene.GetScenePresence(client.AgentId); | 570 | { |
571 | if (sp != null) | 571 | Thread.Sleep(4000); |
572 | client.SendWearables(sp.Appearance.Wearables, sp.Appearance.Serial++); | 572 | |
573 | else | 573 | // m_log.DebugFormat("[AVFACTORY]: Client_OnRequestWearables called for {0} ({1})", client.Name, client.AgentId); |
574 | m_log.WarnFormat("[AVFACTORY]: Client_OnRequestWearables unable to find presence for {0}", client.AgentId); | 574 | ScenePresence sp = m_scene.GetScenePresence(client.AgentId); |
575 | if (sp != null) | ||
576 | client.SendWearables(sp.Appearance.Wearables, sp.Appearance.Serial++); | ||
577 | else | ||
578 | m_log.WarnFormat("[AVFACTORY]: Client_OnRequestWearables unable to find presence for {0}", client.AgentId); | ||
579 | }); | ||
575 | } | 580 | } |
576 | 581 | ||
577 | /// <summary> | 582 | /// <summary> |
diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs index e4452fb..dbbb0ae 100644 --- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs | |||
@@ -49,7 +49,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
49 | private int m_shoutdistance = 100; | 49 | private int m_shoutdistance = 100; |
50 | private int m_whisperdistance = 10; | 50 | private int m_whisperdistance = 10; |
51 | private List<Scene> m_scenes = new List<Scene>(); | 51 | private List<Scene> m_scenes = new List<Scene>(); |
52 | 52 | private List<string> FreezeCache = new List<string>(); | |
53 | private string m_adminPrefix = ""; | ||
53 | internal object m_syncy = new object(); | 54 | internal object m_syncy = new object(); |
54 | 55 | ||
55 | internal IConfig m_config; | 56 | internal IConfig m_config; |
@@ -76,6 +77,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
76 | m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance); | 77 | m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance); |
77 | m_saydistance = config.Configs["Chat"].GetInt("say_distance", m_saydistance); | 78 | m_saydistance = config.Configs["Chat"].GetInt("say_distance", m_saydistance); |
78 | m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance", m_shoutdistance); | 79 | m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance", m_shoutdistance); |
80 | m_adminPrefix = config.Configs["Chat"].GetString("admin_prefix", ""); | ||
79 | } | 81 | } |
80 | 82 | ||
81 | public virtual void AddRegion(Scene scene) | 83 | public virtual void AddRegion(Scene scene) |
@@ -171,7 +173,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
171 | return; | 173 | return; |
172 | } | 174 | } |
173 | 175 | ||
174 | DeliverChatToAvatars(ChatSourceType.Agent, c); | 176 | if (FreezeCache.Contains(c.Sender.AgentId.ToString())) |
177 | { | ||
178 | if (c.Type != ChatTypeEnum.StartTyping || c.Type != ChatTypeEnum.StopTyping) | ||
179 | c.Sender.SendAgentAlertMessage("You may not talk as you are frozen.", false); | ||
180 | } | ||
181 | else | ||
182 | { | ||
183 | DeliverChatToAvatars(ChatSourceType.Agent, c); | ||
184 | } | ||
175 | } | 185 | } |
176 | 186 | ||
177 | public virtual void OnChatFromWorld(Object sender, OSChatMessage c) | 187 | public virtual void OnChatFromWorld(Object sender, OSChatMessage c) |
@@ -185,10 +195,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
185 | protected virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c) | 195 | protected virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c) |
186 | { | 196 | { |
187 | string fromName = c.From; | 197 | string fromName = c.From; |
198 | string fromNamePrefix = ""; | ||
188 | UUID fromID = UUID.Zero; | 199 | UUID fromID = UUID.Zero; |
189 | UUID targetID = c.TargetUUID; | ||
190 | string message = c.Message; | 200 | string message = c.Message; |
191 | IScene scene = c.Scene; | 201 | IScene scene = c.Scene; |
202 | UUID destination = c.Destination; | ||
192 | Vector3 fromPos = c.Position; | 203 | Vector3 fromPos = c.Position; |
193 | Vector3 regionPos = new Vector3(scene.RegionInfo.RegionLocX * Constants.RegionSize, | 204 | Vector3 regionPos = new Vector3(scene.RegionInfo.RegionLocX * Constants.RegionSize, |
194 | scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); | 205 | scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); |
@@ -208,7 +219,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
208 | fromPos = avatar.AbsolutePosition; | 219 | fromPos = avatar.AbsolutePosition; |
209 | fromName = avatar.Name; | 220 | fromName = avatar.Name; |
210 | fromID = c.Sender.AgentId; | 221 | fromID = c.Sender.AgentId; |
211 | 222 | if (avatar.GodLevel >= 200) | |
223 | { | ||
224 | fromNamePrefix = m_adminPrefix; | ||
225 | } | ||
226 | destination = UUID.Zero; // Avatars cant "SayTo" | ||
212 | break; | 227 | break; |
213 | 228 | ||
214 | case ChatSourceType.Object: | 229 | case ChatSourceType.Object: |
@@ -222,38 +237,39 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
222 | message = message.Substring(0, 1000); | 237 | message = message.Substring(0, 1000); |
223 | 238 | ||
224 | // m_log.DebugFormat( | 239 | // m_log.DebugFormat( |
225 | // "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}, targetID {5}", | 240 | // "[CHAT]: DCTA: fromID {0} fromName {1}, region{2}, cType {3}, sType {4}", |
226 | // fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType, targetID); | 241 | // fromID, fromName, scene.RegionInfo.RegionName, c.Type, sourceType); |
227 | 242 | ||
228 | HashSet<UUID> receiverIDs = new HashSet<UUID>(); | 243 | HashSet<UUID> receiverIDs = new HashSet<UUID>(); |
229 | 244 | ||
230 | foreach (Scene s in m_scenes) | 245 | foreach (Scene s in m_scenes) |
231 | { | 246 | { |
232 | if (targetID == UUID.Zero) | 247 | // This should use ForEachClient, but clients don't have a position. |
233 | { | 248 | // If camera is moved into client, then camera position can be used |
234 | // This should use ForEachClient, but clients don't have a position. | 249 | // MT: No, it can't, as chat is heard from the avatar position, not |
235 | // If camera is moved into client, then camera position can be used | 250 | // the camera position. |
236 | s.ForEachRootScenePresence( | 251 | s.ForEachRootScenePresence( |
237 | delegate(ScenePresence presence) | 252 | delegate(ScenePresence presence) |
253 | { | ||
254 | if (destination != UUID.Zero && presence.UUID != destination) | ||
255 | return; | ||
256 | ILandObject Presencecheck = s.LandChannel.GetLandObject(presence.AbsolutePosition.X, presence.AbsolutePosition.Y); | ||
257 | if (Presencecheck != null) | ||
238 | { | 258 | { |
239 | if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, c.Type, message, sourceType, false)) | 259 | // This will pass all chat from objects. Not |
240 | receiverIDs.Add(presence.UUID); | 260 | // perfect, but it will do. For now. Better |
261 | // than the prior behavior of muting all | ||
262 | // objects on a parcel with access restrictions | ||
263 | if (c.Sender == null || Presencecheck.IsEitherBannedOrRestricted(c.Sender.AgentId) != true) | ||
264 | { | ||
265 | if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromNamePrefix + fromName, c.Type, message, sourceType)) | ||
266 | receiverIDs.Add(presence.UUID); | ||
267 | } | ||
241 | } | 268 | } |
242 | ); | ||
243 | } | ||
244 | else | ||
245 | { | ||
246 | // This is a send to a specific client eg from llRegionSayTo | ||
247 | // no need to check distance etc, jand send is as say | ||
248 | ScenePresence presence = s.GetScenePresence(targetID); | ||
249 | if (presence != null && !presence.IsChildAgent) | ||
250 | { | ||
251 | if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, ChatTypeEnum.Say, message, sourceType, true)) | ||
252 | receiverIDs.Add(presence.UUID); | ||
253 | } | 269 | } |
254 | } | 270 | ); |
255 | } | 271 | } |
256 | 272 | ||
257 | (scene as Scene).EventManager.TriggerOnChatToClients( | 273 | (scene as Scene).EventManager.TriggerOnChatToClients( |
258 | fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully); | 274 | fromID, receiverIDs, message, c.Type, fromPos, fromName, sourceType, ChatAudibleLevel.Fully); |
259 | } | 275 | } |
@@ -293,26 +309,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
293 | } | 309 | } |
294 | 310 | ||
295 | // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType); | 311 | // m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType); |
296 | |||
297 | HashSet<UUID> receiverIDs = new HashSet<UUID>(); | 312 | HashSet<UUID> receiverIDs = new HashSet<UUID>(); |
298 | 313 | ||
299 | ((Scene)c.Scene).ForEachRootClient( | 314 | if (c.Scene != null) |
300 | delegate(IClientAPI client) | 315 | { |
301 | { | 316 | ((Scene)c.Scene).ForEachRootClient |
302 | // don't forward SayOwner chat from objects to | 317 | ( |
303 | // non-owner agents | 318 | delegate(IClientAPI client) |
304 | if ((c.Type == ChatTypeEnum.Owner) && | 319 | { |
305 | (null != c.SenderObject) && | 320 | // don't forward SayOwner chat from objects to |
306 | (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId)) | 321 | // non-owner agents |
307 | return; | 322 | if ((c.Type == ChatTypeEnum.Owner) && |
308 | 323 | (null != c.SenderObject) && | |
309 | client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID, | 324 | (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId)) |
310 | (byte)sourceType, (byte)ChatAudibleLevel.Fully); | 325 | return; |
311 | receiverIDs.Add(client.AgentId); | 326 | |
312 | }); | 327 | client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID, |
313 | 328 | (byte)sourceType, (byte)ChatAudibleLevel.Fully); | |
314 | (c.Scene as Scene).EventManager.TriggerOnChatToClients( | 329 | receiverIDs.Add(client.AgentId); |
315 | fromID, receiverIDs, c.Message, cType, CenterOfRegion, fromName, sourceType, ChatAudibleLevel.Fully); | 330 | } |
331 | ); | ||
332 | (c.Scene as Scene).EventManager.TriggerOnChatToClients( | ||
333 | fromID, receiverIDs, c.Message, cType, CenterOfRegion, fromName, sourceType, ChatAudibleLevel.Fully); | ||
334 | } | ||
316 | } | 335 | } |
317 | 336 | ||
318 | /// <summary> | 337 | /// <summary> |
@@ -330,9 +349,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
330 | /// precondition</returns> | 349 | /// precondition</returns> |
331 | protected virtual bool TrySendChatMessage(ScenePresence presence, Vector3 fromPos, Vector3 regionPos, | 350 | protected virtual bool TrySendChatMessage(ScenePresence presence, Vector3 fromPos, Vector3 regionPos, |
332 | UUID fromAgentID, string fromName, ChatTypeEnum type, | 351 | UUID fromAgentID, string fromName, ChatTypeEnum type, |
333 | string message, ChatSourceType src, bool ignoreDistance) | 352 | string message, ChatSourceType src) |
334 | { | 353 | { |
335 | // don't send stuff to child agents | 354 | // don't send chat to child agents |
336 | if (presence.IsChildAgent) return false; | 355 | if (presence.IsChildAgent) return false; |
337 | 356 | ||
338 | Vector3 fromRegionPos = fromPos + regionPos; | 357 | Vector3 fromRegionPos = fromPos + regionPos; |
@@ -341,15 +360,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
341 | presence.Scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); | 360 | presence.Scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); |
342 | 361 | ||
343 | int dis = (int)Util.GetDistanceTo(toRegionPos, fromRegionPos); | 362 | int dis = (int)Util.GetDistanceTo(toRegionPos, fromRegionPos); |
344 | 363 | ||
345 | if (!ignoreDistance) | 364 | if (type == ChatTypeEnum.Whisper && dis > m_whisperdistance || |
365 | type == ChatTypeEnum.Say && dis > m_saydistance || | ||
366 | type == ChatTypeEnum.Shout && dis > m_shoutdistance) | ||
346 | { | 367 | { |
347 | if (type == ChatTypeEnum.Whisper && dis > m_whisperdistance || | 368 | return false; |
348 | type == ChatTypeEnum.Say && dis > m_saydistance || | ||
349 | type == ChatTypeEnum.Shout && dis > m_shoutdistance) | ||
350 | { | ||
351 | return false; | ||
352 | } | ||
353 | } | 369 | } |
354 | 370 | ||
355 | // TODO: should change so the message is sent through the avatar rather than direct to the ClientView | 371 | // TODO: should change so the message is sent through the avatar rather than direct to the ClientView |
@@ -358,5 +374,35 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
358 | 374 | ||
359 | return true; | 375 | return true; |
360 | } | 376 | } |
377 | |||
378 | Dictionary<UUID, System.Threading.Timer> Timers = new Dictionary<UUID, System.Threading.Timer>(); | ||
379 | public void ParcelFreezeUser(IClientAPI client, UUID parcelowner, uint flags, UUID target) | ||
380 | { | ||
381 | System.Threading.Timer Timer; | ||
382 | if (flags == 0) | ||
383 | { | ||
384 | FreezeCache.Add(target.ToString()); | ||
385 | System.Threading.TimerCallback timeCB = new System.Threading.TimerCallback(OnEndParcelFrozen); | ||
386 | Timer = new System.Threading.Timer(timeCB, target, 30000, 0); | ||
387 | Timers.Add(target, Timer); | ||
388 | } | ||
389 | else | ||
390 | { | ||
391 | FreezeCache.Remove(target.ToString()); | ||
392 | Timers.TryGetValue(target, out Timer); | ||
393 | Timers.Remove(target); | ||
394 | Timer.Dispose(); | ||
395 | } | ||
396 | } | ||
397 | |||
398 | private void OnEndParcelFrozen(object avatar) | ||
399 | { | ||
400 | UUID target = (UUID)avatar; | ||
401 | FreezeCache.Remove(target.ToString()); | ||
402 | System.Threading.Timer Timer; | ||
403 | Timers.TryGetValue(target, out Timer); | ||
404 | Timers.Remove(target); | ||
405 | Timer.Dispose(); | ||
406 | } | ||
361 | } | 407 | } |
362 | } | 408 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs index 325067c..3c294bb 100644 --- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs | |||
@@ -216,4 +216,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog | |||
216 | return result; | 216 | return result; |
217 | } | 217 | } |
218 | } | 218 | } |
219 | } \ No newline at end of file | 219 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs index 2e3312f..1492302 100644 --- a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs | |||
@@ -31,16 +31,40 @@ using OpenMetaverse; | |||
31 | using OpenSim.Framework; | 31 | using OpenSim.Framework; |
32 | using OpenSim.Region.Framework.Scenes; | 32 | using OpenSim.Region.Framework.Scenes; |
33 | using OpenSim.Region.Framework.Interfaces; | 33 | using OpenSim.Region.Framework.Interfaces; |
34 | using System; | ||
35 | using System.Reflection; | ||
36 | using System.Collections; | ||
37 | using System.Collections.Specialized; | ||
38 | using System.Reflection; | ||
39 | using System.IO; | ||
40 | using System.Web; | ||
41 | using System.Xml; | ||
42 | using log4net; | ||
43 | using Mono.Addins; | ||
44 | using OpenMetaverse.Messages.Linden; | ||
45 | using OpenMetaverse.StructuredData; | ||
46 | using OpenSim.Framework.Capabilities; | ||
47 | using OpenSim.Framework.Servers; | ||
48 | using OpenSim.Framework.Servers.HttpServer; | ||
49 | using Caps = OpenSim.Framework.Capabilities.Caps; | ||
50 | using OSDArray = OpenMetaverse.StructuredData.OSDArray; | ||
51 | using OSDMap = OpenMetaverse.StructuredData.OSDMap; | ||
34 | 52 | ||
35 | namespace OpenSim.Region.CoreModules.Avatar.Gods | 53 | namespace OpenSim.Region.CoreModules.Avatar.Gods |
36 | { | 54 | { |
37 | public class GodsModule : IRegionModule, IGodsModule | 55 | public class GodsModule : IRegionModule, IGodsModule |
38 | { | 56 | { |
57 | private static readonly ILog m_log = | ||
58 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
59 | |||
39 | /// <summary>Special UUID for actions that apply to all agents</summary> | 60 | /// <summary>Special UUID for actions that apply to all agents</summary> |
40 | private static readonly UUID ALL_AGENTS = new UUID("44e87126-e794-4ded-05b3-7c42da3d5cdb"); | 61 | private static readonly UUID ALL_AGENTS = new UUID("44e87126-e794-4ded-05b3-7c42da3d5cdb"); |
41 | 62 | ||
42 | protected Scene m_scene; | 63 | protected Scene m_scene; |
43 | protected IDialogModule m_dialogModule; | 64 | protected IDialogModule m_dialogModule; |
65 | |||
66 | protected Dictionary<UUID, string> m_capsDict = | ||
67 | new Dictionary<UUID, string>(); | ||
44 | 68 | ||
45 | public void Initialise(Scene scene, IConfigSource source) | 69 | public void Initialise(Scene scene, IConfigSource source) |
46 | { | 70 | { |
@@ -48,6 +72,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods | |||
48 | m_dialogModule = m_scene.RequestModuleInterface<IDialogModule>(); | 72 | m_dialogModule = m_scene.RequestModuleInterface<IDialogModule>(); |
49 | m_scene.RegisterModuleInterface<IGodsModule>(this); | 73 | m_scene.RegisterModuleInterface<IGodsModule>(this); |
50 | m_scene.EventManager.OnNewClient += SubscribeToClientEvents; | 74 | m_scene.EventManager.OnNewClient += SubscribeToClientEvents; |
75 | m_scene.EventManager.OnRegisterCaps += OnRegisterCaps; | ||
76 | m_scene.EventManager.OnClientClosed += OnClientClosed; | ||
77 | scene.EventManager.OnIncomingInstantMessage += | ||
78 | OnIncomingInstantMessage; | ||
51 | } | 79 | } |
52 | 80 | ||
53 | public void PostInitialise() {} | 81 | public void PostInitialise() {} |
@@ -67,6 +95,54 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods | |||
67 | client.OnRequestGodlikePowers -= RequestGodlikePowers; | 95 | client.OnRequestGodlikePowers -= RequestGodlikePowers; |
68 | } | 96 | } |
69 | 97 | ||
98 | private void OnClientClosed(UUID agentID, Scene scene) | ||
99 | { | ||
100 | m_capsDict.Remove(agentID); | ||
101 | } | ||
102 | |||
103 | private void OnRegisterCaps(UUID agentID, Caps caps) | ||
104 | { | ||
105 | string uri = "/CAPS/" + UUID.Random(); | ||
106 | m_capsDict[agentID] = uri; | ||
107 | |||
108 | caps.RegisterHandler("UntrustedSimulatorMessage", | ||
109 | new RestStreamHandler("POST", uri, | ||
110 | HandleUntrustedSimulatorMessage)); | ||
111 | } | ||
112 | |||
113 | private string HandleUntrustedSimulatorMessage(string request, | ||
114 | string path, string param, IOSHttpRequest httpRequest, | ||
115 | IOSHttpResponse httpResponse) | ||
116 | { | ||
117 | OSDMap osd = (OSDMap)OSDParser.DeserializeLLSDXml(request); | ||
118 | |||
119 | string message = osd["message"].AsString(); | ||
120 | |||
121 | if (message == "GodKickUser") | ||
122 | { | ||
123 | OSDMap body = (OSDMap)osd["body"]; | ||
124 | OSDArray userInfo = (OSDArray)body["UserInfo"]; | ||
125 | OSDMap userData = (OSDMap)userInfo[0]; | ||
126 | |||
127 | UUID agentID = userData["AgentID"].AsUUID(); | ||
128 | UUID godID = userData["GodID"].AsUUID(); | ||
129 | UUID godSessionID = userData["GodSessionID"].AsUUID(); | ||
130 | uint kickFlags = userData["KickFlags"].AsUInteger(); | ||
131 | string reason = userData["Reason"].AsString(); | ||
132 | |||
133 | ScenePresence god = m_scene.GetScenePresence(godID); | ||
134 | if (god == null || god.ControllingClient.SessionId != godSessionID) | ||
135 | return String.Empty; | ||
136 | |||
137 | KickUser(godID, godSessionID, agentID, kickFlags, Util.StringToBytes1024(reason)); | ||
138 | } | ||
139 | else | ||
140 | { | ||
141 | m_log.ErrorFormat("[GOD]: Unhandled UntrustedSimulatorMessage: {0}", message); | ||
142 | } | ||
143 | return String.Empty; | ||
144 | } | ||
145 | |||
70 | public void RequestGodlikePowers( | 146 | public void RequestGodlikePowers( |
71 | UUID agentID, UUID sessionID, UUID token, bool godLike, IClientAPI controllingClient) | 147 | UUID agentID, UUID sessionID, UUID token, bool godLike, IClientAPI controllingClient) |
72 | { | 148 | { |
@@ -115,69 +191,85 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods | |||
115 | /// <param name="reason">The message to send to the user after it's been turned into a field</param> | 191 | /// <param name="reason">The message to send to the user after it's been turned into a field</param> |
116 | public void KickUser(UUID godID, UUID sessionID, UUID agentID, uint kickflags, byte[] reason) | 192 | public void KickUser(UUID godID, UUID sessionID, UUID agentID, uint kickflags, byte[] reason) |
117 | { | 193 | { |
118 | UUID kickUserID = ALL_AGENTS; | 194 | if (!m_scene.Permissions.IsGod(godID)) |
119 | 195 | return; | |
196 | |||
120 | ScenePresence sp = m_scene.GetScenePresence(agentID); | 197 | ScenePresence sp = m_scene.GetScenePresence(agentID); |
121 | 198 | ||
122 | if (sp != null || agentID == kickUserID) | 199 | if (sp == null && agentID != ALL_AGENTS) |
123 | { | 200 | { |
124 | if (m_scene.Permissions.IsGod(godID)) | 201 | IMessageTransferModule transferModule = |
202 | m_scene.RequestModuleInterface<IMessageTransferModule>(); | ||
203 | if (transferModule != null) | ||
125 | { | 204 | { |
126 | if (kickflags == 0) | 205 | m_log.DebugFormat("[GODS]: Sending nonlocal kill for agent {0}", agentID); |
127 | { | 206 | transferModule.SendInstantMessage(new GridInstantMessage( |
128 | if (agentID == kickUserID) | 207 | m_scene, godID, "God", agentID, (byte)250, false, |
129 | { | 208 | Utils.BytesToString(reason), UUID.Zero, true, |
130 | string reasonStr = Utils.BytesToString(reason); | 209 | new Vector3(), new byte[] {(byte)kickflags}), |
131 | 210 | delegate(bool success) {} ); | |
132 | m_scene.ForEachClient( | 211 | } |
133 | delegate(IClientAPI controller) | 212 | return; |
134 | { | 213 | } |
135 | if (controller.AgentId != godID) | ||
136 | controller.Kick(reasonStr); | ||
137 | } | ||
138 | ); | ||
139 | |||
140 | // This is a bit crude. It seems the client will be null before it actually stops the thread | ||
141 | // The thread will kill itself eventually :/ | ||
142 | // Is there another way to make sure *all* clients get this 'inter region' message? | ||
143 | m_scene.ForEachRootClient( | ||
144 | delegate(IClientAPI client) | ||
145 | { | ||
146 | if (client.AgentId != godID) | ||
147 | { | ||
148 | client.Close(); | ||
149 | } | ||
150 | } | ||
151 | ); | ||
152 | } | ||
153 | else | ||
154 | { | ||
155 | m_scene.SceneGraph.removeUserCount(!sp.IsChildAgent); | ||
156 | 214 | ||
157 | sp.ControllingClient.Kick(Utils.BytesToString(reason)); | 215 | switch (kickflags) |
158 | sp.ControllingClient.Close(); | 216 | { |
159 | } | 217 | case 0: |
160 | } | 218 | if (sp != null) |
161 | 219 | { | |
162 | if (kickflags == 1) | 220 | KickPresence(sp, Utils.BytesToString(reason)); |
163 | { | ||
164 | sp.AllowMovement = false; | ||
165 | m_dialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason)); | ||
166 | m_dialogModule.SendAlertToUser(godID, "User Frozen"); | ||
167 | } | ||
168 | |||
169 | if (kickflags == 2) | ||
170 | { | ||
171 | sp.AllowMovement = true; | ||
172 | m_dialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason)); | ||
173 | m_dialogModule.SendAlertToUser(godID, "User Unfrozen"); | ||
174 | } | ||
175 | } | 221 | } |
176 | else | 222 | else if (agentID == ALL_AGENTS) |
177 | { | 223 | { |
178 | m_dialogModule.SendAlertToUser(godID, "Kick request denied"); | 224 | m_scene.ForEachRootScenePresence( |
225 | delegate(ScenePresence p) | ||
226 | { | ||
227 | if (p.UUID != godID && (!m_scene.Permissions.IsGod(p.UUID))) | ||
228 | KickPresence(p, Utils.BytesToString(reason)); | ||
229 | } | ||
230 | ); | ||
179 | } | 231 | } |
232 | break; | ||
233 | case 1: | ||
234 | if (sp != null) | ||
235 | { | ||
236 | sp.AllowMovement = false; | ||
237 | m_dialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason)); | ||
238 | m_dialogModule.SendAlertToUser(godID, "User Frozen"); | ||
239 | } | ||
240 | break; | ||
241 | case 2: | ||
242 | if (sp != null) | ||
243 | { | ||
244 | sp.AllowMovement = true; | ||
245 | m_dialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason)); | ||
246 | m_dialogModule.SendAlertToUser(godID, "User Unfrozen"); | ||
247 | } | ||
248 | break; | ||
249 | default: | ||
250 | break; | ||
251 | } | ||
252 | } | ||
253 | |||
254 | private void KickPresence(ScenePresence sp, string reason) | ||
255 | { | ||
256 | if (sp.IsChildAgent) | ||
257 | return; | ||
258 | sp.ControllingClient.Kick(reason); | ||
259 | sp.Scene.IncomingCloseAgent(sp.UUID); | ||
260 | } | ||
261 | |||
262 | private void OnIncomingInstantMessage(GridInstantMessage msg) | ||
263 | { | ||
264 | if (msg.dialog == (uint)250) // Nonlocal kick | ||
265 | { | ||
266 | UUID agentID = new UUID(msg.toAgentID); | ||
267 | string reason = msg.message; | ||
268 | UUID godID = new UUID(msg.fromAgentID); | ||
269 | uint kickMode = (uint)msg.binaryBucket[0]; | ||
270 | |||
271 | KickUser(godID, UUID.Zero, agentID, kickMode, Util.StringToBytes1024(reason)); | ||
180 | } | 272 | } |
181 | } | 273 | } |
182 | } | 274 | } |
183 | } \ No newline at end of file | 275 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs index ca5d485..727f1c9 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | using System; | 27 | using System; |
28 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
29 | using System.Reflection; | 29 | using System.Reflection; |
30 | using System.Timers; | ||
30 | using log4net; | 31 | using log4net; |
31 | using Nini.Config; | 32 | using Nini.Config; |
32 | using OpenMetaverse; | 33 | using OpenMetaverse; |
@@ -42,6 +43,10 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
42 | private static readonly ILog m_log = LogManager.GetLogger( | 43 | private static readonly ILog m_log = LogManager.GetLogger( |
43 | MethodBase.GetCurrentMethod().DeclaringType); | 44 | MethodBase.GetCurrentMethod().DeclaringType); |
44 | 45 | ||
46 | private Timer m_logTimer = new Timer(10000); | ||
47 | private List<GridInstantMessage> m_logData = new List<GridInstantMessage>(); | ||
48 | private string m_restUrl; | ||
49 | |||
45 | /// <value> | 50 | /// <value> |
46 | /// Is this module enabled? | 51 | /// Is this module enabled? |
47 | /// </value> | 52 | /// </value> |
@@ -61,9 +66,12 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
61 | "InstantMessageModule", "InstantMessageModule") != | 66 | "InstantMessageModule", "InstantMessageModule") != |
62 | "InstantMessageModule") | 67 | "InstantMessageModule") |
63 | return; | 68 | return; |
69 | m_restUrl = config.Configs["Messaging"].GetString("LogURL", String.Empty); | ||
64 | } | 70 | } |
65 | 71 | ||
66 | m_enabled = true; | 72 | m_enabled = true; |
73 | m_logTimer.AutoReset = false; | ||
74 | m_logTimer.Elapsed += LogTimerElapsed; | ||
67 | } | 75 | } |
68 | 76 | ||
69 | public void AddRegion(Scene scene) | 77 | public void AddRegion(Scene scene) |
@@ -148,6 +156,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
148 | { | 156 | { |
149 | byte dialog = im.dialog; | 157 | byte dialog = im.dialog; |
150 | 158 | ||
159 | if (client != null && dialog == (byte)InstantMessageDialog.MessageFromAgent) | ||
160 | LogInstantMesssage(im); | ||
161 | |||
151 | if (dialog != (byte)InstantMessageDialog.MessageFromAgent | 162 | if (dialog != (byte)InstantMessageDialog.MessageFromAgent |
152 | && dialog != (byte)InstantMessageDialog.StartTyping | 163 | && dialog != (byte)InstantMessageDialog.StartTyping |
153 | && dialog != (byte)InstantMessageDialog.StopTyping | 164 | && dialog != (byte)InstantMessageDialog.StopTyping |
@@ -157,6 +168,32 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
157 | return; | 168 | return; |
158 | } | 169 | } |
159 | 170 | ||
171 | //DateTime dt = DateTime.UtcNow; | ||
172 | |||
173 | // Ticks from UtcNow, but make it look like local. Evil, huh? | ||
174 | //dt = DateTime.SpecifyKind(dt, DateTimeKind.Local); | ||
175 | |||
176 | //try | ||
177 | //{ | ||
178 | // // Convert that to the PST timezone | ||
179 | // TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById("America/Los_Angeles"); | ||
180 | // dt = TimeZoneInfo.ConvertTime(dt, timeZoneInfo); | ||
181 | //} | ||
182 | //catch | ||
183 | //{ | ||
184 | // //m_log.Info("[OFFLINE MESSAGING]: No PST timezone found on this machine. Saving with local timestamp."); | ||
185 | //} | ||
186 | |||
187 | //// And make it look local again to fool the unix time util | ||
188 | //dt = DateTime.SpecifyKind(dt, DateTimeKind.Utc); | ||
189 | |||
190 | // If client is null, this message comes from storage and IS offline | ||
191 | if (client != null) | ||
192 | im.offline = 0; | ||
193 | |||
194 | if (im.offline == 0) | ||
195 | im.timestamp = (uint)Util.UnixTimeSinceEpoch(); | ||
196 | |||
160 | if (m_TransferModule != null) | 197 | if (m_TransferModule != null) |
161 | { | 198 | { |
162 | if (client != null) | 199 | if (client != null) |
@@ -200,5 +237,35 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
200 | // | 237 | // |
201 | OnInstantMessage(null, msg); | 238 | OnInstantMessage(null, msg); |
202 | } | 239 | } |
240 | |||
241 | private void LogInstantMesssage(GridInstantMessage im) | ||
242 | { | ||
243 | if (m_logData.Count < 20) | ||
244 | { | ||
245 | // Restart the log write timer | ||
246 | m_logTimer.Stop(); | ||
247 | } | ||
248 | if (!m_logTimer.Enabled) | ||
249 | m_logTimer.Start(); | ||
250 | |||
251 | lock (m_logData) | ||
252 | { | ||
253 | m_logData.Add(im); | ||
254 | } | ||
255 | } | ||
256 | |||
257 | private void LogTimerElapsed(object source, ElapsedEventArgs e) | ||
258 | { | ||
259 | lock (m_logData) | ||
260 | { | ||
261 | if (m_restUrl != String.Empty && m_logData.Count > 0) | ||
262 | { | ||
263 | bool success = SynchronousRestObjectRequester.MakeRequest<List<GridInstantMessage>, bool>("POST", m_restUrl + "/LogMessages/", m_logData); | ||
264 | if (!success) | ||
265 | m_log.ErrorFormat("[INSTANT MESSAGE]: Failed to save log data"); | ||
266 | } | ||
267 | m_logData.Clear(); | ||
268 | } | ||
269 | } | ||
203 | } | 270 | } |
204 | } | 271 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs index 596174b..1406aae 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs | |||
@@ -48,6 +48,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
49 | 49 | ||
50 | private bool m_Enabled = false; | 50 | private bool m_Enabled = false; |
51 | protected string m_MessageKey = String.Empty; | ||
51 | protected List<Scene> m_Scenes = new List<Scene>(); | 52 | protected List<Scene> m_Scenes = new List<Scene>(); |
52 | protected Dictionary<UUID, UUID> m_UserRegionMap = new Dictionary<UUID, UUID>(); | 53 | protected Dictionary<UUID, UUID> m_UserRegionMap = new Dictionary<UUID, UUID>(); |
53 | 54 | ||
@@ -67,14 +68,17 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
67 | public virtual void Initialise(IConfigSource config) | 68 | public virtual void Initialise(IConfigSource config) |
68 | { | 69 | { |
69 | IConfig cnf = config.Configs["Messaging"]; | 70 | IConfig cnf = config.Configs["Messaging"]; |
70 | if (cnf != null && cnf.GetString( | 71 | if (cnf != null) |
71 | "MessageTransferModule", "MessageTransferModule") != | ||
72 | "MessageTransferModule") | ||
73 | { | 72 | { |
74 | m_log.Debug("[MESSAGE TRANSFER]: Disabled by configuration"); | 73 | if (cnf.GetString("MessageTransferModule", |
75 | return; | 74 | "MessageTransferModule") != "MessageTransferModule") |
76 | } | 75 | { |
76 | return; | ||
77 | } | ||
77 | 78 | ||
79 | m_MessageKey = cnf.GetString("MessageKey", String.Empty); | ||
80 | } | ||
81 | m_log.Debug("[MESSAGE TRANSFER]: Module enabled"); | ||
78 | m_Enabled = true; | 82 | m_Enabled = true; |
79 | } | 83 | } |
80 | 84 | ||
@@ -247,6 +251,19 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
247 | && requestData.ContainsKey("position_z") && requestData.ContainsKey("region_id") | 251 | && requestData.ContainsKey("position_z") && requestData.ContainsKey("region_id") |
248 | && requestData.ContainsKey("binary_bucket")) | 252 | && requestData.ContainsKey("binary_bucket")) |
249 | { | 253 | { |
254 | if (m_MessageKey != String.Empty) | ||
255 | { | ||
256 | XmlRpcResponse error_resp = new XmlRpcResponse(); | ||
257 | Hashtable error_respdata = new Hashtable(); | ||
258 | error_respdata["success"] = "FALSE"; | ||
259 | error_resp.Value = error_respdata; | ||
260 | |||
261 | if (!requestData.Contains("message_key")) | ||
262 | return error_resp; | ||
263 | if (m_MessageKey != (string)requestData["message_key"]) | ||
264 | return error_resp; | ||
265 | } | ||
266 | |||
250 | // Do the easy way of validating the UUIDs | 267 | // Do the easy way of validating the UUIDs |
251 | UUID.TryParse((string)requestData["from_agent_id"], out fromAgentID); | 268 | UUID.TryParse((string)requestData["from_agent_id"], out fromAgentID); |
252 | UUID.TryParse((string)requestData["to_agent_id"], out toAgentID); | 269 | UUID.TryParse((string)requestData["to_agent_id"], out toAgentID); |
@@ -423,24 +440,37 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
423 | return resp; | 440 | return resp; |
424 | } | 441 | } |
425 | 442 | ||
426 | /// <summary> | 443 | private delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result); |
427 | /// delegate for sending a grid instant message asynchronously | ||
428 | /// </summary> | ||
429 | public delegate void GridInstantMessageDelegate(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID); | ||
430 | 444 | ||
431 | protected virtual void GridInstantMessageCompleted(IAsyncResult iar) | 445 | private class GIM { |
432 | { | 446 | public GridInstantMessage im; |
433 | GridInstantMessageDelegate icon = | 447 | public MessageResultNotification result; |
434 | (GridInstantMessageDelegate)iar.AsyncState; | 448 | }; |
435 | icon.EndInvoke(iar); | ||
436 | } | ||
437 | 449 | ||
450 | private Queue<GIM> pendingInstantMessages = new Queue<GIM>(); | ||
451 | private int numInstantMessageThreads = 0; | ||
438 | 452 | ||
439 | protected virtual void SendGridInstantMessageViaXMLRPC(GridInstantMessage im, MessageResultNotification result) | 453 | private void SendGridInstantMessageViaXMLRPC(GridInstantMessage im, MessageResultNotification result) |
440 | { | 454 | { |
441 | GridInstantMessageDelegate d = SendGridInstantMessageViaXMLRPCAsync; | 455 | lock (pendingInstantMessages) { |
456 | if (numInstantMessageThreads >= 4) { | ||
457 | GIM gim = new GIM(); | ||
458 | gim.im = im; | ||
459 | gim.result = result; | ||
460 | pendingInstantMessages.Enqueue(gim); | ||
461 | } else { | ||
462 | ++ numInstantMessageThreads; | ||
463 | //m_log.DebugFormat("[SendGridInstantMessageViaXMLRPC]: ++numInstantMessageThreads={0}", numInstantMessageThreads); | ||
464 | GridInstantMessageDelegate d = SendGridInstantMessageViaXMLRPCAsyncMain; | ||
465 | d.BeginInvoke(im, result, GridInstantMessageCompleted, d); | ||
466 | } | ||
467 | } | ||
468 | } | ||
442 | 469 | ||
443 | d.BeginInvoke(im, result, UUID.Zero, GridInstantMessageCompleted, d); | 470 | private void GridInstantMessageCompleted(IAsyncResult iar) |
471 | { | ||
472 | GridInstantMessageDelegate d = (GridInstantMessageDelegate)iar.AsyncState; | ||
473 | d.EndInvoke(iar); | ||
444 | } | 474 | } |
445 | 475 | ||
446 | /// <summary> | 476 | /// <summary> |
@@ -455,8 +485,31 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
455 | /// Pass in 0 the first time this method is called. It will be called recursively with the last | 485 | /// Pass in 0 the first time this method is called. It will be called recursively with the last |
456 | /// regionhandle tried | 486 | /// regionhandle tried |
457 | /// </param> | 487 | /// </param> |
458 | protected virtual void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID) | 488 | private void SendGridInstantMessageViaXMLRPCAsyncMain(GridInstantMessage im, MessageResultNotification result) |
459 | { | 489 | { |
490 | GIM gim; | ||
491 | do { | ||
492 | try { | ||
493 | SendGridInstantMessageViaXMLRPCAsync(im, result, UUID.Zero); | ||
494 | } catch (Exception e) { | ||
495 | m_log.Error("[SendGridInstantMessageViaXMLRPC]: exception " + e.Message); | ||
496 | } | ||
497 | lock (pendingInstantMessages) { | ||
498 | if (pendingInstantMessages.Count > 0) { | ||
499 | gim = pendingInstantMessages.Dequeue(); | ||
500 | im = gim.im; | ||
501 | result = gim.result; | ||
502 | } else { | ||
503 | gim = null; | ||
504 | -- numInstantMessageThreads; | ||
505 | //m_log.DebugFormat("[SendGridInstantMessageViaXMLRPC]: --numInstantMessageThreads={0}", numInstantMessageThreads); | ||
506 | } | ||
507 | } | ||
508 | } while (gim != null); | ||
509 | } | ||
510 | private void SendGridInstantMessageViaXMLRPCAsync(GridInstantMessage im, MessageResultNotification result, UUID prevRegionID) | ||
511 | { | ||
512 | |||
460 | UUID toAgentID = new UUID(im.toAgentID); | 513 | UUID toAgentID = new UUID(im.toAgentID); |
461 | 514 | ||
462 | PresenceInfo upd = null; | 515 | PresenceInfo upd = null; |
@@ -523,7 +576,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
523 | 576 | ||
524 | if (upd != null) | 577 | if (upd != null) |
525 | { | 578 | { |
526 | GridRegion reginfo = m_Scenes[0].GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, | 579 | GridRegion reginfo = m_Scenes[0].GridService.GetRegionByUUID(UUID.Zero, |
527 | upd.RegionID); | 580 | upd.RegionID); |
528 | if (reginfo != null) | 581 | if (reginfo != null) |
529 | { | 582 | { |
@@ -672,6 +725,8 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
672 | gim["position_z"] = msg.Position.Z.ToString(); | 725 | gim["position_z"] = msg.Position.Z.ToString(); |
673 | gim["region_id"] = msg.RegionID.ToString(); | 726 | gim["region_id"] = msg.RegionID.ToString(); |
674 | gim["binary_bucket"] = Convert.ToBase64String(msg.binaryBucket,Base64FormattingOptions.None); | 727 | gim["binary_bucket"] = Convert.ToBase64String(msg.binaryBucket,Base64FormattingOptions.None); |
728 | if (m_MessageKey != String.Empty) | ||
729 | gim["message_key"] = m_MessageKey; | ||
675 | return gim; | 730 | return gim; |
676 | } | 731 | } |
677 | 732 | ||
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs index de25048..b27b07d 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs | |||
@@ -171,7 +171,11 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
171 | 171 | ||
172 | private void RetrieveInstantMessages(IClientAPI client) | 172 | private void RetrieveInstantMessages(IClientAPI client) |
173 | { | 173 | { |
174 | if (m_RestURL != "") | 174 | if (m_RestURL == String.Empty) |
175 | { | ||
176 | return; | ||
177 | } | ||
178 | else | ||
175 | { | 179 | { |
176 | m_log.DebugFormat("[OFFLINE MESSAGING]: Retrieving stored messages for {0}", client.AgentId); | 180 | m_log.DebugFormat("[OFFLINE MESSAGING]: Retrieving stored messages for {0}", client.AgentId); |
177 | 181 | ||
@@ -179,22 +183,25 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
179 | = SynchronousRestObjectRequester.MakeRequest<UUID, List<GridInstantMessage>>( | 183 | = SynchronousRestObjectRequester.MakeRequest<UUID, List<GridInstantMessage>>( |
180 | "POST", m_RestURL + "/RetrieveMessages/", client.AgentId); | 184 | "POST", m_RestURL + "/RetrieveMessages/", client.AgentId); |
181 | 185 | ||
182 | if (msglist == null) | 186 | if (msglist != null) |
183 | m_log.WarnFormat("[OFFLINE MESSAGING]: WARNING null message list."); | ||
184 | |||
185 | foreach (GridInstantMessage im in msglist) | ||
186 | { | 187 | { |
187 | // client.SendInstantMessage(im); | 188 | foreach (GridInstantMessage im in msglist) |
188 | 189 | { | |
189 | // Send through scene event manager so all modules get a chance | 190 | // client.SendInstantMessage(im); |
190 | // to look at this message before it gets delivered. | 191 | |
191 | // | 192 | // Send through scene event manager so all modules get a chance |
192 | // Needed for proper state management for stored group | 193 | // to look at this message before it gets delivered. |
193 | // invitations | 194 | // |
194 | // | 195 | // Needed for proper state management for stored group |
195 | Scene s = FindScene(client.AgentId); | 196 | // invitations |
196 | if (s != null) | 197 | // |
197 | s.EventManager.TriggerIncomingInstantMessage(im); | 198 | |
199 | im.offline = 1; | ||
200 | |||
201 | Scene s = FindScene(client.AgentId); | ||
202 | if (s != null) | ||
203 | s.EventManager.TriggerIncomingInstantMessage(im); | ||
204 | } | ||
198 | } | 205 | } |
199 | } | 206 | } |
200 | } | 207 | } |
@@ -205,24 +212,19 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
205 | im.dialog != (byte)InstantMessageDialog.MessageFromAgent && | 212 | im.dialog != (byte)InstantMessageDialog.MessageFromAgent && |
206 | im.dialog != (byte)InstantMessageDialog.GroupNotice && | 213 | im.dialog != (byte)InstantMessageDialog.GroupNotice && |
207 | im.dialog != (byte)InstantMessageDialog.GroupInvitation && | 214 | im.dialog != (byte)InstantMessageDialog.GroupInvitation && |
208 | im.dialog != (byte)InstantMessageDialog.InventoryOffered) | 215 | im.dialog != (byte)InstantMessageDialog.InventoryOffered && |
216 | im.dialog != (byte)InstantMessageDialog.TaskInventoryOffered) | ||
209 | { | 217 | { |
210 | return; | 218 | return; |
211 | } | 219 | } |
212 | 220 | ||
213 | if (!m_ForwardOfflineGroupMessages) | ||
214 | { | ||
215 | if (im.dialog == (byte)InstantMessageDialog.GroupNotice || | ||
216 | im.dialog != (byte)InstantMessageDialog.GroupInvitation) | ||
217 | return; | ||
218 | } | ||
219 | |||
220 | Scene scene = FindScene(new UUID(im.fromAgentID)); | 221 | Scene scene = FindScene(new UUID(im.fromAgentID)); |
221 | if (scene == null) | 222 | if (scene == null) |
222 | scene = m_SceneList[0]; | 223 | scene = m_SceneList[0]; |
223 | 224 | ||
224 | bool success = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, bool>( | 225 | bool success = SynchronousRestObjectRequester.MakeRequest<GridInstantMessage, bool>( |
225 | "POST", m_RestURL+"/SaveMessage/", im); | 226 | "POST", m_RestURL+"/SaveMessage/?scope=" + |
227 | scene.RegionInfo.ScopeID.ToString(), im); | ||
226 | 228 | ||
227 | if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent) | 229 | if (im.dialog == (byte)InstantMessageDialog.MessageFromAgent) |
228 | { | 230 | { |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index ee10d04..0833154 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | |||
@@ -635,4 +635,4 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
635 | m_assetsLoaded = true; | 635 | m_assetsLoaded = true; |
636 | } | 636 | } |
637 | } | 637 | } |
638 | } \ No newline at end of file | 638 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index cf87010..7d1fe68 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs | |||
@@ -492,6 +492,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
492 | return null; | 492 | return null; |
493 | } | 493 | } |
494 | 494 | ||
495 | return account; | ||
496 | /* | ||
495 | try | 497 | try |
496 | { | 498 | { |
497 | string encpass = Util.Md5Hash(pass); | 499 | string encpass = Util.Md5Hash(pass); |
@@ -512,6 +514,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
512 | m_log.ErrorFormat("[INVENTORY ARCHIVER]: Could not authenticate password, {0}", e.Message); | 514 | m_log.ErrorFormat("[INVENTORY ARCHIVER]: Could not authenticate password, {0}", e.Message); |
513 | return null; | 515 | return null; |
514 | } | 516 | } |
517 | */ | ||
515 | } | 518 | } |
516 | 519 | ||
517 | /// <summary> | 520 | /// <summary> |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs index f3af59a..81de29c 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs | |||
@@ -175,8 +175,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
175 | if (im.binaryBucket.Length < 17) // Invalid | 175 | if (im.binaryBucket.Length < 17) // Invalid |
176 | return; | 176 | return; |
177 | 177 | ||
178 | UUID receipientID = new UUID(im.toAgentID); | 178 | UUID recipientID = new UUID(im.toAgentID); |
179 | ScenePresence user = scene.GetScenePresence(receipientID); | 179 | ScenePresence user = scene.GetScenePresence(recipientID); |
180 | UUID copyID; | 180 | UUID copyID; |
181 | 181 | ||
182 | // First byte is the asset type | 182 | // First byte is the asset type |
@@ -191,7 +191,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
191 | folderID, new UUID(im.toAgentID)); | 191 | folderID, new UUID(im.toAgentID)); |
192 | 192 | ||
193 | InventoryFolderBase folderCopy | 193 | InventoryFolderBase folderCopy |
194 | = scene.GiveInventoryFolder(receipientID, client.AgentId, folderID, UUID.Zero); | 194 | = scene.GiveInventoryFolder(recipientID, client.AgentId, folderID, UUID.Zero); |
195 | 195 | ||
196 | if (folderCopy == null) | 196 | if (folderCopy == null) |
197 | { | 197 | { |
@@ -244,6 +244,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
244 | im.imSessionID = itemID.Guid; | 244 | im.imSessionID = itemID.Guid; |
245 | } | 245 | } |
246 | 246 | ||
247 | im.offline = 0; | ||
248 | |||
247 | // Send the IM to the recipient. The item is already | 249 | // Send the IM to the recipient. The item is already |
248 | // in their inventory, so it will not be lost if | 250 | // in their inventory, so it will not be lost if |
249 | // they are offline. | 251 | // they are offline. |
@@ -263,8 +265,42 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
263 | }); | 265 | }); |
264 | } | 266 | } |
265 | } | 267 | } |
266 | else if (im.dialog == (byte) InstantMessageDialog.InventoryAccepted) | 268 | else if (im.dialog == (byte) InstantMessageDialog.InventoryAccepted || |
269 | im.dialog == (byte) InstantMessageDialog.TaskInventoryAccepted) | ||
267 | { | 270 | { |
271 | UUID inventoryID = new UUID(im.imSessionID); // The inventory item/folder, back from it's trip | ||
272 | IInventoryService invService = scene.InventoryService; | ||
273 | |||
274 | // Special case: folder redirect. | ||
275 | // RLV uses this | ||
276 | if (im.dialog == (byte) InstantMessageDialog.TaskInventoryAccepted) | ||
277 | { | ||
278 | InventoryFolderBase folder = new InventoryFolderBase(inventoryID, client.AgentId); | ||
279 | folder = invService.GetFolder(folder); | ||
280 | |||
281 | if (folder != null) | ||
282 | { | ||
283 | if (im.binaryBucket.Length >= 16) | ||
284 | { | ||
285 | UUID destFolderID = new UUID(im.binaryBucket, 0); | ||
286 | if (destFolderID != UUID.Zero) | ||
287 | { | ||
288 | InventoryFolderBase destFolder = new InventoryFolderBase(destFolderID, client.AgentId); | ||
289 | destFolder = invService.GetFolder(destFolder); | ||
290 | if (destFolder != null) | ||
291 | { | ||
292 | if (folder.ParentID != destFolder.ID) | ||
293 | { | ||
294 | folder.ParentID = destFolder.ID; | ||
295 | invService.MoveFolder(folder); | ||
296 | client.SendBulkUpdateInventory(folder); | ||
297 | } | ||
298 | } | ||
299 | } | ||
300 | } | ||
301 | } | ||
302 | } | ||
303 | |||
268 | ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID)); | 304 | ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID)); |
269 | 305 | ||
270 | if (user != null) // Local | 306 | if (user != null) // Local |
@@ -274,27 +310,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
274 | else | 310 | else |
275 | { | 311 | { |
276 | if (m_TransferModule != null) | 312 | if (m_TransferModule != null) |
277 | m_TransferModule.SendInstantMessage(im, delegate(bool success) { | 313 | m_TransferModule.SendInstantMessage(im, delegate(bool success) {}); |
278 | |||
279 | // justincc - FIXME: Comment out for now. This code was added in commit db91044 Mon Aug 22 2011 | ||
280 | // and is apparently supposed to fix bulk inventory updates after accepting items. But | ||
281 | // instead it appears to cause two copies of an accepted folder for the receiving user in | ||
282 | // at least some cases. Folder/item update is already done when the offer is made (see code above) | ||
283 | |||
284 | // // Send BulkUpdateInventory | ||
285 | // IInventoryService invService = scene.InventoryService; | ||
286 | // UUID inventoryEntityID = new UUID(im.imSessionID); // The inventory item /folder, back from it's trip | ||
287 | // | ||
288 | // InventoryFolderBase folder = new InventoryFolderBase(inventoryEntityID, client.AgentId); | ||
289 | // folder = invService.GetFolder(folder); | ||
290 | // | ||
291 | // ScenePresence fromUser = scene.GetScenePresence(new UUID(im.fromAgentID)); | ||
292 | // | ||
293 | // // If the user has left the scene by the time the message comes back then we can't send | ||
294 | // // them the update. | ||
295 | // if (fromUser != null) | ||
296 | // fromUser.ControllingClient.SendBulkUpdateInventory(folder); | ||
297 | }); | ||
298 | } | 314 | } |
299 | } | 315 | } |
300 | else if ( | 316 | else if ( |
@@ -335,6 +351,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
335 | { | 351 | { |
336 | folder.ParentID = trashFolder.ID; | 352 | folder.ParentID = trashFolder.ID; |
337 | invService.MoveFolder(folder); | 353 | invService.MoveFolder(folder); |
354 | client.SendBulkUpdateInventory(folder); | ||
338 | } | 355 | } |
339 | } | 356 | } |
340 | 357 | ||
@@ -435,22 +452,113 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
435 | /// | 452 | /// |
436 | /// </summary> | 453 | /// </summary> |
437 | /// <param name="msg"></param> | 454 | /// <param name="msg"></param> |
438 | private void OnGridInstantMessage(GridInstantMessage msg) | 455 | private void OnGridInstantMessage(GridInstantMessage im) |
439 | { | 456 | { |
440 | // Check if this is ours to handle | 457 | // Check if this is ours to handle |
441 | // | 458 | // |
442 | Scene scene = FindClientScene(new UUID(msg.toAgentID)); | 459 | Scene scene = FindClientScene(new UUID(im.toAgentID)); |
443 | 460 | ||
444 | if (scene == null) | 461 | if (scene == null) |
445 | return; | 462 | return; |
446 | 463 | ||
447 | // Find agent to deliver to | 464 | // Find agent to deliver to |
448 | // | 465 | // |
449 | ScenePresence user = scene.GetScenePresence(new UUID(msg.toAgentID)); | 466 | ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID)); |
467 | if (user == null) | ||
468 | return; | ||
469 | |||
470 | // This requires a little bit of processing because we have to make the | ||
471 | // new item visible in the recipient's inventory here | ||
472 | // | ||
473 | if (im.dialog == (byte) InstantMessageDialog.InventoryOffered) | ||
474 | { | ||
475 | if (im.binaryBucket.Length < 17) // Invalid | ||
476 | return; | ||
477 | |||
478 | UUID recipientID = new UUID(im.toAgentID); | ||
479 | |||
480 | // First byte is the asset type | ||
481 | AssetType assetType = (AssetType)im.binaryBucket[0]; | ||
482 | |||
483 | if (AssetType.Folder == assetType) | ||
484 | { | ||
485 | UUID folderID = new UUID(im.binaryBucket, 1); | ||
450 | 486 | ||
451 | // Just forward to local handling | 487 | InventoryFolderBase given = |
452 | OnInstantMessage(user.ControllingClient, msg); | 488 | new InventoryFolderBase(folderID, recipientID); |
489 | InventoryFolderBase folder = | ||
490 | scene.InventoryService.GetFolder(given); | ||
453 | 491 | ||
492 | if (folder != null) | ||
493 | user.ControllingClient.SendBulkUpdateInventory(folder); | ||
494 | } | ||
495 | else | ||
496 | { | ||
497 | UUID itemID = new UUID(im.binaryBucket, 1); | ||
498 | |||
499 | InventoryItemBase given = | ||
500 | new InventoryItemBase(itemID, recipientID); | ||
501 | InventoryItemBase item = | ||
502 | scene.InventoryService.GetItem(given); | ||
503 | |||
504 | if (item != null) | ||
505 | { | ||
506 | user.ControllingClient.SendBulkUpdateInventory(item); | ||
507 | } | ||
508 | } | ||
509 | user.ControllingClient.SendInstantMessage(im); | ||
510 | } | ||
511 | if (im.dialog == (byte) InstantMessageDialog.TaskInventoryOffered) | ||
512 | { | ||
513 | if (im.binaryBucket.Length < 1) // Invalid | ||
514 | return; | ||
515 | |||
516 | UUID recipientID = new UUID(im.toAgentID); | ||
517 | |||
518 | // Bucket is the asset type | ||
519 | AssetType assetType = (AssetType)im.binaryBucket[0]; | ||
520 | |||
521 | if (AssetType.Folder == assetType) | ||
522 | { | ||
523 | UUID folderID = new UUID(im.imSessionID); | ||
524 | |||
525 | InventoryFolderBase given = | ||
526 | new InventoryFolderBase(folderID, recipientID); | ||
527 | InventoryFolderBase folder = | ||
528 | scene.InventoryService.GetFolder(given); | ||
529 | |||
530 | if (folder != null) | ||
531 | user.ControllingClient.SendBulkUpdateInventory(folder); | ||
532 | } | ||
533 | else | ||
534 | { | ||
535 | UUID itemID = new UUID(im.imSessionID); | ||
536 | |||
537 | InventoryItemBase given = | ||
538 | new InventoryItemBase(itemID, recipientID); | ||
539 | InventoryItemBase item = | ||
540 | scene.InventoryService.GetItem(given); | ||
541 | |||
542 | if (item != null) | ||
543 | { | ||
544 | user.ControllingClient.SendBulkUpdateInventory(item); | ||
545 | } | ||
546 | } | ||
547 | |||
548 | // Fix up binary bucket since this may be 17 chars long here | ||
549 | Byte[] bucket = new Byte[1]; | ||
550 | bucket[0] = im.binaryBucket[0]; | ||
551 | im.binaryBucket = bucket; | ||
552 | |||
553 | user.ControllingClient.SendInstantMessage(im); | ||
554 | } | ||
555 | else if (im.dialog == (byte) InstantMessageDialog.InventoryAccepted || | ||
556 | im.dialog == (byte) InstantMessageDialog.InventoryDeclined || | ||
557 | im.dialog == (byte) InstantMessageDialog.TaskInventoryDeclined || | ||
558 | im.dialog == (byte) InstantMessageDialog.TaskInventoryAccepted) | ||
559 | { | ||
560 | user.ControllingClient.SendInstantMessage(im); | ||
561 | } | ||
454 | } | 562 | } |
455 | } | 563 | } |
456 | } | 564 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs index 2d4cffd..a889984 100644 --- a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs | |||
@@ -161,16 +161,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure | |||
161 | scene.RegionInfo.RegionHandle, | 161 | scene.RegionInfo.RegionHandle, |
162 | (uint)presence.AbsolutePosition.X, | 162 | (uint)presence.AbsolutePosition.X, |
163 | (uint)presence.AbsolutePosition.Y, | 163 | (uint)presence.AbsolutePosition.Y, |
164 | (uint)Math.Ceiling(presence.AbsolutePosition.Z)); | 164 | (uint)presence.AbsolutePosition.Z + 2); |
165 | 165 | ||
166 | m_log.DebugFormat("TP invite with message {0}", message); | 166 | m_log.DebugFormat("[LURE]: TP invite with message {0}", message); |
167 | |||
168 | GridInstantMessage m; | ||
169 | |||
170 | if (scene.Permissions.IsAdministrator(client.AgentId) && presence.GodLevel >= 200 && (!scene.Permissions.IsAdministrator(targetid))) | ||
171 | { | ||
172 | m = new GridInstantMessage(scene, client.AgentId, | ||
173 | client.FirstName+" "+client.LastName, targetid, | ||
174 | (byte)InstantMessageDialog.GodLikeRequestTeleport, false, | ||
175 | message, dest, false, presence.AbsolutePosition, | ||
176 | new Byte[0]); | ||
177 | } | ||
178 | else | ||
179 | { | ||
180 | m = new GridInstantMessage(scene, client.AgentId, | ||
181 | client.FirstName+" "+client.LastName, targetid, | ||
182 | (byte)InstantMessageDialog.RequestTeleport, false, | ||
183 | message, dest, false, presence.AbsolutePosition, | ||
184 | new Byte[0]); | ||
185 | } | ||
167 | 186 | ||
168 | GridInstantMessage m = new GridInstantMessage(scene, client.AgentId, | ||
169 | client.FirstName+" "+client.LastName, targetid, | ||
170 | (byte)InstantMessageDialog.RequestTeleport, false, | ||
171 | message, dest, false, presence.AbsolutePosition, | ||
172 | new Byte[0]); | ||
173 | |||
174 | if (m_TransferModule != null) | 187 | if (m_TransferModule != null) |
175 | { | 188 | { |
176 | m_TransferModule.SendInstantMessage(m, | 189 | m_TransferModule.SendInstantMessage(m, |
@@ -205,7 +218,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Lure | |||
205 | { | 218 | { |
206 | // Forward remote teleport requests | 219 | // Forward remote teleport requests |
207 | // | 220 | // |
208 | if (msg.dialog != 22) | 221 | if (msg.dialog != (byte)InstantMessageDialog.RequestTeleport && |
222 | msg.dialog != (byte)InstantMessageDialog.GodLikeRequestTeleport) | ||
209 | return; | 223 | return; |
210 | 224 | ||
211 | if (m_TransferModule != null) | 225 | if (m_TransferModule != null) |