diff options
author | lbsa71 | 2009-04-08 19:59:37 +0000 |
---|---|---|
committer | lbsa71 | 2009-04-08 19:59:37 +0000 |
commit | e93b782f9d86e4049a28d7f90c691dc5d242f234 (patch) | |
tree | 892fcce074d5e5a817c0b14d2a5e4fefe1b692a9 /OpenSim | |
parent | * Make it possible to store creator strings in user inventory items as well a... (diff) | |
download | opensim-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 'OpenSim')
7 files changed, 98 insertions, 3 deletions
diff --git a/OpenSim/Framework/AssetBase.cs b/OpenSim/Framework/AssetBase.cs index 5c311c0..03b6ea8 100644 --- a/OpenSim/Framework/AssetBase.cs +++ b/OpenSim/Framework/AssetBase.cs | |||
@@ -49,6 +49,28 @@ namespace OpenSim.Framework | |||
49 | m_metadata.Name = name; | 49 | m_metadata.Name = name; |
50 | } | 50 | } |
51 | 51 | ||
52 | public bool IsTextualAsset | ||
53 | { | ||
54 | get | ||
55 | { | ||
56 | return !IsBinaryAsset; | ||
57 | } | ||
58 | |||
59 | } | ||
60 | |||
61 | public bool IsBinaryAsset | ||
62 | { | ||
63 | get | ||
64 | { | ||
65 | return | ||
66 | Type == (sbyte) AssetType.Animation || | ||
67 | Type == (sbyte) AssetType.Gesture || | ||
68 | Type == (sbyte) AssetType.ImageJPEG || | ||
69 | Type == (sbyte) AssetType.ImageTGA || | ||
70 | Type == (sbyte) AssetType.LSLBytecode ||; | ||
71 | } | ||
72 | } | ||
73 | |||
52 | public virtual byte[] Data | 74 | public virtual byte[] Data |
53 | { | 75 | { |
54 | get { return m_data; } | 76 | get { return m_data; } |
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 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using System.Text.RegularExpressions; | ||
31 | using System.Threading; | 32 | using System.Threading; |
32 | using GlynnTucker.Cache; | 33 | using GlynnTucker.Cache; |
33 | using log4net; | 34 | using 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 | ||
28 | using System; | ||
28 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
29 | using OpenMetaverse; | 30 | using 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) |
diff --git a/OpenSim/Region/Communications/Hypergrid/HGUserServices.cs b/OpenSim/Region/Communications/Hypergrid/HGUserServices.cs index e9eb18c..6a39876 100644 --- a/OpenSim/Region/Communications/Hypergrid/HGUserServices.cs +++ b/OpenSim/Region/Communications/Hypergrid/HGUserServices.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 | ||
28 | using System; | ||
28 | using System.Collections; | 29 | using System.Collections; |
29 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
30 | using OpenMetaverse; | 31 | using OpenMetaverse; |
@@ -57,6 +58,11 @@ namespace OpenSim.Region.Communications.Hypergrid | |||
57 | return m_remoteUserServices.ConvertXMLRPCDataToUserProfile(data); | 58 | return m_remoteUserServices.ConvertXMLRPCDataToUserProfile(data); |
58 | } | 59 | } |
59 | 60 | ||
61 | public UserProfileData GetUserProfile(Uri uri) | ||
62 | { | ||
63 | throw new System.NotImplementedException(); | ||
64 | } | ||
65 | |||
60 | /// <summary> | 66 | /// <summary> |
61 | /// Get a user agent from the user server | 67 | /// Get a user agent from the user server |
62 | /// </summary> | 68 | /// </summary> |
diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs index 6235565..09c1d6a 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs | |||
@@ -108,6 +108,11 @@ namespace OpenSim.Region.Communications.OGS1 | |||
108 | return userData; | 108 | return userData; |
109 | } | 109 | } |
110 | 110 | ||
111 | public UserProfileData GetUserProfile(Uri uri) | ||
112 | { | ||
113 | throw new System.NotImplementedException(); | ||
114 | } | ||
115 | |||
111 | /// <summary> | 116 | /// <summary> |
112 | /// Get a user agent from the user server | 117 | /// Get a user agent from the user server |
113 | /// </summary> | 118 | /// </summary> |