diff options
author | lbsa71 | 2009-04-09 16:45:22 +0000 |
---|---|---|
committer | lbsa71 | 2009-04-09 16:45:22 +0000 |
commit | d2a412e94bf3ef1e332d44b7106c606f26b1636b (patch) | |
tree | ba7535b2a55edf538e067d7ac72a1ee55943215e /OpenSim/Framework/Communications | |
parent | * Moved the DatabaseTestAttribute to Test.Common, and thus included ref to th... (diff) | |
download | opensim-SC-d2a412e94bf3ef1e332d44b7106c606f26b1636b.zip opensim-SC-d2a412e94bf3ef1e332d44b7106c606f26b1636b.tar.gz opensim-SC-d2a412e94bf3ef1e332d44b7106c606f26b1636b.tar.bz2 opensim-SC-d2a412e94bf3ef1e332d44b7106c606f26b1636b.tar.xz |
* Added some more experimental code; nothing wired in so far.
Diffstat (limited to 'OpenSim/Framework/Communications')
-rw-r--r-- | OpenSim/Framework/Communications/Cache/AssetCache.cs | 43 | ||||
-rw-r--r-- | OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs | 98 |
2 files changed, 127 insertions, 14 deletions
diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index b571c0b..cbb2a5a 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs | |||
@@ -393,22 +393,26 @@ namespace OpenSim.Framework.Communications.Cache | |||
393 | 393 | ||
394 | protected void ProcessReceivedAsset(bool IsTexture, AssetInfo assetInf) | 394 | protected void ProcessReceivedAsset(bool IsTexture, AssetInfo assetInf) |
395 | { | 395 | { |
396 | if(!IsTexture && assetInf.ContainsReferences && false ) | ||
397 | { | ||
398 | assetInf.Data = ProcessAssetData(assetInf.Data); | ||
399 | } | ||
396 | } | 400 | } |
397 | 401 | ||
398 | // See IAssetReceiver | 402 | // See IAssetReceiver |
399 | public virtual void AssetNotFound(UUID assetID, bool IsTexture) | 403 | public virtual void AssetNotFound(UUID assetId, bool isTexture) |
400 | { | 404 | { |
401 | // m_log.WarnFormat("[ASSET CACHE]: AssetNotFound for {0}", assetID); | 405 | // m_log.WarnFormat("[ASSET CACHE]: AssetNotFound for {0}", assetId); |
402 | 406 | ||
403 | // Remember the fact that this asset could not be found to prevent delays from repeated requests | 407 | // Remember the fact that this asset could not be found to prevent delays from repeated requests |
404 | m_memcache.Add(assetID, null, TimeSpan.FromHours(24)); | 408 | m_memcache.Add(assetId, null, TimeSpan.FromHours(24)); |
405 | 409 | ||
406 | // Notify requesters for this asset | 410 | // Notify requesters for this asset |
407 | AssetRequestsList reqList; | 411 | AssetRequestsList reqList; |
408 | lock (RequestLists) | 412 | lock (RequestLists) |
409 | { | 413 | { |
410 | if (RequestLists.TryGetValue(assetID, out reqList)) | 414 | if (RequestLists.TryGetValue(assetId, out reqList)) |
411 | RequestLists.Remove(assetID); | 415 | RequestLists.Remove(assetId); |
412 | } | 416 | } |
413 | 417 | ||
414 | if (reqList != null) | 418 | if (reqList != null) |
@@ -418,7 +422,7 @@ namespace OpenSim.Framework.Communications.Cache | |||
418 | 422 | ||
419 | foreach (NewAssetRequest req in reqList.Requests) | 423 | foreach (NewAssetRequest req in reqList.Requests) |
420 | { | 424 | { |
421 | req.Callback(assetID, null); | 425 | req.Callback(assetId, null); |
422 | } | 426 | } |
423 | } | 427 | } |
424 | } | 428 | } |
@@ -554,12 +558,12 @@ namespace OpenSim.Framework.Communications.Cache | |||
554 | { | 558 | { |
555 | string data = Encoding.ASCII.GetString(assetData); | 559 | string data = Encoding.ASCII.GetString(assetData); |
556 | 560 | ||
557 | data = ProcessAssetDataString(data); | 561 | data = ProcessAssetDataString(data, null); |
558 | 562 | ||
559 | return Encoding.ASCII.GetBytes( data ); | 563 | return Encoding.ASCII.GetBytes( data ); |
560 | } | 564 | } |
561 | 565 | ||
562 | public string ProcessAssetDataString(string data) | 566 | public string ProcessAssetDataString(string data, IUserService userService) |
563 | { | 567 | { |
564 | Regex regex = new Regex("(creator_url|owner_url)\\s+(\\S+)"); | 568 | Regex regex = new Regex("(creator_url|owner_url)\\s+(\\S+)"); |
565 | 569 | ||
@@ -571,16 +575,18 @@ namespace OpenSim.Framework.Communications.Cache | |||
571 | 575 | ||
572 | string value = m.Groups[2].Captures[0].Value; | 576 | string value = m.Groups[2].Captures[0].Value; |
573 | 577 | ||
574 | Guid id = Util.GetHashGuid(value, AssetInfo.Secret); | 578 | Uri userUri; |
575 | 579 | ||
576 | switch (key) | 580 | switch (key) |
577 | { | 581 | { |
578 | case "creator_url": | 582 | case "creator_url": |
579 | result = "creator_id " + id; | 583 | userUri = new Uri(value); |
584 | result = "creator_id " + ResolveUserUri(userService, userUri); | ||
580 | break; | 585 | break; |
581 | 586 | ||
582 | case "owner_url": | 587 | case "owner_url": |
583 | result = "owner_id " + id; | 588 | userUri = new Uri(value); |
589 | result = "owner_id " + ResolveUserUri(userService, userUri); | ||
584 | break; | 590 | break; |
585 | } | 591 | } |
586 | 592 | ||
@@ -590,6 +596,21 @@ namespace OpenSim.Framework.Communications.Cache | |||
590 | return data; | 596 | return data; |
591 | } | 597 | } |
592 | 598 | ||
599 | private Guid ResolveUserUri(IUserService userService, Uri userUri) | ||
600 | { | ||
601 | Guid id; | ||
602 | UserProfileData userProfile = userService.GetUserProfile(userUri); | ||
603 | if( userProfile == null ) | ||
604 | { | ||
605 | id = Guid.Empty; | ||
606 | } | ||
607 | else | ||
608 | { | ||
609 | id = userProfile.ID.Guid; | ||
610 | } | ||
611 | return id; | ||
612 | } | ||
613 | |||
593 | 614 | ||
594 | public class AssetRequest | 615 | public class AssetRequest |
595 | { | 616 | { |
diff --git a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs index 70a398e..3779f55 100644 --- a/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs +++ b/OpenSim/Framework/Communications/Tests/Cache/AssetCacheTests.cs | |||
@@ -25,6 +25,8 @@ | |||
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; | ||
29 | using System.Collections.Generic; | ||
28 | using System.Threading; | 30 | using System.Threading; |
29 | using NUnit.Framework; | 31 | using NUnit.Framework; |
30 | using NUnit.Framework.SyntaxHelpers; | 32 | using NUnit.Framework.SyntaxHelpers; |
@@ -85,15 +87,105 @@ namespace OpenSim.Framework.Communications.Tests | |||
85 | } | 87 | } |
86 | } | 88 | } |
87 | 89 | ||
90 | private class FakeUserService : IUserService | ||
91 | { | ||
92 | public UserProfileData GetUserProfile(string firstName, string lastName) | ||
93 | { | ||
94 | throw new NotImplementedException(); | ||
95 | } | ||
96 | |||
97 | public UserProfileData GetUserProfile(UUID userId) | ||
98 | { | ||
99 | throw new NotImplementedException(); | ||
100 | } | ||
101 | |||
102 | public UserProfileData GetUserProfile(Uri uri) | ||
103 | { | ||
104 | UserProfileData userProfile = new UserProfileData(); | ||
105 | |||
106 | userProfile.ID = new UUID( Util.GetHashGuid( uri.ToString(), AssetCache.AssetInfo.Secret )); | ||
107 | |||
108 | return userProfile; | ||
109 | } | ||
110 | |||
111 | public UserAgentData GetAgentByUUID(UUID userId) | ||
112 | { | ||
113 | throw new NotImplementedException(); | ||
114 | } | ||
115 | |||
116 | public void ClearUserAgent(UUID avatarID) | ||
117 | { | ||
118 | throw new NotImplementedException(); | ||
119 | } | ||
120 | |||
121 | public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID QueryID, string Query) | ||
122 | { | ||
123 | throw new NotImplementedException(); | ||
124 | } | ||
125 | |||
126 | public UserProfileData SetupMasterUser(string firstName, string lastName) | ||
127 | { | ||
128 | throw new NotImplementedException(); | ||
129 | } | ||
130 | |||
131 | public UserProfileData SetupMasterUser(string firstName, string lastName, string password) | ||
132 | { | ||
133 | throw new NotImplementedException(); | ||
134 | } | ||
135 | |||
136 | public UserProfileData SetupMasterUser(UUID userId) | ||
137 | { | ||
138 | throw new NotImplementedException(); | ||
139 | } | ||
140 | |||
141 | public bool UpdateUserProfile(UserProfileData data) | ||
142 | { | ||
143 | throw new NotImplementedException(); | ||
144 | } | ||
145 | |||
146 | public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) | ||
147 | { | ||
148 | throw new NotImplementedException(); | ||
149 | } | ||
150 | |||
151 | public void RemoveUserFriend(UUID friendlistowner, UUID friend) | ||
152 | { | ||
153 | throw new NotImplementedException(); | ||
154 | } | ||
155 | |||
156 | public void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) | ||
157 | { | ||
158 | throw new NotImplementedException(); | ||
159 | } | ||
160 | |||
161 | public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat) | ||
162 | { | ||
163 | throw new NotImplementedException(); | ||
164 | } | ||
165 | |||
166 | public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz) | ||
167 | { | ||
168 | throw new NotImplementedException(); | ||
169 | } | ||
170 | |||
171 | public List<FriendListItem> GetUserFriendList(UUID friendlistowner) | ||
172 | { | ||
173 | throw new NotImplementedException(); | ||
174 | } | ||
175 | } | ||
176 | |||
88 | [Test] | 177 | [Test] |
89 | public void ProcessAssetDataTest() | 178 | public void TestProcessAssetData() |
90 | { | 179 | { |
91 | string url = "http://host/dir/"; | 180 | string url = "http://host/dir/"; |
92 | string data = " creator_url " + url + " "; | 181 | string creatorData = " creator_url " + url + " "; |
182 | string ownerData = " owner_url " + url + " "; | ||
93 | 183 | ||
94 | AssetCache assetCache = new AssetCache(); | 184 | AssetCache assetCache = new AssetCache(); |
185 | FakeUserService fakeUserService = new FakeUserService(); | ||
95 | 186 | ||
96 | Assert.AreEqual(" creator_id "+Util.GetHashGuid( url, AssetCache.AssetInfo.Secret )+" ", assetCache.ProcessAssetDataString( data )); | 187 | Assert.AreEqual(" creator_id " + Util.GetHashGuid(url, AssetCache.AssetInfo.Secret) + " ", assetCache.ProcessAssetDataString(creatorData, fakeUserService)); |
188 | Assert.AreEqual(" owner_id " + Util.GetHashGuid(url, AssetCache.AssetInfo.Secret) + " ", assetCache.ProcessAssetDataString(ownerData, fakeUserService)); | ||
97 | } | 189 | } |
98 | } | 190 | } |
99 | } | 191 | } |