diff --git a/OpenSim/Framework/ChildAgentDataUpdate.cs b/OpenSim/Framework/ChildAgentDataUpdate.cs index 89ee39cecc..0dc5dbc292 100644 --- a/OpenSim/Framework/ChildAgentDataUpdate.cs +++ b/OpenSim/Framework/ChildAgentDataUpdate.cs @@ -150,10 +150,10 @@ namespace OpenSim.Framework Vector3.TryParse(args["at_axis"].AsString(), out AtAxis); if (args["left_axis"] != null) - Vector3.TryParse(args["left_axis"].AsString(), out AtAxis); + Vector3.TryParse(args["left_axis"].AsString(), out LeftAxis); if (args["up_axis"] != null) - Vector3.TryParse(args["up_axis"].AsString(), out AtAxis); + Vector3.TryParse(args["up_axis"].AsString(), out UpAxis); if (args["changed_grid"] != null) ChangedGrid = args["changed_grid"].AsBoolean(); diff --git a/OpenSim/Framework/Console/RemoteConsole.cs b/OpenSim/Framework/Console/RemoteConsole.cs index c038aaca5c..7eb289ba72 100644 --- a/OpenSim/Framework/Console/RemoteConsole.cs +++ b/OpenSim/Framework/Console/RemoteConsole.cs @@ -288,7 +288,7 @@ namespace OpenSim.Framework.Console reply["str_response_string"] = xmldoc.InnerXml; reply["int_response_code"] = 200; - reply["content_type"] = "text/plain"; + reply["content_type"] = "text/xml"; return reply; } @@ -343,7 +343,7 @@ namespace OpenSim.Framework.Console reply["str_response_string"] = xmldoc.InnerXml; reply["int_response_code"] = 200; - reply["content_type"] = "text/plain"; + reply["content_type"] = "text/xml"; return reply; } diff --git a/OpenSim/Framework/MapAndArray.cs b/OpenSim/Framework/MapAndArray.cs index bbe6a9e28e..c98d3ccd6f 100644 --- a/OpenSim/Framework/MapAndArray.cs +++ b/OpenSim/Framework/MapAndArray.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -131,7 +131,8 @@ namespace OpenSim.Framework /// True if the key was found, otherwise false public bool ContainsKey(TKey key) { - return m_dict.ContainsKey(key); + lock (m_syncRoot) + return m_dict.ContainsKey(key); } /// diff --git a/OpenSim/Framework/Tests/AnimationTests.cs b/OpenSim/Framework/Tests/AnimationTests.cs new file mode 100644 index 0000000000..719ddce306 --- /dev/null +++ b/OpenSim/Framework/Tests/AnimationTests.cs @@ -0,0 +1,96 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Reflection; +using NUnit.Framework; +using NUnit.Framework.SyntaxHelpers; +using OpenMetaverse; +using OpenMetaverse.StructuredData; +using OpenSim.Framework; +using OpenSim.Tests.Common; +using OpenSim.Tests.Common.Mock; +using OpenSim.Tests.Common.Setup; +using Animation = OpenSim.Framework.Animation; + +namespace OpenSim.Framework.Tests +{ + [TestFixture] + public class AnimationTests + { + private Animation anim1 = null; + private Animation anim2 = null; + private UUID animUUID1 = UUID.Zero; + private UUID objUUID1 = UUID.Zero; + private UUID animUUID2 = UUID.Zero; + private UUID objUUID2 = UUID.Zero; + + [SetUp] + public void Setup() + { + animUUID1 = UUID.Random(); + animUUID2 = UUID.Random(); + objUUID1 = UUID.Random(); + objUUID2 = UUID.Random(); + + anim1 = new Animation(animUUID1, 1, objUUID1); + anim2 = new Animation(animUUID2, 1, objUUID2); + } + + [Test] + public void AnimationOSDTest() + { + Assert.That(anim1.AnimID==animUUID1 && anim1.ObjectID == objUUID1 && anim1.SequenceNum ==1, "The Animation Constructor didn't set the fields correctly"); + OSD updateMessage = anim1.PackUpdateMessage(); + Assert.That(updateMessage is OSDMap, "Packed UpdateMessage isn't an OSDMap"); + OSDMap updateMap = (OSDMap) updateMessage; + Assert.That(updateMap.ContainsKey("animation"), "Packed Message doesn't contain an animation element"); + Assert.That(updateMap.ContainsKey("object_id"), "Packed Message doesn't contain an object_id element"); + Assert.That(updateMap.ContainsKey("seq_num"), "Packed Message doesn't contain a seq_num element"); + Assert.That(updateMap["animation"].AsUUID() == animUUID1); + Assert.That(updateMap["object_id"].AsUUID() == objUUID1); + Assert.That(updateMap["seq_num"].AsInteger() == 1); + + Animation anim3 = new Animation(updateMap); + + Assert.That(anim3.ObjectID == anim1.ObjectID && anim3.AnimID == anim1.AnimID && anim3.SequenceNum == anim1.SequenceNum, "OSDMap Constructor failed to set the properties correctly."); + + anim3.UnpackUpdateMessage(anim2.PackUpdateMessage()); + + Assert.That(anim3.ObjectID == objUUID2 && anim3.AnimID == animUUID2 && anim3.SequenceNum == 1, "Animation.UnpackUpdateMessage failed to set the properties correctly."); + + Animation anim4 = new Animation(); + anim4.AnimID = anim2.AnimID; + anim4.ObjectID = anim2.ObjectID; + anim4.SequenceNum = anim2.SequenceNum; + + Assert.That(anim4.ObjectID == objUUID2 && anim4.AnimID == animUUID2 && anim4.SequenceNum == 1, "void constructor and manual field population failed to set the properties correctly."); + + + } + } +} \ No newline at end of file diff --git a/OpenSim/Framework/Tests/CacheTests.cs b/OpenSim/Framework/Tests/CacheTests.cs index 32c0c9510a..c3613e6410 100644 --- a/OpenSim/Framework/Tests/CacheTests.cs +++ b/OpenSim/Framework/Tests/CacheTests.cs @@ -40,6 +40,7 @@ namespace OpenSim.Framework.Tests public void Build() { cache = new Cache(); + cache = new Cache(CacheMedium.Memory,CacheStrategy.Aggressive,CacheFlags.AllowUpdate); cacheItemUUID = UUID.Random(); MemoryCacheItem cachedItem = new MemoryCacheItem(cacheItemUUID.ToString(),DateTime.Now + TimeSpan.FromDays(1)); byte[] foo = new byte[1]; @@ -68,23 +69,7 @@ namespace OpenSim.Framework.Tests Assert.That(citem == null, "Item should not be in Cache"); } - //NOTE: Test Case disabled until Cache is fixed - [Test] - public void TestTTLExpiredEntry() - { - UUID ImmediateExpiryUUID = UUID.Random(); - MemoryCacheItem cachedItem = new MemoryCacheItem(ImmediateExpiryUUID.ToString(), TimeSpan.FromDays(-1)); - byte[] foo = new byte[1]; - foo[0] = 1; - cachedItem.Store(foo); - cache.Store(cacheItemUUID.ToString(), cachedItem); - - cache.Get(cacheItemUUID.ToString()); - //object citem = cache.Get(cacheItemUUID.ToString()); - //Assert.That(citem == null, "Item should not be in Cache because the expiry time was before now"); - } - - //NOTE: Test Case disabled until Cache is fixed + [Test] public void ExpireItemManually() { @@ -94,10 +79,45 @@ namespace OpenSim.Framework.Tests foo[0] = 1; cachedItem.Store(foo); cache.Store(cacheItemUUID.ToString(), cachedItem); - cache.Invalidate(ImmediateExpiryUUID.ToString()); + cache.Invalidate(cacheItemUUID.ToString()); cache.Get(cacheItemUUID.ToString()); - //object citem = cache.Get(cacheItemUUID.ToString()); - //Assert.That(citem == null, "Item should not be in Cache because we manually invalidated it"); + object citem = cache.Get(cacheItemUUID.ToString()); + Assert.That(citem == null, "Item should not be in Cache because we manually invalidated it"); + } + + [Test] + public void ClearCacheTest() + { + UUID ImmediateExpiryUUID = UUID.Random(); + MemoryCacheItem cachedItem = new MemoryCacheItem(ImmediateExpiryUUID.ToString(), DateTime.Now - TimeSpan.FromDays(1)); + byte[] foo = new byte[1]; + foo[0] = 1; + cachedItem.Store(foo); + cache.Store(cacheItemUUID.ToString(), cachedItem); + cache.Clear(); + + object citem = cache.Get(cacheItemUUID.ToString()); + Assert.That(citem == null, "Item should not be in Cache because we manually invalidated it"); + } + + [Test] + public void CacheItemMundane() + { + UUID Random1 = UUID.Random(); + UUID Random2 = UUID.Random(); + byte[] data = new byte[0]; + CacheItemBase cb1 = new CacheItemBase(Random1.ToString(), DateTime.Now + TimeSpan.FromDays(1)); + CacheItemBase cb2 = new CacheItemBase(Random2.ToString(), DateTime.Now + TimeSpan.FromDays(1)); + CacheItemBase cb3 = new CacheItemBase(Random1.ToString(), DateTime.Now + TimeSpan.FromDays(1)); + + cb1.Store(data); + + Assert.That(cb1.Equals(cb3), "cb1 should equal cb3, their uuids are the same"); + Assert.That(!cb2.Equals(cb1), "cb2 should not equal cb1, their uuids are NOT the same"); + Assert.That(cb1.IsLocked() == false, "CacheItemBase default is false"); + Assert.That(cb1.Retrieve() == null, "Virtual Retrieve method should return null"); + + } } diff --git a/OpenSim/Framework/Tests/LocationTest.cs b/OpenSim/Framework/Tests/LocationTest.cs index 237568f5e4..2707afa066 100644 --- a/OpenSim/Framework/Tests/LocationTest.cs +++ b/OpenSim/Framework/Tests/LocationTest.cs @@ -54,9 +54,28 @@ namespace OpenSim.Framework.Tests Location TestLocation2 = new Location(1099511628032000); Assert.That(TestLocation1 == TestLocation2); + Assert.That(TestLocation2.X == 256000 && TestLocation2.Y == 256000, "Test xy location doesn't match regionhandle provided"); + + Assert.That(TestLocation2.RegionHandle == 1099511628032000, + "Location RegionHandle Property didn't match regionhandle provided in constructor"); + + TestLocation1 = new Location(256001, 256001); TestLocation2 = new Location(1099511628032000); Assert.That(TestLocation1 != TestLocation2); + + Assert.That(TestLocation1.Equals(256001, 256001), "Equals(x,y) failed to match the position in the constructor"); + + Assert.That(TestLocation2.GetHashCode() == (TestLocation2.X.GetHashCode() ^ TestLocation2.Y.GetHashCode()), "GetHashCode failed to produce the expected hashcode"); + + Location TestLocation3; + object cln = TestLocation2.Clone(); + TestLocation3 = (Location) cln; + Assert.That(TestLocation3.X == TestLocation2.X && TestLocation3.Y == TestLocation2.Y, + "Cloned Location values do not match"); + + Assert.That(TestLocation2.Equals(cln), "Cloned object failed .Equals(obj) Test"); + } } diff --git a/OpenSim/Framework/Tests/MundaneFrameworkTests.cs b/OpenSim/Framework/Tests/MundaneFrameworkTests.cs new file mode 100644 index 0000000000..04be0839fb --- /dev/null +++ b/OpenSim/Framework/Tests/MundaneFrameworkTests.cs @@ -0,0 +1,311 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using NUnit.Framework; +using OpenSim.Framework; +using OpenMetaverse; +using OpenMetaverse.StructuredData; +using System; +using System.Globalization; +using System.Threading; + +namespace OpenSim.Framework.Tests +{ + [TestFixture] + public class MundaneFrameworkTests + { + private bool m_RegionSettingsOnSaveEventFired; + private bool m_RegionLightShareDataOnSaveEventFired; + + + [Test] + public void ChildAgentDataUpdate01() + { + // code coverage + ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); + Assert.IsFalse(cadu.alwaysrun, "Default is false"); + } + + [Test] + public void AgentPositionTest01() + { + UUID AgentId1 = UUID.Random(); + UUID SessionId1 = UUID.Random(); + uint CircuitCode1 = uint.MinValue; + Vector3 Size1 = Vector3.UnitZ; + Vector3 Position1 = Vector3.UnitX; + Vector3 LeftAxis1 = Vector3.UnitY; + Vector3 UpAxis1 = Vector3.UnitZ; + Vector3 AtAxis1 = Vector3.UnitX; + + ulong RegionHandle1 = ulong.MinValue; + byte[] Throttles1 = new byte[] {0, 1, 0}; + + Vector3 Velocity1 = Vector3.Zero; + float Far1 = 256; + + bool ChangedGrid1 = false; + Vector3 Center1 = Vector3.Zero; + + AgentPosition position1 = new AgentPosition(); + position1.AgentID = AgentId1; + position1.SessionID = SessionId1; + position1.CircuitCode = CircuitCode1; + position1.Size = Size1; + position1.Position = Position1; + position1.LeftAxis = LeftAxis1; + position1.UpAxis = UpAxis1; + position1.AtAxis = AtAxis1; + position1.RegionHandle = RegionHandle1; + position1.Throttles = Throttles1; + position1.Velocity = Velocity1; + position1.Far = Far1; + position1.ChangedGrid = ChangedGrid1; + position1.Center = Center1; + + ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); + cadu.AgentID = AgentId1.Guid; + cadu.ActiveGroupID = UUID.Zero.Guid; + cadu.throttles = Throttles1; + cadu.drawdistance = Far1; + cadu.Position = Position1; + cadu.Velocity = Velocity1; + cadu.regionHandle = RegionHandle1; + cadu.cameraPosition = Center1; + cadu.AVHeight = Size1.Z; + + AgentPosition position2 = new AgentPosition(); + position2.CopyFrom(cadu); + + Assert.IsTrue( + position2.AgentID == position1.AgentID + && position2.Size == position1.Size + && position2.Position == position1.Position + && position2.Velocity == position1.Velocity + && position2.Center == position1.Center + && position2.RegionHandle == position1.RegionHandle + && position2.Far == position1.Far + + ,"Copy From ChildAgentDataUpdate failed"); + + position2 = new AgentPosition(); + + Assert.IsFalse(position2.AgentID == position1.AgentID, "Test Error, position2 should be a blank uninitialized AgentPosition"); + position2.Unpack(position1.Pack()); + + Assert.IsTrue(position2.AgentID == position1.AgentID, "Agent ID didn't unpack the same way it packed"); + Assert.IsTrue(position2.Position == position1.Position, "Position didn't unpack the same way it packed"); + Assert.IsTrue(position2.Velocity == position1.Velocity, "Velocity didn't unpack the same way it packed"); + Assert.IsTrue(position2.SessionID == position1.SessionID, "SessionID didn't unpack the same way it packed"); + Assert.IsTrue(position2.CircuitCode == position1.CircuitCode, "CircuitCode didn't unpack the same way it packed"); + Assert.IsTrue(position2.LeftAxis == position1.LeftAxis, "LeftAxis didn't unpack the same way it packed"); + Assert.IsTrue(position2.UpAxis == position1.UpAxis, "UpAxis didn't unpack the same way it packed"); + Assert.IsTrue(position2.AtAxis == position1.AtAxis, "AtAxis didn't unpack the same way it packed"); + Assert.IsTrue(position2.RegionHandle == position1.RegionHandle, "RegionHandle didn't unpack the same way it packed"); + Assert.IsTrue(position2.ChangedGrid == position1.ChangedGrid, "ChangedGrid didn't unpack the same way it packed"); + Assert.IsTrue(position2.Center == position1.Center, "Center didn't unpack the same way it packed"); + Assert.IsTrue(position2.Size == position1.Size, "Size didn't unpack the same way it packed"); + + } + + [Test] + public void RegionSettingsTest01() + { + RegionSettings settings = new RegionSettings(); + settings.OnSave += RegionSaveFired; + settings.Save(); + settings.OnSave -= RegionSaveFired; + + string str = settings.LoadedCreationDate; + int dt = settings.LoadedCreationDateTime; + string id = settings.LoadedCreationID; + string time = settings.LoadedCreationTime; + + Assert.That(m_RegionSettingsOnSaveEventFired, "RegionSettings Save Event didn't Fire"); + + } + public void RegionSaveFired(RegionSettings settings) + { + m_RegionSettingsOnSaveEventFired = true; + } + + [Test] + public void InventoryItemBaseConstructorTest01() + { + InventoryItemBase b1 = new InventoryItemBase(); + Assert.That(b1.ID == UUID.Zero, "void constructor should create an inventory item with ID = UUID.Zero"); + Assert.That(b1.Owner == UUID.Zero, "void constructor should create an inventory item with Owner = UUID.Zero"); + + UUID ItemID = UUID.Random(); + UUID OwnerID = UUID.Random(); + + InventoryItemBase b2 = new InventoryItemBase(ItemID); + Assert.That(b2.ID == ItemID, "ID constructor should create an inventory item with ID = ItemID"); + Assert.That(b2.Owner == UUID.Zero, "ID constructor should create an inventory item with Owner = UUID.Zero"); + + InventoryItemBase b3 = new InventoryItemBase(ItemID,OwnerID); + Assert.That(b3.ID == ItemID, "ID,OwnerID constructor should create an inventory item with ID = ItemID"); + Assert.That(b3.Owner == OwnerID, "ID,OwnerID constructor should create an inventory item with Owner = OwnerID"); + + } + + [Test] + public void AssetMetaDataNonNullContentTypeTest01() + { + AssetMetadata assetMetadata = new AssetMetadata(); + assetMetadata.ContentType = "image/jp2"; + Assert.That(assetMetadata.Type == (sbyte)AssetType.Texture, "Content type should be AssetType.Texture"); + Assert.That(assetMetadata.ContentType == "image/jp2", "Text of content type should be image/jp2"); + UUID rndID = UUID.Random(); + assetMetadata.ID = rndID.ToString(); + Assert.That(assetMetadata.ID.ToLower() == rndID.ToString().ToLower(), "assetMetadata.ID Setter/Getter not Consistent"); + DateTime fixedTime = DateTime.Now; + assetMetadata.CreationDate = fixedTime; + } + + [Test] + public void RegionLightShareDataCloneSaveTest01() + { + RegionLightShareData rlsd = new RegionLightShareData(); + rlsd.OnSave += RegionLightShareDataSaveFired; + rlsd.Save(); + rlsd.OnSave -= RegionLightShareDataSaveFired; + Assert.IsTrue(m_RegionLightShareDataOnSaveEventFired, "OnSave Event Never Fired"); + + object o = rlsd.Clone(); + RegionLightShareData dupe = (RegionLightShareData) o; + Assert.IsTrue(rlsd.sceneGamma == dupe.sceneGamma, "Memberwise Clone of RegionLightShareData failed"); + } + public void RegionLightShareDataSaveFired(RegionLightShareData settings) + { + m_RegionLightShareDataOnSaveEventFired = true; + } + + [Test] + public void EstateSettingsMundateTests() + { + EstateSettings es = new EstateSettings(); + es.AddBan(null); + UUID bannedUserId = UUID.Random(); + es.AddBan(new EstateBan() + { BannedHostAddress = string.Empty, + BannedHostIPMask = string.Empty, + BannedHostNameMask = string.Empty, + BannedUserID = bannedUserId} + ); + Assert.IsTrue(es.IsBanned(bannedUserId), "User Should be banned but is not."); + Assert.IsFalse(es.IsBanned(UUID.Zero), "User Should not be banned but is."); + + es.RemoveBan(bannedUserId); + + Assert.IsFalse(es.IsBanned(bannedUserId), "User Should not be banned but is."); + + es.AddEstateManager(UUID.Zero); + + es.AddEstateManager(bannedUserId); + Assert.IsTrue(es.IsEstateManager(bannedUserId), "bannedUserId should be EstateManager but isn't."); + + es.RemoveEstateManager(bannedUserId); + Assert.IsFalse(es.IsEstateManager(bannedUserId), "bannedUserID is estateManager but shouldn't be"); + + Assert.IsFalse(es.HasAccess(bannedUserId), "bannedUserID has access but shouldn't"); + + es.AddEstateUser(bannedUserId); + + Assert.IsTrue(es.HasAccess(bannedUserId), "bannedUserID doesn't have access but should"); + es.RemoveEstateUser(bannedUserId); + + es.AddEstateManager(bannedUserId); + + Assert.IsTrue(es.HasAccess(bannedUserId), "bannedUserID doesn't have access but should"); + + Assert.That(es.EstateGroups.Length == 0, "No Estate Groups Added.. so the array should be 0 length"); + + es.AddEstateGroup(bannedUserId); + + Assert.That(es.EstateGroups.Length == 1, "1 Estate Groups Added.. so the array should be 1 length"); + + Assert.That(es.EstateGroups[0] == bannedUserId,"User ID should be in EstateGroups"); + + } + + [Test] + public void InventoryFolderBaseConstructorTest01() + { + UUID uuid1 = UUID.Random(); + UUID uuid2 = UUID.Random(); + + InventoryFolderBase fld = new InventoryFolderBase(uuid1); + Assert.That(fld.ID == uuid1, "ID constructor failed to save value in ID field."); + + fld = new InventoryFolderBase(uuid1, uuid2); + Assert.That(fld.ID == uuid1, "ID,Owner constructor failed to save value in ID field."); + Assert.That(fld.Owner == uuid2, "ID,Owner constructor failed to save value in ID field."); + } + + [Test] + public void AsssetBaseConstructorTest01() + { + AssetBase abase = new AssetBase(); + Assert.IsNotNull(abase.Metadata, "void constructor of AssetBase should have created a MetaData element but didn't."); + UUID itemID = UUID.Random(); + UUID creatorID = UUID.Random(); + abase = new AssetBase(itemID.ToString(), "test item", (sbyte) AssetType.Texture, creatorID.ToString()); + + Assert.IsNotNull(abase.Metadata, "string,string,sbyte,string constructor of AssetBase should have created a MetaData element but didn't."); + Assert.That(abase.ID == itemID.ToString(), "string,string,sbyte,string constructor failed to set ID property"); + Assert.That(abase.Metadata.CreatorID == creatorID.ToString(), "string,string,sbyte,string constructor failed to set Creator ID"); + + + abase = new AssetBase(itemID.ToString(), "test item", -1, creatorID.ToString()); + Assert.IsNotNull(abase.Metadata, "string,string,sbyte,string constructor of AssetBase with unknown type should have created a MetaData element but didn't."); + Assert.That(abase.Metadata.Type == -1, "Unknown Type passed to string,string,sbyte,string constructor and was a known type when it came out again"); + + AssetMetadata metts = new AssetMetadata(); + metts.FullID = itemID; + metts.ID = string.Empty; + metts.Name = "test item"; + abase.Metadata = metts; + + Assert.That(abase.ToString() == itemID.ToString(), "ToString is overriden to be fullID.ToString()"); + Assert.That(abase.ID == itemID.ToString(),"ID should be MetaData.FullID.ToString() when string.empty or null is provided to the ID property"); + } + + [Test] + public void CultureSetCultureTest01() + { + CultureInfo ci = new CultureInfo("en-US", false); + Culture.SetCurrentCulture(); + Assert.That(Thread.CurrentThread.CurrentCulture.Name == ci.Name, "SetCurrentCulture failed to set thread culture to en-US"); + + } + + + + } +} + diff --git a/OpenSim/Framework/Tests/PrimeNumberHelperTests.cs b/OpenSim/Framework/Tests/PrimeNumberHelperTests.cs new file mode 100644 index 0000000000..d741f9116d --- /dev/null +++ b/OpenSim/Framework/Tests/PrimeNumberHelperTests.cs @@ -0,0 +1,146 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Reflection; +using NUnit.Framework; +using NUnit.Framework.SyntaxHelpers; +using OpenMetaverse; +using OpenMetaverse.StructuredData; +using OpenSim.Framework; + +namespace OpenSim.Framework.Tests +{ + [TestFixture] + public class PrimeNumberHelperTests + { + + + [Test] + public void TestGetPrime() + { + int prime1 = PrimeNumberHelper.GetPrime(7919); + Assert.That(prime1 == 8419, "Prime Number Get Prime Failed, 7919 is prime"); + Assert.That(PrimeNumberHelper.IsPrime(prime1),"Prime1 should be prime"); + Assert.That(PrimeNumberHelper.IsPrime(7919), "7919 is prime but is falsely failing the prime test"); + prime1 = PrimeNumberHelper.GetPrime(Int32.MaxValue - 1); + Assert.That(prime1 == -1, "prime1 should have been -1 since there are no primes between Int32.MaxValue-1 and Int32.MaxValue"); + + } + + [Test] + public void Test1000SmallPrimeNumbers() + { + int[] primes = { + 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, + 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191 + , 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, + 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, + 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, + 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, + 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, + 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, + 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009, + 1013, 1019, 1021, 1031, 1033, 1039, 1049, 1051, 1061, 1063, 1069, 1087, 1091, 1093, 1097, + 1103, 1109, 1117, 1123, 1129, 1151, 1153, 1163, 1171, 1181, 1187, 1193, 1201, 1213, 1217, + 1223, 1229, 1231, 1237, 1249, 1259, 1277, 1279, 1283, 1289, 1291, 1297, 1301, 1303, 1307, + 1319, 1321, 1327, 1361, 1367, 1373, 1381, 1399, 1409, 1423, 1427, 1429, 1433, 1439, 1447, + 1451, 1453, 1459, 1471, 1481, 1483, 1487, 1489, 1493, 1499, 1511, 1523, 1531, 1543, 1549, + 1553, 1559, 1567, 1571, 1579, 1583, 1597, 1601, 1607, 1609, 1613, 1619, 1621, 1627, 1637, + 1657, 1663, 1667, 1669, 1693, 1697, 1699, 1709, 1721, 1723, 1733, 1741, 1747, 1753, 1759, + 1777, 1783, 1787, 1789, 1801, 1811, 1823, 1831, 1847, 1861, 1867, 1871, 1873, 1877, 1879, + 1889, 1901, 1907, 1913, 1931, 1933, 1949, 1951, 1973, 1979, 1987, 1993, 1997, 1999, 2003, + 2011, 2017, 2027, 2029, 2039, 2053, 2063, 2069, 2081, 2083, 2087, 2089, 2099, 2111, 2113, + 2129, 2131, 2137, 2141, 2143, 2153, 2161, 2179, 2203, 2207, 2213, 2221, 2237, 2239, 2243, + 2251, 2267, 2269, 2273, 2281, 2287, 2293, 2297, 2309, 2311, 2333, 2339, 2341, 2347, 2351, + 2357, 2371, 2377, 2381, 2383, 2389, 2393, 2399, 2411, 2417, 2423, 2437, 2441, 2447, 2459, + 2467, 2473, 2477, 2503, 2521, 2531, 2539, 2543, 2549, 2551, 2557, 2579, 2591, 2593, 2609, + 2617, 2621, 2633, 2647, 2657, 2659, 2663, 2671, 2677, 2683, 2687, 2689, 2693, 2699, 2707, + 2711, 2713, 2719, 2729, 2731, 2741, 2749, 2753, 2767, 2777, 2789, 2791, 2797, 2801, 2803, + 2819, 2833, 2837, 2843, 2851, 2857, 2861, 2879, 2887, 2897, 2903, 2909, 2917, 2927, 2939, + 2953, 2957, 2963, 2969, 2971, 2999, 3001, 3011, 3019, 3023, 3037, 3041, 3049, 3061, 3067, + 3079, 3083, 3089, 3109, 3119, 3121, 3137, 3163, 3167, 3169, 3181, 3187, 3191, 3203, 3209, + 3217, 3221, 3229, 3251, 3253, 3257, 3259, 3271, 3299, 3301, 3307, 3313, 3319, 3323, 3329, + 3331, 3343, 3347, 3359, 3361, 3371, 3373, 3389, 3391, 3407, 3413, 3433, 3449, 3457, 3461, + 3463, 3467, 3469, 3491, 3499, 3511, 3517, 3527, 3529, 3533, 3539, 3541, 3547, 3557, 3559, + 3571, 3581, 3583, 3593, 3607, 3613, 3617, 3623, 3631, 3637, 3643, 3659, 3671, 3673, 3677, + 3691, 3697, 3701, 3709, 3719, 3727, 3733, 3739, 3761, 3767, 3769, 3779, 3793, 3797, 3803, + 3821, 3823, 3833, 3847, 3851, 3853, 3863, 3877, 3881, 3889, 3907, 3911, 3917, 3919, 3923, + 3929, 3931, 3943, 3947, 3967, 3989, 4001, 4003, 4007, 4013, 4019, 4021, 4027, 4049, 4051, + 4057, 4073, 4079, 4091, 4093, 4099, 4111, 4127, 4129, 4133, 4139, 4153, 4157, 4159, 4177, + 4201, 4211, 4217, 4219, 4229, 4231, 4241, 4243, 4253, 4259, 4261, 4271, 4273, 4283, 4289, + 4297, 4327, 4337, 4339, 4349, 4357, 4363, 4373, 4391, 4397, 4409, 4421, 4423, 4441, 4447, + 4451, 4457, 4463, 4481, 4483, 4493, 4507, 4513, 4517, 4519, 4523, 4547, 4549, 4561, 4567, + 4583, 4591, 4597, 4603, 4621, 4637, 4639, 4643, 4649, 4651, 4657, 4663, 4673, 4679, 4691, + 4703, 4721, 4723, 4729, 4733, 4751, 4759, 4783, 4787, 4789, 4793, 4799, 4801, 4813, 4817, + 4831, 4861, 4871, 4877, 4889, 4903, 4909, 4919, 4931, 4933, 4937, 4943, 4951, 4957, 4967, + 4969, 4973, 4987, 4993, 4999, 5003, 5009, 5011, 5021, 5023, 5039, 5051, 5059, 5077, 5081, + 5087, 5099, 5101, 5107, 5113, 5119, 5147, 5153, 5167, 5171, 5179, 5189, 5197, 5209, 5227, + 5231, 5233, 5237, 5261, 5273, 5279, 5281, 5297, 5303, 5309, 5323, 5333, 5347, 5351, 5381, + 5387, 5393, 5399, 5407, 5413, 5417, 5419, 5431, 5437, 5441, 5443, 5449, 5471, 5477, 5479, + 5483, 5501, 5503, 5507, 5519, 5521, 5527, 5531, 5557, 5563, 5569, 5573, 5581, 5591, 5623, + 5639, 5641, 5647, 5651, 5653, 5657, 5659, 5669, 5683, 5689, 5693, 5701, 5711, 5717, 5737, + 5741, 5743, 5749, 5779, 5783, 5791, 5801, 5807, 5813, 5821, 5827, 5839, 5843, 5849, 5851, + 5857, 5861, 5867, 5869, 5879, 5881, 5897, 5903, 5923, 5927, 5939, 5953, 5981, 5987, 6007, + 6011, 6029, 6037, 6043, 6047, 6053, 6067, 6073, 6079, 6089, 6091, 6101, 6113, 6121, 6131, + 6133, 6143, 6151, 6163, 6173, 6197, 6199, 6203, 6211, 6217, 6221, 6229, 6247, 6257, 6263, + 6269, 6271, 6277, 6287, 6299, 6301, 6311, 6317, 6323, 6329, 6337, 6343, 6353, 6359, 6361, + 6367, 6373, 6379, 6389, 6397, 6421, 6427, 6449, 6451, 6469, 6473, 6481, 6491, 6521, 6529, + 6547, 6551, 6553, 6563, 6569, 6571, 6577, 6581, 6599, 6607, 6619, 6637, 6653, 6659, 6661, + 6673, 6679, 6689, 6691, 6701, 6703, 6709, 6719, 6733, 6737, 6761, 6763, 6779, 6781, 6791, + 6793, 6803, 6823, 6827, 6829, 6833, 6841, 6857, 6863, 6869, 6871, 6883, 6899, 6907, 6911, + 6917, 6947, 6949, 6959, 6961, 6967, 6971, 6977, 6983, 6991, 6997, 7001, 7013, 7019, 7027, + 7039, 7043, 7057, 7069, 7079, 7103, 7109, 7121, 7127, 7129, 7151, 7159, 7177, 7187, 7193, + 7207, 7211, 7213, 7219, 7229, 7237, 7243, 7247, 7253, 7283, 7297, 7307, 7309, 7321, 7331, + 7333, 7349, 7351, 7369, 7393, 7411, 7417, 7433, 7451, 7457, 7459, 7477, 7481, 7487, 7489, + 7499, 7507, 7517, 7523, 7529, 7537, 7541, 7547, 7549, 7559, 7561, 7573, 7577, 7583, 7589, + 7591, 7603, 7607, 7621, 7639, 7643, 7649, 7669, 7673, 7681, 7687, 7691, 7699, 7703, 7717, + 7723, 7727, 7741, 7753, 7757, 7759, 7789, 7793, 7817, 7823, 7829, 7841, 7853, 7867, 7873, + 7877, 7879, 7883, 7901, 7907, 7919 + }; + for (int i = 0; i < primes.Length; i++) + { + Assert.That(PrimeNumberHelper.IsPrime(primes[i]),primes[i] + " is prime but is erroniously failing the prime test"); + } + + int[] nonprimes = { + 4, 6, 8, 10, 14, 16, 18, 22, 28, 30, 36, 40, 42, 46, 52, 58, 60, 66, 70, 72, 78, 82, 88, + 96, 366, 372, 378, 382, 388, 396, 400, 408, 418, 420, 430, 432, 438, 442, 448, 456, 460, 462, + 466, 478, 486, 490, 498, 502, 508, 856, 858, 862, 876, 880, 882, 886, 906, 910, 918, 928, 936, + 940, 946, 952, 966, 970, 976, 982, 990, 996, 1008, 1740, 1746, 1752, 1758, 4650, 4656, 4662, + 4672, 4678, 4690, 7740, 7752, 7756, 7758, 7788, 7792, 7816, 7822, 7828, 7840, 7852, 7866, 7872, + 7876, 7878, 7882, 7900, 7906, 7918 + }; + for (int i = 0; i < nonprimes.Length; i++) + { + Assert.That(!PrimeNumberHelper.IsPrime(nonprimes[i]), nonprimes[i] + " is not prime but is erroniously passing the prime test"); + } + + Assert.That(PrimeNumberHelper.IsPrime(3)); + } + } +} \ No newline at end of file diff --git a/OpenSim/Framework/Tests/UtilTest.cs b/OpenSim/Framework/Tests/UtilTest.cs index 45d822cec2..89f5c0cba9 100644 --- a/OpenSim/Framework/Tests/UtilTest.cs +++ b/OpenSim/Framework/Tests/UtilTest.cs @@ -170,5 +170,119 @@ namespace OpenSim.Framework.Tests // Varying secrets should not eqal the same Assert.AreNotEqual(Util.GetHashGuid(string1, "secret1"), Util.GetHashGuid(string1, "secret2")); } + + [Test] + public void SLUtilTypeConvertTests() + { + int[] assettypes = new int[]{-1,0,1,2,3,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22 + ,23,24,25,46,47,48}; + string[] contenttypes = new string[] + { + "application/octet-stream", + "image/x-j2c", + "audio/ogg", + "application/vnd.ll.callingcard", + "application/vnd.ll.landmark", + "application/vnd.ll.clothing", + "application/vnd.ll.primitive", + "application/vnd.ll.notecard", + "application/vnd.ll.folder", + "application/vnd.ll.rootfolder", + "application/vnd.ll.lsltext", + "application/vnd.ll.lslbyte", + "image/tga", + "application/vnd.ll.bodypart", + "application/vnd.ll.trashfolder", + "application/vnd.ll.snapshotfolder", + "application/vnd.ll.lostandfoundfolder", + "audio/x-wav", + "image/tga", + "image/jpeg", + "application/vnd.ll.animation", + "application/vnd.ll.gesture", + "application/x-metaverse-simstate", + "application/vnd.ll.favoritefolder", + "application/vnd.ll.link", + "application/vnd.ll.linkfolder", + "application/vnd.ll.currentoutfitfolder", + "application/vnd.ll.outfitfolder", + "application/vnd.ll.myoutfitsfolder" + }; + for (int i=0;i", "Create a new region.", - "The settings for \"region name\" are read from in your Regions directory." + "The settings for \"region name\" are read from . Paths specified with are relative to your Regions directory, unless an absolute path is given." + " If \"region name\" does not exist in , it will be added." + Environment.NewLine + "Without \"region name\", the first region found in will be created." + Environment.NewLine + "If does not exist, it will be created.", diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index cede0502fd..48d5a12204 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -1531,6 +1531,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP OutPacket(kill, ThrottleOutPacketType.Task); } } + else + { + OutPacket(kill, ThrottleOutPacketType.State); + } } /// diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs index 02f0968c40..ef5efdd9e5 100644 --- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs @@ -237,9 +237,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat public virtual void OnChatBroadcast(Object sender, OSChatMessage c) { - // unless the chat to be broadcast is of type Region, we - // drop it if its channel is neither 0 nor DEBUG_CHANNEL - if (c.Channel != 0 && c.Channel != DEBUG_CHANNEL && c.Type != ChatTypeEnum.Region) return; + if (c.Channel != 0 && c.Channel != DEBUG_CHANNEL) return; ChatTypeEnum cType = c.Type; if (c.Channel == DEBUG_CHANNEL) diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index 4e4eee9386..7a21d5e6b2 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -317,7 +317,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends continue; UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(client.Scene.RegionInfo.ScopeID, fromAgentID); - PresenceInfo presence = PresenceService.GetAgent(fromAgentID); + + PresenceInfo presence = null; + PresenceInfo[] presences = PresenceService.GetAgents(new string[] { fid }); + if (presences != null && presences.Length > 0) + presence = presences[0]; + if (presence != null) + im.offline = 0; im.fromAgentID = fromAgentID.Guid; im.fromAgentName = account.FirstName + " " + account.LastName; @@ -430,13 +436,26 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends return; // The friend is not here [as root]. Let's forward. - PresenceInfo friendSession = PresenceService.GetAgent(friendID); - if (friendSession != null && friendSession.RegionID != UUID.Zero) // let's guard against sessions-gone-bad with the RegionID check + PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); + if (friendSessions != null && friendSessions.Length > 0) { - GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); - //m_log.DebugFormat("[FRIENDS]: Remote Notify to region {0}", region.RegionName); - m_FriendsSimConnector.StatusNotify(region, userID, friendID, online); + PresenceInfo friendSession = null; + foreach (PresenceInfo pinfo in friendSessions) + if (pinfo.RegionID != UUID.Zero) // let's guard against sessions-gone-bad + { + friendSession = pinfo; + break; + } + + if (friendSession != null) + { + GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); + //m_log.DebugFormat("[FRIENDS]: Remote Notify to region {0}", region.RegionName); + m_FriendsSimConnector.StatusNotify(region, userID, friendID, online); + } } + + // Friend is not online. Ignore. } else { @@ -477,11 +496,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends return; // The prospective friend is not here [as root]. Let's forward. - PresenceInfo friendSession = PresenceService.GetAgent(friendID); - if (friendSession != null) + PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); + if (friendSessions != null && friendSessions.Length > 0) { - GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); - m_FriendsSimConnector.FriendshipOffered(region, agentID, friendID, im.message); + PresenceInfo friendSession = friendSessions[0]; + if (friendSession != null) + { + GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); + m_FriendsSimConnector.FriendshipOffered(region, agentID, friendID, im.message); + } } // If the prospective friend is not online, he'll get the message upon login. } @@ -508,12 +531,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends } // The friend is not here - PresenceInfo friendSession = PresenceService.GetAgent(friendID); - if (friendSession != null) + PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); + if (friendSessions != null && friendSessions.Length > 0) { - GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); - m_FriendsSimConnector.FriendshipApproved(region, agentID, client.Name, friendID); - client.SendAgentOnline(new UUID[] { friendID }); + PresenceInfo friendSession = friendSessions[0]; + if (friendSession != null) + { + GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); + m_FriendsSimConnector.FriendshipApproved(region, agentID, client.Name, friendID); + client.SendAgentOnline(new UUID[] { friendID }); + } } } @@ -532,14 +559,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends if (LocalFriendshipDenied(agentID, client.Name, friendID)) return; - PresenceInfo friendSession = PresenceService.GetAgent(friendID); - if (friendSession != null) + PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); + if (friendSessions != null && friendSessions.Length > 0) { - GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); - if (region != null) - m_FriendsSimConnector.FriendshipDenied(region, agentID, client.Name, friendID); - else - m_log.WarnFormat("[FRIENDS]: Could not find region {0} in locating {1}", friendSession.RegionID, friendID); + PresenceInfo friendSession = friendSessions[0]; + if (friendSession != null) + { + GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); + if (region != null) + m_FriendsSimConnector.FriendshipDenied(region, agentID, client.Name, friendID); + else + m_log.WarnFormat("[FRIENDS]: Could not find region {0} in locating {1}", friendSession.RegionID, friendID); + } } } @@ -561,11 +592,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends if (LocalFriendshipTerminated(exfriendID)) return; - PresenceInfo friendSession = PresenceService.GetAgent(exfriendID); - if (friendSession != null) + PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { exfriendID.ToString() }); + if (friendSessions != null && friendSessions.Length > 0) { - GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); - m_FriendsSimConnector.FriendshipTerminated(region, agentID, exfriendID); + PresenceInfo friendSession = friendSessions[0]; + if (friendSession != null) + { + GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); + m_FriendsSimConnector.FriendshipTerminated(region, agentID, exfriendID); + } } } @@ -604,13 +639,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends if (LocalGrantRights(requester, target, myFlags, rights)) return; - PresenceInfo friendSession = PresenceService.GetAgent(target); - if (friendSession != null) + PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { target.ToString() }); + if (friendSessions != null && friendSessions.Length > 0) { - GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); - // TODO: You might want to send the delta to save the lookup - // on the other end!! - m_FriendsSimConnector.GrantRights(region, requester, target, myFlags, rights); + PresenceInfo friendSession = friendSessions[0]; + if (friendSession != null) + { + GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); + // TODO: You might want to send the delta to save the lookup + // on the other end!! + m_FriendsSimConnector.GrantRights(region, requester, target, myFlags, rights); + } } } } diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs index 43bbf0d5ad..9b1222b627 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs @@ -498,7 +498,18 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage if (lookupAgent) { // Non-cached user agent lookup. - upd = PresenceService.GetAgent(toAgentID); + PresenceInfo[] presences = PresenceService.GetAgents(new string[] { toAgentID.ToString() }); + if (presences != null && presences.Length > 0) + { + foreach (PresenceInfo p in presences) + { + if (p.RegionID != UUID.Zero) + { + upd = p; + break; + } + } + } if (upd != null) { diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs index a88c5e2d60..5fabbb03dd 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs @@ -957,7 +957,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups CacheKey = sb.ToString(); m_memoryCache.TryGetValue(CacheKey, out resp); } - } if (resp == null) @@ -965,22 +964,19 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups string UserService; UUID SessionID; GetClientGroupRequestID(requestingAgentID, out UserService, out SessionID); - param.Add("requestingAgentID", requestingAgentID.ToString()); + + param.Add("RequestingAgentID", requestingAgentID.ToString()); param.Add("RequestingAgentUserService", UserService); param.Add("RequestingSessionID", SessionID.ToString()); - - param.Add("ReadKey", m_groupReadKey); param.Add("WriteKey", m_groupWriteKey); - IList parameters = new ArrayList(); parameters.Add(param); ConfigurableKeepAliveXmlRpcRequest req; req = new ConfigurableKeepAliveXmlRpcRequest(function, parameters, m_disableKeepAlive); - try { resp = req.Send(m_groupsServerURI, 10000); @@ -989,7 +985,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups { m_memoryCache.AddOrUpdate(CacheKey, resp, TimeSpan.FromSeconds(m_cacheTimeout)); } - } catch (Exception e) { @@ -1058,10 +1053,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups { m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: {0}", line); } - } } - /// /// Group Request Tokens are an attempt to allow the groups service to authenticate diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 01c026ee93..a6ca17125a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -3956,7 +3956,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api } - pinfo = World.PresenceService.GetAgent(uuid); + PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() }); + if (pinfos != null && pinfos.Length > 0) + { + foreach (PresenceInfo p in pinfos) + { + if (p.RegionID != UUID.Zero) + { + pinfo = p; + } + } + } ce = new UserInfoCacheEntry(); ce.time = Util.EnvironmentTickCount(); @@ -3974,7 +3984,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api if (Util.EnvironmentTickCount() < ce.time || (Util.EnvironmentTickCount() - ce.time) >= 20000) { - pinfo = World.PresenceService.GetAgent(uuid); + PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() }); + if (pinfos != null && pinfos.Length > 0) + { + foreach (PresenceInfo p in pinfos) + { + if (p.RegionID != UUID.Zero) + { + pinfo = p; + } + } + } + else + pinfo = null; ce.time = Util.EnvironmentTickCount(); ce.pinfo = pinfo; @@ -5579,78 +5601,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api ScriptSleep(5000); } - public LSL_List llParseString2List(string str, LSL_List separators, LSL_List in_spacers) - { - m_host.AddScriptLPS(1); - LSL_List ret = new LSL_List(); - LSL_List spacers = new LSL_List(); - if (in_spacers.Length > 0 && separators.Length > 0) - { - for (int i = 0; i < in_spacers.Length; i++) - { - object s = in_spacers.Data[i]; - for (int j = 0; j < separators.Length; j++) - { - if (separators.Data[j].ToString() == s.ToString()) - { - s = null; - break; - } - } - if (s != null) - { - spacers.Add(s); - } - } - } - object[] delimiters = new object[separators.Length + spacers.Length]; - separators.Data.CopyTo(delimiters, 0); - spacers.Data.CopyTo(delimiters, separators.Length); - bool dfound = false; - do - { - dfound = false; - int cindex = -1; - string cdeli = ""; - for (int i = 0; i < delimiters.Length; i++) - { - int index = str.IndexOf(delimiters[i].ToString()); - bool found = index != -1; - if (found && String.Empty != delimiters[i].ToString()) - { - if ((cindex > index) || (cindex == -1)) - { - cindex = index; - cdeli = delimiters[i].ToString(); - } - dfound = dfound || found; - } - } - if (cindex != -1) - { - if (cindex > 0) - { - ret.Add(new LSL_String(str.Substring(0, cindex))); - } - // Cannot use spacers.Contains() because spacers may be either type String or LSLString - for (int j = 0; j < spacers.Length; j++) - { - if (spacers.Data[j].ToString() == cdeli) - { - ret.Add(new LSL_String(cdeli)); - break; - } - } - str = str.Substring(cindex + cdeli.Length); - } - } while (dfound); - if (str != "") - { - ret.Add(new LSL_String(str)); - } - return ret; - } - public LSL_Integer llOverMyLand(string id) { m_host.AddScriptLPS(1); @@ -8414,7 +8364,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // of arrays or other objects. // - public LSL_List llParseStringKeepNulls(string src, LSL_List separators, LSL_List spacers) + private LSL_List ParseString(string src, LSL_List separators, LSL_List spacers, bool keepNulls) { int beginning = 0; int srclen = src.Length; @@ -8434,8 +8384,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api LSL_List tokens = new LSL_List(); - m_host.AddScriptLPS(1); - // All entries are initially valid for (int i = 0; i < mlen; i++) @@ -8507,14 +8455,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api { // no markers were found on this pass // so we're pretty much done - tokens.Add(new LSL_String(src.Substring(beginning, srclen - beginning))); + if ((keepNulls) || ((!keepNulls) && (srclen - beginning) > 0)) + tokens.Add(new LSL_String(src.Substring(beginning, srclen - beginning))); break; } // Otherwise we just add the newly delimited token // and recalculate where the search should continue. - - tokens.Add(new LSL_String(src.Substring(beginning,offset[best]-beginning))); + if ((keepNulls) || ((!keepNulls) && (offset[best] - beginning) > 0)) + tokens.Add(new LSL_String(src.Substring(beginning,offset[best]-beginning))); if (best < seplen) { @@ -8523,7 +8472,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api else { beginning = offset[best] + (spcarray[best - seplen].ToString()).Length; - tokens.Add(new LSL_String(spcarray[best - seplen].ToString())); + string str = spcarray[best - seplen].ToString(); + if ((keepNulls) || ((!keepNulls) && (str.Length > 0))) + tokens.Add(new LSL_String(str)); } } @@ -8533,7 +8484,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // arduous. Alternatively the 'break' could be replced with a return // but that's shabby programming. - if (beginning == srclen) + if ((beginning == srclen) && (keepNulls)) { if (srclen != 0) tokens.Add(new LSL_String("")); @@ -8541,7 +8492,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api return tokens; } - + + public LSL_List llParseString2List(string src, LSL_List separators, LSL_List spacers) + { + m_host.AddScriptLPS(1); + return this.ParseString(src, separators, spacers, false); + } + + public LSL_List llParseStringKeepNulls(string src, LSL_List separators, LSL_List spacers) + { + m_host.AddScriptLPS(1); + return this.ParseString(src, separators, spacers, true); + } + public LSL_Integer llGetObjectPermMask(int mask) { m_host.AddScriptLPS(1); diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs b/OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs index b7e8538824..0ef4974f79 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianProfiles.cs @@ -291,8 +291,8 @@ namespace OpenSim.Services.Connectors.SimianGrid // Check if the user is online if (client.Scene is Scene) { - OpenSim.Services.Interfaces.PresenceInfo presence = ((Scene)client.Scene).PresenceService.GetAgent(avatarID); - if (presence != null) + OpenSim.Services.Interfaces.PresenceInfo[] presences = ((Scene)client.Scene).PresenceService.GetAgents(new string[] { avatarID.ToString() }); + if (presences != null && presences.Length > 0) flags |= ProfileFlags.Online; } diff --git a/bin/config-include/Grid.ini b/bin/config-include/Grid.ini index 1794573853..5624a380d3 100644 --- a/bin/config-include/Grid.ini +++ b/bin/config-include/Grid.ini @@ -20,6 +20,7 @@ SimulationServices = "RemoteSimulationConnectorModule" EntityTransferModule = "BasicEntityTransferModule" InventoryAccessModule = "BasicInventoryAccessModule" + LandServices = "RemoteLandServicesConnector" LandServiceInConnector = true NeighbourServiceInConnector = true diff --git a/bin/config-include/GridHypergrid.ini b/bin/config-include/GridHypergrid.ini index cb9ead4391..409b2a9760 100644 --- a/bin/config-include/GridHypergrid.ini +++ b/bin/config-include/GridHypergrid.ini @@ -23,6 +23,7 @@ SimulationServices = "RemoteSimulationConnectorModule" EntityTransferModule = "HGEntityTransferModule" InventoryAccessModule = "HGInventoryAccessModule" + LandServices = "RemoteLandServicesConnector" LandServiceInConnector = true NeighbourServiceInConnector = true