Add the option to have variable costing for uploads
parent
94a8e5572b
commit
bd1d9a214b
|
@ -60,7 +60,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
|
|
||||||
public delegate void UpdateTaskScript(UUID itemID, UUID primID, bool isScriptRunning, byte[] data, ref ArrayList errors);
|
public delegate void UpdateTaskScript(UUID itemID, UUID primID, bool isScriptRunning, byte[] data, ref ArrayList errors);
|
||||||
|
|
||||||
public delegate void NewInventoryItem(UUID userID, InventoryItemBase item);
|
public delegate void NewInventoryItem(UUID userID, InventoryItemBase item, uint cost);
|
||||||
|
|
||||||
public delegate void NewAsset(AssetBase asset);
|
public delegate void NewAsset(AssetBase asset);
|
||||||
|
|
||||||
|
@ -386,6 +386,38 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
return UUID.Zero;
|
return UUID.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private delegate void UploadWithCostCompleteDelegate(string assetName,
|
||||||
|
string assetDescription, UUID assetID, UUID inventoryItem,
|
||||||
|
UUID parentFolder, byte[] data, string inventoryType,
|
||||||
|
string assetType, uint cost);
|
||||||
|
|
||||||
|
private class AssetUploaderWithCost : AssetUploader
|
||||||
|
{
|
||||||
|
private uint m_cost;
|
||||||
|
|
||||||
|
public event UploadWithCostCompleteDelegate OnUpLoad;
|
||||||
|
|
||||||
|
public AssetUploaderWithCost(string assetName, string description, UUID assetID,
|
||||||
|
UUID inventoryItem, UUID parentFolderID, string invType, string assetType,
|
||||||
|
string path, IHttpServer httpServer, bool dumpAssetsToFile, uint cost) :
|
||||||
|
base(assetName, description, assetID, inventoryItem, parentFolderID,
|
||||||
|
invType, assetType, path, httpServer, dumpAssetsToFile)
|
||||||
|
{
|
||||||
|
m_cost = cost;
|
||||||
|
|
||||||
|
base.OnUpLoad += UploadCompleteHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID,
|
||||||
|
UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType,
|
||||||
|
string assetType)
|
||||||
|
{
|
||||||
|
OnUpLoad(assetName, assetDescription, assetID, inventoryItem, parentFolder,
|
||||||
|
data, inventoryType, assetType, m_cost);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -396,6 +428,8 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
//m_log.Debug("[CAPS]: NewAgentInventoryRequest Request is: " + llsdRequest.ToString());
|
//m_log.Debug("[CAPS]: NewAgentInventoryRequest Request is: " + llsdRequest.ToString());
|
||||||
//m_log.Debug("asset upload request via CAPS" + llsdRequest.inventory_type + " , " + llsdRequest.asset_type);
|
//m_log.Debug("asset upload request via CAPS" + llsdRequest.inventory_type + " , " + llsdRequest.asset_type);
|
||||||
|
|
||||||
|
uint cost = 0;
|
||||||
|
|
||||||
if (llsdRequest.asset_type == "texture" ||
|
if (llsdRequest.asset_type == "texture" ||
|
||||||
llsdRequest.asset_type == "animation" ||
|
llsdRequest.asset_type == "animation" ||
|
||||||
llsdRequest.asset_type == "sound")
|
llsdRequest.asset_type == "sound")
|
||||||
|
@ -428,7 +462,10 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
|
|
||||||
if (mm != null)
|
if (mm != null)
|
||||||
{
|
{
|
||||||
if (!mm.UploadCovered(client.AgentId, mm.UploadCharge))
|
// XPTO: The cost should be calculated about here
|
||||||
|
cost = (uint)mm.UploadCharge;
|
||||||
|
|
||||||
|
if (!mm.UploadCovered(client.AgentId, (int)cost))
|
||||||
{
|
{
|
||||||
client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false);
|
client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false);
|
||||||
|
|
||||||
|
@ -449,9 +486,9 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
UUID parentFolder = llsdRequest.folder_id;
|
UUID parentFolder = llsdRequest.folder_id;
|
||||||
string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000");
|
string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000");
|
||||||
|
|
||||||
AssetUploader uploader =
|
AssetUploaderWithCost uploader =
|
||||||
new AssetUploader(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type,
|
new AssetUploaderWithCost(assetName, assetDes, newAsset, newInvItem, parentFolder, llsdRequest.inventory_type,
|
||||||
llsdRequest.asset_type, capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_dumpAssetsToFile);
|
llsdRequest.asset_type, capsBase + uploaderPath, m_HostCapsObj.HttpListener, m_dumpAssetsToFile, cost);
|
||||||
|
|
||||||
m_HostCapsObj.HttpListener.AddStreamHandler(
|
m_HostCapsObj.HttpListener.AddStreamHandler(
|
||||||
new BinaryStreamHandler(
|
new BinaryStreamHandler(
|
||||||
|
@ -484,7 +521,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
/// <param name="data"></param>
|
/// <param name="data"></param>
|
||||||
public void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID,
|
public void UploadCompleteHandler(string assetName, string assetDescription, UUID assetID,
|
||||||
UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType,
|
UUID inventoryItem, UUID parentFolder, byte[] data, string inventoryType,
|
||||||
string assetType)
|
string assetType, uint cost)
|
||||||
{
|
{
|
||||||
m_log.DebugFormat(
|
m_log.DebugFormat(
|
||||||
"[BUNCH OF CAPS]: Uploaded asset {0} for inventory item {1}, inv type {2}, asset type {3}",
|
"[BUNCH OF CAPS]: Uploaded asset {0} for inventory item {1}, inv type {2}, asset type {3}",
|
||||||
|
@ -703,7 +740,7 @@ namespace OpenSim.Region.ClientStack.Linden
|
||||||
|
|
||||||
if (AddNewInventoryItem != null)
|
if (AddNewInventoryItem != null)
|
||||||
{
|
{
|
||||||
AddNewInventoryItem(m_HostCapsObj.AgentID, item);
|
AddNewInventoryItem(m_HostCapsObj.AgentID, item, cost);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,12 +101,12 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
engine.StartProcessing();
|
engine.StartProcessing();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddUploadedInventoryItem(UUID agentID, InventoryItemBase item)
|
public void AddUploadedInventoryItem(UUID agentID, InventoryItemBase item, uint cost)
|
||||||
{
|
{
|
||||||
IMoneyModule money = RequestModuleInterface<IMoneyModule>();
|
IMoneyModule money = RequestModuleInterface<IMoneyModule>();
|
||||||
if (money != null)
|
if (money != null)
|
||||||
{
|
{
|
||||||
money.ApplyUploadCharge(agentID, money.UploadCharge, "Asset upload");
|
money.ApplyUploadCharge(agentID, (int)cost, "Asset upload");
|
||||||
}
|
}
|
||||||
|
|
||||||
AddInventoryItem(item);
|
AddInventoryItem(item);
|
||||||
|
|
Loading…
Reference in New Issue