Merge branch 'ubitwork' of ssh://3dhosting.de/var/git/careminster into ubitwork

avinationmerge
ubit 2012-09-22 22:15:35 +02:00
commit 80a81896b6
4 changed files with 87 additions and 29 deletions

View File

@ -30,12 +30,14 @@ using OpenMetaverse;
namespace OpenSim.Framework.Capabilities namespace OpenSim.Framework.Capabilities
{ {
[LLSDType("MAP")] [LLSDType("MAP")]
public class LLSDAssetUploadComplete public class LLSDAssetUploadComplete
{ {
public string new_asset = String.Empty; public string new_asset = String.Empty;
public UUID new_inventory_item = UUID.Zero; public UUID new_inventory_item = UUID.Zero;
public string state = String.Empty; public string state = String.Empty;
public LLSDAssetUploadError error = null;
//public bool success = false; //public bool success = false;
public LLSDAssetUploadComplete() public LLSDAssetUploadComplete()

View File

@ -26,9 +26,17 @@
*/ */
using System; using System;
using OpenMetaverse;
namespace OpenSim.Framework.Capabilities namespace OpenSim.Framework.Capabilities
{ {
[OSDMap]
public class LLSDAssetUploadError
{
public string message = String.Empty;
public UUID identifier = UUID.Zero;
}
[OSDMap] [OSDMap]
public class LLSDAssetUploadResponsePricebrkDown public class LLSDAssetUploadResponsePricebrkDown
{ {
@ -56,11 +64,13 @@ namespace OpenSim.Framework.Capabilities
public string state = String.Empty; public string state = String.Empty;
public int upload_price = 0; public int upload_price = 0;
public LLSDAssetUploadResponseData data = null; public LLSDAssetUploadResponseData data = null;
public LLSDAssetUploadError error = null;
public LLSDAssetUploadResponse() public LLSDAssetUploadResponse()
{ {
} }
} }
[OSDMap] [OSDMap]
public class LLSDNewFileAngentInventoryVariablePriceReplyResponse public class LLSDNewFileAngentInventoryVariablePriceReplyResponse
{ {

View File

@ -55,7 +55,7 @@ namespace OpenSim.Region.ClientStack.Linden
{ {
public delegate void UpLoadedAsset( public delegate void UpLoadedAsset(
string assetName, string description, UUID assetID, UUID inventoryItem, UUID parentFolder, string assetName, string description, UUID assetID, UUID inventoryItem, UUID parentFolder,
byte[] data, string inventoryType, string assetType, int cost); byte[] data, string inventoryType, string assetType, int cost, ref string error);
public delegate UUID UpdateItem(UUID itemID, byte[] data); public delegate UUID UpdateItem(UUID itemID, byte[] data);
@ -455,11 +455,14 @@ namespace OpenSim.Region.ClientStack.Linden
{ {
case FileAgentInventoryState.processRequest: case FileAgentInventoryState.processRequest:
case FileAgentInventoryState.processUpload: case FileAgentInventoryState.processUpload:
if (client != null) LLSDAssetUploadError resperror = new LLSDAssetUploadError();
client.SendAgentAlertMessage("Unable to upload asset. Processing previus request", false); resperror.message = "Uploader busy processing previus request";
resperror.identifier = UUID.Zero;
LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse();
errorResponse.uploader = ""; errorResponse.uploader = "";
errorResponse.state = "error"; errorResponse.state = "error";
errorResponse.error = resperror;
return errorResponse; return errorResponse;
break; break;
case FileAgentInventoryState.waitUpload: case FileAgentInventoryState.waitUpload:
@ -489,12 +492,15 @@ namespace OpenSim.Region.ClientStack.Linden
{ {
if (avatar.UserLevel < m_levelUpload) if (avatar.UserLevel < m_levelUpload)
{ {
if (client != null) LLSDAssetUploadError resperror = new LLSDAssetUploadError();
client.SendAgentAlertMessage("Unable to upload asset. Insufficient permissions.", false); resperror.message = "Insufficient permissions to upload";
resperror.identifier = UUID.Zero;
LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse();
errorResponse.uploader = ""; errorResponse.uploader = "";
errorResponse.state = "error"; errorResponse.state = "error";
errorResponse.error = resperror;
lock (m_ModelCost) lock (m_ModelCost)
m_FileAgentInventoryState = FileAgentInventoryState.idle; m_FileAgentInventoryState = FileAgentInventoryState.idle;
return errorResponse; return errorResponse;
@ -518,11 +524,15 @@ namespace OpenSim.Region.ClientStack.Linden
if (!m_ModelCost.MeshModelCost(llsdRequest.asset_resources, baseCost, out modelcost, if (!m_ModelCost.MeshModelCost(llsdRequest.asset_resources, baseCost, out modelcost,
meshcostdata, out error)) meshcostdata, out error))
{ {
client.SendAgentAlertMessage(error, false); LLSDAssetUploadError resperror = new LLSDAssetUploadError();
resperror.message = error;
resperror.identifier = UUID.Zero;
LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse();
errorResponse.uploader = ""; errorResponse.uploader = "";
errorResponse.state = "error"; errorResponse.state = "error";
errorResponse.error = resperror;
lock (m_ModelCost) lock (m_ModelCost)
m_FileAgentInventoryState = FileAgentInventoryState.idle; m_FileAgentInventoryState = FileAgentInventoryState.idle;
return errorResponse; return errorResponse;
@ -539,11 +549,14 @@ namespace OpenSim.Region.ClientStack.Linden
{ {
if (!mm.UploadCovered(client.AgentId, (int)cost)) if (!mm.UploadCovered(client.AgentId, (int)cost))
{ {
client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false); LLSDAssetUploadError resperror = new LLSDAssetUploadError();
resperror.message = "Insuficient funds";
resperror.identifier = UUID.Zero;
LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse(); LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse();
errorResponse.uploader = ""; errorResponse.uploader = "";
errorResponse.state = "error"; errorResponse.state = "error";
errorResponse.error = resperror;
lock (m_ModelCost) lock (m_ModelCost)
m_FileAgentInventoryState = FileAgentInventoryState.idle; m_FileAgentInventoryState = FileAgentInventoryState.idle;
return errorResponse; return errorResponse;
@ -607,8 +620,9 @@ 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, int cost) string assetType, int cost, ref string error)
{ {
lock (m_ModelCost) lock (m_ModelCost)
m_FileAgentInventoryState = FileAgentInventoryState.processUpload; m_FileAgentInventoryState = FileAgentInventoryState.processUpload;
@ -619,17 +633,13 @@ namespace OpenSim.Region.ClientStack.Linden
sbyte assType = 0; sbyte assType = 0;
sbyte inType = 0; sbyte inType = 0;
IClientAPI client = null;
IMoneyModule mm = m_Scene.RequestModuleInterface<IMoneyModule>(); IMoneyModule mm = m_Scene.RequestModuleInterface<IMoneyModule>();
if (mm != null) if (mm != null)
{ {
// make sure client still has enougth credit // make sure client still has enougth credit
if (!mm.UploadCovered(m_HostCapsObj.AgentID, (int)cost)) if (!mm.UploadCovered(m_HostCapsObj.AgentID, (int)cost))
{ {
m_Scene.TryGetClient(m_HostCapsObj.AgentID, out client); error = "Insufficient funds.";
if (client != null)
client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false);
return; return;
} }
} }
@ -668,6 +678,25 @@ namespace OpenSim.Region.ClientStack.Linden
List<Vector3> positions = new List<Vector3>(); List<Vector3> positions = new List<Vector3>();
List<Quaternion> rotations = new List<Quaternion>(); List<Quaternion> rotations = new List<Quaternion>();
OSDMap request = (OSDMap)OSDParser.DeserializeLLSDXml(data); OSDMap request = (OSDMap)OSDParser.DeserializeLLSDXml(data);
// compare and get updated information
bool mismatchError = true;
while (mismatchError)
{
mismatchError = false;
}
if (mismatchError)
{
error = "Upload and fee estimation information don't match";
lock (m_ModelCost)
m_FileAgentInventoryState = FileAgentInventoryState.idle;
return;
}
OSDArray instance_list = (OSDArray)request["instance_list"]; OSDArray instance_list = (OSDArray)request["instance_list"];
OSDArray mesh_list = (OSDArray)request["mesh_list"]; OSDArray mesh_list = (OSDArray)request["mesh_list"];
OSDArray texture_list = (OSDArray)request["texture_list"]; OSDArray texture_list = (OSDArray)request["texture_list"];
@ -1240,7 +1269,8 @@ namespace OpenSim.Region.ClientStack.Linden
private string m_invType = String.Empty; private string m_invType = String.Empty;
private string m_assetType = String.Empty; private string m_assetType = String.Empty;
private int m_cost; private int m_cost;
private string m_error = String.Empty;
private Timer m_timeoutTimer = new Timer(); private Timer m_timeoutTimer = new Timer();
@ -1278,12 +1308,13 @@ namespace OpenSim.Region.ClientStack.Linden
UUID inv = inventoryItemID; UUID inv = inventoryItemID;
string res = String.Empty; string res = String.Empty;
LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete(); LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete();
/*
uploadComplete.new_asset = newAssetID.ToString(); uploadComplete.new_asset = newAssetID.ToString();
uploadComplete.new_inventory_item = inv; uploadComplete.new_inventory_item = inv;
uploadComplete.state = "complete"; uploadComplete.state = "complete";
res = LLSDHelpers.SerialiseLLSDReply(uploadComplete); res = LLSDHelpers.SerialiseLLSDReply(uploadComplete);
*/
m_timeoutTimer.Stop(); m_timeoutTimer.Stop();
httpListener.RemoveStreamHandler("POST", uploaderPath); httpListener.RemoveStreamHandler("POST", uploaderPath);
@ -1301,8 +1332,25 @@ namespace OpenSim.Region.ClientStack.Linden
handlerUpLoad = OnUpLoad; handlerUpLoad = OnUpLoad;
if (handlerUpLoad != null) if (handlerUpLoad != null)
{ {
handlerUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data, m_invType, m_assetType,m_cost); handlerUpLoad(m_assetName, m_assetDes, newAssetID, inv, parentFolder, data, m_invType, m_assetType,m_cost, ref m_error);
} }
if(m_error == String.Empty)
{
uploadComplete.new_asset = newAssetID.ToString();
uploadComplete.new_inventory_item = inv;
uploadComplete.state = "complete";
}
else
{
LLSDAssetUploadError resperror = new LLSDAssetUploadError();
resperror.message = m_error;
resperror.identifier = inv;
uploadComplete.error = resperror;
uploadComplete.state = "failed";
}
res = LLSDHelpers.SerialiseLLSDReply(uploadComplete);
return res; return res;
} }

View File

@ -105,7 +105,7 @@ namespace OpenSim.Region.ClientStack.Linden
resources.instance_list == null || resources.instance_list == null ||
resources.instance_list.Array.Count == 0) resources.instance_list.Array.Count == 0)
{ {
error = "Unable to upload mesh model. missing information."; error = "missing model information.";
return false; return false;
} }
@ -113,7 +113,7 @@ namespace OpenSim.Region.ClientStack.Linden
if( numberInstances > ObjectLinkedPartsMax ) if( numberInstances > ObjectLinkedPartsMax )
{ {
error = "upload failed: Model whould have two many linked prims"; error = "Model whould have more than " + ObjectLinkedPartsMax.ToString() + " linked prims";
return false; return false;
} }
@ -186,15 +186,13 @@ namespace OpenSim.Region.ClientStack.Linden
if (scale.X < PrimScaleMin || scale.Y < PrimScaleMin || scale.Z < PrimScaleMin) if (scale.X < PrimScaleMin || scale.Y < PrimScaleMin || scale.Z < PrimScaleMin)
{ {
// error = " upload fail: Model contains parts with a dimension lower than 0.001. Please adjust scaling";
// return false;
skipedSmall++; skipedSmall++;
continue; continue;
} }
if (scale.X > NonPhysicalPrimScaleMax || scale.Y > NonPhysicalPrimScaleMax || scale.Z > NonPhysicalPrimScaleMax) if (scale.X > NonPhysicalPrimScaleMax || scale.Y > NonPhysicalPrimScaleMax || scale.Z > NonPhysicalPrimScaleMax)
{ {
error = "upload fail: Model contains parts larger than maximum allowed. Please adjust scaling"; error = "Model contains parts with sides larger than " + NonPhysicalPrimScaleMax.ToString() + "m. Please ajust scale";
return false; return false;
} }
@ -204,7 +202,7 @@ namespace OpenSim.Region.ClientStack.Linden
if (mesh >= numberMeshs) if (mesh >= numberMeshs)
{ {
error = "Unable to upload mesh model. incoerent information."; error = "Incoerent model information.";
return false; return false;
} }
@ -233,7 +231,7 @@ namespace OpenSim.Region.ClientStack.Linden
if (skipedSmall >0 && skipedSmall > numberInstances / 2) if (skipedSmall >0 && skipedSmall > numberInstances / 2)
{ {
error = "Upload failed: Model contains too much prims smaller than minimum size to ignore"; error = "Model contains too many prims smaller than " + PrimScaleMin.ToString() + "m";
return false; return false;
} }
@ -279,14 +277,14 @@ namespace OpenSim.Region.ClientStack.Linden
if (data == null || data.Length == 0) if (data == null || data.Length == 0)
{ {
error = "Unable to upload mesh model. missing information."; error = "Missing model information.";
return false; return false;
} }
OSD meshOsd = null; OSD meshOsd = null;
int start = 0; int start = 0;
error = "Unable to upload mesh model. Invalid data"; error = "Invalid model data";
using (MemoryStream ms = new MemoryStream(data)) using (MemoryStream ms = new MemoryStream(data))
{ {
@ -334,13 +332,13 @@ namespace OpenSim.Region.ClientStack.Linden
if (submesh_offset < 0 || hulls_size == 0) if (submesh_offset < 0 || hulls_size == 0)
{ {
error = "Unable to upload mesh model. missing physics_convex block"; error = "Missing physics_convex block";
return false; return false;
} }
if (!hulls(data, submesh_offset, hulls_size, out phys_hullsvertices, out phys_nhulls)) if (!hulls(data, submesh_offset, hulls_size, out phys_hullsvertices, out phys_nhulls))
{ {
error = "Unable to upload mesh model. bad physics_convex block"; error = "Bad physics_convex block";
return false; return false;
} }
@ -360,7 +358,7 @@ namespace OpenSim.Region.ClientStack.Linden
if (submesh_offset < 0 || highlod_size <= 0) if (submesh_offset < 0 || highlod_size <= 0)
{ {
error = "Unable to upload mesh model. missing high_lod"; error = "Missing high_lod block";
return false; return false;
} }
@ -418,7 +416,7 @@ namespace OpenSim.Region.ClientStack.Linden
if (!submesh(data, submesh_offset, physmesh_size, out phys_ntriangles)) if (!submesh(data, submesh_offset, physmesh_size, out phys_ntriangles))
{ {
error = "Unable to upload mesh model. parsing error"; error = "Model data parsing error";
return false; return false;
} }
} }