mirror of
https://github.com/opensim/opensim.git
synced 2026-08-07 09:45:47 +08:00
Some work on Inventory (not yet finished or enabled)
This commit is contained in:
@@ -36,7 +36,7 @@ namespace OpenSim.Framework.Communications.Caches
|
||||
return returnFolder;
|
||||
}
|
||||
|
||||
public InventoryFolder CreateNewSubFolder(LLUUID folderID, string folderName, ushort type)
|
||||
public InventoryFolder CreateNewSubFolder(LLUUID folderID, string folderName, ushort type )
|
||||
{
|
||||
InventoryFolder subFold = new InventoryFolder();
|
||||
subFold.name = folderName;
|
||||
@@ -47,5 +47,15 @@ namespace OpenSim.Framework.Communications.Caches
|
||||
this.SubFolders.Add(subFold.folderID, subFold);
|
||||
return subFold;
|
||||
}
|
||||
|
||||
public List<InventoryItemBase> RequestListOfItems()
|
||||
{
|
||||
List<InventoryItemBase> itemList = new List<InventoryItemBase>();
|
||||
foreach (InventoryItemBase item in this.Items.Values)
|
||||
{
|
||||
itemList.Add(item);
|
||||
}
|
||||
return itemList;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using libsecondlife;
|
||||
using OpenSim.Framework.Interfaces;
|
||||
using OpenSim.Framework.Data;
|
||||
using OpenSim.Framework.Communications;
|
||||
|
||||
@@ -29,14 +30,17 @@ namespace OpenSim.Framework.Communications.Caches
|
||||
{
|
||||
CachedUserInfo userInfo = new CachedUserInfo();
|
||||
userInfo.UserProfile = this.RequestUserProfileForUser(userID);
|
||||
this.m_parent.InventoryServer.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive);
|
||||
|
||||
if (userInfo.UserProfile != null)
|
||||
{
|
||||
this.RequestInventoryForUser(userID, userInfo);
|
||||
this.UserProfiles.Add(userID, userInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
//no profile for this user, what do we do now?
|
||||
Console.WriteLine("UserProfileCache.cs: user profile for user not found");
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -68,6 +72,52 @@ namespace OpenSim.Framework.Communications.Caches
|
||||
|
||||
}
|
||||
|
||||
public void HandleCreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType, string folderName, LLUUID parentID)
|
||||
{
|
||||
if (this.UserProfiles.ContainsKey(remoteClient.AgentId))
|
||||
{
|
||||
CachedUserInfo userInfo = this.UserProfiles[remoteClient.AgentId];
|
||||
if (userInfo.RootFolder.folderID == parentID)
|
||||
{
|
||||
userInfo.RootFolder.CreateNewSubFolder(folderID, folderName, folderType);
|
||||
}
|
||||
else
|
||||
{
|
||||
InventoryFolder parentFolder = userInfo.RootFolder.HasSubFolder(parentID);
|
||||
if (parentFolder != null)
|
||||
{
|
||||
parentFolder.CreateNewSubFolder(folderID, folderName, folderType);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void HandleFecthInventoryDescendents(IClientAPI remoteClient, LLUUID folderID, LLUUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder)
|
||||
{
|
||||
if (this.UserProfiles.ContainsKey(remoteClient.AgentId))
|
||||
{
|
||||
CachedUserInfo userInfo = this.UserProfiles[remoteClient.AgentId];
|
||||
if (userInfo.RootFolder.folderID == folderID)
|
||||
{
|
||||
if (fetchItems)
|
||||
{
|
||||
remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, userInfo.RootFolder.RequestListOfItems());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
InventoryFolder parentFolder = userInfo.RootFolder.HasSubFolder(folderID);
|
||||
if(parentFolder != null)
|
||||
{
|
||||
if(fetchItems)
|
||||
{
|
||||
remoteClient.SendInventoryFolderDetails(remoteClient.AgentId, folderID, parentFolder.RequestListOfItems());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Request the user profile from User server
|
||||
/// </summary>
|
||||
@@ -81,9 +131,20 @@ namespace OpenSim.Framework.Communications.Caches
|
||||
/// Request Iventory Info from Inventory server
|
||||
/// </summary>
|
||||
/// <param name="userID"></param>
|
||||
private void RequestInventoryForUser(LLUUID userID)
|
||||
private void RequestInventoryForUser(LLUUID userID, CachedUserInfo userInfo)
|
||||
{
|
||||
|
||||
// this.m_parent.InventoryServer.RequestInventoryForUser(userID, userInfo.FolderReceive, userInfo.ItemReceive);
|
||||
|
||||
//for now we manually create the root folder,
|
||||
// but should be requesting all inventory from inventory server.
|
||||
InventoryFolder rootFolder = new InventoryFolder();
|
||||
rootFolder.agentID = userID;
|
||||
rootFolder.folderID = userInfo.UserProfile.rootInventoryFolderID;
|
||||
rootFolder.name = "My Inventory";
|
||||
rootFolder.parentID = LLUUID.Zero;
|
||||
rootFolder.type = 8;
|
||||
rootFolder.version = 1;
|
||||
userInfo.FolderReceive(userID, rootFolder);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -81,6 +81,8 @@ namespace OpenSim.Framework.Data
|
||||
/// </summary>
|
||||
public int lastLogin;
|
||||
|
||||
public LLUUID rootInventoryFolderID;
|
||||
|
||||
/// <summary>
|
||||
/// A URI to the users inventory server, used for foreigners and large grids
|
||||
/// </summary>
|
||||
|
||||
@@ -52,12 +52,11 @@ namespace OpenSim.Framework.Inventory
|
||||
|
||||
public virtual void Initialise()
|
||||
{
|
||||
Wearables = new AvatarWearable[13]; //should be 12 of these
|
||||
Wearables = new AvatarWearable[13];
|
||||
for (int i = 0; i < 13; i++)
|
||||
{
|
||||
Wearables[i] = new AvatarWearable();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public bool CreateNewFolder(LLUUID folderID, ushort type)
|
||||
@@ -96,11 +95,10 @@ namespace OpenSim.Framework.Inventory
|
||||
Folder.DefaultType = type;
|
||||
Folder.FolderName = folderName;
|
||||
this.InventoryFolders.Add(Folder.FolderID, Folder);
|
||||
|
||||
return (true);
|
||||
}
|
||||
|
||||
public bool CreateNewFolder(LLUUID folderID, ushort type, string folderName, LLUUID parent)
|
||||
public bool CreateNewFolder(LLUUID folderID, ushort type, string folderName, LLUUID parentID)
|
||||
{
|
||||
if (!this.InventoryFolders.ContainsKey(folderID))
|
||||
{
|
||||
@@ -110,10 +108,9 @@ namespace OpenSim.Framework.Inventory
|
||||
Folder.OwnerID = this.AgentID;
|
||||
Folder.DefaultType = type;
|
||||
Folder.FolderName = folderName;
|
||||
Folder.ParentID = parent;
|
||||
Folder.ParentID = parentID;
|
||||
this.InventoryFolders.Add(Folder.FolderID, Folder);
|
||||
}
|
||||
|
||||
return (true);
|
||||
}
|
||||
|
||||
@@ -135,7 +132,6 @@ namespace OpenSim.Framework.Inventory
|
||||
return inv.FolderID;
|
||||
}
|
||||
}
|
||||
|
||||
return LLUUID.Zero;
|
||||
}
|
||||
|
||||
|
||||
@@ -80,7 +80,10 @@ namespace OpenSim.Framework.Interfaces
|
||||
|
||||
public delegate void AddNewPrim(LLUUID ownerID, LLVector3 pos, PrimitiveBaseShape shape);
|
||||
|
||||
|
||||
public delegate void CreateInventoryFolder(IClientAPI remoteClient, LLUUID folderID, ushort folderType, string folderName, LLUUID parentID);
|
||||
public delegate void FetchInventoryDescendents(IClientAPI remoteClient, LLUUID folderID, LLUUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder);
|
||||
|
||||
public delegate void RequestTaskInventory(IClientAPI remoteClient, uint localID);
|
||||
|
||||
public interface IClientAPI
|
||||
{
|
||||
@@ -125,6 +128,10 @@ namespace OpenSim.Framework.Interfaces
|
||||
event NewAvatar OnNewAvatar;
|
||||
event GenericCall6 OnRemoveAvatar;
|
||||
|
||||
event CreateInventoryFolder OnCreateNewInventoryFolder;
|
||||
event FetchInventoryDescendents OnFetchInventoryDescendents;
|
||||
event RequestTaskInventory OnRequestTaskInventory;
|
||||
|
||||
event UUIDNameRequest OnNameFromUUIDRequest;
|
||||
|
||||
event ParcelPropertiesRequest OnParcelPropertiesRequest;
|
||||
@@ -188,8 +195,10 @@ namespace OpenSim.Framework.Interfaces
|
||||
|
||||
void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, List<InventoryItemBase> items);
|
||||
void SendInventoryItemDetails(LLUUID ownerID, LLUUID folderID, InventoryItemBase item);
|
||||
void SendNameReply(LLUUID profileId, string firstname, string lastname);
|
||||
void SendInventoryItemUpdate(InventoryItemBase Item);
|
||||
void SendTaskInventory(LLUUID taskID, short serial, byte[] fileName);
|
||||
|
||||
void SendNameReply(LLUUID profileId, string firstname, string lastname);
|
||||
void SendAlertMessage(string message);
|
||||
void SendAgentAlertMessage(string message, bool modal);
|
||||
}
|
||||
|
||||
@@ -52,6 +52,10 @@ namespace OpenSim.Framework
|
||||
public event NewAvatar OnNewAvatar;
|
||||
public event GenericCall6 OnRemoveAvatar;
|
||||
|
||||
public event CreateInventoryFolder OnCreateNewInventoryFolder;
|
||||
public event FetchInventoryDescendents OnFetchInventoryDescendents;
|
||||
public event RequestTaskInventory OnRequestTaskInventory;
|
||||
|
||||
public event UUIDNameRequest OnNameFromUUIDRequest;
|
||||
|
||||
public event ParcelPropertiesRequest OnParcelPropertiesRequest;
|
||||
@@ -124,8 +128,10 @@ namespace OpenSim.Framework
|
||||
|
||||
public virtual void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, List<InventoryItemBase> items){}
|
||||
public virtual void SendInventoryItemDetails(LLUUID ownerID, LLUUID folderID, InventoryItemBase item){}
|
||||
public virtual void SendNameReply(LLUUID profileId, string firstname, string lastname){}
|
||||
public virtual void SendInventoryItemUpdate(InventoryItemBase Item) { }
|
||||
public virtual void SendTaskInventory(LLUUID taskID, short serial, byte[] fileName) { }
|
||||
|
||||
public virtual void SendNameReply(LLUUID profileId, string firstname, string lastname){}
|
||||
public void SendAlertMessage(string message) { }
|
||||
public void SendAgentAlertMessage(string message, bool modal) { }
|
||||
}
|
||||
|
||||
@@ -417,7 +417,7 @@ namespace OpenSim.Framework.UserManagement
|
||||
Hashtable TempHash;
|
||||
|
||||
AgentInventory Library = new AgentInventory();
|
||||
Library.CreateRootFolder(AgentID, true);
|
||||
Library.CreateRootFolder(AgentID, false);
|
||||
|
||||
foreach (InventoryFolder InvFolder in Library.InventoryFolders.Values)
|
||||
{
|
||||
@@ -434,6 +434,7 @@ namespace OpenSim.Framework.UserManagement
|
||||
InventoryRootHash["folder_id"] = Library.InventoryRoot.FolderID.ToStringHyphenated();
|
||||
ArrayList InventoryRoot = new ArrayList();
|
||||
InventoryRoot.Add(InventoryRootHash);
|
||||
userProfile.rootInventoryFolderID = Library.InventoryRoot.FolderID;
|
||||
|
||||
// Circuit Code
|
||||
uint circode = (uint)(Util.RandomClass.Next());
|
||||
|
||||
Reference in New Issue
Block a user