preliminary support for editing notecards and scripts.
Although there seems to sometimes be a problem of when you login again, old notecards and scripts will have their permissions messed up and you won't be able to even view their text. This seems to be related to the client's cache, and if you clear your client's cache, on the next login they should be fine again. [I have a couple of ideas about what might be causing this so hopefully will have it fixed soon.]afrisby
parent
16defc30eb
commit
a979808493
|
@ -89,7 +89,7 @@ namespace OpenSim.Framework.Communications.Caches
|
|||
private string uploaderPath = "";
|
||||
|
||||
// Events
|
||||
public event UpLoadedTexture OnUpLoad;
|
||||
public event UpLoadedAsset OnUpLoad;
|
||||
|
||||
// Methods
|
||||
public void Initialise(string assetName, string assetDescription, LLUUID assetID, LLUUID inventoryItem, LLUUID folderID, string path, BaseHttpServer httpServer)
|
||||
|
@ -230,7 +230,7 @@ namespace OpenSim.Framework.Communications.Caches
|
|||
private string uploaderPath = "";
|
||||
|
||||
// Events
|
||||
public event UpLoadedTexture OnUpLoad;
|
||||
public event UpLoadedAsset OnUpLoad;
|
||||
|
||||
// Methods
|
||||
public void Initialise(LLUUID inventoryItem, string path, BaseHttpServer httpServer)
|
||||
|
|
|
@ -104,6 +104,14 @@ namespace OpenSim.Framework.Communications.Caches
|
|||
this.m_parentCommsManager.InventoryServer.AddNewInventoryItem(userID, itemInfo);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateItem(LLUUID userID, InventoryItemBase itemInfo)
|
||||
{
|
||||
if ((userID == this.UserProfile.UUID) && (this.RootFolder != null))
|
||||
{
|
||||
this.m_parentCommsManager.InventoryServer.AddNewInventoryItem(userID, itemInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -39,8 +39,10 @@ using OpenSim.Framework.Data;
|
|||
|
||||
namespace OpenSim.Region.Capabilities
|
||||
{
|
||||
public delegate void UpLoadedTexture(string assetName, string description, LLUUID assetID, LLUUID inventoryItem, LLUUID parentFolder, byte[] data);
|
||||
public delegate void UpLoadedAsset(string assetName, string description, LLUUID assetID, LLUUID inventoryItem, LLUUID parentFolder, byte[] data);
|
||||
public delegate LLUUID UpdateItem(LLUUID itemID, byte[] data);
|
||||
public delegate void NewInventoryItem(LLUUID userID, InventoryItemBase item);
|
||||
public delegate LLUUID ItemUpdatedCallback(LLUUID userID, LLUUID itemID, byte[] data);
|
||||
|
||||
public class Caps
|
||||
{
|
||||
|
@ -59,6 +61,7 @@ namespace OpenSim.Region.Capabilities
|
|||
private int eventQueueCount = 1;
|
||||
private Queue<string> CapsEventQueue = new Queue<string>();
|
||||
public NewInventoryItem AddNewInventoryItem = null;
|
||||
public ItemUpdatedCallback ItemUpdatedCall = null;
|
||||
|
||||
public Caps(AssetCache assetCach, BaseHttpServer httpServer, string httpListen, int httpPort, string capsPath, LLUUID agent)
|
||||
{
|
||||
|
@ -125,7 +128,8 @@ namespace OpenSim.Region.Capabilities
|
|||
string capsBaseUrl = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + "/CAPS/" + m_capsObjectPath;
|
||||
caps.MapLayer = capsBaseUrl + m_mapLayerPath;
|
||||
caps.NewFileAgentInventory = capsBaseUrl + m_newInventory;
|
||||
// caps.UpdateNotecardAgentInventory = capsBaseUrl + m_notecardUpdatePath;
|
||||
caps.UpdateNotecardAgentInventory = capsBaseUrl + m_notecardUpdatePath;
|
||||
caps.UpdateScriptAgentInventory = capsBaseUrl + m_notecardUpdatePath;
|
||||
return caps;
|
||||
}
|
||||
|
||||
|
@ -238,21 +242,24 @@ namespace OpenSim.Region.Capabilities
|
|||
/// <returns></returns>
|
||||
public string NoteCardAgentInventory(string request, string path, string param)
|
||||
{
|
||||
Console.WriteLine("notecard update request " + request);
|
||||
string assetName = "notecardupdate";
|
||||
Hashtable hash = (Hashtable)LLSD.LLSDDeserialize(Helpers.StringToField(request));
|
||||
LLSDItemUpdate llsdRequest = new LLSDItemUpdate();
|
||||
LLSDHelpers.DeserialiseLLSDMap(hash, llsdRequest);
|
||||
|
||||
string capsBase = "/CAPS/" + m_capsObjectPath;
|
||||
LLUUID newAsset = LLUUID.Random();
|
||||
LLUUID newInvItem = LLUUID.Random();
|
||||
LLUUID newInvItem = llsdRequest.item_id;
|
||||
string uploaderPath = Util.RandomClass.Next(5000, 8000).ToString("0000");
|
||||
|
||||
AssetUploader uploader = new AssetUploader(assetName, "description", newAsset, newInvItem, LLUUID.Zero, "", "", capsBase + uploaderPath, this.httpListener);
|
||||
ItemUpdater uploader = new ItemUpdater(newInvItem, capsBase + uploaderPath, this.httpListener);
|
||||
uploader.OnUpLoad += this.ItemUpdated;
|
||||
|
||||
httpListener.AddStreamHandler(new BinaryStreamHandler("POST", capsBase + uploaderPath, uploader.uploaderCaps));
|
||||
string uploaderURL = "http://" + m_httpListenerHostName + ":" + m_httpListenPort.ToString() + capsBase + uploaderPath;
|
||||
|
||||
LLSDAssetUploadResponse uploadResponse = new LLSDAssetUploadResponse();
|
||||
uploadResponse.uploader = uploaderURL;
|
||||
uploadResponse.state = "upload";
|
||||
// uploader.OnUpLoad += this.UploadCompleteHandler;
|
||||
|
||||
return LLSDHelpers.SerialiseLLSDReply(uploadResponse);
|
||||
}
|
||||
|
||||
|
@ -321,9 +328,18 @@ namespace OpenSim.Region.Capabilities
|
|||
|
||||
}
|
||||
|
||||
public LLUUID ItemUpdated(LLUUID itemID, byte[] data)
|
||||
{
|
||||
if (ItemUpdatedCall != null)
|
||||
{
|
||||
return ItemUpdatedCall(this.agentID, itemID, data);
|
||||
}
|
||||
return LLUUID.Zero;
|
||||
}
|
||||
|
||||
public class AssetUploader
|
||||
{
|
||||
public event UpLoadedTexture OnUpLoad;
|
||||
public event UpLoadedAsset OnUpLoad;
|
||||
|
||||
private string uploaderPath = "";
|
||||
private LLUUID newAssetID;
|
||||
|
@ -392,6 +408,74 @@ namespace OpenSim.Region.Capabilities
|
|||
fs.Close();
|
||||
}
|
||||
}
|
||||
|
||||
public class ItemUpdater
|
||||
{
|
||||
public event UpdateItem OnUpLoad;
|
||||
|
||||
private string uploaderPath = "";
|
||||
private LLUUID inventoryItemID;
|
||||
private BaseHttpServer httpListener;
|
||||
private bool SaveAssets = false;
|
||||
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="assetID"></param>
|
||||
/// <param name="inventoryItem"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="httpServer"></param>
|
||||
public ItemUpdater( LLUUID inventoryItem, string path, BaseHttpServer httpServer)
|
||||
{
|
||||
|
||||
inventoryItemID = inventoryItem;
|
||||
uploaderPath = path;
|
||||
httpListener = httpServer;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="param"></param>
|
||||
/// <returns></returns>
|
||||
public string uploaderCaps(byte[] data, string path, string param)
|
||||
{
|
||||
LLUUID inv = this.inventoryItemID;
|
||||
string res = "";
|
||||
LLSDAssetUploadComplete uploadComplete = new LLSDAssetUploadComplete();
|
||||
LLUUID assetID = LLUUID.Zero;
|
||||
|
||||
if (OnUpLoad != null)
|
||||
{
|
||||
assetID = OnUpLoad(inv, data);
|
||||
}
|
||||
|
||||
uploadComplete.new_asset = assetID.ToStringHyphenated();
|
||||
uploadComplete.new_inventory_item = inv;
|
||||
uploadComplete.state = "complete";
|
||||
|
||||
res = LLSDHelpers.SerialiseLLSDReply(uploadComplete);
|
||||
|
||||
httpListener.RemoveStreamHandler("POST", uploaderPath);
|
||||
|
||||
if (this.SaveAssets)
|
||||
this.SaveAssetToFile("updateditem"+Util.RandomClass.Next(1,1000) + ".dat", data);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
private void SaveAssetToFile(string filename, byte[] data)
|
||||
{
|
||||
FileStream fs = File.Create(filename);
|
||||
BinaryWriter bw = new BinaryWriter(fs);
|
||||
bw.Write(data);
|
||||
bw.Close();
|
||||
fs.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ namespace OpenSim.Region.Capabilities
|
|||
// public string RequestTextureDownload = "";
|
||||
// public string ChatSessionRequest = "";
|
||||
public string UpdateNotecardAgentInventory = "";
|
||||
public string UpdateScriptAgentInventory = "";
|
||||
// public string ParcelVoiceInfoRequest = "";
|
||||
|
||||
public LLSDCapsDetails()
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using libsecondlife;
|
||||
|
||||
namespace OpenSim.Region.Capabilities
|
||||
{
|
||||
[LLSDMap]
|
||||
public class LLSDItemUpdate
|
||||
{
|
||||
public LLUUID item_id;
|
||||
|
||||
public LLSDItemUpdate()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -732,15 +732,6 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends prims to a client
|
||||
/// </summary>
|
||||
/// <param name="RemoteClient">Client to send to</param>
|
||||
public void GetInitialPrims(IClientAPI RemoteClient)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void ProcessObjectGrab(uint localID, LLVector3 offsetPos, IClientAPI remoteClient)
|
||||
{
|
||||
this.EventManager.TriggerObjectGrab(localID, offsetPos, remoteClient);
|
||||
|
|
|
@ -827,6 +827,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
agent.CapsPath, agent.AgentID);
|
||||
cap.RegisterHandlers();
|
||||
cap.AddNewInventoryItem = this.AddInventoryItem;
|
||||
cap.ItemUpdatedCall = this.UpdateInventoryItemAsset;
|
||||
if (capsHandlers.ContainsKey(agent.AgentID))
|
||||
{
|
||||
MainLog.Instance.Warn("client", "Adding duplicate CAPS entry for user " +
|
||||
|
@ -1023,7 +1024,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
{
|
||||
ScriptEngines.Add(ScriptEngine);
|
||||
|
||||
ScriptEngine.InitializeEngine(this, m_logger);
|
||||
ScriptEngine.InitializeEngine(this, m_logger);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -1046,7 +1047,7 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
|
||||
public void AddInventoryItem(LLUUID userID, InventoryItemBase item)
|
||||
{
|
||||
if(this.Avatars.ContainsKey(userID))
|
||||
if (this.Avatars.ContainsKey(userID))
|
||||
{
|
||||
this.AddInventoryItem(this.Avatars[userID].ControllingClient, item);
|
||||
}
|
||||
|
@ -1062,5 +1063,45 @@ namespace OpenSim.Region.Environment.Scenes
|
|||
}
|
||||
}
|
||||
|
||||
public LLUUID UpdateInventoryItemAsset(LLUUID userID, LLUUID itemID, byte[] data)
|
||||
{
|
||||
if (this.Avatars.ContainsKey(userID))
|
||||
{
|
||||
return this.UpdateInventoryItemAsset(this.Avatars[userID].ControllingClient, itemID, data);
|
||||
}
|
||||
return LLUUID.Zero;
|
||||
}
|
||||
|
||||
public LLUUID UpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID itemID, byte[] data)
|
||||
{
|
||||
CachedUserInfo userInfo = commsManager.UserProfiles.GetUserDetails(remoteClient.AgentId);
|
||||
if (userInfo != null)
|
||||
{
|
||||
if (userInfo.RootFolder != null)
|
||||
{
|
||||
InventoryItemBase item = userInfo.RootFolder.HasItem(itemID);
|
||||
if (item != null)
|
||||
{
|
||||
AssetBase asset;
|
||||
asset = new AssetBase();
|
||||
asset.FullID = LLUUID.Random();
|
||||
asset.Type = (sbyte)item.assetType;
|
||||
asset.InvType = (sbyte)item.invType;
|
||||
asset.Name = item.inventoryName;
|
||||
asset.Data = data;
|
||||
this.assetCache.AddAsset(asset);
|
||||
|
||||
item.assetID = asset.FullID;
|
||||
userInfo.updateItem(remoteClient.AgentId, item);
|
||||
|
||||
remoteClient.SendInventoryItemUpdate(item);
|
||||
|
||||
return (asset.FullID);
|
||||
}
|
||||
}
|
||||
}
|
||||
return LLUUID.Zero;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue