aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/Communications
diff options
context:
space:
mode:
authorlbsa712009-04-08 19:59:37 +0000
committerlbsa712009-04-08 19:59:37 +0000
commite93b782f9d86e4049a28d7f90c691dc5d242f234 (patch)
tree892fcce074d5e5a817c0b14d2a5e4fefe1b692a9 /OpenSim/Framework/Communications
parent* Make it possible to store creator strings in user inventory items as well a... (diff)
downloadopensim-SC-e93b782f9d86e4049a28d7f90c691dc5d242f234.zip
opensim-SC-e93b782f9d86e4049a28d7f90c691dc5d242f234.tar.gz
opensim-SC-e93b782f9d86e4049a28d7f90c691dc5d242f234.tar.bz2
opensim-SC-e93b782f9d86e4049a28d7f90c691dc5d242f234.tar.xz
* Introduced some experimental code with regards to asset data substitution
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetCache.cs43
-rw-r--r--OpenSim/Framework/Communications/IUserService.cs3
-rw-r--r--OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs17
-rw-r--r--OpenSim/Framework/Communications/UserManagerBase.cs5
4 files changed, 65 insertions, 3 deletions
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 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31using System.Text.RegularExpressions;
31using System.Threading; 32using System.Threading;
32using GlynnTucker.Cache; 33using GlynnTucker.Cache;
33using log4net; 34using log4net;
@@ -547,9 +548,49 @@ namespace OpenSim.Framework.Communications.Cache
547 req.RequestUser.SendAsset(req2); 548 req.RequestUser.SendAsset(req2);
548 549
549 } 550 }
551 }
552
553 public byte[] ProcessAssetData(byte[] assetData)
554 {
555 string data = Encoding.ASCII.GetString(assetData);
556
557 data = ProcessAssetDataString(data);
558
559 return Encoding.ASCII.GetBytes( data );
560 }
561
562 public string ProcessAssetDataString(string data)
563 {
564 Regex regex = new Regex("(creator_url|owner_url)\\s+(\\S+)");
565
566 data = regex.Replace(data, delegate(Match m)
567 {
568 string result = String.Empty;
550 569
570 string key = m.Groups[1].Captures[0].Value;
571
572 string value = m.Groups[2].Captures[0].Value;
573
574 Guid id = Util.GetHashGuid(value, AssetInfo.Secret);
575
576 switch (key)
577 {
578 case "creator_url":
579 result = "creator_id " + id;
580 break;
581
582 case "owner_url":
583 result = "owner_id " + id;
584 break;
585 }
586
587 return result;
588 });
589
590 return data;
551 } 591 }
552 592
593
553 public class AssetRequest 594 public class AssetRequest
554 { 595 {
555 public IClientAPI RequestUser; 596 public IClientAPI RequestUser;
@@ -578,6 +619,8 @@ namespace OpenSim.Framework.Communications.Cache
578 Name = aBase.Name; 619 Name = aBase.Name;
579 Description = aBase.Description; 620 Description = aBase.Description;
580 } 621 }
622
623 public const string Secret = "secret";
581 } 624 }
582 625
583 public class TextureImage : AssetBase 626 public class TextureImage : AssetBase
diff --git a/OpenSim/Framework/Communications/IUserService.cs b/OpenSim/Framework/Communications/IUserService.cs
index 0846024..38c360a 100644
--- a/OpenSim/Framework/Communications/IUserService.cs
+++ b/OpenSim/Framework/Communications/IUserService.cs
@@ -25,6 +25,7 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System;
28using System.Collections.Generic; 29using System.Collections.Generic;
29using OpenMetaverse; 30using OpenMetaverse;
30 31
@@ -46,6 +47,8 @@ namespace OpenSim.Framework.Communications
46 /// <param name="userId">The target UUID</param> 47 /// <param name="userId">The target UUID</param>
47 /// <returns>A user profile. Returns null if no user profile is found.</returns> 48 /// <returns>A user profile. Returns null if no user profile is found.</returns>
48 UserProfileData GetUserProfile(UUID userId); 49 UserProfileData GetUserProfile(UUID userId);
50
51 UserProfileData GetUserProfile(Uri uri);
49 52
50 UserAgentData GetAgentByUUID(UUID userId); 53 UserAgentData GetAgentByUUID(UUID userId);
51 54
diff --git a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs
index 18ae9a7..70a398e 100644
--- a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs
+++ b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs
@@ -73,16 +73,27 @@ namespace OpenSim.Framework.Communications.Tests
73 Assert.That( 73 Assert.That(
74 assetData, Is.EqualTo(m_assetReceived.Data), "Asset data stored differs from asset data received"); 74 assetData, Is.EqualTo(m_assetReceived.Data), "Asset data stored differs from asset data received");
75 } 75 }
76 76
77 private void AssetRequestCallback(UUID assetId, AssetBase asset) 77 private void AssetRequestCallback(UUID assetId, AssetBase asset)
78 { 78 {
79 m_assetIdReceived = assetId; 79 m_assetIdReceived = assetId;
80 m_assetReceived = asset; 80 m_assetReceived = asset;
81 81
82 lock (this) 82 lock (this)
83 { 83 {
84 Monitor.PulseAll(this); 84 Monitor.PulseAll(this);
85 } 85 }
86 }
87
88 [Test]
89 public void ProcessAssetDataTest()
90 {
91 string url = "http://host/dir/";
92 string data = " creator_url " + url + " ";
93
94 AssetCache assetCache = new AssetCache();
95
96 Assert.AreEqual(" creator_id "+Util.GetHashGuid( url, AssetCache.AssetInfo.Secret )+" ", assetCache.ProcessAssetDataString( data ));
86 } 97 }
87 } 98 }
88} 99}
diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs
index c177d4f..b7280d3 100644
--- a/OpenSim/Framework/Communications/UserManagerBase.cs
+++ b/OpenSim/Framework/Communications/UserManagerBase.cs
@@ -122,6 +122,11 @@ namespace OpenSim.Framework.Communications
122 } 122 }
123 } 123 }
124 124
125 public UserProfileData GetUserProfile(Uri uri)
126 {
127 throw new System.NotImplementedException();
128 }
129
125 public UserAgentData GetAgentByUUID(UUID userId) 130 public UserAgentData GetAgentByUUID(UUID userId)
126 { 131 {
127 foreach (IUserDataPlugin plugin in _plugins) 132 foreach (IUserDataPlugin plugin in _plugins)