Deleted the unused and commented code from 2 commits ago.
parent
4c32f79c10
commit
6a9f36788d
|
@ -411,36 +411,6 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
// COMPLETE FAIL
|
|
||||||
//private void RemoveRootFolderContents(IClientAPI client)
|
|
||||||
//{
|
|
||||||
// InventoryFolderBase root = m_Scenes[0].InventoryService.GetRootFolder(client.AgentId);
|
|
||||||
// m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Removing root inventory for user {0}, version {1}", client.AgentId, root.Version);
|
|
||||||
// InventoryCollection content = m_Scenes[0].InventoryService.GetFolderContent(client.AgentId, root.ID);
|
|
||||||
|
|
||||||
// List<InventoryFolderBase> keep = new List<InventoryFolderBase>();
|
|
||||||
// foreach (InventoryFolderBase f in content.Folders)
|
|
||||||
// {
|
|
||||||
// if (f.Type == (short)AssetType.TrashFolder || f.Type == (short)AssetType.Landmark ||
|
|
||||||
// f.Type == (short)AssetType.FavoriteFolder || f.Type == (short)AssetType.CurrentOutfitFolder)
|
|
||||||
// {
|
|
||||||
// // Don't remove these because the viewer refuses to exist without them
|
|
||||||
// // and immediately sends a request to create them again, which makes things
|
|
||||||
// // very confusing in the viewer.
|
|
||||||
// // Just change their names
|
|
||||||
// f.Name = "Home " + f.Name + " (Unavailable)";
|
|
||||||
// keep.Add(f);
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// m_log.DebugFormat("[RRR]: Name={0}, Version={1}, Type={2}, PfolderID={3}", f.Name, f.Version, f.Type, f.ParentID);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
// client.SendInventoryFolderDetails(client.AgentId, root.ID, new List<InventoryItemBase>(), keep, root.Version + 1, true, true);
|
|
||||||
//}
|
|
||||||
|
|
||||||
private void RemoveRootFolderContents(IClientAPI client)
|
private void RemoveRootFolderContents(IClientAPI client)
|
||||||
{
|
{
|
||||||
// TODO tell the viewer to remove the root folder's content
|
// TODO tell the viewer to remove the root folder's content
|
||||||
|
@ -473,31 +443,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
foreach (InventoryItemBase it in content.Items)
|
foreach (InventoryItemBase it in content.Items)
|
||||||
it.Name = it.Name + " (Unavailable)"; ;
|
it.Name = it.Name + " (Unavailable)"; ;
|
||||||
|
|
||||||
// next, add the subfolders and items of the keep folders
|
// Send the new names
|
||||||
//foreach (InventoryFolderBase f in keep)
|
|
||||||
//{
|
|
||||||
// InventoryCollection c = m_Scenes[0].InventoryService.GetFolderContent(client.AgentId, f.ID);
|
|
||||||
// foreach (InventoryFolderBase sf in c.Folders)
|
|
||||||
// {
|
|
||||||
// m_log.DebugFormat("[RRR]: Name={0}, Version={1}, Type={2}, PfolderID={3}", f.Name, f.Version, f.Type, f.ParentID);
|
|
||||||
// fids.Add(sf.ID);
|
|
||||||
// }
|
|
||||||
// foreach (InventoryItemBase it in c.Items)
|
|
||||||
// iids.Add(it.ID);
|
|
||||||
//}
|
|
||||||
|
|
||||||
//inv.SendRemoveInventoryFolders(fids.ToArray());
|
|
||||||
|
|
||||||
// Increase the version number
|
|
||||||
//root.Version += 1;
|
|
||||||
//m_Scenes[0].InventoryService.UpdateFolder(root);
|
|
||||||
//foreach (InventoryFolderBase f in keep)
|
|
||||||
//{
|
|
||||||
// f.Version += 1;
|
|
||||||
// m_Scenes[0].InventoryService.UpdateFolder(f);
|
|
||||||
//}
|
|
||||||
|
|
||||||
// Send the new names and versions
|
|
||||||
inv.SendBulkUpdateInventory(keep.ToArray(), content.Items.ToArray());
|
inv.SendBulkUpdateInventory(keep.ToArray(), content.Items.ToArray());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -505,133 +451,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RemoveRootFolderContents2(IClientAPI client)
|
|
||||||
{
|
|
||||||
// TODO tell the viewer to remove the root folder's content
|
|
||||||
if (client is IClientCore)
|
|
||||||
{
|
|
||||||
IClientCore core = (IClientCore)client;
|
|
||||||
IClientInventory inv;
|
|
||||||
|
|
||||||
if (core.TryGet<IClientInventory>(out inv))
|
|
||||||
{
|
|
||||||
InventoryFolderBase root = m_Scenes[0].InventoryService.GetRootFolder(client.AgentId);
|
|
||||||
if (root != null)
|
|
||||||
{
|
|
||||||
m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Removing root inventory for user {0}", client.Name);
|
|
||||||
InventoryCollection content = m_Scenes[0].InventoryService.GetFolderContent(client.AgentId, root.ID);
|
|
||||||
List<UUID> fids = new List<UUID>();
|
|
||||||
List<UUID> iids = new List<UUID>();
|
|
||||||
List<InventoryFolderBase> keep = new List<InventoryFolderBase>();
|
|
||||||
|
|
||||||
foreach (InventoryFolderBase f in content.Folders)
|
|
||||||
{
|
|
||||||
if (f.Type == (short)AssetType.TrashFolder || f.Type == (short)AssetType.Landmark ||
|
|
||||||
f.Type == (short)AssetType.FavoriteFolder || f.Type == (short)AssetType.CurrentOutfitFolder)
|
|
||||||
{
|
|
||||||
// Don't remove these because the viewer refuses to exist without them
|
|
||||||
// and immediately sends a request to create them again, which makes things
|
|
||||||
// very confusing in the viewer.
|
|
||||||
// Just change their names
|
|
||||||
f.Name = "Home " + f.Name + " (Unavailable)";
|
|
||||||
keep.Add(f);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_log.DebugFormat("[RRR]: Name={0}, Version={1}, Type={2}, PfolderID={3}", f.Name, f.Version, f.Type, f.ParentID);
|
|
||||||
fids.Add(f.ID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (InventoryItemBase it in content.Items)
|
|
||||||
iids.Add(it.ID);
|
|
||||||
|
|
||||||
// next, add the subfolders and items of the keep folders
|
|
||||||
foreach (InventoryFolderBase f in keep)
|
|
||||||
{
|
|
||||||
InventoryCollection c = m_Scenes[0].InventoryService.GetFolderContent(client.AgentId, f.ID);
|
|
||||||
foreach (InventoryFolderBase sf in c.Folders)
|
|
||||||
{
|
|
||||||
m_log.DebugFormat("[RRR]: Name={0}, Version={1}, Type={2}, PfolderID={3}", f.Name, f.Version, f.Type, f.ParentID);
|
|
||||||
fids.Add(sf.ID);
|
|
||||||
}
|
|
||||||
foreach (InventoryItemBase it in c.Items)
|
|
||||||
iids.Add(it.ID);
|
|
||||||
}
|
|
||||||
|
|
||||||
inv.SendRemoveInventoryFolders(fids.ToArray());
|
|
||||||
inv.SendRemoveInventoryItems(iids.ToArray());
|
|
||||||
|
|
||||||
// Increase the version number
|
|
||||||
root.Version += 1;
|
|
||||||
m_Scenes[0].InventoryService.UpdateFolder(root);
|
|
||||||
//foreach (InventoryFolderBase f in keep)
|
|
||||||
//{
|
|
||||||
// f.Version += 1;
|
|
||||||
// m_Scenes[0].InventoryService.UpdateFolder(f);
|
|
||||||
//}
|
|
||||||
|
|
||||||
// Send the new names and versions
|
|
||||||
inv.SendBulkUpdateInventory(keep.ToArray(), new InventoryItemBase[0]);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void RemoveSuitcaseFolderContents(IClientAPI client)
|
private void RemoveSuitcaseFolderContents(IClientAPI client)
|
||||||
{
|
{
|
||||||
return;
|
|
||||||
|
|
||||||
//// TODO tell the viewer to remove the suitcase folder's content
|
|
||||||
//if (client is IClientCore)
|
|
||||||
//{
|
|
||||||
// IClientCore core = (IClientCore)client;
|
|
||||||
// IClientInventory inv;
|
|
||||||
|
|
||||||
// if (core.TryGet<IClientInventory>(out inv))
|
|
||||||
// {
|
|
||||||
// InventoryFolderBase root = m_Scenes[0].InventoryService.GetRootFolder(client.AgentId);
|
|
||||||
// if (root != null)
|
|
||||||
// {
|
|
||||||
// m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Removing suitcase inventory for user {0}", client.Name);
|
|
||||||
// InventoryCollection content = m_Scenes[0].InventoryService.GetFolderContent(client.AgentId, root.ID);
|
|
||||||
// List<UUID> fids = new List<UUID>();
|
|
||||||
// List<UUID> iids = new List<UUID>();
|
|
||||||
|
|
||||||
// if (content.Folders.Count == 0)
|
|
||||||
// m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: no subfolders???");
|
|
||||||
// foreach (InventoryFolderBase f in content.Folders)
|
|
||||||
// {
|
|
||||||
// m_log.DebugFormat("[RRR]: Name={0}, Version={1}, Type={2}, PfolderID={3}", f.Name, f.Version, f.Type, f.ParentID);
|
|
||||||
// fids.Add(f.ID);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// foreach (InventoryItemBase it in content.Items)
|
|
||||||
// iids.Add(it.ID);
|
|
||||||
|
|
||||||
// inv.SendRemoveInventoryFolders(fids.ToArray());
|
|
||||||
// inv.SendRemoveInventoryItems(iids.ToArray());
|
|
||||||
|
|
||||||
// // Increase the version number
|
|
||||||
// root.Version += 1;
|
|
||||||
// m_Scenes[0].InventoryService.UpdateFolder(root);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RestoreRootFolderContents(IClientAPI client)
|
private void RestoreRootFolderContents(IClientAPI client)
|
||||||
{
|
{
|
||||||
// This works!
|
|
||||||
//InventoryFolderBase root = m_Scenes[0].InventoryService.GetRootFolder(client.AgentId);
|
|
||||||
//client.SendBulkUpdateInventory(root);
|
|
||||||
|
|
||||||
// SORTA KINDA some items are missing...
|
|
||||||
//InventoryCollection userInventory = m_Scenes[0].InventoryService.GetUserInventory(client.AgentId);
|
|
||||||
//InventoryFolderBase root = m_Scenes[0].InventoryService.GetRootFolder(client.AgentId);
|
|
||||||
//client.SendBulkUpdateInventory(root);
|
|
||||||
|
|
||||||
m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Restoring root folder");
|
m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Restoring root folder");
|
||||||
if (client is IClientCore)
|
if (client is IClientCore)
|
||||||
{
|
{
|
||||||
|
@ -646,75 +471,10 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
inv.SendBulkUpdateInventory(content.Folders.ToArray(), content.Items.ToArray());
|
inv.SendBulkUpdateInventory(content.Folders.ToArray(), content.Items.ToArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ATTEMPT # 3 -- STILL DOESN'T WORK!
|
|
||||||
//if (client is IClientCore)
|
|
||||||
//{
|
|
||||||
// IClientCore core = (IClientCore)client;
|
|
||||||
// IClientInventory inv;
|
|
||||||
|
|
||||||
// if (core.TryGet<IClientInventory>(out inv))
|
|
||||||
// {
|
|
||||||
// InventoryCollection userInventory = m_Scenes[0].InventoryService.GetUserInventory(client.AgentId);
|
|
||||||
// if (userInventory != null)
|
|
||||||
// {
|
|
||||||
// m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Restoring root inventory for user {0}", client.AgentId);
|
|
||||||
// foreach (InventoryFolderBase f in userInventory.Folders)
|
|
||||||
// m_log.DebugFormat("[AAA]: FOLDER {0} {1} {2} {3} {4}", f.Name, f.Type, f.Version, f.ID, f.ParentID);
|
|
||||||
// foreach (InventoryItemBase f in userInventory.Items)
|
|
||||||
// m_log.DebugFormat("[AAA]: ITEM {0} {1} {2}", f.Name, f.ID, f.Folder);
|
|
||||||
// inv.SendBulkUpdateInventory(userInventory.Folders.ToArray(), userInventory.Items.ToArray());
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: Unable to retrieve inventory for user {0}", client.AgentId);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
// ATTEMPT #2 -- BETTER THAN 1, BUT STILL DOES NOT WORK WELL
|
|
||||||
//if (client is IClientCore)
|
|
||||||
//{
|
|
||||||
// IClientCore core = (IClientCore)client;
|
|
||||||
// IClientInventory inv;
|
|
||||||
|
|
||||||
// if (core.TryGet<IClientInventory>(out inv))
|
|
||||||
// {
|
|
||||||
// List<InventoryFolderBase> skel = m_Scenes[0].InventoryService.GetInventorySkeleton(client.AgentId);
|
|
||||||
// if (skel != null)
|
|
||||||
// {
|
|
||||||
// m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Restoring root inventory for user {0}", client.AgentId);
|
|
||||||
// foreach (InventoryFolderBase f in skel)
|
|
||||||
// m_log.DebugFormat("[AAA]: {0} {1} {2} {3} {4}", f.Name, f.Type, f.Version, f.ID, f.ParentID);
|
|
||||||
// inv.SendBulkUpdateInventory(skel.ToArray(), new InventoryItemBase[0]);
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: Unable to retrieve skeleton for user {0}", client.AgentId);
|
|
||||||
|
|
||||||
// ATTEMPT #1 -- DOES NOT WORK
|
|
||||||
//InventoryFolderBase root = m_Scenes[0].InventoryService.GetRootFolder(client.AgentId);
|
|
||||||
//if (root != null)
|
|
||||||
//{
|
|
||||||
//InventoryCollection content = m_Scenes[0].InventoryService.GetFolderContent(client.AgentId, root.ID);
|
|
||||||
//InventoryFolderBase[] folders = new InventoryFolderBase[content.Folders.Count + 1];
|
|
||||||
//m_log.DebugFormat("[AAA]: Folder name {0}, id {1}, version {2}, parent {3}", root.Name, root.ID, root.Version, root.ParentID);
|
|
||||||
//folders[0] = root;
|
|
||||||
//for (int count = 1; count < content.Folders.Count + 1; count++)
|
|
||||||
//{
|
|
||||||
// folders[count] = content.Folders[count - 1];
|
|
||||||
// m_log.DebugFormat("[AAA]: Name={0}, Id={1}, Version={2}, type={3}, folderID={4}",
|
|
||||||
// folders[count].Name, folders[count].ID, folders[count].Version, folders[count].Type, folders[count].ParentID);
|
|
||||||
//}
|
|
||||||
//foreach (InventoryItemBase i in content.Items)
|
|
||||||
// m_log.DebugFormat("[AAA]: Name={0}, folderID={1}", i.Name, i.Folder);
|
|
||||||
//inv.SendBulkUpdateInventory(/*content.Folders.ToArray()*/ folders, content.Items.ToArray());
|
|
||||||
//}
|
|
||||||
//}
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RestoreSuitcaseFolderContents(IClientAPI client)
|
private void RestoreSuitcaseFolderContents(IClientAPI client)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private GridRegion MakeRegion(AgentCircuitData aCircuit)
|
private GridRegion MakeRegion(AgentCircuitData aCircuit)
|
||||||
|
|
|
@ -48,600 +48,6 @@ namespace OpenSim.Services.HypergridService
|
||||||
/// and it responds to GetRootFolder requests with the ID of the
|
/// and it responds to GetRootFolder requests with the ID of the
|
||||||
/// Suitcase folder, not the actual "My Inventory" folder.
|
/// Suitcase folder, not the actual "My Inventory" folder.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class HGSuitcaseInventoryService1 : XInventoryService, IInventoryService
|
|
||||||
{
|
|
||||||
private static readonly ILog m_log =
|
|
||||||
LogManager.GetLogger(
|
|
||||||
MethodBase.GetCurrentMethod().DeclaringType);
|
|
||||||
|
|
||||||
private string m_HomeURL;
|
|
||||||
private IUserAccountService m_UserAccountService;
|
|
||||||
|
|
||||||
private UserAccountCache m_Cache;
|
|
||||||
|
|
||||||
private ExpiringCache<UUID, List<XInventoryFolder>> m_SuitcaseTrees = new ExpiringCache<UUID,List<XInventoryFolder>>();
|
|
||||||
|
|
||||||
public HGSuitcaseInventoryService1(IConfigSource config, string configName)
|
|
||||||
: base(config, configName)
|
|
||||||
{
|
|
||||||
m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Starting with config name {0}", configName);
|
|
||||||
if (configName != string.Empty)
|
|
||||||
m_ConfigName = configName;
|
|
||||||
|
|
||||||
if (m_Database == null)
|
|
||||||
m_log.WarnFormat("[XXX]: m_Database is null!");
|
|
||||||
|
|
||||||
//
|
|
||||||
// Try reading the [InventoryService] section, if it exists
|
|
||||||
//
|
|
||||||
IConfig invConfig = config.Configs[m_ConfigName];
|
|
||||||
if (invConfig != null)
|
|
||||||
{
|
|
||||||
// realm = authConfig.GetString("Realm", realm);
|
|
||||||
string userAccountsDll = invConfig.GetString("UserAccountsService", string.Empty);
|
|
||||||
if (userAccountsDll == string.Empty)
|
|
||||||
throw new Exception("Please specify UserAccountsService in HGInventoryService configuration");
|
|
||||||
|
|
||||||
Object[] args = new Object[] { config };
|
|
||||||
m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(userAccountsDll, args);
|
|
||||||
if (m_UserAccountService == null)
|
|
||||||
throw new Exception(String.Format("Unable to create UserAccountService from {0}", userAccountsDll));
|
|
||||||
|
|
||||||
// legacy configuration [obsolete]
|
|
||||||
m_HomeURL = invConfig.GetString("ProfileServerURI", string.Empty);
|
|
||||||
// Preferred
|
|
||||||
m_HomeURL = invConfig.GetString("HomeURI", m_HomeURL);
|
|
||||||
|
|
||||||
m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_log.Debug("[HG SUITCASE INVENTORY SERVICE]: Starting...");
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool CreateUserInventory(UUID principalID)
|
|
||||||
{
|
|
||||||
// NOGO
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override List<InventoryFolderBase> GetInventorySkeleton(UUID principalID)
|
|
||||||
{
|
|
||||||
XInventoryFolder suitcase = GetSuitcaseXFolder(principalID);
|
|
||||||
XInventoryFolder root = GetRootXFolder(principalID);
|
|
||||||
|
|
||||||
List<XInventoryFolder> tree = GetFolderTree(suitcase.folderID);
|
|
||||||
if (tree == null || (tree != null && tree.Count == 0))
|
|
||||||
return null;
|
|
||||||
|
|
||||||
List<InventoryFolderBase> folders = new List<InventoryFolderBase>();
|
|
||||||
foreach (XInventoryFolder x in tree)
|
|
||||||
{
|
|
||||||
if (x.parentFolderID == suitcase.folderID)
|
|
||||||
x.parentFolderID = root.folderID;
|
|
||||||
|
|
||||||
folders.Add(ConvertToOpenSim(x));
|
|
||||||
}
|
|
||||||
|
|
||||||
SetAsRootFolder(suitcase, root);
|
|
||||||
folders.Add(ConvertToOpenSim(suitcase));
|
|
||||||
|
|
||||||
return folders;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override InventoryCollection GetUserInventory(UUID userID)
|
|
||||||
{
|
|
||||||
m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Get Suitcase inventory for user {0}", userID);
|
|
||||||
InventoryCollection userInventory = new InventoryCollection();
|
|
||||||
userInventory.UserID = userID;
|
|
||||||
userInventory.Folders = new List<InventoryFolderBase>();
|
|
||||||
userInventory.Items = new List<InventoryItemBase>();
|
|
||||||
|
|
||||||
XInventoryFolder suitcase = GetSuitcaseXFolder(userID);
|
|
||||||
XInventoryFolder root = GetRootXFolder(userID);
|
|
||||||
|
|
||||||
List<XInventoryFolder> tree = GetFolderTree(suitcase.folderID);
|
|
||||||
if (tree == null || (tree != null && tree.Count == 0))
|
|
||||||
{
|
|
||||||
SetAsRootFolder(suitcase, root);
|
|
||||||
userInventory.Folders.Add(ConvertToOpenSim(suitcase));
|
|
||||||
return userInventory;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<InventoryItemBase> items;
|
|
||||||
foreach (XInventoryFolder f in tree)
|
|
||||||
{
|
|
||||||
// Add the items of this subfolder
|
|
||||||
items = GetFolderItems(userID, f.folderID);
|
|
||||||
if (items != null && items.Count > 0)
|
|
||||||
{
|
|
||||||
userInventory.Items.AddRange(items);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add the folder itself
|
|
||||||
if (f.parentFolderID == suitcase.folderID)
|
|
||||||
f.parentFolderID = root.folderID;
|
|
||||||
userInventory.Folders.Add(ConvertToOpenSim(f));
|
|
||||||
}
|
|
||||||
|
|
||||||
items = GetFolderItems(userID, suitcase.folderID);
|
|
||||||
if (items != null && items.Count > 0)
|
|
||||||
{
|
|
||||||
foreach (InventoryItemBase i in items)
|
|
||||||
i.Folder = root.folderID;
|
|
||||||
userInventory.Items.AddRange(items);
|
|
||||||
}
|
|
||||||
|
|
||||||
SetAsRootFolder(suitcase, root);
|
|
||||||
userInventory.Folders.Add(ConvertToOpenSim(suitcase));
|
|
||||||
|
|
||||||
m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetUserInventory for user {0} returning {1} folders and {2} items",
|
|
||||||
userID, userInventory.Folders.Count, userInventory.Items.Count);
|
|
||||||
return userInventory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override InventoryFolderBase GetRootFolder(UUID principalID)
|
|
||||||
{
|
|
||||||
m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetRootFolder for {0}", principalID);
|
|
||||||
if (m_Database == null)
|
|
||||||
m_log.ErrorFormat("[XXX]: m_Database is NULL!");
|
|
||||||
|
|
||||||
// Let's find out the local root folder
|
|
||||||
XInventoryFolder root = GetRootXFolder(principalID); ;
|
|
||||||
if (root == null)
|
|
||||||
{
|
|
||||||
m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: Unable to retrieve local root folder for user {0}", principalID);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Warp! Root folder for travelers is the suitcase folder
|
|
||||||
XInventoryFolder suitcase = GetSuitcaseXFolder(principalID);
|
|
||||||
|
|
||||||
if (suitcase == null)
|
|
||||||
{
|
|
||||||
m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: User {0} does not have a Suitcase folder. Creating it...", principalID);
|
|
||||||
// make one, and let's add it to the user's inventory as a direct child of the root folder
|
|
||||||
// In the DB we tag it as type 100, but we use -1 (Unknown) outside
|
|
||||||
suitcase = CreateFolder(principalID, root.folderID, 100, "My Suitcase");
|
|
||||||
if (suitcase == null)
|
|
||||||
m_log.ErrorFormat("[HG SUITCASE INVENTORY SERVICE]: Unable to create suitcase folder");
|
|
||||||
suitcase.version = root.version;
|
|
||||||
m_Database.StoreFolder(suitcase);
|
|
||||||
|
|
||||||
// Create System folders
|
|
||||||
CreateSystemFolders(principalID, suitcase.folderID);
|
|
||||||
}
|
|
||||||
else if (suitcase.version < root.version)
|
|
||||||
{
|
|
||||||
suitcase.version = root.version;
|
|
||||||
m_Database.StoreFolder(suitcase);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now let's change the folder ID to match that of the real root folder
|
|
||||||
SetAsRootFolder(suitcase, root);
|
|
||||||
|
|
||||||
return ConvertToOpenSim(suitcase);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void CreateSystemFolders(UUID principalID, UUID rootID)
|
|
||||||
{
|
|
||||||
m_log.Debug("[HG SUITCASE INVENTORY SERVICE]: Creating System folders under Suitcase...");
|
|
||||||
XInventoryFolder[] sysFolders = GetSystemFolders(principalID, rootID);
|
|
||||||
|
|
||||||
if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.Animation) return true; return false; }))
|
|
||||||
CreateFolder(principalID, rootID, (int)AssetType.Animation, "Animations");
|
|
||||||
if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.Bodypart) return true; return false; }))
|
|
||||||
CreateFolder(principalID, rootID, (int)AssetType.Bodypart, "Body Parts");
|
|
||||||
if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.CallingCard) return true; return false; }))
|
|
||||||
CreateFolder(principalID, rootID, (int)AssetType.CallingCard, "Calling Cards");
|
|
||||||
if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.Clothing) return true; return false; }))
|
|
||||||
CreateFolder(principalID, rootID, (int)AssetType.Clothing, "Clothing");
|
|
||||||
if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.Gesture) return true; return false; }))
|
|
||||||
CreateFolder(principalID, rootID, (int)AssetType.Gesture, "Gestures");
|
|
||||||
if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.Landmark) return true; return false; }))
|
|
||||||
CreateFolder(principalID, rootID, (int)AssetType.Landmark, "Landmarks");
|
|
||||||
if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.LostAndFoundFolder) return true; return false; }))
|
|
||||||
CreateFolder(principalID, rootID, (int)AssetType.LostAndFoundFolder, "Lost And Found");
|
|
||||||
if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.Notecard) return true; return false; }))
|
|
||||||
CreateFolder(principalID, rootID, (int)AssetType.Notecard, "Notecards");
|
|
||||||
if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.Object) return true; return false; }))
|
|
||||||
CreateFolder(principalID, rootID, (int)AssetType.Object, "Objects");
|
|
||||||
if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.SnapshotFolder) return true; return false; }))
|
|
||||||
CreateFolder(principalID, rootID, (int)AssetType.SnapshotFolder, "Photo Album");
|
|
||||||
if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.LSLText) return true; return false; }))
|
|
||||||
CreateFolder(principalID, rootID, (int)AssetType.LSLText, "Scripts");
|
|
||||||
if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.Sound) return true; return false; }))
|
|
||||||
CreateFolder(principalID, rootID, (int)AssetType.Sound, "Sounds");
|
|
||||||
if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.Texture) return true; return false; }))
|
|
||||||
CreateFolder(principalID, rootID, (int)AssetType.Texture, "Textures");
|
|
||||||
if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.TrashFolder) return true; return false; }))
|
|
||||||
CreateFolder(principalID, rootID, (int)AssetType.TrashFolder, "Trash");
|
|
||||||
if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.FavoriteFolder) return true; return false; }))
|
|
||||||
CreateFolder(principalID, rootID, (int)AssetType.FavoriteFolder, "Favorites");
|
|
||||||
if (!Array.Exists(sysFolders, delegate(XInventoryFolder f) { if (f.type == (int)AssetType.CurrentOutfitFolder) return true; return false; }))
|
|
||||||
CreateFolder(principalID, rootID, (int)AssetType.CurrentOutfitFolder, "Current Outfit");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public override InventoryFolderBase GetFolderForType(UUID principalID, AssetType type)
|
|
||||||
{
|
|
||||||
//m_log.DebugFormat("[HG INVENTORY SERVICE]: GetFolderForType for {0} {0}", principalID, type);
|
|
||||||
XInventoryFolder suitcase = GetSuitcaseXFolder(principalID);
|
|
||||||
XInventoryFolder[] folders = m_Database.GetFolders(
|
|
||||||
new string[] { "agentID", "type", "parentFolderID"},
|
|
||||||
new string[] { principalID.ToString(), ((int)type).ToString(), suitcase.folderID.ToString() });
|
|
||||||
|
|
||||||
if (folders.Length == 0)
|
|
||||||
{
|
|
||||||
m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: Found no folder for type {0} for user {1}", type, principalID);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_log.DebugFormat(
|
|
||||||
"[HG SUITCASE INVENTORY SERVICE]: Found folder {0} {1} for type {2} for user {3}",
|
|
||||||
folders[0].folderName, folders[0].folderID, type, principalID);
|
|
||||||
|
|
||||||
return ConvertToOpenSim(folders[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override InventoryCollection GetFolderContent(UUID principalID, UUID folderID)
|
|
||||||
{
|
|
||||||
InventoryCollection coll = null;
|
|
||||||
XInventoryFolder suitcase = GetSuitcaseXFolder(principalID);
|
|
||||||
XInventoryFolder root = GetRootXFolder(principalID);
|
|
||||||
|
|
||||||
if (!IsWithinSuitcaseTree(folderID, root, suitcase))
|
|
||||||
return new InventoryCollection();
|
|
||||||
|
|
||||||
if (folderID == root.folderID) // someone's asking for the root folder, we'll give them the suitcase
|
|
||||||
{
|
|
||||||
if (suitcase != null)
|
|
||||||
{
|
|
||||||
coll = base.GetFolderContent(principalID, suitcase.folderID);
|
|
||||||
foreach (InventoryFolderBase f in coll.Folders)
|
|
||||||
f.ParentID = root.folderID;
|
|
||||||
foreach (InventoryItemBase i in coll.Items)
|
|
||||||
i.Folder = root.folderID;
|
|
||||||
m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetFolderContent for root folder returned content for suitcase folder");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
coll = base.GetFolderContent(principalID, folderID);
|
|
||||||
m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: GetFolderContent for non-root folder {0}", folderID);
|
|
||||||
}
|
|
||||||
if (coll == null)
|
|
||||||
{
|
|
||||||
m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: Something wrong with user {0}'s suitcase folder", principalID);
|
|
||||||
coll = new InventoryCollection();
|
|
||||||
}
|
|
||||||
return coll;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override List<InventoryItemBase> GetFolderItems(UUID principalID, UUID folderID)
|
|
||||||
{
|
|
||||||
// Let's do a bit of sanity checking, more than the base service does
|
|
||||||
// make sure the given folder exists under the suitcase tree of this user
|
|
||||||
XInventoryFolder root = GetRootXFolder(principalID);
|
|
||||||
XInventoryFolder suitcase = GetSuitcaseXFolder(principalID);
|
|
||||||
|
|
||||||
if (!IsWithinSuitcaseTree(folderID, root, suitcase))
|
|
||||||
return new List<InventoryItemBase>();
|
|
||||||
|
|
||||||
return base.GetFolderItems(principalID, folderID);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool AddFolder(InventoryFolderBase folder)
|
|
||||||
{
|
|
||||||
m_log.WarnFormat("[HG SUITCASE INVENTORY SERVICE]: AddFolder {0} {1}", folder.Name, folder.ParentID);
|
|
||||||
// Let's do a bit of sanity checking, more than the base service does
|
|
||||||
// make sure the given folder's parent folder exists under the suitcase tree of this user
|
|
||||||
XInventoryFolder root = GetRootXFolder(folder.Owner);
|
|
||||||
XInventoryFolder suitcase = GetSuitcaseXFolder(folder.Owner);
|
|
||||||
|
|
||||||
if (!IsWithinSuitcaseTree(folder.ParentID, root, suitcase))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// OK, it's legit
|
|
||||||
// Check if it's under the Root folder directly
|
|
||||||
if (folder.ParentID == root.folderID)
|
|
||||||
{
|
|
||||||
// someone's trying to add a subfolder of the root folder, we'll add it to the suitcase instead
|
|
||||||
m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: AddFolder for root folder for user {0}. Adding in suitcase instead", folder.Owner);
|
|
||||||
folder.ParentID = suitcase.folderID;
|
|
||||||
}
|
|
||||||
|
|
||||||
return base.AddFolder(folder);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool UpdateFolder(InventoryFolderBase folder)
|
|
||||||
{
|
|
||||||
XInventoryFolder root = GetRootXFolder(folder.Owner);
|
|
||||||
XInventoryFolder suitcase = GetSuitcaseXFolder(folder.Owner);
|
|
||||||
|
|
||||||
m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Update folder {0}, version {1}", folder.ID, folder.Version);
|
|
||||||
if (!IsWithinSuitcaseTree(folder.ID, root, suitcase))
|
|
||||||
{
|
|
||||||
m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: folder {0} not within Suitcase tree", folder.Name);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (folder.ID == root.folderID)
|
|
||||||
{
|
|
||||||
if (folder.Version <= suitcase.version)
|
|
||||||
{
|
|
||||||
m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: version {0} <= suitcase version {1}. Ignoring.", folder.Version, suitcase.version);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (folder.Version <= root.version)
|
|
||||||
{
|
|
||||||
m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: version {0} <= root version {1}. Ignoring.", folder.Version, suitcase.version);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
suitcase.version = root.version = folder.Version;
|
|
||||||
m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Storing {0} type {1} version {2}", suitcase.folderName, suitcase.type, suitcase.version);
|
|
||||||
m_Database.StoreFolder(suitcase);
|
|
||||||
m_Database.StoreFolder(root);
|
|
||||||
}
|
|
||||||
|
|
||||||
// For all others
|
|
||||||
return base.UpdateFolder(folder);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool MoveFolder(InventoryFolderBase folder)
|
|
||||||
{
|
|
||||||
XInventoryFolder root = GetRootXFolder(folder.Owner);
|
|
||||||
XInventoryFolder suitcase = GetSuitcaseXFolder(folder.Owner);
|
|
||||||
|
|
||||||
if (!IsWithinSuitcaseTree(folder.ID, root, suitcase) || !IsWithinSuitcaseTree(folder.ParentID, root, suitcase))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (folder.ParentID == root.folderID)
|
|
||||||
{
|
|
||||||
// someone's trying to add a subfolder of the root folder, we'll add it to the suitcase instead
|
|
||||||
m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveFolder to root folder for user {0}. Moving it to suitcase instead", folder.Owner);
|
|
||||||
folder.ParentID = suitcase.folderID;
|
|
||||||
}
|
|
||||||
|
|
||||||
return base.MoveFolder(folder);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool DeleteFolders(UUID principalID, List<UUID> folderIDs)
|
|
||||||
{
|
|
||||||
// NOGO
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool PurgeFolder(InventoryFolderBase folder)
|
|
||||||
{
|
|
||||||
// NOGO
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool AddItem(InventoryItemBase item)
|
|
||||||
{
|
|
||||||
// Let's do a bit of sanity checking, more than the base service does
|
|
||||||
// make sure the given folder's parent folder exists under the suitcase tree of this user
|
|
||||||
XInventoryFolder root = GetRootXFolder(item.Owner);
|
|
||||||
XInventoryFolder suitcase = GetSuitcaseXFolder(item.Owner);
|
|
||||||
|
|
||||||
if (!IsWithinSuitcaseTree(item.Folder, root, suitcase))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// OK, it's legit
|
|
||||||
// Check if it's under the Root folder directly
|
|
||||||
if (item.Folder == root.folderID)
|
|
||||||
{
|
|
||||||
// someone's trying to add a subfolder of the root folder, we'll add it to the suitcase instead
|
|
||||||
m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: AddItem for root folder for user {0}. Adding in suitcase instead", item.Owner);
|
|
||||||
item.Folder = suitcase.folderID;
|
|
||||||
}
|
|
||||||
|
|
||||||
return base.AddItem(item);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool UpdateItem(InventoryItemBase item)
|
|
||||||
{
|
|
||||||
XInventoryFolder root = GetRootXFolder(item.Owner);
|
|
||||||
XInventoryFolder suitcase = GetSuitcaseXFolder(item.Owner);
|
|
||||||
|
|
||||||
if (!IsWithinSuitcaseTree(item.Folder, root, suitcase))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return base.UpdateItem(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool MoveItems(UUID principalID, List<InventoryItemBase> items)
|
|
||||||
{
|
|
||||||
// Principal is b0rked. *sigh*
|
|
||||||
|
|
||||||
XInventoryFolder root = GetRootXFolder(items[0].Owner);
|
|
||||||
XInventoryFolder suitcase = GetSuitcaseXFolder(items[0].Owner);
|
|
||||||
|
|
||||||
foreach (InventoryItemBase it in items)
|
|
||||||
if (it.Folder == root.folderID)
|
|
||||||
{
|
|
||||||
// someone's trying to add a subfolder of the root folder, we'll add it to the suitcase instead
|
|
||||||
m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: MoveItem to root folder for user {0}. Moving it to suitcase instead", it.Owner);
|
|
||||||
it.Folder = suitcase.folderID;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!IsWithinSuitcaseTree(items[0].Folder, root, suitcase))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return base.MoveItems(principalID, items);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Let these pass. Use inherited methods.
|
|
||||||
public override bool DeleteItems(UUID principalID, List<UUID> itemIDs)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public new InventoryItemBase GetItem(InventoryItemBase item)
|
|
||||||
{
|
|
||||||
InventoryItemBase it = base.GetItem(item);
|
|
||||||
if (it == null)
|
|
||||||
{
|
|
||||||
m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Unable to retrieve item {0} ({1}) in folder {2}",
|
|
||||||
item.Name, item.ID, item.Folder);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
XInventoryFolder root = GetRootXFolder(it.Owner);
|
|
||||||
XInventoryFolder suitcase = GetSuitcaseXFolder(it.Owner);
|
|
||||||
if (root == null || suitcase == null)
|
|
||||||
{
|
|
||||||
m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Root or Suitcase are null for user {0}",
|
|
||||||
it.Owner);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (it.Folder == suitcase.folderID)
|
|
||||||
it.Folder = root.folderID;
|
|
||||||
|
|
||||||
if (!IsWithinSuitcaseTree(it.Folder, root, suitcase))
|
|
||||||
{
|
|
||||||
m_log.DebugFormat("[HG SUITCASE INVENTORY SERVICE]: Item {0} (folder {1}) is not within Suitcase",
|
|
||||||
it.Name, it.Folder);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// UserAccount user = m_Cache.GetUser(it.CreatorId);
|
|
||||||
|
|
||||||
// // Adjust the creator data
|
|
||||||
// if (user != null && it != null && (it.CreatorData == null || it.CreatorData == string.Empty))
|
|
||||||
// it.CreatorData = m_HomeURL + ";" + user.FirstName + " " + user.LastName;
|
|
||||||
//}
|
|
||||||
|
|
||||||
return it;
|
|
||||||
}
|
|
||||||
|
|
||||||
public new InventoryFolderBase GetFolder(InventoryFolderBase folder)
|
|
||||||
{
|
|
||||||
InventoryFolderBase f = base.GetFolder(folder);
|
|
||||||
|
|
||||||
if (f != null)
|
|
||||||
{
|
|
||||||
XInventoryFolder root = GetRootXFolder(f.Owner);
|
|
||||||
XInventoryFolder suitcase = GetSuitcaseXFolder(f.Owner);
|
|
||||||
if (f.ParentID == suitcase.folderID)
|
|
||||||
f.ParentID = root.folderID;
|
|
||||||
|
|
||||||
if (!IsWithinSuitcaseTree(f.ID, root, suitcase))
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return f;
|
|
||||||
}
|
|
||||||
|
|
||||||
//public List<InventoryItemBase> GetActiveGestures(UUID principalID)
|
|
||||||
//{
|
|
||||||
//}
|
|
||||||
|
|
||||||
//public int GetAssetPermissions(UUID principalID, UUID assetID)
|
|
||||||
//{
|
|
||||||
//}
|
|
||||||
|
|
||||||
#region Auxiliary functions
|
|
||||||
private XInventoryFolder GetXFolder(UUID userID, UUID folderID)
|
|
||||||
{
|
|
||||||
XInventoryFolder[] folders = m_Database.GetFolders(
|
|
||||||
new string[] { "agentID", "folderID" },
|
|
||||||
new string[] { userID.ToString(), folderID.ToString() });
|
|
||||||
|
|
||||||
if (folders.Length == 0)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return folders[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
private XInventoryFolder GetRootXFolder(UUID principalID)
|
|
||||||
{
|
|
||||||
XInventoryFolder[] folders = m_Database.GetFolders(
|
|
||||||
new string[] { "agentID", "folderName", "type" },
|
|
||||||
new string[] { principalID.ToString(), "My Inventory", ((int)AssetType.RootFolder).ToString() });
|
|
||||||
|
|
||||||
if (folders != null && folders.Length > 0)
|
|
||||||
return folders[0];
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private XInventoryFolder GetSuitcaseXFolder(UUID principalID)
|
|
||||||
{
|
|
||||||
// Warp! Root folder for travelers
|
|
||||||
XInventoryFolder[] folders = m_Database.GetFolders(
|
|
||||||
new string[] { "agentID", "type" },
|
|
||||||
new string[] { principalID.ToString(), "100" }); // This is a special folder type...
|
|
||||||
|
|
||||||
if (folders != null && folders.Length > 0)
|
|
||||||
return folders[0];
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SetAsRootFolder(XInventoryFolder suitcase, XInventoryFolder root)
|
|
||||||
{
|
|
||||||
suitcase.version = root.version;
|
|
||||||
suitcase.folderID = root.folderID;
|
|
||||||
suitcase.parentFolderID = UUID.Zero;
|
|
||||||
suitcase.type = (short)AssetType.Folder;
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<XInventoryFolder> GetFolderTree(UUID folder)
|
|
||||||
{
|
|
||||||
List<XInventoryFolder> t = null;
|
|
||||||
if (m_SuitcaseTrees.TryGetValue(folder, out t))
|
|
||||||
return t;
|
|
||||||
|
|
||||||
t = GetFolderTreeRecursive(folder);
|
|
||||||
m_SuitcaseTrees.AddOrUpdate(folder, t, 120);
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<XInventoryFolder> GetFolderTreeRecursive(UUID root)
|
|
||||||
{
|
|
||||||
List<XInventoryFolder> tree = new List<XInventoryFolder>();
|
|
||||||
XInventoryFolder[] folders = m_Database.GetFolders(
|
|
||||||
new string[] { "parentFolderID" },
|
|
||||||
new string[] { root.ToString() });
|
|
||||||
|
|
||||||
if (folders == null || (folders != null && folders.Length == 0))
|
|
||||||
return tree; // empty tree
|
|
||||||
else
|
|
||||||
{
|
|
||||||
foreach (XInventoryFolder f in folders)
|
|
||||||
{
|
|
||||||
tree.Add(f);
|
|
||||||
tree.AddRange(GetFolderTreeRecursive(f.folderID));
|
|
||||||
}
|
|
||||||
return tree;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Return true if the folderID is a subfolder of the Suitcase or the root folder ID itself
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="folderID"></param>
|
|
||||||
/// <param name="root"></param>
|
|
||||||
/// <param name="suitcase"></param>
|
|
||||||
/// <returns></returns>
|
|
||||||
private bool IsWithinSuitcaseTree(UUID folderID, XInventoryFolder root, XInventoryFolder suitcase)
|
|
||||||
{
|
|
||||||
List<XInventoryFolder> tree = new List<XInventoryFolder>();
|
|
||||||
tree.Add(root); // Warp! the tree is the real root folder plus the children of the suitcase folder
|
|
||||||
tree.AddRange(GetFolderTree(suitcase.folderID));
|
|
||||||
XInventoryFolder f = tree.Find(delegate(XInventoryFolder fl)
|
|
||||||
{
|
|
||||||
if (fl.folderID == folderID) return true;
|
|
||||||
else return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (f == null) return false;
|
|
||||||
else return true;
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
|
|
||||||
public class HGSuitcaseInventoryService : XInventoryService, IInventoryService
|
public class HGSuitcaseInventoryService : XInventoryService, IInventoryService
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log =
|
private static readonly ILog m_log =
|
||||||
|
|
Loading…
Reference in New Issue