From e93b782f9d86e4049a28d7f90c691dc5d242f234 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Wed, 8 Apr 2009 19:59:37 +0000 Subject: * Introduced some experimental code with regards to asset data substitution --- .../Framework/Communications/Cache/AssetCache.cs | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'OpenSim/Framework/Communications/Cache/AssetCache.cs') diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index e0d0bd7..b571c0b 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs @@ -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 -- cgit v1.1