* Implment task inventory item asset update for the old non CAPS transaction system
* This means that saving notecards in prim inventories should now work. * Not the nicest code in the world - the transactions system is pretty fugly right now * PLEASE NOTE: Currently, the prim will not repersist until up to 15 seconds after it is unselected. * What we really need is a proper mechanism so that any prim updates still waiting when the simulator is quit are performed before exit.0.6.0-stable
parent
9c26c8c8da
commit
7ee1f3dff6
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
|
using OpenSim.Region.Environment.Scenes;
|
||||||
|
|
||||||
namespace OpenSim.Region.Environment.Interfaces
|
namespace OpenSim.Region.Environment.Interfaces
|
||||||
{
|
{
|
||||||
|
@ -39,6 +40,9 @@ namespace OpenSim.Region.Environment.Interfaces
|
||||||
uint callbackID, string description, string name, sbyte invType,
|
uint callbackID, string description, string name, sbyte invType,
|
||||||
sbyte type, byte wearableType, uint nextOwnerMask);
|
sbyte type, byte wearableType, uint nextOwnerMask);
|
||||||
|
|
||||||
|
void HandleTaskItemUpdateFromTransaction(
|
||||||
|
IClientAPI remoteClient, SceneObjectPart part, UUID transactionID, TaskInventoryItem item);
|
||||||
|
|
||||||
void RemoveAgentAssetTransactions(UUID userID);
|
void RemoveAgentAssetTransactions(UUID userID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,10 +28,13 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Reflection;
|
||||||
|
using log4net;
|
||||||
using OpenMetaverse;
|
using OpenMetaverse;
|
||||||
using OpenMetaverse.Packets;
|
using OpenMetaverse.Packets;
|
||||||
using OpenSim.Framework;
|
using OpenSim.Framework;
|
||||||
using OpenSim.Framework.Communications.Cache;
|
using OpenSim.Framework.Communications.Cache;
|
||||||
|
using OpenSim.Region.Environment.Scenes;
|
||||||
|
|
||||||
namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
|
namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
|
||||||
{
|
{
|
||||||
|
@ -75,8 +78,6 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
|
||||||
|
|
||||||
public void HandleXfer(ulong xferID, uint packetID, byte[] data)
|
public void HandleXfer(ulong xferID, uint packetID, byte[] data)
|
||||||
{
|
{
|
||||||
// AssetXferUploader uploaderFound = null;
|
|
||||||
|
|
||||||
lock (XferUploaders)
|
lock (XferUploaders)
|
||||||
{
|
{
|
||||||
foreach (AssetXferUploader uploader in XferUploaders.Values)
|
foreach (AssetXferUploader uploader in XferUploaders.Values)
|
||||||
|
@ -111,6 +112,15 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void RequestUpdateTaskInventoryItem(
|
||||||
|
IClientAPI remoteClient, SceneObjectPart part, UUID transactionID, TaskInventoryItem item)
|
||||||
|
{
|
||||||
|
if (XferUploaders.ContainsKey(transactionID))
|
||||||
|
{
|
||||||
|
XferUploaders[transactionID].RequestUpdateTaskInventoryItem(remoteClient, part, transactionID, item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get an uploaded asset. If the data is successfully retrieved, the transaction will be removed.
|
/// Get an uploaded asset. If the data is successfully retrieved, the transaction will be removed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -140,6 +150,8 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
|
||||||
|
|
||||||
public class AssetXferUploader
|
public class AssetXferUploader
|
||||||
{
|
{
|
||||||
|
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
// Fields
|
// Fields
|
||||||
public bool AddToInventory;
|
public bool AddToInventory;
|
||||||
public AssetBase Asset;
|
public AssetBase Asset;
|
||||||
|
@ -225,6 +237,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
|
||||||
|
|
||||||
TransactionID = transaction;
|
TransactionID = transaction;
|
||||||
m_storeLocal = storeLocal;
|
m_storeLocal = storeLocal;
|
||||||
|
|
||||||
if (Asset.Data.Length > 2)
|
if (Asset.Data.Length > 2)
|
||||||
{
|
{
|
||||||
SendCompleteMessage();
|
SendCompleteMessage();
|
||||||
|
@ -251,7 +264,6 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
|
||||||
|
|
||||||
ourClient.SendAssetUploadCompleteMessage(Asset.Type, true, Asset.FullID);
|
ourClient.SendAssetUploadCompleteMessage(Asset.Type, true, Asset.FullID);
|
||||||
|
|
||||||
|
|
||||||
m_finished = true;
|
m_finished = true;
|
||||||
if (m_createItem)
|
if (m_createItem)
|
||||||
{
|
{
|
||||||
|
@ -262,7 +274,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
|
||||||
m_userTransactions.Manager.MyScene.CommsManager.AssetCache.AddAsset(Asset);
|
m_userTransactions.Manager.MyScene.CommsManager.AssetCache.AddAsset(Asset);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Console.WriteLine("upload complete "+ this.TransactionID);
|
m_log.DebugFormat("[ASSET TRANSACTIONS]: Uploaded asset data for transaction {0}", TransactionID);
|
||||||
|
|
||||||
if (m_dumpAssetToFile)
|
if (m_dumpAssetToFile)
|
||||||
{
|
{
|
||||||
|
@ -274,15 +286,6 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
///Left this in and commented in case there are unforseen issues
|
|
||||||
//private void SaveAssetToFile(string filename, byte[] data)
|
|
||||||
//{
|
|
||||||
// FileStream fs = File.Create(filename);
|
|
||||||
// BinaryWriter bw = new BinaryWriter(fs);
|
|
||||||
// bw.Write(data);
|
|
||||||
// bw.Close();
|
|
||||||
// fs.Close();
|
|
||||||
//}
|
|
||||||
private void SaveAssetToFile(string filename, byte[] data)
|
private void SaveAssetToFile(string filename, byte[] data)
|
||||||
{
|
{
|
||||||
string assetPath = "UserAssets";
|
string assetPath = "UserAssets";
|
||||||
|
@ -314,6 +317,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
|
||||||
Asset.Description = description;
|
Asset.Description = description;
|
||||||
Asset.Type = type;
|
Asset.Type = type;
|
||||||
m_createItem = true;
|
m_createItem = true;
|
||||||
|
|
||||||
if (m_finished)
|
if (m_finished)
|
||||||
{
|
{
|
||||||
DoCreateItem();
|
DoCreateItem();
|
||||||
|
@ -360,6 +364,24 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void RequestUpdateTaskInventoryItem(
|
||||||
|
IClientAPI remoteClient, SceneObjectPart part, UUID transactionID, TaskInventoryItem item)
|
||||||
|
{
|
||||||
|
m_log.DebugFormat(
|
||||||
|
"[ASSET TRANSACTIONS]: Updating task item {0} in {1} with asset in transaction {2}",
|
||||||
|
item.Name, part.Name, transactionID);
|
||||||
|
|
||||||
|
Asset.Name = item.Name;
|
||||||
|
Asset.Description = item.Description;
|
||||||
|
Asset.Type = (sbyte) item.Type;
|
||||||
|
item.AssetID = Asset.FullID;
|
||||||
|
|
||||||
|
m_userTransactions.Manager.MyScene.CommsManager.AssetCache.AddAsset(Asset);
|
||||||
|
|
||||||
|
if (part.UpdateInventoryItem(item))
|
||||||
|
part.GetProperties(remoteClient);
|
||||||
|
}
|
||||||
|
|
||||||
private void DoCreateItem()
|
private void DoCreateItem()
|
||||||
{
|
{
|
||||||
//really need to fix this call, if lbsa71 saw this he would die.
|
//really need to fix this call, if lbsa71 saw this he would die.
|
||||||
|
|
|
@ -61,12 +61,17 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
|
||||||
wearableType, nextOwnerMask);
|
wearableType, nextOwnerMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HandleItemUpdateFromTransaction(IClientAPI remoteClient, UUID transactionID,
|
public void HandleItemUpdateFromTransaction(IClientAPI remoteClient, UUID transactionID, InventoryItemBase item)
|
||||||
InventoryItemBase item)
|
|
||||||
{
|
{
|
||||||
m_transactionManager.HandleItemUpdateFromTransaction(remoteClient, transactionID, item);
|
m_transactionManager.HandleItemUpdateFromTransaction(remoteClient, transactionID, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void HandleTaskItemUpdateFromTransaction(
|
||||||
|
IClientAPI remoteClient, SceneObjectPart part, UUID transactionID, TaskInventoryItem item)
|
||||||
|
{
|
||||||
|
m_transactionManager.HandleTaskItemUpdateFromTransaction(remoteClient, part, transactionID, item);
|
||||||
|
}
|
||||||
|
|
||||||
public void RemoveAgentAssetTransactions(UUID userID)
|
public void RemoveAgentAssetTransactions(UUID userID)
|
||||||
{
|
{
|
||||||
m_transactionManager.RemoveAgentAssetTransactions(userID);
|
m_transactionManager.RemoveAgentAssetTransactions(userID);
|
||||||
|
@ -141,8 +146,6 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
|
||||||
private static readonly ILog m_log
|
private static readonly ILog m_log
|
||||||
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
= LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||||
|
|
||||||
// Fields
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Each agent has its own singleton collection of transactions
|
/// Each agent has its own singleton collection of transactions
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -218,8 +221,8 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
|
||||||
uint callbackID, string description, string name, sbyte invType,
|
uint callbackID, string description, string name, sbyte invType,
|
||||||
sbyte type, byte wearableType, uint nextOwnerMask)
|
sbyte type, byte wearableType, uint nextOwnerMask)
|
||||||
{
|
{
|
||||||
m_log.DebugFormat(
|
// m_log.DebugFormat(
|
||||||
"[TRANSACTIONS MANAGER] Called HandleItemCreationFromTransaction with item {0}", name);
|
// "[TRANSACTIONS MANAGER] Called HandleItemCreationFromTransaction with item {0}", name);
|
||||||
|
|
||||||
AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);
|
AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);
|
||||||
|
|
||||||
|
@ -240,16 +243,37 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
|
||||||
public void HandleItemUpdateFromTransaction(IClientAPI remoteClient, UUID transactionID,
|
public void HandleItemUpdateFromTransaction(IClientAPI remoteClient, UUID transactionID,
|
||||||
InventoryItemBase item)
|
InventoryItemBase item)
|
||||||
{
|
{
|
||||||
m_log.DebugFormat(
|
// m_log.DebugFormat(
|
||||||
"[TRANSACTIONS MANAGER] Called HandleItemUpdateFromTransaction with item {0}",
|
// "[TRANSACTIONS MANAGER] Called HandleItemUpdateFromTransaction with item {0}",
|
||||||
item.Name);
|
// item.Name);
|
||||||
|
|
||||||
AgentAssetTransactions transactions
|
AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);
|
||||||
= GetUserTransactions(remoteClient.AgentId);
|
|
||||||
|
|
||||||
transactions.RequestUpdateInventoryItem(remoteClient, transactionID, item);
|
transactions.RequestUpdateInventoryItem(remoteClient, transactionID, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Update a task inventory item with data that has been received through a transaction.
|
||||||
|
///
|
||||||
|
/// This is currently called when, for instance, a notecard in a prim is saved. The data is sent
|
||||||
|
/// up through a single AssetUploadRequest. A subsequent UpdateTaskInventory then references the transaction
|
||||||
|
/// and comes through this method.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="remoteClient"></param>
|
||||||
|
/// <param name="transactionID"></param>
|
||||||
|
/// <param name="item"></param>
|
||||||
|
public void HandleTaskItemUpdateFromTransaction(
|
||||||
|
IClientAPI remoteClient, SceneObjectPart part, UUID transactionID, TaskInventoryItem item)
|
||||||
|
{
|
||||||
|
// m_log.DebugFormat(
|
||||||
|
// "[TRANSACTIONS MANAGER] Called HandleTaskItemUpdateFromTransaction with item {0}",
|
||||||
|
// item.Name);
|
||||||
|
|
||||||
|
AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);
|
||||||
|
|
||||||
|
transactions.RequestUpdateTaskInventoryItem(remoteClient, part, transactionID, item);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Request that a client (agent) begin an asset transfer.
|
/// Request that a client (agent) begin an asset transfer.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -270,6 +294,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
|
||||||
{
|
{
|
||||||
Scene scene = (Scene)remoteClient.Scene;
|
Scene scene = (Scene)remoteClient.Scene;
|
||||||
IMoneyModule mm = scene.RequestModuleInterface<IMoneyModule>();
|
IMoneyModule mm = scene.RequestModuleInterface<IMoneyModule>();
|
||||||
|
|
||||||
if (mm != null)
|
if (mm != null)
|
||||||
{
|
{
|
||||||
if (!mm.UploadCovered(remoteClient))
|
if (!mm.UploadCovered(remoteClient))
|
||||||
|
@ -280,15 +305,13 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Console.WriteLine("asset upload of " + assetID);
|
//Console.WriteLine("asset upload of " + assetID);
|
||||||
AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);
|
AgentAssetTransactions transactions = GetUserTransactions(remoteClient.AgentId);
|
||||||
|
|
||||||
AgentAssetTransactions.AssetXferUploader uploader = transactions.RequestXferUploader(transaction);
|
AgentAssetTransactions.AssetXferUploader uploader = transactions.RequestXferUploader(transaction);
|
||||||
if (uploader != null)
|
if (uploader != null)
|
||||||
{
|
{
|
||||||
if (uploader.Initialise(remoteClient, assetID, transaction, type, data, storeLocal, tempFile))
|
uploader.Initialise(remoteClient, assetID, transaction, type, data, storeLocal, tempFile);
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1257,11 +1257,12 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
}
|
}
|
||||||
else // Updating existing item with new perms etc
|
else // Updating existing item with new perms etc
|
||||||
{
|
{
|
||||||
TaskInventoryItem prevItem = part.GetInventoryItem(itemID);
|
IAgentAssetTransactions agentTransactions = this.RequestModuleInterface<IAgentAssetTransactions>();
|
||||||
System.Console.WriteLine("Item asset {0}, request asset {1}", prevItem.AssetID.ToString(), itemInfo.AssetID.ToString());
|
if (agentTransactions != null)
|
||||||
itemInfo.AssetID = prevItem.AssetID;
|
{
|
||||||
if (part.UpdateInventoryItem(itemInfo))
|
agentTransactions.HandleTaskItemUpdateFromTransaction(
|
||||||
part.GetProperties(remoteClient);
|
remoteClient, part, transactionID, currentItem);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue