mirror of
https://github.com/opensim/opensim.git
synced 2026-08-10 11:33:28 +08:00
More work on inventory, can now create other inventory types, like Clothes and body parts. [Note while you can edit these, at the moment your changes won't be saved between restarts. This will be fixed very soon.]
This commit is contained in:
@@ -41,14 +41,20 @@ namespace OpenSim.Framework.Communications.Caches
|
||||
public class AssetTransactionManager
|
||||
{
|
||||
// Fields
|
||||
public CommunicationsManager CommsManager;
|
||||
public Dictionary<LLUUID, AgentAssetTransactions> AgentTransactions = new Dictionary<LLUUID, AgentAssetTransactions>();
|
||||
|
||||
public AssetTransactionManager(CommunicationsManager commsManager)
|
||||
{
|
||||
CommsManager = commsManager;
|
||||
}
|
||||
|
||||
// Methods
|
||||
public AgentAssetTransactions AddUser(LLUUID userID)
|
||||
{
|
||||
if (!this.AgentTransactions.ContainsKey(userID))
|
||||
{
|
||||
AgentAssetTransactions transactions = new AgentAssetTransactions(userID);
|
||||
AgentAssetTransactions transactions = new AgentAssetTransactions(userID, this);
|
||||
this.AgentTransactions.Add(userID, transactions);
|
||||
return transactions;
|
||||
}
|
||||
@@ -64,18 +70,38 @@ namespace OpenSim.Framework.Communications.Caches
|
||||
return null;
|
||||
}
|
||||
|
||||
public void HandleInventoryFromTransaction()
|
||||
public void HandleInventoryFromTransaction(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask)
|
||||
{
|
||||
AgentAssetTransactions transactions = this.GetUserTransActions(remoteClient.AgentId);
|
||||
if (transactions != null)
|
||||
{
|
||||
transactions.RequestCreateInventoryItem(remoteClient, transactionID, folderID, callbackID, description, name, invType, type, wearableType, nextOwnerMask);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void HandleUDPUploadRequest()
|
||||
public void HandleUDPUploadRequest(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data)
|
||||
{
|
||||
AgentAssetTransactions transactions = this.GetUserTransActions(remoteClient.AgentId);
|
||||
if (transactions != null)
|
||||
{
|
||||
AgentAssetTransactions.AssetXferUploader uploader = transactions.RequestXferUploader(transaction);
|
||||
if (uploader != null)
|
||||
{
|
||||
uploader.Initialise(remoteClient, assetID, transaction, type, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void HandleXfer(IClientAPI remoteClient, uint xferID, uint packetID, byte[] data)
|
||||
public void HandleXfer(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data)
|
||||
{
|
||||
AgentAssetTransactions transactions = this.GetUserTransActions(remoteClient.AgentId);
|
||||
if (transactions != null)
|
||||
{
|
||||
transactions.HandleXfer(xferID, packetID, data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ using libsecondlife.Packets;
|
||||
using OpenSim.Framework.Interfaces;
|
||||
using OpenSim.Framework.Types;
|
||||
using OpenSim.Framework.Utilities;
|
||||
using OpenSim.Framework.Data;
|
||||
using OpenSim.Region.Capabilities;
|
||||
using OpenSim.Framework.Servers;
|
||||
|
||||
@@ -47,11 +48,13 @@ namespace OpenSim.Framework.Communications.Caches
|
||||
public List<NoteCardCapsUpdate> NotecardUpdaters = new List<NoteCardCapsUpdate>();
|
||||
public LLUUID UserID;
|
||||
public Dictionary<LLUUID, AssetXferUploader> XferUploaders = new Dictionary<LLUUID, AssetXferUploader>();
|
||||
public AssetTransactionManager Manager;
|
||||
|
||||
// Methods
|
||||
public AgentAssetTransactions(LLUUID agentID)
|
||||
public AgentAssetTransactions(LLUUID agentID, AssetTransactionManager manager)
|
||||
{
|
||||
this.UserID = agentID;
|
||||
Manager = manager;
|
||||
}
|
||||
|
||||
public AssetCapsUploader RequestCapsUploader()
|
||||
@@ -70,9 +73,34 @@ namespace OpenSim.Framework.Communications.Caches
|
||||
|
||||
public AssetXferUploader RequestXferUploader(LLUUID transactionID)
|
||||
{
|
||||
AssetXferUploader uploader = new AssetXferUploader();
|
||||
this.XferUploaders.Add(transactionID, uploader);
|
||||
return uploader;
|
||||
if (!this.XferUploaders.ContainsKey(transactionID))
|
||||
{
|
||||
AssetXferUploader uploader = new AssetXferUploader(this);
|
||||
|
||||
this.XferUploaders.Add(transactionID, uploader);
|
||||
return uploader;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void HandleXfer(ulong xferID, uint packetID, byte[] data)
|
||||
{
|
||||
foreach (AssetXferUploader uploader in this.XferUploaders.Values)
|
||||
{
|
||||
if (uploader.XferID == xferID)
|
||||
{
|
||||
uploader.HandleXferPacket(xferID, packetID, data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void RequestCreateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask)
|
||||
{
|
||||
if (this.XferUploaders.ContainsKey(transactionID))
|
||||
{
|
||||
this.XferUploaders[transactionID].RequestCreateInventoryItem(remoteClient, transactionID, folderID, callbackID, description, name, invType, type, wearableType, nextOwnerMask);
|
||||
}
|
||||
}
|
||||
|
||||
// Nested Types
|
||||
@@ -143,10 +171,23 @@ namespace OpenSim.Framework.Communications.Caches
|
||||
private IClientAPI ourClient;
|
||||
public LLUUID TransactionID = LLUUID.Zero;
|
||||
public bool UploadComplete;
|
||||
public uint XferID;
|
||||
public ulong XferID;
|
||||
private string m_name = "";
|
||||
private string m_description = "";
|
||||
private sbyte type = 0;
|
||||
private sbyte invType = 0;
|
||||
private uint nextPerm = 0;
|
||||
private bool m_finished = false;
|
||||
private bool m_createItem = false;
|
||||
private AgentAssetTransactions m_userTransactions;
|
||||
|
||||
public AssetXferUploader(AgentAssetTransactions transactions)
|
||||
{
|
||||
this.m_userTransactions = transactions;
|
||||
}
|
||||
|
||||
// Methods
|
||||
public void HandleXferPacket(uint xferID, uint packetID, byte[] data)
|
||||
public void HandleXferPacket(ulong xferID, uint packetID, byte[] data)
|
||||
{
|
||||
if (this.XferID == xferID)
|
||||
{
|
||||
@@ -216,6 +257,67 @@ namespace OpenSim.Framework.Communications.Caches
|
||||
newPack.AssetBlock.Success = true;
|
||||
newPack.AssetBlock.UUID = this.Asset.FullID;
|
||||
this.ourClient.OutPacket(newPack);
|
||||
this.m_finished = true;
|
||||
if (m_createItem)
|
||||
{
|
||||
DoCreateItem();
|
||||
}
|
||||
Console.WriteLine("upload complete "+ this.TransactionID);
|
||||
//SaveAssetToFile("testudpupload" + Util.RandomClass.Next(1, 1000) + ".dat", this.Asset.Data);
|
||||
}
|
||||
private void SaveAssetToFile(string filename, byte[] data)
|
||||
{
|
||||
FileStream fs = File.Create(filename);
|
||||
BinaryWriter bw = new BinaryWriter(fs);
|
||||
bw.Write(data);
|
||||
bw.Close();
|
||||
fs.Close();
|
||||
}
|
||||
|
||||
public void RequestCreateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask)
|
||||
{
|
||||
if (this.TransactionID == transactionID)
|
||||
{
|
||||
this.InventFolder = folderID;
|
||||
this.m_name = name;
|
||||
this.m_description = description;
|
||||
this.type = type;
|
||||
this.invType = invType;
|
||||
this.nextPerm = nextOwnerMask;
|
||||
this.Asset.Name = name;
|
||||
this.Asset.Description = description;
|
||||
this.Asset.Type = type;
|
||||
this.Asset.InvType = invType;
|
||||
m_createItem = true;
|
||||
if (m_finished)
|
||||
{
|
||||
DoCreateItem();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DoCreateItem()
|
||||
{
|
||||
this.m_userTransactions.Manager.CommsManager.AssetCache.AddAsset(this.Asset);
|
||||
CachedUserInfo userInfo = m_userTransactions.Manager.CommsManager.UserProfiles.GetUserDetails(ourClient.AgentId);
|
||||
if (userInfo != null)
|
||||
{
|
||||
InventoryItemBase item = new InventoryItemBase();
|
||||
item.avatarID = this.ourClient.AgentId;
|
||||
item.creatorsID = ourClient.AgentId;
|
||||
item.inventoryID = LLUUID.Random();
|
||||
item.assetID = Asset.FullID;
|
||||
item.inventoryDescription = this.m_description;
|
||||
item.inventoryName = m_name;
|
||||
item.assetType = type;
|
||||
item.invType = this.invType;
|
||||
item.parentFolderID = this.InventFolder;
|
||||
item.inventoryCurrentPermissions = 2147483647;
|
||||
item.inventoryNextPermissions = this.nextPerm;
|
||||
|
||||
userInfo.AddItem(ourClient.AgentId, item);
|
||||
ourClient.SendInventoryItemUpdate(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,7 @@ namespace OpenSim.Framework.Communications
|
||||
public IInventoryServices InventoryServer;
|
||||
public IInterRegionCommunications InterRegion;
|
||||
public UserProfileCache UserProfiles;
|
||||
public AssetTransactionManager TransactionsManager;
|
||||
public AssetCache AssetCache;
|
||||
|
||||
public NetworkServersInfo ServersInfo;
|
||||
@@ -53,6 +54,7 @@ namespace OpenSim.Framework.Communications
|
||||
ServersInfo = serversInfo;
|
||||
this.AssetCache = assetCache;
|
||||
UserProfiles = new UserProfileCache(this);
|
||||
TransactionsManager = new AssetTransactionManager(this);
|
||||
}
|
||||
|
||||
#region Packet Handlers
|
||||
|
||||
@@ -87,6 +87,9 @@ namespace OpenSim.Framework.Interfaces
|
||||
public delegate void FetchInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID ownerID);
|
||||
public delegate void RequestTaskInventory(IClientAPI remoteClient, uint localID);
|
||||
|
||||
public delegate void UDPAssetUploadRequest(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data);
|
||||
public delegate void XferReceive(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data);
|
||||
|
||||
public interface IClientAPI
|
||||
{
|
||||
event ImprovedInstantMessage OnInstantMessage;
|
||||
@@ -135,6 +138,8 @@ namespace OpenSim.Framework.Interfaces
|
||||
event FetchInventoryDescendents OnFetchInventoryDescendents;
|
||||
event FetchInventory OnFetchInventory;
|
||||
event RequestTaskInventory OnRequestTaskInventory;
|
||||
event UDPAssetUploadRequest OnAssetUploadRequest;
|
||||
event XferReceive OnXferReceive;
|
||||
|
||||
event UUIDNameRequest OnNameFromUUIDRequest;
|
||||
|
||||
|
||||
@@ -57,6 +57,8 @@ namespace OpenSim.Framework
|
||||
public event FetchInventoryDescendents OnFetchInventoryDescendents;
|
||||
public event FetchInventory OnFetchInventory;
|
||||
public event RequestTaskInventory OnRequestTaskInventory;
|
||||
public event UDPAssetUploadRequest OnAssetUploadRequest;
|
||||
public event XferReceive OnXferReceive;
|
||||
|
||||
public event UUIDNameRequest OnNameFromUUIDRequest;
|
||||
|
||||
|
||||
38
OpenSim/Framework/UserManager/CAPSService.cs
Normal file
38
OpenSim/Framework/UserManager/CAPSService.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Security.Cryptography;
|
||||
using libsecondlife;
|
||||
using Nwc.XmlRpc;
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenSim.Framework.Data;
|
||||
using OpenSim.Framework.Interfaces;
|
||||
using OpenSim.Framework.Inventory;
|
||||
using OpenSim.Framework.Utilities;
|
||||
using OpenSim.Framework.Servers;
|
||||
|
||||
namespace OpenSim.Framework.UserManagement
|
||||
{
|
||||
public class CAPSService
|
||||
{
|
||||
private BaseHttpServer m_server;
|
||||
|
||||
public CAPSService(BaseHttpServer httpServer)
|
||||
{
|
||||
m_server = httpServer;
|
||||
this.AddCapsSeedHandler("/CapsSeed/", CapsRequest);
|
||||
}
|
||||
|
||||
private void AddCapsSeedHandler(string path, RestMethod restMethod)
|
||||
{
|
||||
m_server.AddStreamHandler(new RestStreamHandler("POST", path, restMethod));
|
||||
}
|
||||
|
||||
public string CapsRequest(string request, string path, string param)
|
||||
{
|
||||
System.Console.WriteLine("new caps request " + request +" from path "+ path);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user