* Introduced some experimental code with regards to asset data substitution
parent
f3c7298fc5
commit
e93b782f9d
|
@ -49,6 +49,28 @@ namespace OpenSim.Framework
|
|||
m_metadata.Name = name;
|
||||
}
|
||||
|
||||
public bool IsTextualAsset
|
||||
{
|
||||
get
|
||||
{
|
||||
return !IsBinaryAsset;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public bool IsBinaryAsset
|
||||
{
|
||||
get
|
||||
{
|
||||
return
|
||||
Type == (sbyte) AssetType.Animation ||
|
||||
Type == (sbyte) AssetType.Gesture ||
|
||||
Type == (sbyte) AssetType.ImageJPEG ||
|
||||
Type == (sbyte) AssetType.ImageTGA ||
|
||||
Type == (sbyte) AssetType.LSLBytecode ||;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual byte[] Data
|
||||
{
|
||||
get { return m_data; }
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using GlynnTucker.Cache;
|
||||
using log4net;
|
||||
|
@ -547,9 +548,49 @@ namespace OpenSim.Framework.Communications.Cache
|
|||
req.RequestUser.SendAsset(req2);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public byte[] ProcessAssetData(byte[] assetData)
|
||||
{
|
||||
string data = Encoding.ASCII.GetString(assetData);
|
||||
|
||||
data = ProcessAssetDataString(data);
|
||||
|
||||
return Encoding.ASCII.GetBytes( data );
|
||||
}
|
||||
|
||||
public string ProcessAssetDataString(string data)
|
||||
{
|
||||
Regex regex = new Regex("(creator_url|owner_url)\\s+(\\S+)");
|
||||
|
||||
data = regex.Replace(data, delegate(Match m)
|
||||
{
|
||||
string result = String.Empty;
|
||||
|
||||
string key = m.Groups[1].Captures[0].Value;
|
||||
|
||||
string value = m.Groups[2].Captures[0].Value;
|
||||
|
||||
Guid id = Util.GetHashGuid(value, AssetInfo.Secret);
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case "creator_url":
|
||||
result = "creator_id " + id;
|
||||
break;
|
||||
|
||||
case "owner_url":
|
||||
result = "owner_id " + id;
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
});
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
public class AssetRequest
|
||||
{
|
||||
public IClientAPI RequestUser;
|
||||
|
@ -578,6 +619,8 @@ namespace OpenSim.Framework.Communications.Cache
|
|||
Name = aBase.Name;
|
||||
Description = aBase.Description;
|
||||
}
|
||||
|
||||
public const string Secret = "secret";
|
||||
}
|
||||
|
||||
public class TextureImage : AssetBase
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using OpenMetaverse;
|
||||
|
||||
|
@ -47,6 +48,8 @@ namespace OpenSim.Framework.Communications
|
|||
/// <returns>A user profile. Returns null if no user profile is found.</returns>
|
||||
UserProfileData GetUserProfile(UUID userId);
|
||||
|
||||
UserProfileData GetUserProfile(Uri uri);
|
||||
|
||||
UserAgentData GetAgentByUUID(UUID userId);
|
||||
|
||||
void ClearUserAgent(UUID avatarID);
|
||||
|
|
|
@ -84,5 +84,16 @@ namespace OpenSim.Framework.Communications.Tests
|
|||
Monitor.PulseAll(this);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ProcessAssetDataTest()
|
||||
{
|
||||
string url = "http://host/dir/";
|
||||
string data = " creator_url " + url + " ";
|
||||
|
||||
AssetCache assetCache = new AssetCache();
|
||||
|
||||
Assert.AreEqual(" creator_id "+Util.GetHashGuid( url, AssetCache.AssetInfo.Secret )+" ", assetCache.ProcessAssetDataString( data ));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,6 +122,11 @@ namespace OpenSim.Framework.Communications
|
|||
}
|
||||
}
|
||||
|
||||
public UserProfileData GetUserProfile(Uri uri)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public UserAgentData GetAgentByUUID(UUID userId)
|
||||
{
|
||||
foreach (IUserDataPlugin plugin in _plugins)
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using OpenMetaverse;
|
||||
|
@ -57,6 +58,11 @@ namespace OpenSim.Region.Communications.Hypergrid
|
|||
return m_remoteUserServices.ConvertXMLRPCDataToUserProfile(data);
|
||||
}
|
||||
|
||||
public UserProfileData GetUserProfile(Uri uri)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a user agent from the user server
|
||||
/// </summary>
|
||||
|
|
|
@ -108,6 +108,11 @@ namespace OpenSim.Region.Communications.OGS1
|
|||
return userData;
|
||||
}
|
||||
|
||||
public UserProfileData GetUserProfile(Uri uri)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a user agent from the user server
|
||||
/// </summary>
|
||||
|
|
Loading…
Reference in New Issue