* Introduced some experimental code with regards to asset data substitution

0.6.5-rc1
lbsa71 2009-04-08 19:59:37 +00:00
parent f3c7298fc5
commit e93b782f9d
7 changed files with 99 additions and 4 deletions

View File

@ -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; }

View File

@ -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

View File

@ -25,6 +25,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using OpenMetaverse;
@ -46,6 +47,8 @@ namespace OpenSim.Framework.Communications
/// <param name="userId">The target UUID</param>
/// <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);

View File

@ -73,16 +73,27 @@ namespace OpenSim.Framework.Communications.Tests
Assert.That(
assetData, Is.EqualTo(m_assetReceived.Data), "Asset data stored differs from asset data received");
}
private void AssetRequestCallback(UUID assetId, AssetBase asset)
{
m_assetIdReceived = assetId;
m_assetReceived = asset;
lock (this)
{
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 ));
}
}
}

View File

@ -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)

View File

@ -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>

View File

@ -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>