The first 2 handlers for the XInventory system.

mysql-performance
Melanie 2010-01-08 22:51:37 +00:00
parent c76c80a28a
commit bc68390b14
2 changed files with 76 additions and 2 deletions

View File

@ -38,6 +38,7 @@ using OpenSim.Services.Interfaces;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Server.Handlers.Base;
using log4net;
using OpenMetaverse;
namespace OpenSim.Server.Handlers.Asset
{
@ -193,6 +194,14 @@ namespace OpenSim.Server.Handlers.Asset
{
Dictionary<string,object> result = new Dictionary<string,object>();
if (!request.ContainsKey("PRINCIPAL"))
return FailureResult();
if(m_InventoryService.CreateUserInventory(new UUID(request["PRINCIPAL"].ToString())))
result["RESULT"] = "True";
else
result["RESULT"] = "False";
string xmlString = ServerUtils.BuildXmlResponse(result);
m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
UTF8Encoding encoding = new UTF8Encoding();
@ -203,6 +212,15 @@ namespace OpenSim.Server.Handlers.Asset
{
Dictionary<string,object> result = new Dictionary<string,object>();
if (!request.ContainsKey("PRINCIPAL"))
return FailureResult();
List<InventoryFolderBase> folders = m_InventoryService.GetInventorySkeleton(new UUID(request["PRINCIPAL"].ToString()));
foreach (InventoryFolderBase f in folders)
result[f.ID.ToString()] = EncodeFolder(f);
string xmlString = ServerUtils.BuildXmlResponse(result);
m_log.DebugFormat("[XXX]: resp string: {0}", xmlString);
UTF8Encoding encoding = new UTF8Encoding();
@ -378,5 +396,61 @@ namespace OpenSim.Server.Handlers.Asset
UTF8Encoding encoding = new UTF8Encoding();
return encoding.GetBytes(xmlString);
}
private Dictionary<string, object> EncodeFolder(InventoryFolderBase f)
{
Dictionary<string, object> ret = new Dictionary<string, object>();
ret["ParentID"] = f.ParentID.ToString();
ret["Type"] = f.Type.ToString();
ret["Version"] = f.Version.ToString();
ret["Name"] = f.Name;
ret["Owner"] = f.Owner.ToString();
ret["ID"] = f.ID.ToString();
return ret;
}
private InventoryFolderBase BuildFolder(Dictionary<string,object> data)
{
InventoryFolderBase folder = new InventoryFolderBase();
folder.ParentID = new UUID(data["ParentID"].ToString());
folder.Type = short.Parse(data["Type"].ToString());
folder.Version = ushort.Parse(data["Version"].ToString());
folder.Name = data["Name"].ToString();
folder.Owner = new UUID(data["Owner"].ToString());
folder.ID = new UUID(data["ID"].ToString());
return folder;
}
private InventoryItemBase BuildItem(Dictionary<string,object> data)
{
InventoryItemBase item = new InventoryItemBase();
item.AssetID = new UUID(data["AssetID"].ToString());
item.AssetType = int.Parse(data["AssetType"].ToString());
item.Name = data["Name"].ToString();
item.Owner = new UUID(data["Owner"].ToString());
item.ID = new UUID(data["ID"].ToString());
item.InvType = int.Parse(data["InvType"].ToString());
item.Folder = new UUID(data["Folder"].ToString());
item.CreatorId = data["CreatorId"].ToString();
item.Description = data["Description"].ToString();
item.NextPermissions = uint.Parse(data["NextPermissions"].ToString());
item.CurrentPermissions = uint.Parse(data["CurrentPermissions"].ToString());
item.BasePermissions = uint.Parse(data["BasePermissions"].ToString());
item.EveryOnePermissions = uint.Parse(data["EveryOnePermissions"].ToString());
item.GroupPermissions = uint.Parse(data["GroupPermissions"].ToString());
item.GroupID = new UUID(data["GroupID"].ToString());
item.GroupOwned = bool.Parse(data["GroupOwned"].ToString());
item.SalePrice = int.Parse(data["SalePrice"].ToString());
item.SaleType = byte.Parse(data["SaleType"].ToString());
item.Flags = uint.Parse(data["Flags"].ToString());
item.CreationDate = int.Parse(data["CreationDate"].ToString());
return item;
}
}
}

View File

@ -490,7 +490,7 @@ namespace OpenSim.Services.Connectors
return replyData;
}
InventoryFolderBase BuildFolder(Dictionary<string,object> data)
private InventoryFolderBase BuildFolder(Dictionary<string,object> data)
{
InventoryFolderBase folder = new InventoryFolderBase();
@ -504,7 +504,7 @@ namespace OpenSim.Services.Connectors
return folder;
}
InventoryItemBase BuildItem(Dictionary<string,object> data)
private InventoryItemBase BuildItem(Dictionary<string,object> data)
{
InventoryItemBase item = new InventoryItemBase();