Added one more delegate to Caps, and a few guards, so that these objects can be used from more than just Scenes. Added the NewFileAgentInvengory cap to HGInventoryService.

0.6.5-rc1
diva 2009-04-03 16:08:07 +00:00
parent fc1b1bc797
commit 7322e19212
2 changed files with 43 additions and 15 deletions

View File

@ -49,6 +49,8 @@ namespace OpenSim.Framework.Communications.Capabilities
public delegate void NewInventoryItem(UUID userID, InventoryItemBase item);
public delegate void NewAsset(AssetBase asset);
public delegate UUID ItemUpdatedCallback(UUID userID, UUID itemID, byte[] data);
public delegate void TaskScriptUpdatedCallback(UUID userID, UUID itemID, UUID primID,
@ -120,6 +122,7 @@ namespace OpenSim.Framework.Communications.Capabilities
// These are callbacks which will be setup by the scene so that we can update scene data when we
// receive capability calls
public NewInventoryItem AddNewInventoryItem = null;
public NewAsset AddNewAsset = null;
public ItemUpdatedCallback ItemUpdatedCall = null;
public TaskScriptUpdatedCallback TaskScriptUpdatedCall = null;
public FetchInventoryDescendentsCAPS CAPSFetchInventoryDescendents = null;
@ -674,30 +677,38 @@ namespace OpenSim.Framework.Communications.Capabilities
/// <returns></returns>
public LLSDAssetUploadResponse NewAgentInventoryRequest(LLSDAssetUploadRequest llsdRequest)
{
//m_log.Debug("[CAPS]: NewAgentInventoryRequest Request is: " + llsdRequest.ToString());
//m_log.Debug("asset upload request via CAPS" + llsdRequest.inventory_type + " , " + llsdRequest.asset_type);
if (llsdRequest.asset_type == "texture" ||
llsdRequest.asset_type == "animation" ||
llsdRequest.asset_type == "sound")
{
IClientAPI client = GetClient(m_agentID);
IScene scene = client.Scene;
IMoneyModule mm = scene.RequestModuleInterface<IMoneyModule>();
if (mm != null)
IClientAPI client = null;
IScene scene = null;
if (GetClient != null)
{
if (!mm.UploadCovered(client))
{
client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false);
client = GetClient(m_agentID);
scene = client.Scene;
LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse();
errorResponse.uploader = "";
errorResponse.state = "error";
return errorResponse;
IMoneyModule mm = scene.RequestModuleInterface<IMoneyModule>();
if (mm != null)
{
if (!mm.UploadCovered(client))
{
if (client != null)
client.SendAgentAlertMessage("Unable to upload asset. Insufficient funds.", false);
LLSDAssetUploadResponse errorResponse = new LLSDAssetUploadResponse();
errorResponse.uploader = "";
errorResponse.state = "error";
return errorResponse;
}
}
}
}
//m_log.Debug("asset upload request via CAPS" + llsdRequest.inventory_type +" , "+ llsdRequest.asset_type);
string assetName = llsdRequest.name;
string assetDes = llsdRequest.description;
@ -771,7 +782,10 @@ namespace OpenSim.Framework.Communications.Capabilities
asset.Type = assType;
asset.Name = assetName;
asset.Data = data;
m_assetCache.AddAsset(asset);
if (AddNewAsset != null)
AddNewAsset(asset);
else if (m_assetCache != null)
m_assetCache.AddAsset(asset);
InventoryItemBase item = new InventoryItemBase();
item.Owner = m_agentID;

View File

@ -234,6 +234,11 @@ namespace OpenSim.Framework.Communications.Services
}
}
public void AddUploadedInventoryItem(UUID agentID, InventoryItemBase item)
{
AddItem(item);
}
public InventoryItemBase UpdateItem(InventoryItemBase item)
{
m_log.DebugFormat("[HGStandaloneInvService]: Update item {0} from {1}", item.ID, item.Owner);
@ -372,6 +377,11 @@ namespace OpenSim.Framework.Communications.Services
return true;
}
public void PostAnAsset(AssetBase asset)
{
PostAsset(asset);
}
/// <summary>
/// <see>CapsUpdatedInventoryItemAsset(IClientAPI, UUID, byte[])</see>
/// </summary>
@ -598,6 +608,10 @@ namespace OpenSim.Framework.Communications.Services
Caps caps = new Caps(null, httpServer, m_thisHostname, m_thisPort, authToken, userID, false, "Inventory");
caps.RegisterInventoryServiceHandlers("/" + authToken + "/InventoryCap/");
caps.ItemUpdatedCall = UpdateInventoryItemAsset;
caps.AddNewInventoryItem = AddUploadedInventoryItem;
caps.AddNewAsset = PostAnAsset;
//caps.GetClient =
Hashtable capsHandlers = caps.CapsHandlers.CapsDetails;
httpServer.AddStreamHandler(new RestDeserialiseSecureHandler<Guid, InventoryCollection>(