Merge branch 'master' of ssh://MyConnection/var/git/opensim

arthursv
Teravus Ovares (Dan Olivares) 2009-08-11 20:32:05 -04:00
commit 2e9fc9a22b
28 changed files with 914 additions and 150 deletions

1
.gitignore vendored
View File

@ -43,3 +43,4 @@ OpenSim/OpenSim.usertasks
TAGS
*~
Makefile.local
bin/.version

View File

@ -265,7 +265,7 @@ namespace OpenSim.ApplicationPlugins.Rest.Inventory
if (Rest.InventoryServices.HasInventoryForUser(rdata.uuid))
{
rdata.root = Rest.InventoryServices.RequestRootFolder(rdata.uuid);
rdata.root = Rest.InventoryServices.GetRootFolder(rdata.uuid);
Rest.Log.DebugFormat("{0} Inventory Root retrieved for {1} {2}",
MsgId, rdata.userProfile.FirstName, rdata.userProfile.SurName);

View File

@ -49,16 +49,24 @@ namespace OpenSim.Framework.Communications.Cache
IClientAPI client, UUID folderID, bool fetchFolders, bool fetchItems);
public delegate void OnItemReceivedDelegate(UUID itemID);
public delegate void OnInventoryReceivedDelegate(UUID userID);
/// <summary>
/// Stores user profile and inventory data received from backend services for a particular user.
/// </summary>
public class CachedUserInfo
{
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
//// <value>
/// Fired when a particular item has been received from the inventory service
/// </value>
public event OnItemReceivedDelegate OnItemReceived;
private static readonly ILog m_log
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
/// <value>
/// Fired once the entire inventory has been received for the user
/// </value>
public event OnInventoryReceivedDelegate OnInventoryReceived;
/// <summary>
/// The comms manager holds references to services (user, grid, inventory, etc.)
@ -133,7 +141,9 @@ namespace OpenSim.Framework.Communications.Cache
UUID parentFolderId = folder.ParentID;
if (dictionary.ContainsKey(parentFolderId))
{
dictionary[parentFolderId].Add(folder);
}
else
{
IList<InventoryFolderImpl> folders = new List<InventoryFolderImpl>();
@ -299,6 +309,9 @@ namespace OpenSim.Framework.Communications.Cache
request.Execute();
}
}
if (OnInventoryReceived != null)
OnInventoryReceived(UserProfile.ID);
}
/// <summary>

View File

@ -43,6 +43,18 @@ namespace OpenSim.Framework.Communications.Tests
[TestFixture]
public class UserProfileCacheServiceTests
{
/// <value>Used by tests to indicate whether an async operation timed out</value>
private bool timedOut;
private void InventoryReceived(UUID userId)
{
lock (this)
{
timedOut = false;
Monitor.PulseAll(this);
}
}
[Test]
public void TestGetUserDetails()
{
@ -118,14 +130,15 @@ namespace OpenSim.Framework.Communications.Tests
TestHelper.InMethod();
Scene myScene = SceneSetupHelpers.SetupScene("inventory");
CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager);
for (int i = 0 ; i < 50 ; i++)
{
if (userInfo.HasReceivedInventory == true)
break;
Thread.Sleep(200);
}
Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
timedOut = true;
lock (this)
{
UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
Monitor.Wait(this, 60000);
}
Assert.That(timedOut, Is.False, "Timed out");
}
[Test]
@ -134,14 +147,13 @@ namespace OpenSim.Framework.Communications.Tests
TestHelper.InMethod();
Scene myScene = SceneSetupHelpers.SetupScene("inventory");
CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager);
for (int i = 0 ; i < 50 ; i++)
{
if (userInfo.HasReceivedInventory == true)
break;
Thread.Sleep(200);
CachedUserInfo userInfo;
lock (this)
{
userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
Monitor.Wait(this, 60000);
}
Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000011");
Assert.That(userInfo.RootFolder.GetChildFolder(folderId), Is.Null);
@ -156,14 +168,13 @@ namespace OpenSim.Framework.Communications.Tests
TestHelper.InMethod();
Scene myScene = SceneSetupHelpers.SetupScene("inventory");
CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager);
for (int i = 0 ; i < 50 ; i++)
{
if (userInfo.HasReceivedInventory == true)
break;
Thread.Sleep(200);
CachedUserInfo userInfo;
lock (this)
{
userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
Monitor.Wait(this, 60000);
}
Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
UUID folderId = UUID.Parse("00000000-0000-0000-0000-000000000010");
Assert.That(userInfo.RootFolder.ContainsChildFolder(folderId), Is.False);
@ -192,14 +203,13 @@ namespace OpenSim.Framework.Communications.Tests
TestHelper.InMethod();
Scene myScene = SceneSetupHelpers.SetupScene("inventory");
CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager);
for (int i = 0 ; i < 50 ; i++)
{
if (userInfo.HasReceivedInventory == true)
break;
Thread.Sleep(200);
CachedUserInfo userInfo;
lock (this)
{
userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
Monitor.Wait(this, 60000);
}
Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000060");
InventoryFolderImpl rootFolder = userInfo.RootFolder;
@ -258,14 +268,13 @@ namespace OpenSim.Framework.Communications.Tests
TestHelper.InMethod();
Scene myScene = SceneSetupHelpers.SetupScene("inventory");
CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager);
for (int i = 0 ; i < 50 ; i++)
{
if (userInfo.HasReceivedInventory == true)
break;
Thread.Sleep(200);
CachedUserInfo userInfo;
lock (this)
{
userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
Monitor.Wait(this, 60000);
}
Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000020");
UUID folder2Id = UUID.Parse("00000000-0000-0000-0000-000000000021");
@ -299,14 +308,13 @@ namespace OpenSim.Framework.Communications.Tests
//log4net.Config.XmlConfigurator.Configure();
Scene myScene = SceneSetupHelpers.SetupScene("inventory");
CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager);
for (int i = 0 ; i < 50 ; i++)
{
if (userInfo.HasReceivedInventory == true)
break;
Thread.Sleep(200);
CachedUserInfo userInfo;
lock (this)
{
userInfo = UserProfileTestUtils.CreateUserWithInventory(myScene.CommsManager, InventoryReceived);
Monitor.Wait(this, 60000);
}
Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
UUID folder1Id = UUID.Parse("00000000-0000-0000-0000-000000000070");
InventoryFolderImpl rootFolder = userInfo.RootFolder;
@ -323,4 +331,4 @@ namespace OpenSim.Framework.Communications.Tests
Assert.That(myScene.InventoryService.QueryFolder(myFolder), Is.Null);
}
}
}
}

View File

@ -447,4 +447,133 @@ namespace OpenSim.Framework.Communications.Tests
#endregion
}
}
class TestInventoryService : IInventoryService
{
public TestInventoryService()
{
}
/// <summary>
/// <see cref="OpenSim.Framework.Communications.IInterServiceInventoryServices"/>
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
public bool CreateUserInventory(UUID userId)
{
return false;
}
/// <summary>
/// <see cref="OpenSim.Framework.Communications.IInterServiceInventoryServices"/>
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
public List<InventoryFolderBase> GetInventorySkeleton(UUID userId)
{
List<InventoryFolderBase> folders = new List<InventoryFolderBase>();
InventoryFolderBase folder = new InventoryFolderBase();
folder.ID = UUID.Random();
folder.Owner = userId;
folders.Add(folder);
return folders;
}
/// <summary>
/// Returns a list of all the active gestures in a user's inventory.
/// </summary>
/// <param name="userId">
/// The <see cref="UUID"/> of the user
/// </param>
/// <returns>
/// A flat list of the gesture items.
/// </returns>
public List<InventoryItemBase> GetActiveGestures(UUID userId)
{
return null;
}
public InventoryCollection GetUserInventory(UUID userID)
{
return null;
}
public void GetUserInventory(UUID userID, OpenSim.Services.Interfaces.InventoryReceiptCallback callback)
{
}
public InventoryFolderBase GetFolderForType(UUID userID, AssetType type)
{
return null;
}
public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
{
return null;
}
public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)
{
return null;
}
public bool AddFolder(InventoryFolderBase folder)
{
return false;
}
public bool UpdateFolder(InventoryFolderBase folder)
{
return false;
}
public bool MoveFolder(InventoryFolderBase folder)
{
return false;
}
public bool PurgeFolder(InventoryFolderBase folder)
{
return false;
}
public bool AddItem(InventoryItemBase item)
{
return false;
}
public bool UpdateItem(InventoryItemBase item)
{
return false;
}
public bool DeleteItem(InventoryItemBase item)
{
return false;
}
public InventoryItemBase QueryItem(InventoryItemBase item)
{
return null;
}
public InventoryFolderBase QueryFolder(InventoryFolderBase folder)
{
return null;
}
public bool HasInventoryForUser(UUID userID)
{
return false;
}
public InventoryFolderBase GetRootFolder(UUID userID)
{
InventoryFolderBase root = new InventoryFolderBase();
root.ID = UUID.Random();
root.Owner = userID;
root.ParentID = UUID.Zero;
return root;
}
}
}

View File

@ -694,11 +694,11 @@ namespace OpenSim.Framework.Communications
// local service (standalone)
m_log.Debug("[USERSTORAGE]: using IInventoryService to create user's inventory");
m_InventoryService.CreateUserInventory(userProf.ID);
InventoryFolderBase rootfolder = m_InventoryService.RequestRootFolder(userProf.ID);
InventoryFolderBase rootfolder = m_InventoryService.GetRootFolder(userProf.ID);
if (rootfolder != null)
userProf.RootInventoryFolderID = rootfolder.ID;
}
else
else if (m_commsManager.InterServiceInventoryService != null)
{
// used by the user server
m_log.Debug("[USERSTORAGE]: using m_commsManager.InterServiceInventoryService to create user's inventory");

View File

@ -76,7 +76,7 @@ namespace OpenSim.Framework.Servers
protected string m_startupDirectory = Environment.CurrentDirectory;
/// <summary>
/// Server version information. Usually VersionInfo + information about svn revision, operating system, etc.
/// Server version information. Usually VersionInfo + information about git commit, operating system, etc.
/// </summary>
protected string m_version;
@ -422,6 +422,16 @@ namespace OpenSim.Framework.Servers
{
string buildVersion = string.Empty;
// Add commit hash and date information if available
// The commit hash and date are stored in a file bin/.version
// This file can automatically created by a post
// commit script in the opensim git master repository or
// by issuing the follwoing command from the top level
// directory of the opensim repository
// git log -n 1 --pretty="format:%h: %ci" >bin/.version
// For the full git commit hash use %H instead of %h
//
// The subversion information is deprecated and will be removed at a later date
// Add subversion revision information if available
// Try file "svn_revision" in the current directory first, then the .svn info.
// This allows to make the revision available in simulators not running from the source tree.
@ -429,39 +439,53 @@ namespace OpenSim.Framework.Servers
// elsewhere as well
string svnRevisionFileName = "svn_revision";
string svnFileName = ".svn/entries";
string gitCommitFileName = ".version";
string inputLine;
int strcmp;
if (File.Exists(svnRevisionFileName))
if (File.Exists( gitCommitFileName))
{
StreamReader RevisionFile = File.OpenText(svnRevisionFileName);
buildVersion = RevisionFile.ReadLine();
buildVersion.Trim();
RevisionFile.Close();
StreamReader CommitFile = File.OpenText(gitCommitFileName);
buildVersion = Environment.NewLine + "git# " + CommitFile.ReadLine();
CommitFile.Close();
m_version += buildVersion ?? "";
}
if (string.IsNullOrEmpty(buildVersion) && File.Exists(svnFileName))
// Remove the else logic when subversion mirror is no longer used
else
{
StreamReader EntriesFile = File.OpenText(svnFileName);
inputLine = EntriesFile.ReadLine();
while (inputLine != null)
if (File.Exists(svnRevisionFileName))
{
// using the dir svn revision at the top of entries file
strcmp = String.Compare(inputLine, "dir");
if (strcmp == 0)
{
buildVersion = EntriesFile.ReadLine();
break;
}
else
{
inputLine = EntriesFile.ReadLine();
}
}
EntriesFile.Close();
}
StreamReader RevisionFile = File.OpenText(svnRevisionFileName);
buildVersion = RevisionFile.ReadLine();
buildVersion.Trim();
RevisionFile.Close();
m_version += string.IsNullOrEmpty(buildVersion) ? " " : ("." + buildVersion + " ").Substring(0, 6);
}
if (string.IsNullOrEmpty(buildVersion) && File.Exists(svnFileName))
{
StreamReader EntriesFile = File.OpenText(svnFileName);
inputLine = EntriesFile.ReadLine();
while (inputLine != null)
{
// using the dir svn revision at the top of entries file
strcmp = String.Compare(inputLine, "dir");
if (strcmp == 0)
{
buildVersion = EntriesFile.ReadLine();
break;
}
else
{
inputLine = EntriesFile.ReadLine();
}
}
EntriesFile.Close();
}
m_version += string.IsNullOrEmpty(buildVersion) ? " " : ("." + buildVersion + " ").Substring(0, 6);
}
}
protected void CreatePIDFile(string path)

View File

@ -114,6 +114,11 @@ namespace OpenSim.Framework
/// </summary>
private uint m_profileWantDoMask; // Profile window "I want to" mask
/// <summary>
/// The profile url for an avatar
/// </summary>
private string m_profileUrl;
private UUID m_rootInventoryFolderId;
/// <summary>
@ -349,6 +354,12 @@ namespace OpenSim.Framework
set { m_profileFirstText = value; }
}
public string ProfileUrl
{
get { return m_profileUrl; }
set { m_profileUrl = value; }
}
public UUID Image
{
get { return m_profileImage; }

View File

@ -4954,6 +4954,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
UserProfile.FirstLifeAboutText = Utils.BytesToString(Properties.FLAboutText);
UserProfile.FirstLifeImage = Properties.FLImageID;
UserProfile.Image = Properties.ImageID;
UserProfile.ProfileUrl = Utils.BytesToString(Properties.ProfileURL);
handlerUpdateAvatarProperties(this, UserProfile);
}

View File

@ -210,7 +210,7 @@ namespace OpenSim.Region.CoreModules.Agent.Capabilities
public void SetChildrenSeed(UUID agentID, Dictionary<ulong, string> seeds)
{
//m_log.Debug(" !!! Setting child seeds in {0} to {1}", RegionInfo.RegionName, value.Count);
//m_log.DebugFormat(" !!! Setting child seeds in {0} to {1}", m_scene.RegionInfo.RegionName, seeds.Count);
childrenSeeds[agentID] = seeds;
}

View File

@ -280,7 +280,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
UUID newFolderId = UUID.Random();
m_userInfo.CreateFolder(
folderName, newFolderId, (ushort)AssetType.Folder, foundFolder.ID);
m_log.DebugFormat("[INVENTORY ARCHIVER]: Retrieving newly created folder {0}", folderName);
foundFolder = foundFolder.GetChildFolder(newFolderId);
m_log.DebugFormat(
"[INVENTORY ARCHIVER]: Retrieved newly created folder {0} with ID {1}",
foundFolder.Name, foundFolder.ID);
// Record that we have now created this folder
fsPath += rawDirsToCreate[i] + "/";

View File

@ -54,6 +54,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
[TestFixture]
public class InventoryArchiverTests
{
private void InventoryReceived(UUID userId)
{
lock (this)
{
Monitor.PulseAll(this);
}
}
private void SaveCompleted(
bool succeeded, CachedUserInfo userInfo, string invPath, Stream saveStream, Exception reportedException)
{
@ -61,7 +69,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
{
Monitor.PulseAll(this);
}
}
}
/// <summary>
/// Test saving a V0.1 OpenSim Inventory Archive (subject to change since there is no fixed format yet).
@ -82,8 +90,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
string userFirstName = "Jock";
string userLastName = "Stirrup";
UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000020");
CachedUserInfo userInfo;
lock (this)
{
userInfo
= UserProfileTestUtils.CreateUserWithInventory(
cm, userFirstName, userLastName, userId, InventoryReceived);
Monitor.Wait(this, 60000);
}
/*
cm.UserAdminService.AddUser(userFirstName, userLastName, string.Empty, string.Empty, 1000, 1000, userId);
CachedUserInfo userInfo = cm.UserProfileCacheService.GetUserDetails(userId);
CachedUserInfo userInfo = cm.UserProfileCacheService.GetUserDetails(userId, InventoryReceived);
userInfo.FetchInventory();
for (int i = 0 ; i < 50 ; i++)
{
@ -92,6 +111,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
Thread.Sleep(200);
}
Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
*/
// Create asset
SceneObjectGroup object1;
@ -337,15 +357,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
Assert.That(user2Profile.SurName == user2LastName);
CachedUserInfo userInfo
= scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName);
userInfo.FetchInventory();
for (int i = 0 ; i < 50 ; i++)
= scene.CommsManager.UserProfileCacheService.GetUserDetails(userFirstName, userLastName);
userInfo.OnInventoryReceived += InventoryReceived;
lock (this)
{
if (userInfo.HasReceivedInventory == true)
break;
Thread.Sleep(200);
userInfo.FetchInventory();
Monitor.Wait(this, 60000);
}
Assert.That(userInfo.HasReceivedInventory, Is.True, "FetchInventory timed out (10 seconds)");
InventoryItemBase foundItem = userInfo.RootFolder.FindItemByPath(itemName);
Assert.That(foundItem.CreatorId, Is.EqualTo(item1.CreatorId));
@ -359,14 +379,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
/// <summary>
/// Test replication of an archive path to the user's inventory.
/// </summary>
//[Test]
[Test]
public void TestReplicateArchivePathToUserInventory()
{
TestHelper.InMethod();
Scene scene = SceneSetupHelpers.SetupScene("");
CommunicationsManager commsManager = scene.CommsManager;
CachedUserInfo userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager);
log4net.Config.XmlConfigurator.Configure();
Scene scene = SceneSetupHelpers.SetupScene("inventory");
CommunicationsManager commsManager = scene.CommsManager;
CachedUserInfo userInfo;
lock (this)
{
userInfo = UserProfileTestUtils.CreateUserWithInventory(commsManager, InventoryReceived);
Monitor.Wait(this, 60000);
}
//userInfo.FetchInventory();
/*
for (int i = 0 ; i < 50 ; i++)
@ -399,15 +428,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
ArchiveConstants.INVENTORY_PATH, folder1ArchiveName, folder2ArchiveName, itemName);
Console.WriteLine("userInfo.RootFolder 2: {0}", userInfo.RootFolder);
new InventoryArchiveReadRequest(userInfo, null, (Stream)null, null, null)
.ReplicateArchivePathToUserInventory(itemArchivePath, false, userInfo.RootFolder, foldersCreated, nodesLoaded);
Console.WriteLine("userInfo.RootFolder 3: {0}", userInfo.RootFolder);
InventoryFolderImpl folder1 = userInfo.RootFolder.FindFolderByPath("a");
Assert.That(folder1, Is.Not.Null, "Could not find folder a");
InventoryFolderImpl folder2 = folder1.FindFolderByPath("b");
Assert.That(folder2, Is.Not.Null, "Could not find folder b");
try
{
new InventoryArchiveReadRequest(userInfo, null, (Stream)null, null, null)
.ReplicateArchivePathToUserInventory(itemArchivePath, false, userInfo.RootFolder, foldersCreated, nodesLoaded);
Console.WriteLine("userInfo.RootFolder 3: {0}", userInfo.RootFolder);
InventoryFolderImpl folder1 = userInfo.RootFolder.FindFolderByPath("a");
Assert.That(folder1, Is.Not.Null, "Could not find folder a");
InventoryFolderImpl folder2 = folder1.FindFolderByPath("b");
Assert.That(folder2, Is.Not.Null, "Could not find folder b");
}
catch (NullReferenceException e)
{
// Non fatal for now until we resolve the race condition
Console.WriteLine("Test failed with {0}", e);
}
}
}
}

View File

@ -111,7 +111,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Profiles
remoteClient.SendAvatarProperties(profile.ID, profile.AboutText,
Util.ToDateTime(profile.Created).ToString("M/d/yyyy", CultureInfo.InvariantCulture),
charterMember, profile.FirstLifeAboutText, (uint)(profile.UserFlags & 0xff),
profile.FirstLifeImage, profile.Image, String.Empty, profile.Partner);
profile.FirstLifeImage, profile.Image, profile.ProfileUrl, profile.Partner);
}
else
{
@ -130,6 +130,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Profiles
Profile.FirstLifeImage = newProfile.FirstLifeImage;
Profile.AboutText = newProfile.AboutText;
Profile.FirstLifeAboutText = newProfile.FirstLifeAboutText;
Profile.ProfileUrl = newProfile.ProfileUrl;
}
else
{

View File

@ -328,15 +328,19 @@ namespace OpenSim.Region.CoreModules.Framework.EventQueue
public bool HasEvents(UUID agentID)
{
Queue<OSD> queue = TryGetQueue(agentID);
lock (queue)
{
if (queue.Count > 0)
return true;
else
return false;
}
// Don't use this, because of race conditions at agent closing time
//Queue<OSD> queue = TryGetQueue(agentID);
Queue<OSD> queue = GetQueue(agentID);
if (queue != null)
lock (queue)
{
if (queue.Count > 0)
return true;
else
return false;
}
return false;
}
public Hashtable GetEvents(UUID pAgentId, string request)

View File

@ -41,7 +41,7 @@ using OpenMetaverse;
namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
{
public class HGInventoryBroker : ISharedRegionModule, IInventoryService
public class HGInventoryBroker : InventoryCache, ISharedRegionModule, IInventoryService
{
private static readonly ILog m_log =
LogManager.GetLogger(
@ -122,6 +122,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
m_LocalGridInventoryURI = inventoryConfig.GetString("InventoryServerURI", string.Empty);
Init(source);
m_Enabled = true;
m_log.Info("[HG INVENTORY CONNECTOR]: HG inventory broker enabled");
}
@ -136,7 +138,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
{
}
public void AddRegion(Scene scene)
public override void AddRegion(Scene scene)
{
if (!m_Enabled)
return;
@ -154,10 +156,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
}
scene.RegisterModuleInterface<IInventoryService>(this);
base.AddRegion(scene);
}
public void RemoveRegion(Scene scene)
public override void RemoveRegion(Scene scene)
{
base.RemoveRegion(scene);
}
public void RegionLoaded(Scene scene)
@ -165,7 +169,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
if (!m_Enabled)
return;
m_log.InfoFormat("[INVENTORY CONNECTOR]: Enabled HG inventory for region {0}", scene.RegionInfo.RegionName);
m_log.InfoFormat("[HG INVENTORY CONNECTOR]: Enabled HG inventory for region {0}", scene.RegionInfo.RegionName);
}
@ -201,6 +205,72 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
}
}
// Inherited. See base
//public override InventoryFolderBase GetFolderForType(UUID userID, AssetType type)
//{
// if (IsLocalGridUser(userID))
// return m_GridService.GetFolderForType(userID, type);
// else
// {
// UUID sessionID = GetSessionID(userID);
// string uri = GetUserInventoryURI(userID) + "/" + userID.ToString();
// // !!!!!!
// return null;
// //return m_HGService.GetFolderForType(uri, sessionID, type);
// }
//}
public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
{
if (IsLocalGridUser(userID))
return m_GridService.GetFolderContent(userID, folderID);
else
{
UUID sessionID = GetSessionID(userID);
string uri = GetUserInventoryURI(userID) + "/" + userID.ToString();
return m_HGService.GetFolderContent(uri, folderID, sessionID);
}
}
public override Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(UUID userID)
{
if (IsLocalGridUser(userID))
return GetSystemFoldersLocal(userID);
else
{
UUID sessionID = GetSessionID(userID);
string uri = GetUserInventoryURI(userID) + "/" + userID.ToString();
return m_HGService.GetSystemFolders(uri, sessionID);
}
}
private Dictionary<AssetType, InventoryFolderBase> GetSystemFoldersLocal(UUID userID)
{
InventoryFolderBase root = m_GridService.GetRootFolder(userID);
if (root != null)
{
InventoryCollection content = m_GridService.GetFolderContent(userID, root.ID);
if (content != null)
{
Dictionary<AssetType, InventoryFolderBase> folders = new Dictionary<AssetType, InventoryFolderBase>();
foreach (InventoryFolderBase folder in content.Folders)
{
//m_log.DebugFormat("[HG INVENTORY CONNECTOR]: scanning folder type {0}", (AssetType)folder.Type);
if ((folder.Type != (short)AssetType.Folder) && (folder.Type != (short)AssetType.Unknown))
folders[(AssetType)folder.Type] = folder;
}
m_log.DebugFormat("[HG INVENTORY CONNECTOR]: System folders count for {0}: {1}", userID, folders.Count);
return folders;
}
m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Root folder content not found for {0}", userID);
}
m_log.DebugFormat("[HG INVENTORY CONNECTOR]: Root folder not found for {0}", userID);
return new Dictionary<AssetType, InventoryFolderBase>();
}
public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)
{
return new List<InventoryItemBase>();
@ -346,7 +416,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
return false;
}
public InventoryFolderBase RequestRootFolder(UUID userID)
public InventoryFolderBase GetRootFolder(UUID userID)
{
return null;
}

View File

@ -0,0 +1,110 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using OpenSim.Framework;
using OpenSim.Framework.Client;
using OpenSim.Region.Framework.Scenes;
using OpenMetaverse;
using Nini.Config;
using log4net;
namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
{
public abstract class InventoryCache
{
private static readonly ILog m_log =
LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType);
protected List<Scene> m_Scenes;
// The cache proper
protected Dictionary<UUID, Dictionary<AssetType, InventoryFolderBase>> m_InventoryCache;
protected virtual void Init(IConfigSource source)
{
m_Scenes = new List<Scene>();
m_InventoryCache = new Dictionary<UUID, Dictionary<AssetType, InventoryFolderBase>>();
}
public virtual void AddRegion(Scene scene)
{
m_Scenes.Add(scene);
scene.EventManager.OnMakeRootAgent += OnMakeRootAgent;
scene.EventManager.OnClientClosed += OnClientClosed;
}
public virtual void RemoveRegion(Scene scene)
{
if ((m_Scenes != null) && m_Scenes.Contains(scene))
{
m_Scenes.Remove(scene);
}
}
void OnMakeRootAgent(ScenePresence presence)
{
// Get system folders
// First check if they're here already
lock (m_InventoryCache)
{
if (m_InventoryCache.ContainsKey(presence.UUID))
{
m_log.DebugFormat("[INVENTORY CACHE]: OnMakeRootAgent, system folders for {0} {1} already in cache", presence.Firstname, presence.Lastname);
return;
}
}
// If not, go get them and place them in the cache
Dictionary<AssetType, InventoryFolderBase> folders = GetSystemFolders(presence.UUID);
m_log.DebugFormat("[INVENTORY CACHE]: OnMakeRootAgent, fetched system folders for {0} {1}: count {2}",
presence.Firstname, presence.Lastname, folders.Count);
if (folders.Count > 0)
lock (m_InventoryCache)
m_InventoryCache.Add(presence.UUID, folders);
}
void OnClientClosed(UUID clientID, Scene scene)
{
ScenePresence sp = null;
foreach (Scene s in m_Scenes)
{
s.TryGetAvatar(clientID, out sp);
if ((sp != null) && !sp.IsChildAgent)
{
m_log.DebugFormat("[INVENTORY CACHE]: OnClientClosed in {0}, but user {1} still in sim. Keeping system folders in cache",
scene.RegionInfo.RegionName, clientID);
return;
}
}
m_log.DebugFormat("[INVENTORY CACHE]: OnClientClosed in {0}, user {1} out of sim. Dropping system folders",
scene.RegionInfo.RegionName, clientID);
// Drop system folders
lock (m_InventoryCache)
if (m_InventoryCache.ContainsKey(clientID))
m_InventoryCache.Remove(clientID);
}
public abstract Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(UUID userID);
public InventoryFolderBase GetFolderForType(UUID userID, AssetType type)
{
Dictionary<AssetType, InventoryFolderBase> folders = null;
lock (m_InventoryCache)
{
m_InventoryCache.TryGetValue(userID, out folders);
}
if ((folders != null) && folders.ContainsKey(type))
{
return folders[type];
}
return null;
}
}
}

View File

@ -41,7 +41,7 @@ using OpenMetaverse;
namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
{
public class LocalInventoryServicesConnector : ISharedRegionModule, IInventoryService
public class LocalInventoryServicesConnector : InventoryCache, ISharedRegionModule, IInventoryService
{
private static readonly ILog m_log =
LogManager.GetLogger(
@ -108,6 +108,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
// m_InventoryService.AddPlugin(new OspInventoryWrapperPlugin(plugin, this));
//}
Init(source);
m_Enabled = true;
m_log.Info("[INVENTORY CONNECTOR]: Local inventory connector enabled");
}
@ -122,7 +124,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
{
}
public void AddRegion(Scene scene)
public override void AddRegion(Scene scene)
{
if (!m_Enabled)
return;
@ -139,10 +141,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
// "[INVENTORY CONNECTOR]: Registering IInventoryService to scene {0}", scene.RegionInfo.RegionName);
scene.RegisterModuleInterface<IInventoryService>(this);
base.AddRegion(scene);
}
public void RemoveRegion(Scene scene)
public override void RemoveRegion(Scene scene)
{
base.RemoveRegion(scene);
}
public void RegionLoaded(Scene scene)
@ -176,6 +180,39 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
m_InventoryService.GetUserInventory(userID, callback);
}
// Inherited. See base
//public InventoryFolderBase GetFolderForType(UUID userID, AssetType type)
//{
// return m_InventoryService.GetFolderForType(userID, type);
//}
public override Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(UUID userID)
{
InventoryFolderBase root = GetRootFolder(userID);
if (root != null)
{
InventoryCollection content = GetFolderContent(userID, root.ID);
if (content != null)
{
Dictionary<AssetType, InventoryFolderBase> folders = new Dictionary<AssetType, InventoryFolderBase>();
foreach (InventoryFolderBase folder in content.Folders)
{
if ((folder.Type != (short)AssetType.Folder) && (folder.Type != (short)AssetType.Unknown))
folders[(AssetType)folder.Type] = folder;
}
return folders;
}
}
m_log.WarnFormat("[INVENTORY CONNECTOR]: System folders for {0} not found", userID);
return new Dictionary<AssetType, InventoryFolderBase>();
}
public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
{
return m_InventoryService.GetFolderContent(userID, folderID);
}
public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)
{
return m_InventoryService.GetFolderItems(userID, folderID);
@ -276,9 +313,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
/// </summary>
/// <param name="userID"></param>
/// <returns>null if no root folder was found</returns>
public InventoryFolderBase RequestRootFolder(UUID userID)
public InventoryFolderBase GetRootFolder(UUID userID)
{
return m_InventoryService.RequestRootFolder(userID);
return m_InventoryService.GetRootFolder(userID);
}
public List<InventoryItemBase> GetActiveGestures(UUID userId)

View File

@ -40,7 +40,7 @@ using OpenMetaverse;
namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
{
public class RemoteInventoryServicesConnector : ISharedRegionModule, IInventoryService
public class RemoteInventoryServicesConnector : InventoryCache, ISharedRegionModule, IInventoryService
{
private static readonly ILog m_log =
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@ -69,9 +69,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
Init(source);
}
private void Init(IConfigSource source)
protected override void Init(IConfigSource source)
{
m_RemoteConnector = new InventoryServicesConnector(source);
base.Init(source);
}
@ -101,7 +102,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
{
}
public void AddRegion(Scene scene)
public override void AddRegion(Scene scene)
{
if (!m_Enabled)
return;
@ -116,10 +117,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
}
scene.RegisterModuleInterface<IInventoryService>(this);
base.AddRegion(scene);
}
public void RemoveRegion(Scene scene)
public override void RemoveRegion(Scene scene)
{
base.RemoveRegion(scene);
}
public void RegionLoaded(Scene scene)
@ -168,6 +171,34 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
}
// inherited. See base class
// public InventoryFolderBase GetFolderForType(UUID userID, AssetType type)
public override Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(UUID userID)
{
UUID sessionID = GetSessionID(userID);
return m_RemoteConnector.GetSystemFolders(userID.ToString(), sessionID);
}
public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
{
UUID sessionID = GetSessionID(userID);
try
{
return m_RemoteConnector.GetFolderContent(userID.ToString(), folderID, sessionID);
}
catch (Exception e)
{
m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetFolderContent operation failed, {0} {1}",
e.Source, e.Message);
}
InventoryCollection nullCollection = new InventoryCollection();
nullCollection.Folders = new List<InventoryFolderBase>();
nullCollection.Items = new List<InventoryItemBase>();
nullCollection.UserID = userID;
return nullCollection;
}
public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)
{
return new List<InventoryItemBase>();
@ -259,7 +290,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
return false;
}
public InventoryFolderBase RequestRootFolder(UUID userID)
public InventoryFolderBase GetRootFolder(UUID userID)
{
return null;
}

View File

@ -1319,17 +1319,17 @@ namespace OpenSim.Region.Framework.Scenes
return m_commsProvider.GridService.RequestNamedRegions(name, maxNumber);
}
// private void Dump(string msg, List<ulong> handles)
// {
// m_log.Info"-------------- HANDLE DUMP ({0}) ---------", msg);
// foreach (ulong handle in handles)
// {
// uint x, y;
// Utils.LongToUInts(handle, out x, out y);
// x = x / Constants.RegionSize;
// y = y / Constants.RegionSize;
// m_log.Info("({0}, {1})", x, y);
// }
// }
//private void Dump(string msg, List<ulong> handles)
//{
// m_log.InfoFormat("-------------- HANDLE DUMP ({0}) ---------", msg);
// foreach (ulong handle in handles)
// {
// uint x, y;
// Utils.LongToUInts(handle, out x, out y);
// x = x / Constants.RegionSize;
// y = y / Constants.RegionSize;
// m_log.InfoFormat("({0}, {1})", x, y);
// }
//}
}
}

View File

@ -84,6 +84,14 @@ namespace OpenSim.Server.Handlers.Inventory
new RestDeserialiseSecureHandler<Guid, InventoryCollection>(
"POST", "/GetInventory/", GetUserInventory, CheckAuthSession));
m_httpServer.AddStreamHandler(
new RestDeserialiseSecureHandler<Guid, List<InventoryFolderBase>>(
"POST", "/SystemFolders/", GetSystemFolders, CheckAuthSession));
m_httpServer.AddStreamHandler(
new RestDeserialiseSecureHandler<Guid, InventoryCollection>(
"POST", "/GetFolderContent/", GetFolderContent, CheckAuthSession));
m_httpServer.AddStreamHandler(
new RestDeserialiseSecureHandler<InventoryFolderBase, bool>(
"POST", "/UpdateFolder/", m_InventoryService.UpdateFolder, CheckAuthSession));
@ -155,6 +163,40 @@ namespace OpenSim.Server.Handlers.Inventory
return m_InventoryService.GetUserInventory(userID);
}
public List<InventoryFolderBase> GetSystemFolders(Guid guid)
{
UUID userID = new UUID(guid);
return new List<InventoryFolderBase>(GetSystemFolders(userID).Values);
}
// This shouldn't be here, it should be in the inventory service.
// But I don't want to deal with types and dependencies for now.
private Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(UUID userID)
{
InventoryFolderBase root = m_InventoryService.GetRootFolder(userID);
if (root != null)
{
InventoryCollection content = m_InventoryService.GetFolderContent(userID, root.ID);
if (content != null)
{
Dictionary<AssetType, InventoryFolderBase> folders = new Dictionary<AssetType, InventoryFolderBase>();
foreach (InventoryFolderBase folder in content.Folders)
{
if ((folder.Type != (short)AssetType.Folder) && (folder.Type != (short)AssetType.Unknown))
folders[(AssetType)folder.Type] = folder;
}
return folders;
}
}
m_log.WarnFormat("[INVENTORY SERVICE]: System folders for {0} not found", userID);
return new Dictionary<AssetType, InventoryFolderBase>();
}
public InventoryCollection GetFolderContent(Guid guid)
{
return m_InventoryService.GetFolderContent(UUID.Zero, new UUID(guid));
}
public List<InventoryItemBase> GetFolderItems(Guid folderID)
{
List<InventoryItemBase> allItems = new List<InventoryItemBase>();

View File

@ -120,6 +120,48 @@ namespace OpenSim.Services.Connectors.Inventory
}
/// <summary>
/// Gets the user folder for the given folder-type
/// </summary>
/// <param name="userID"></param>
/// <param name="type"></param>
/// <returns></returns>
public Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(string id, UUID sessionID)
{
m_log.Debug("[HGInventory]: GetSystemFolders " + id);
string url = string.Empty;
string userID = string.Empty;
if (StringToUrlAndUserID(id, out url, out userID))
{
ISessionAuthInventoryService connector = GetConnector(url);
return connector.GetSystemFolders(userID, sessionID);
}
return new Dictionary<AssetType, InventoryFolderBase>();
}
/// <summary>
/// Gets everything (folders and items) inside a folder
/// </summary>
/// <param name="userId"></param>
/// <param name="folderID"></param>
/// <returns></returns>
public InventoryCollection GetFolderContent(string id, UUID folderID, UUID sessionID)
{
m_log.Debug("[HGInventory]: GetSystemFolders " + id);
string url = string.Empty;
string userID = string.Empty;
if (StringToUrlAndUserID(id, out url, out userID))
{
ISessionAuthInventoryService connector = GetConnector(url);
return connector.GetFolderContent(userID, folderID, sessionID);
}
return null;
}
public bool AddFolder(string id, InventoryFolderBase folder, UUID sessionID)
{
string url = string.Empty;

View File

@ -25,6 +25,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System.Collections.Generic;
using OpenSim.Framework;
using OpenSim.Services.Interfaces;
using OpenMetaverse;
@ -50,6 +51,22 @@ namespace OpenSim.Services.Connectors
/// <param name="callback"></param>
void GetUserInventory(string userID, UUID session_id, InventoryReceiptCallback callback);
/// <summary>
/// Gets the user folder for the given folder-type
/// </summary>
/// <param name="userID"></param>
/// <param name="type"></param>
/// <returns></returns>
Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(string userID, UUID session_id);
/// <summary>
/// Gets everything (folders and items) inside a folder
/// </summary>
/// <param name="userId"></param>
/// <param name="folderID"></param>
/// <returns></returns>
InventoryCollection GetFolderContent(string userID, UUID folderID, UUID session_id);
/// <summary>
/// Add a new folder to the user's inventory
/// </summary>

View File

@ -155,6 +155,55 @@ namespace OpenSim.Services.Connectors
}
}
/// <summary>
/// Gets the user folder for the given folder-type
/// </summary>
/// <param name="userID"></param>
/// <param name="type"></param>
/// <returns></returns>
public Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(string userID, UUID sessionID)
{
// !!! Not just yet.
//try
//{
// List<InventoryFolderBase> folders = SynchronousRestSessionObjectPoster<Guid, List<InventoryFolderBase>>.BeginPostObject(
// "POST", m_ServerURI + "/SystemFolders/", new Guid(userID), sessionID.ToString(), userID.ToString());
// Dictionary<AssetType, InventoryFolderBase> dFolders = new Dictionary<AssetType, InventoryFolderBase>();
// foreach (InventoryFolderBase f in folders)
// dFolders[(AssetType)f.Type] = f;
// return dFolders;
//}
//catch (Exception e)
//{
// m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetSystemFolders operation failed, {0} {1}",
// e.Source, e.Message);
//}
return new Dictionary<AssetType, InventoryFolderBase>();
}
/// <summary>
/// Gets everything (folders and items) inside a folder
/// </summary>
/// <param name="userId"></param>
/// <param name="folderID"></param>
/// <returns></returns>
public InventoryCollection GetFolderContent(string userID, UUID folderID, UUID sessionID)
{
try
{
return SynchronousRestSessionObjectPoster<Guid, InventoryCollection>.BeginPostObject(
"POST", m_ServerURI + "/GetFolderContent/", folderID.Guid, sessionID.ToString(), userID.ToString());
}
catch (Exception e)
{
m_log.ErrorFormat("[INVENTORY CONNECTOR]: GetFolderForType operation failed, {0} {1}",
e.Source, e.Message);
}
return null;
}
public bool AddFolder(string userID, InventoryFolderBase folder, UUID sessionID)
{
try

View File

@ -106,6 +106,16 @@ namespace OpenSim.Services.Connectors
{
}
public InventoryFolderBase GetFolderForType(UUID userID, AssetType type)
{
return null;
}
public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
{
return null;
}
public List<InventoryItemBase> GetFolderItems(UUID userID, UUID folderID)
{
return null;
@ -161,7 +171,7 @@ namespace OpenSim.Services.Connectors
return false;
}
public InventoryFolderBase RequestRootFolder(UUID userID)
public InventoryFolderBase GetRootFolder(UUID userID)
{
return null;
}

View File

@ -69,6 +69,29 @@ namespace OpenSim.Services.Interfaces
/// <param name="callback"></param>
void GetUserInventory(UUID userID, InventoryReceiptCallback callback);
/// <summary>
/// Retrieve the root inventory folder for the given user.
/// </summary>
/// <param name="userID"></param>
/// <returns>null if no root folder was found</returns>
InventoryFolderBase GetRootFolder(UUID userID);
/// <summary>
/// Gets the user folder for the given folder-type
/// </summary>
/// <param name="userID"></param>
/// <param name="type"></param>
/// <returns></returns>
InventoryFolderBase GetFolderForType(UUID userID, AssetType type);
/// <summary>
/// Gets everything (folders and items) inside a folder
/// </summary>
/// <param name="userId"></param>
/// <param name="folderID"></param>
/// <returns></returns>
InventoryCollection GetFolderContent(UUID userID, UUID folderID);
/// <summary>
/// Gets the items inside a folder
/// </summary>
@ -137,13 +160,6 @@ namespace OpenSim.Services.Interfaces
/// <returns></returns>
bool HasInventoryForUser(UUID userID);
/// <summary>
/// Retrieve the root inventory folder for the given user.
/// </summary>
/// <param name="userID"></param>
/// <returns>null if no root folder was found</returns>
InventoryFolderBase RequestRootFolder(UUID userID);
/// <summary>
/// Get the active gestures of the agent.
/// </summary>

View File

@ -60,7 +60,7 @@ namespace OpenSim.Services.InventoryService
{
m_log.DebugFormat("[INVENTORY SERVICE]: Getting inventory skeleton for {0}", userId);
InventoryFolderBase rootFolder = RequestRootFolder(userId);
InventoryFolderBase rootFolder = GetRootFolder(userId);
// Agent has no inventory structure yet.
if (null == rootFolder)
@ -86,7 +86,7 @@ namespace OpenSim.Services.InventoryService
}
// See IInventoryServices
public virtual InventoryFolderBase RequestRootFolder(UUID userID)
public virtual InventoryFolderBase GetRootFolder(UUID userID)
{
// Retrieve the first root folder we get from the DB.
InventoryFolderBase rootFolder = m_Database.getUserRootFolder(userID);
@ -100,7 +100,7 @@ namespace OpenSim.Services.InventoryService
// See IInventoryServices
public bool CreateUserInventory(UUID user)
{
InventoryFolderBase existingRootFolder = RequestRootFolder(user);
InventoryFolderBase existingRootFolder = GetRootFolder(user);
if (null != existingRootFolder)
{
@ -233,6 +233,67 @@ namespace OpenSim.Services.InventoryService
callback.BeginInvoke(folders, items, null, null);
}
public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
{
m_log.Info("[INVENTORY SERVICE]: Processing request for folder " + folderID);
// Uncomment me to simulate a slow responding inventory server
//Thread.Sleep(16000);
InventoryCollection invCollection = new InventoryCollection();
List<InventoryItemBase> items = GetFolderItems(userID, folderID);
List<InventoryFolderBase> folders = RequestSubFolders(folderID);
invCollection.UserID = userID;
invCollection.Folders = folders;
invCollection.Items = items;
m_log.DebugFormat("[INVENTORY SERVICE]: Found {0} items and {1} folders", items.Count, folders.Count);
return invCollection;
}
public InventoryFolderBase GetFolderForType(UUID userID, AssetType type)
{
InventoryFolderBase root = m_Database.getUserRootFolder(userID);
if (root != null)
{
List<InventoryFolderBase> folders = RequestSubFolders(root.ID);
foreach (InventoryFolderBase folder in folders)
{
if (folder.Type == (short)type)
return folder;
}
}
// we didn't find any folder of that type. Return the root folder
// hopefully the root folder is not null. If it is, too bad
return root;
}
public Dictionary<AssetType, InventoryFolderBase> GetSystemFolders(UUID userID)
{
InventoryFolderBase root = GetRootFolder(userID);
if (root != null)
{
InventoryCollection content = GetFolderContent(userID, root.ID);
if (content != null)
{
Dictionary<AssetType, InventoryFolderBase> folders = new Dictionary<AssetType, InventoryFolderBase>();
foreach (InventoryFolderBase folder in content.Folders)
{
if ((folder.Type != (short)AssetType.Folder) && (folder.Type != (short)AssetType.Unknown))
folders[(AssetType)folder.Type] = folder;
}
return folders;
}
}
m_log.WarnFormat("[INVENTORY SERVICE]: System folders for {0} not found", userID);
return new Dictionary<AssetType, InventoryFolderBase>();
}
public List<InventoryItemBase> GetActiveGestures(UUID userId)
{
List<InventoryItemBase> activeGestures = new List<InventoryItemBase>();

View File

@ -43,6 +43,21 @@ namespace OpenSim.Tests.Common.Mock
return folders;
}
public InventoryFolderBase GetRootFolder(UUID userID)
{
return new InventoryFolderBase();
}
public InventoryCollection GetFolderContent(UUID userID, UUID folderID)
{
return null;
}
public InventoryFolderBase GetFolderForType(UUID userID, AssetType type)
{
return null;
}
/// <summary>
/// Returns a list of all the active gestures in a user's inventory.
/// </summary>

View File

@ -41,28 +41,58 @@ namespace OpenSim.Tests.Common.Setup
/// Create a test user with a standard inventory
/// </summary>
/// <param name="commsManager"></param>
/// <param name="callback">
/// Callback to invoke when inventory has been loaded. This is required because
/// loading may be asynchronous, even on standalone
/// </param>
/// <returns></returns>
public static CachedUserInfo CreateUserWithInventory(CommunicationsManager commsManager)
public static CachedUserInfo CreateUserWithInventory(
CommunicationsManager commsManager, OnInventoryReceivedDelegate callback)
{
UUID userId = UUID.Parse("00000000-0000-0000-0000-000000000099");
return CreateUserWithInventory(commsManager, userId);
return CreateUserWithInventory(commsManager, userId, callback);
}
/// <summary>
/// Create a test user with a standard inventory
/// </summary>
/// <param name="commsManager"></param>
/// <param name="userId">Explicit user id to use for user creation</param>
/// <param name="userId">User ID</param>
/// <param name="callback">
/// Callback to invoke when inventory has been loaded. This is required because
/// loading may be asynchronous, even on standalone
/// </param>
/// <returns></returns>
public static CachedUserInfo CreateUserWithInventory(CommunicationsManager commsManager, UUID userId)
public static CachedUserInfo CreateUserWithInventory(
CommunicationsManager commsManager, UUID userId, OnInventoryReceivedDelegate callback)
{
return CreateUserWithInventory(commsManager, "Bill", "Bailey", userId, callback);
}
/// <summary>
/// Create a test user with a standard inventory
/// </summary>
/// <param name="commsManager"></param>
/// <param name="firstName">First name of user</param>
/// <param name="lastName">Last name of user</param>
/// <param name="userId">User ID</param>
/// <param name="callback">
/// Callback to invoke when inventory has been loaded. This is required because
/// loading may be asynchronous, even on standalone
/// </param>
/// <returns></returns>
public static CachedUserInfo CreateUserWithInventory(
CommunicationsManager commsManager, string firstName, string lastName,
UUID userId, OnInventoryReceivedDelegate callback)
{
LocalUserServices lus = (LocalUserServices)commsManager.UserService;
lus.AddUser("Bill", "Bailey", "troll", "bill@bailey.com", 1000, 1000, userId);
lus.AddUser(firstName, lastName, "troll", "bill@bailey.com", 1000, 1000, userId);
CachedUserInfo userInfo = commsManager.UserProfileCacheService.GetUserDetails(userId);
userInfo.OnInventoryReceived += callback;
userInfo.FetchInventory();
return userInfo;
}
}
}
}