Merge branch 'master' into careminster

Conflicts:
	OpenSim/Region/Framework/Scenes/Scene.cs
avinationmerge
Melanie 2013-04-30 23:45:38 +01:00
commit b89d18e6f4
9 changed files with 549 additions and 97 deletions

View File

@ -75,6 +75,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
[SetUp]
public void SetUp()
{
base.SetUp();
UUID userId = TestHelpers.ParseTail(0x3);
J2KDecoderModule j2kdm = new J2KDecoderModule();

View File

@ -47,10 +47,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
/// <summary>
private List<Scene> m_Scenelist = new List<Scene>();
// private Dictionary<UUID, Scene> m_AgentRegions =
// new Dictionary<UUID, Scene>();
private IMessageTransferModule m_TransferModule = null;
private IMessageTransferModule m_TransferModule;
private bool m_Enabled = true;
#region Region Module interface
@ -81,9 +79,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
// scene.RegisterModuleInterface<IInventoryTransferModule>(this);
scene.EventManager.OnNewClient += OnNewClient;
// scene.EventManager.OnClientClosed += ClientLoggedOut;
scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage;
// scene.EventManager.OnSetRootAgentScene += OnSetRootAgentScene;
}
public void RegionLoaded(Scene scene)
@ -96,11 +92,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
m_log.Error("[INVENTORY TRANSFER]: No Message transfer module found, transfers will be local only");
m_Enabled = false;
m_Scenelist.Clear();
scene.EventManager.OnNewClient -= OnNewClient;
// scene.EventManager.OnClientClosed -= ClientLoggedOut;
// m_Scenelist.Clear();
// scene.EventManager.OnNewClient -= OnNewClient;
scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage;
// scene.EventManager.OnSetRootAgentScene -= OnSetRootAgentScene;
}
}
}
@ -108,9 +102,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
public void RemoveRegion(Scene scene)
{
scene.EventManager.OnNewClient -= OnNewClient;
// scene.EventManager.OnClientClosed -= ClientLoggedOut;
scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage;
// scene.EventManager.OnSetRootAgentScene -= OnSetRootAgentScene;
m_Scenelist.Remove(scene);
}
@ -140,11 +132,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
client.OnInstantMessage += OnInstantMessage;
}
// protected void OnSetRootAgentScene(UUID id, Scene scene)
// {
// m_AgentRegions[id] = scene;
// }
private Scene FindClientScene(UUID agentId)
{
lock (m_Scenelist)
@ -188,8 +175,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
{
UUID folderID = new UUID(im.binaryBucket, 1);
m_log.DebugFormat("[INVENTORY TRANSFER]: Inserting original folder {0} "+
"into agent {1}'s inventory",
m_log.DebugFormat(
"[INVENTORY TRANSFER]: Inserting original folder {0} into agent {1}'s inventory",
folderID, new UUID(im.toAgentID));
InventoryFolderBase folderCopy
@ -213,7 +200,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
user.ControllingClient.SendBulkUpdateInventory(folderCopy);
// HACK!!
im.imSessionID = folderID.Guid;
// Insert the ID of the copied folder into the IM so that we know which item to move to trash if it
// is rejected.
// XXX: This is probably a misuse of the session ID slot.
im.imSessionID = copyID.Guid;
}
else
{
@ -243,7 +233,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
user.ControllingClient.SendBulkUpdateInventory(itemCopy);
// HACK!!
im.imSessionID = itemID.Guid;
// Insert the ID of the copied item into the IM so that we know which item to move to trash if it
// is rejected.
// XXX: This is probably a misuse of the session ID slot.
im.imSessionID = copyID.Guid;
}
im.offline = 0;
@ -471,70 +464,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
}
}
// public bool NeedSceneCacheClear(UUID agentID, Scene scene)
// {
// if (!m_AgentRegions.ContainsKey(agentID))
// {
// // Since we can get here two ways, we need to scan
// // the scenes here. This is somewhat more expensive
// // but helps avoid a nasty bug
// //
//
// foreach (Scene s in m_Scenelist)
// {
// ScenePresence presence;
//
// if (s.TryGetScenePresence(agentID, out presence))
// {
// // If the agent is in this scene, then we
// // are being called twice in a single
// // teleport. This is wasteful of cycles
// // but harmless due to this 2nd level check
// //
// // If the agent is found in another scene
// // then the list wasn't current
// //
// // If the agent is totally unknown, then what
// // are we even doing here??
// //
// if (s == scene)
// {
// //m_log.Debug("[INVTRANSFERMOD]: s == scene. Returning true in " + scene.RegionInfo.RegionName);
// return true;
// }
// else
// {
// //m_log.Debug("[INVTRANSFERMOD]: s != scene. Returning false in " + scene.RegionInfo.RegionName);
// return false;
// }
// }
// }
// //m_log.Debug("[INVTRANSFERMOD]: agent not in scene. Returning true in " + scene.RegionInfo.RegionName);
// return true;
// }
//
// // The agent is left in current Scene, so we must be
// // going to another instance
// //
// if (m_AgentRegions[agentID] == scene)
// {
// //m_log.Debug("[INVTRANSFERMOD]: m_AgentRegions[agentID] == scene. Returning true in " + scene.RegionInfo.RegionName);
// m_AgentRegions.Remove(agentID);
// return true;
// }
//
// // Another region has claimed the agent
// //
// //m_log.Debug("[INVTRANSFERMOD]: last resort. Returning false in " + scene.RegionInfo.RegionName);
// return false;
// }
//
// public void ClientLoggedOut(UUID agentID, Scene scene)
// {
// if (m_AgentRegions.ContainsKey(agentID))
// m_AgentRegions.Remove(agentID);
// }
/// <summary>
///
/// </summary>

View File

@ -0,0 +1,449 @@
/*
* 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.Collections.Generic;
using System.Reflection;
using log4net.Config;
using Nini.Config;
using NUnit.Framework;
using OpenMetaverse;
using OpenMetaverse.Assets;
using OpenSim.Framework;
using OpenSim.Region.CoreModules.Avatar.Inventory.Transfer;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces;
using OpenSim.Tests.Common;
using OpenSim.Tests.Common.Mock;
namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer.Tests
{
[TestFixture]
public class InventoryTransferModuleTests : OpenSimTestCase
{
protected TestScene m_scene;
[SetUp]
public override void SetUp()
{
base.SetUp();
IConfigSource config = new IniConfigSource();
config.AddConfig("Messaging");
config.Configs["Messaging"].Set("InventoryTransferModule", "InventoryTransferModule");
m_scene = new SceneHelpers().SetupScene();
SceneHelpers.SetupSceneModules(m_scene, config, new InventoryTransferModule());
}
[Test]
public void TestAcceptGivenItem()
{
// TestHelpers.EnableLogging();
UUID initialSessionId = TestHelpers.ParseTail(0x10);
UUID itemId = TestHelpers.ParseTail(0x100);
UUID assetId = TestHelpers.ParseTail(0x200);
UserAccount ua1
= UserAccountHelpers.CreateUserWithInventory(m_scene, "User", "One", TestHelpers.ParseTail(0x1), "pw");
UserAccount ua2
= UserAccountHelpers.CreateUserWithInventory(m_scene, "User", "Two", TestHelpers.ParseTail(0x2), "pw");
ScenePresence giverSp = SceneHelpers.AddScenePresence(m_scene, ua1);
TestClient giverClient = (TestClient)giverSp.ControllingClient;
ScenePresence receiverSp = SceneHelpers.AddScenePresence(m_scene, ua2);
TestClient receiverClient = (TestClient)receiverSp.ControllingClient;
// Create the object to test give
InventoryItemBase originalItem
= UserInventoryHelpers.CreateInventoryItem(
m_scene, "givenObj", itemId, assetId, giverSp.UUID, InventoryType.Object);
byte[] giveImBinaryBucket = new byte[17];
byte[] itemIdBytes = itemId.GetBytes();
Array.Copy(itemIdBytes, 0, giveImBinaryBucket, 1, itemIdBytes.Length);
GridInstantMessage giveIm
= new GridInstantMessage(
m_scene,
giverSp.UUID,
giverSp.Name,
receiverSp.UUID,
(byte)InstantMessageDialog.InventoryOffered,
false,
"inventory offered msg",
initialSessionId,
false,
Vector3.Zero,
giveImBinaryBucket,
true);
giverClient.HandleImprovedInstantMessage(giveIm);
// These details might not all be correct.
GridInstantMessage acceptIm
= new GridInstantMessage(
m_scene,
receiverSp.UUID,
receiverSp.Name,
giverSp.UUID,
(byte)InstantMessageDialog.InventoryAccepted,
false,
"inventory accepted msg",
initialSessionId,
false,
Vector3.Zero,
null,
true);
receiverClient.HandleImprovedInstantMessage(acceptIm);
// Test for item remaining in the giver's inventory (here we assume a copy item)
// TODO: Test no-copy items.
InventoryItemBase originalItemAfterGive
= UserInventoryHelpers.GetInventoryItem(m_scene.InventoryService, giverSp.UUID, "Objects/givenObj");
Assert.That(originalItemAfterGive, Is.Not.Null);
Assert.That(originalItemAfterGive.ID, Is.EqualTo(originalItem.ID));
// Test for item successfully making it into the receiver's inventory
InventoryItemBase receivedItem
= UserInventoryHelpers.GetInventoryItem(m_scene.InventoryService, receiverSp.UUID, "Objects/givenObj");
Assert.That(receivedItem, Is.Not.Null);
Assert.That(receivedItem.ID, Is.Not.EqualTo(originalItem.ID));
// Test that on a delete, item still exists and is accessible for the giver.
m_scene.InventoryService.DeleteItems(receiverSp.UUID, new List<UUID>() { receivedItem.ID });
InventoryItemBase originalItemAfterDelete
= UserInventoryHelpers.GetInventoryItem(m_scene.InventoryService, giverSp.UUID, "Objects/givenObj");
Assert.That(originalItemAfterDelete, Is.Not.Null);
// TODO: Test scenario where giver deletes their item first.
}
/// <summary>
/// Test user rejection of a given item.
/// </summary>
/// <remarks>
/// A rejected item still ends up in the user's trash folder.
/// </remarks>
[Test]
public void TestRejectGivenItem()
{
// TestHelpers.EnableLogging();
UUID initialSessionId = TestHelpers.ParseTail(0x10);
UUID itemId = TestHelpers.ParseTail(0x100);
UUID assetId = TestHelpers.ParseTail(0x200);
UserAccount ua1
= UserAccountHelpers.CreateUserWithInventory(m_scene, "User", "One", TestHelpers.ParseTail(0x1), "pw");
UserAccount ua2
= UserAccountHelpers.CreateUserWithInventory(m_scene, "User", "Two", TestHelpers.ParseTail(0x2), "pw");
ScenePresence giverSp = SceneHelpers.AddScenePresence(m_scene, ua1);
TestClient giverClient = (TestClient)giverSp.ControllingClient;
ScenePresence receiverSp = SceneHelpers.AddScenePresence(m_scene, ua2);
TestClient receiverClient = (TestClient)receiverSp.ControllingClient;
// Create the object to test give
InventoryItemBase originalItem
= UserInventoryHelpers.CreateInventoryItem(
m_scene, "givenObj", itemId, assetId, giverSp.UUID, InventoryType.Object);
GridInstantMessage receivedIm = null;
receiverClient.OnReceivedInstantMessage += im => receivedIm = im;
byte[] giveImBinaryBucket = new byte[17];
byte[] itemIdBytes = itemId.GetBytes();
Array.Copy(itemIdBytes, 0, giveImBinaryBucket, 1, itemIdBytes.Length);
GridInstantMessage giveIm
= new GridInstantMessage(
m_scene,
giverSp.UUID,
giverSp.Name,
receiverSp.UUID,
(byte)InstantMessageDialog.InventoryOffered,
false,
"inventory offered msg",
initialSessionId,
false,
Vector3.Zero,
giveImBinaryBucket,
true);
giverClient.HandleImprovedInstantMessage(giveIm);
// These details might not all be correct.
// Session ID is now the created item ID (!)
GridInstantMessage rejectIm
= new GridInstantMessage(
m_scene,
receiverSp.UUID,
receiverSp.Name,
giverSp.UUID,
(byte)InstantMessageDialog.InventoryDeclined,
false,
"inventory declined msg",
new UUID(receivedIm.imSessionID),
false,
Vector3.Zero,
null,
true);
receiverClient.HandleImprovedInstantMessage(rejectIm);
// Test for item remaining in the giver's inventory (here we assume a copy item)
// TODO: Test no-copy items.
InventoryItemBase originalItemAfterGive
= UserInventoryHelpers.GetInventoryItem(m_scene.InventoryService, giverSp.UUID, "Objects/givenObj");
Assert.That(originalItemAfterGive, Is.Not.Null);
Assert.That(originalItemAfterGive.ID, Is.EqualTo(originalItem.ID));
// Test for item successfully making it into the receiver's inventory
InventoryItemBase receivedItem
= UserInventoryHelpers.GetInventoryItem(m_scene.InventoryService, receiverSp.UUID, "Trash/givenObj");
InventoryFolderBase trashFolder
= m_scene.InventoryService.GetFolderForType(receiverSp.UUID, AssetType.TrashFolder);
Assert.That(receivedItem, Is.Not.Null);
Assert.That(receivedItem.ID, Is.Not.EqualTo(originalItem.ID));
Assert.That(receivedItem.Folder, Is.EqualTo(trashFolder.ID));
// Test that on a delete, item still exists and is accessible for the giver.
m_scene.InventoryService.PurgeFolder(trashFolder);
InventoryItemBase originalItemAfterDelete
= UserInventoryHelpers.GetInventoryItem(m_scene.InventoryService, giverSp.UUID, "Objects/givenObj");
Assert.That(originalItemAfterDelete, Is.Not.Null);
}
[Test]
public void TestAcceptGivenFolder()
{
TestHelpers.InMethod();
// TestHelpers.EnableLogging();
UUID initialSessionId = TestHelpers.ParseTail(0x10);
UUID folderId = TestHelpers.ParseTail(0x100);
UserAccount ua1
= UserAccountHelpers.CreateUserWithInventory(m_scene, "User", "One", TestHelpers.ParseTail(0x1), "pw");
UserAccount ua2
= UserAccountHelpers.CreateUserWithInventory(m_scene, "User", "Two", TestHelpers.ParseTail(0x2), "pw");
ScenePresence giverSp = SceneHelpers.AddScenePresence(m_scene, ua1);
TestClient giverClient = (TestClient)giverSp.ControllingClient;
ScenePresence receiverSp = SceneHelpers.AddScenePresence(m_scene, ua2);
TestClient receiverClient = (TestClient)receiverSp.ControllingClient;
InventoryFolderBase originalFolder
= UserInventoryHelpers.CreateInventoryFolder(
m_scene.InventoryService, giverSp.UUID, folderId, "f1", true);
byte[] giveImBinaryBucket = new byte[17];
giveImBinaryBucket[0] = (byte)AssetType.Folder;
byte[] itemIdBytes = folderId.GetBytes();
Array.Copy(itemIdBytes, 0, giveImBinaryBucket, 1, itemIdBytes.Length);
GridInstantMessage giveIm
= new GridInstantMessage(
m_scene,
giverSp.UUID,
giverSp.Name,
receiverSp.UUID,
(byte)InstantMessageDialog.InventoryOffered,
false,
"inventory offered msg",
initialSessionId,
false,
Vector3.Zero,
giveImBinaryBucket,
true);
giverClient.HandleImprovedInstantMessage(giveIm);
// These details might not all be correct.
GridInstantMessage acceptIm
= new GridInstantMessage(
m_scene,
receiverSp.UUID,
receiverSp.Name,
giverSp.UUID,
(byte)InstantMessageDialog.InventoryAccepted,
false,
"inventory accepted msg",
initialSessionId,
false,
Vector3.Zero,
null,
true);
receiverClient.HandleImprovedInstantMessage(acceptIm);
// Test for item remaining in the giver's inventory (here we assume a copy item)
// TODO: Test no-copy items.
InventoryFolderBase originalFolderAfterGive
= UserInventoryHelpers.GetInventoryFolder(m_scene.InventoryService, giverSp.UUID, "f1");
Assert.That(originalFolderAfterGive, Is.Not.Null);
Assert.That(originalFolderAfterGive.ID, Is.EqualTo(originalFolder.ID));
// Test for item successfully making it into the receiver's inventory
InventoryFolderBase receivedFolder
= UserInventoryHelpers.GetInventoryFolder(m_scene.InventoryService, receiverSp.UUID, "f1");
Assert.That(receivedFolder, Is.Not.Null);
Assert.That(receivedFolder.ID, Is.Not.EqualTo(originalFolder.ID));
// Test that on a delete, item still exists and is accessible for the giver.
m_scene.InventoryService.DeleteFolders(receiverSp.UUID, new List<UUID>() { receivedFolder.ID });
InventoryFolderBase originalFolderAfterDelete
= UserInventoryHelpers.GetInventoryFolder(m_scene.InventoryService, giverSp.UUID, "f1");
Assert.That(originalFolderAfterDelete, Is.Not.Null);
// TODO: Test scenario where giver deletes their item first.
}
/// <summary>
/// Test user rejection of a given item.
/// </summary>
/// <remarks>
/// A rejected item still ends up in the user's trash folder.
/// </remarks>
[Test]
public void TestRejectGivenFolder()
{
TestHelpers.InMethod();
// TestHelpers.EnableLogging();
UUID initialSessionId = TestHelpers.ParseTail(0x10);
UUID folderId = TestHelpers.ParseTail(0x100);
UserAccount ua1
= UserAccountHelpers.CreateUserWithInventory(m_scene, "User", "One", TestHelpers.ParseTail(0x1), "pw");
UserAccount ua2
= UserAccountHelpers.CreateUserWithInventory(m_scene, "User", "Two", TestHelpers.ParseTail(0x2), "pw");
ScenePresence giverSp = SceneHelpers.AddScenePresence(m_scene, ua1);
TestClient giverClient = (TestClient)giverSp.ControllingClient;
ScenePresence receiverSp = SceneHelpers.AddScenePresence(m_scene, ua2);
TestClient receiverClient = (TestClient)receiverSp.ControllingClient;
// Create the folder to test give
InventoryFolderBase originalFolder
= UserInventoryHelpers.CreateInventoryFolder(
m_scene.InventoryService, giverSp.UUID, folderId, "f1", true);
GridInstantMessage receivedIm = null;
receiverClient.OnReceivedInstantMessage += im => receivedIm = im;
byte[] giveImBinaryBucket = new byte[17];
giveImBinaryBucket[0] = (byte)AssetType.Folder;
byte[] itemIdBytes = folderId.GetBytes();
Array.Copy(itemIdBytes, 0, giveImBinaryBucket, 1, itemIdBytes.Length);
GridInstantMessage giveIm
= new GridInstantMessage(
m_scene,
giverSp.UUID,
giverSp.Name,
receiverSp.UUID,
(byte)InstantMessageDialog.InventoryOffered,
false,
"inventory offered msg",
initialSessionId,
false,
Vector3.Zero,
giveImBinaryBucket,
true);
giverClient.HandleImprovedInstantMessage(giveIm);
// These details might not all be correct.
// Session ID is now the created item ID (!)
GridInstantMessage rejectIm
= new GridInstantMessage(
m_scene,
receiverSp.UUID,
receiverSp.Name,
giverSp.UUID,
(byte)InstantMessageDialog.InventoryDeclined,
false,
"inventory declined msg",
new UUID(receivedIm.imSessionID),
false,
Vector3.Zero,
null,
true);
receiverClient.HandleImprovedInstantMessage(rejectIm);
// Test for item remaining in the giver's inventory (here we assume a copy item)
// TODO: Test no-copy items.
InventoryFolderBase originalFolderAfterGive
= UserInventoryHelpers.GetInventoryFolder(m_scene.InventoryService, giverSp.UUID, "f1");
Assert.That(originalFolderAfterGive, Is.Not.Null);
Assert.That(originalFolderAfterGive.ID, Is.EqualTo(originalFolder.ID));
// Test for folder successfully making it into the receiver's inventory
InventoryFolderBase receivedFolder
= UserInventoryHelpers.GetInventoryFolder(m_scene.InventoryService, receiverSp.UUID, "Trash/f1");
InventoryFolderBase trashFolder
= m_scene.InventoryService.GetFolderForType(receiverSp.UUID, AssetType.TrashFolder);
Assert.That(receivedFolder, Is.Not.Null);
Assert.That(receivedFolder.ID, Is.Not.EqualTo(originalFolder.ID));
Assert.That(receivedFolder.ParentID, Is.EqualTo(trashFolder.ID));
// Test that on a delete, item still exists and is accessible for the giver.
m_scene.InventoryService.PurgeFolder(trashFolder);
InventoryFolderBase originalFolderAfterDelete
= UserInventoryHelpers.GetInventoryFolder(m_scene.InventoryService, giverSp.UUID, "f1");
Assert.That(originalFolderAfterDelete, Is.Not.Null);
}
}
}

View File

@ -97,6 +97,9 @@ public abstract class BSPhysObject : PhysicsActor
CollisionCollection = new CollisionEventUpdate();
CollisionsLastReported = CollisionCollection;
CollisionsLastTick = new CollisionEventUpdate();
CollisionsLastTickStep = -1;
SubscribedEventsMs = 0;
CollidingStep = 0;
CollidingGroundStep = 0;

View File

@ -171,11 +171,6 @@ namespace OpenSim.Server.Base
m_console = MainConsole.Instance;
// Configure the appenders for log4net
//
OpenSimAppender consoleAppender = null;
FileAppender fileAppender = null;
if (logConfig != null)
{
FileInfo cfg = new FileInfo(logConfig);

View File

@ -217,13 +217,38 @@ namespace OpenSim.Tests.Common
/// </returns>
public static InventoryFolderBase CreateInventoryFolder(
IInventoryService inventoryService, UUID userId, string path, bool useExistingFolders)
{
return CreateInventoryFolder(inventoryService, userId, UUID.Random(), path, useExistingFolders);
}
/// <summary>
/// Create inventory folders starting from the user's root folder.
/// </summary>
/// <param name="inventoryService"></param>
/// <param name="userId"></param>
/// <param name="folderId"></param>
/// <param name="path">
/// The folders to create. Multiple folders can be specified on a path delimited by the PATH_DELIMITER
/// </param>
/// <param name="useExistingFolders">
/// If true, then folders in the path which already the same name are
/// used. This applies to the terminal folder as well.
/// If false, then all folders in the path are created, even if there is already a folder at a particular
/// level with the same name.
/// </param>
/// <returns>
/// The folder created. If the path contains multiple folders then the last one created is returned.
/// Will return null if the root folder could not be found.
/// </returns>
public static InventoryFolderBase CreateInventoryFolder(
IInventoryService inventoryService, UUID userId, UUID folderId, string path, bool useExistingFolders)
{
InventoryFolderBase rootFolder = inventoryService.GetRootFolder(userId);
if (null == rootFolder)
return null;
return CreateInventoryFolder(inventoryService, rootFolder, path, useExistingFolders);
return CreateInventoryFolder(inventoryService, folderId, rootFolder, path, useExistingFolders);
}
/// <summary>
@ -235,6 +260,7 @@ namespace OpenSim.Tests.Common
/// TODO: May need to make it an option to create duplicate folders.
/// </remarks>
/// <param name="inventoryService"></param>
/// <param name="folderId">ID of the folder to create</param>
/// <param name="parentFolder"></param>
/// <param name="path">
/// The folder to create.
@ -249,7 +275,7 @@ namespace OpenSim.Tests.Common
/// The folder created. If the path contains multiple folders then the last one created is returned.
/// </returns>
public static InventoryFolderBase CreateInventoryFolder(
IInventoryService inventoryService, InventoryFolderBase parentFolder, string path, bool useExistingFolders)
IInventoryService inventoryService, UUID folderId, InventoryFolderBase parentFolder, string path, bool useExistingFolders)
{
string[] components = path.Split(new string[] { PATH_DELIMITER }, 2, StringSplitOptions.None);
@ -262,9 +288,16 @@ namespace OpenSim.Tests.Common
{
// Console.WriteLine("Creating folder {0} at {1}", components[0], parentFolder.Name);
UUID folderIdForCreate;
if (components.Length > 1)
folderIdForCreate = UUID.Random();
else
folderIdForCreate = folderId;
folder
= new InventoryFolderBase(
UUID.Random(), components[0], parentFolder.Owner, (short)AssetType.Unknown, parentFolder.ID, 0);
folderIdForCreate, components[0], parentFolder.Owner, (short)AssetType.Unknown, parentFolder.ID, 0);
inventoryService.AddFolder(folder);
}
@ -274,7 +307,7 @@ namespace OpenSim.Tests.Common
// }
if (components.Length > 1)
return CreateInventoryFolder(inventoryService, folder, components[1], useExistingFolders);
return CreateInventoryFolder(inventoryService, folderId, folder, components[1], useExistingFolders);
else
return folder;
}

View File

@ -61,6 +61,7 @@ namespace OpenSim.Tests.Common.Mock
// Test client specific events - for use by tests to implement some IClientAPI behaviour.
public event Action<RegionInfo, Vector3, Vector3> OnReceivedMoveAgentIntoRegion;
public event Action<ulong, IPEndPoint> OnTestClientInformClientOfNeighbour;
public event Action<GridInstantMessage> OnReceivedInstantMessage;
// disable warning: public events, part of the public API
#pragma warning disable 67
@ -487,6 +488,18 @@ namespace OpenSim.Tests.Common.Mock
OnCompleteMovementToRegion(this, true);
}
/// <summary>
/// Emulate sending an IM from the viewer to the simulator.
/// </summary>
/// <param name='im'></param>
public void HandleImprovedInstantMessage(GridInstantMessage im)
{
ImprovedInstantMessage handlerInstantMessage = OnInstantMessage;
if (handlerInstantMessage != null)
handlerInstantMessage(this, im);
}
public virtual void ActivateGesture(UUID assetId, UUID gestureId)
{
}
@ -547,7 +560,8 @@ namespace OpenSim.Tests.Common.Mock
public void SendInstantMessage(GridInstantMessage im)
{
if (OnReceivedInstantMessage != null)
OnReceivedInstantMessage(im);
}
public void SendGenericMessage(string method, UUID invoice, List<string> message)

View File

@ -53,6 +53,9 @@ namespace OpenSim.Tests.Common.Mock
public XInventoryFolder[] GetFolders(string[] fields, string[] vals)
{
// Console.WriteLine(
// "Requesting folders, fields {0}, vals {1}", string.Join(",", fields), string.Join(",", vals));
List<XInventoryFolder> origFolders
= Get<XInventoryFolder>(fields, vals, m_allFolders.Values.ToList());
@ -104,7 +107,30 @@ namespace OpenSim.Tests.Common.Mock
}
public bool MoveItem(string id, string newParent) { throw new NotImplementedException(); }
public bool MoveFolder(string id, string newParent) { throw new NotImplementedException(); }
public bool MoveFolder(string id, string newParent)
{
// Don't use GetFolders() here - it takes a clone!
XInventoryFolder folder = m_allFolders[new UUID(id)];
if (folder == null)
return false;
folder.parentFolderID = new UUID(newParent);
XInventoryFolder[] newParentFolders
= GetFolders(new string[] { "folderID" }, new string[] { folder.parentFolderID.ToString() });
// Console.WriteLine(
// "Moved folder {0} {1}, to {2} {3}",
// folder.folderName, folder.folderID, newParentFolders[0].folderName, folder.parentFolderID);
// TODO: Really need to implement folder version incrementing, though this should be common code anyway,
// not reimplemented in each db plugin.
return true;
}
public XInventoryItem[] GetActiveGestures(UUID principalID) { throw new NotImplementedException(); }
public int GetAssetPermissions(UUID principalID, UUID assetID) { throw new NotImplementedException(); }
}

View File

@ -3180,6 +3180,7 @@
<Match path="Avatar/AvatarFactory/Tests" pattern="*.cs" recurse="true"/>
<Match path="Avatar/Friends/Tests" pattern="*.cs" recurse="true"/>
<Match path="Avatar/Inventory/Archiver/Tests" pattern="*.cs" recurse="true"/>
<Match path="Avatar/Inventory/Transfer/Tests" pattern="*.cs" recurse="true"/>
<Match path="Framework/InventoryAccess/Tests" pattern="*.cs" recurse="true"/>
<Match path="Scripting/VectorRender/Tests" pattern="*.cs" recurse="true"/>
<Match path="World/Archiver/Tests" pattern="*.cs" recurse="true"/>