diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/UserProfiles.cs | 14 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs | 387 |
2 files changed, 310 insertions, 91 deletions
diff --git a/OpenSim/Framework/UserProfiles.cs b/OpenSim/Framework/UserProfiles.cs index 98ab651..6d46fe9 100644 --- a/OpenSim/Framework/UserProfiles.cs +++ b/OpenSim/Framework/UserProfiles.cs | |||
@@ -27,6 +27,8 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using OpenMetaverse; | 29 | using OpenMetaverse; |
30 | using System.Collections.Generic; | ||
31 | |||
30 | 32 | ||
31 | namespace OpenSim.Framework | 33 | namespace OpenSim.Framework |
32 | { | 34 | { |
@@ -122,5 +124,17 @@ namespace OpenSim.Framework | |||
122 | public string UserId = UUID.Zero.ToString(); | 124 | public string UserId = UUID.Zero.ToString(); |
123 | public string DataVal = string.Empty; | 125 | public string DataVal = string.Empty; |
124 | } | 126 | } |
127 | |||
128 | public class UserProfileCacheEntry | ||
129 | { | ||
130 | public Dictionary<UUID, string> picksList; | ||
131 | public Dictionary<UUID, UserProfilePick> picks; | ||
132 | public Dictionary<UUID, string> classifiedsLists; | ||
133 | public Dictionary<UUID, UserClassifiedAdd> classifieds; | ||
134 | public UserProfileProperties props; | ||
135 | public string born; | ||
136 | public byte[] membershipType; | ||
137 | public uint flags; | ||
138 | } | ||
125 | } | 139 | } |
126 | 140 | ||
diff --git a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs index 57025bf..3890bb2 100644 --- a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs | |||
@@ -57,6 +57,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
57 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "UserProfilesModule")] | 57 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "UserProfilesModule")] |
58 | public class UserProfileModule : IProfileModule, INonSharedRegionModule | 58 | public class UserProfileModule : IProfileModule, INonSharedRegionModule |
59 | { | 59 | { |
60 | const double PROFILECACHEEXPIRE = 300; | ||
60 | /// <summary> | 61 | /// <summary> |
61 | /// Logging | 62 | /// Logging |
62 | /// </summary> | 63 | /// </summary> |
@@ -67,6 +68,8 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
67 | // count. The entries are removed when the interest count reaches 0. | 68 | // count. The entries are removed when the interest count reaches 0. |
68 | Dictionary<UUID, UUID> m_classifiedCache = new Dictionary<UUID, UUID>(); | 69 | Dictionary<UUID, UUID> m_classifiedCache = new Dictionary<UUID, UUID>(); |
69 | Dictionary<UUID, int> m_classifiedInterest = new Dictionary<UUID, int>(); | 70 | Dictionary<UUID, int> m_classifiedInterest = new Dictionary<UUID, int>(); |
71 | ExpiringCache<UUID, UserProfileCacheEntry> m_profilesCache = new ExpiringCache<UUID, UserProfileCacheEntry>(); | ||
72 | IImprovedAssetCache m_assetCache; | ||
70 | 73 | ||
71 | private JsonRpcRequestManager rpc = new JsonRpcRequestManager(); | 74 | private JsonRpcRequestManager rpc = new JsonRpcRequestManager(); |
72 | private bool m_allowUserProfileWebURLs = true; | 75 | private bool m_allowUserProfileWebURLs = true; |
@@ -128,7 +131,6 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
128 | get; private set; | 131 | get; private set; |
129 | } | 132 | } |
130 | 133 | ||
131 | |||
132 | #region IRegionModuleBase implementation | 134 | #region IRegionModuleBase implementation |
133 | /// <summary> | 135 | /// <summary> |
134 | /// This is called to initialize the region module. For shared modules, this is called exactly once, after | 136 | /// This is called to initialize the region module. For shared modules, this is called exactly once, after |
@@ -185,22 +187,11 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
185 | Scene = scene; | 187 | Scene = scene; |
186 | Scene.RegisterModuleInterface<IProfileModule>(this); | 188 | Scene.RegisterModuleInterface<IProfileModule>(this); |
187 | Scene.EventManager.OnNewClient += OnNewClient; | 189 | Scene.EventManager.OnNewClient += OnNewClient; |
188 | Scene.EventManager.OnMakeRootAgent += HandleOnMakeRootAgent; | 190 | Scene.EventManager.OnClientClosed += OnClientClosed; |
189 | 191 | ||
190 | UserManagementModule = Scene.RequestModuleInterface<IUserManagement>(); | 192 | UserManagementModule = Scene.RequestModuleInterface<IUserManagement>(); |
191 | } | 193 | } |
192 | 194 | ||
193 | void HandleOnMakeRootAgent (ScenePresence obj) | ||
194 | { | ||
195 | if(obj.PresenceType == PresenceType.Npc) | ||
196 | return; | ||
197 | |||
198 | Util.FireAndForget(delegate | ||
199 | { | ||
200 | GetImageAssets(((IScenePresence)obj).UUID); | ||
201 | }, null, "UserProfileModule.GetImageAssets"); | ||
202 | } | ||
203 | |||
204 | /// <summary> | 195 | /// <summary> |
205 | /// Removes the region. | 196 | /// Removes the region. |
206 | /// </summary> | 197 | /// </summary> |
@@ -211,6 +202,10 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
211 | { | 202 | { |
212 | if(!Enabled) | 203 | if(!Enabled) |
213 | return; | 204 | return; |
205 | |||
206 | m_profilesCache.Clear(); | ||
207 | m_classifiedCache.Clear(); | ||
208 | m_classifiedInterest.Clear(); | ||
214 | } | 209 | } |
215 | 210 | ||
216 | /// <summary> | 211 | /// <summary> |
@@ -226,6 +221,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
226 | { | 221 | { |
227 | if(!Enabled) | 222 | if(!Enabled) |
228 | return; | 223 | return; |
224 | m_assetCache = Scene.RequestModuleInterface<IImprovedAssetCache>(); | ||
229 | } | 225 | } |
230 | 226 | ||
231 | /// <summary> | 227 | /// <summary> |
@@ -297,6 +293,40 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
297 | client.OnUserInfoRequest += UserPreferencesRequest; | 293 | client.OnUserInfoRequest += UserPreferencesRequest; |
298 | client.OnUpdateUserInfo += UpdateUserPreferences; | 294 | client.OnUpdateUserInfo += UpdateUserPreferences; |
299 | } | 295 | } |
296 | |||
297 | void OnClientClosed(UUID AgentId, Scene scene) | ||
298 | { | ||
299 | ScenePresence sp = scene.GetScenePresence(AgentId); | ||
300 | IClientAPI client = sp.ControllingClient; | ||
301 | if (client == null) | ||
302 | return; | ||
303 | |||
304 | //Profile | ||
305 | client.OnRequestAvatarProperties -= RequestAvatarProperties; | ||
306 | client.OnUpdateAvatarProperties -= AvatarPropertiesUpdate; | ||
307 | client.OnAvatarInterestUpdate -= AvatarInterestsUpdate; | ||
308 | |||
309 | // Classifieds | ||
310 | // client.r GenericPacketHandler("avatarclassifiedsrequest", ClassifiedsRequest); | ||
311 | client.OnClassifiedInfoUpdate -= ClassifiedInfoUpdate; | ||
312 | client.OnClassifiedInfoRequest -= ClassifiedInfoRequest; | ||
313 | client.OnClassifiedDelete -= ClassifiedDelete; | ||
314 | |||
315 | // Picks | ||
316 | // client.AddGenericPacketHandler("avatarpicksrequest", PicksRequest); | ||
317 | // client.AddGenericPacketHandler("pickinforequest", PickInfoRequest); | ||
318 | client.OnPickInfoUpdate -= PickInfoUpdate; | ||
319 | client.OnPickDelete -= PickDelete; | ||
320 | |||
321 | // Notes | ||
322 | // client.AddGenericPacketHandler("avatarnotesrequest", NotesRequest); | ||
323 | client.OnAvatarNotesUpdate -= NotesUpdate; | ||
324 | |||
325 | // Preferences | ||
326 | client.OnUserInfoRequest -= UserPreferencesRequest; | ||
327 | client.OnUpdateUserInfo -= UpdateUserPreferences; | ||
328 | } | ||
329 | |||
300 | #endregion Region Event Handlers | 330 | #endregion Region Event Handlers |
301 | 331 | ||
302 | #region Classified | 332 | #region Classified |
@@ -332,6 +362,34 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
332 | return; | 362 | return; |
333 | } | 363 | } |
334 | 364 | ||
365 | UserProfileCacheEntry uce = null; | ||
366 | lock(m_profilesCache) | ||
367 | { | ||
368 | if(m_profilesCache.TryGetValue(targetID, out uce) && uce != null) | ||
369 | { | ||
370 | if(uce.classifiedsLists != null) | ||
371 | { | ||
372 | foreach(KeyValuePair<UUID,string> kvp in uce.classifiedsLists) | ||
373 | { | ||
374 | UUID kvpkey = kvp.Key; | ||
375 | classifieds[kvpkey] = kvp.Value; | ||
376 | lock (m_classifiedCache) | ||
377 | { | ||
378 | if (!m_classifiedCache.ContainsKey(kvpkey)) | ||
379 | { | ||
380 | m_classifiedCache.Add(kvpkey,targetID); | ||
381 | m_classifiedInterest.Add(kvpkey, 0); | ||
382 | } | ||
383 | |||
384 | m_classifiedInterest[kvpkey]++; | ||
385 | } | ||
386 | } | ||
387 | remoteClient.SendAvatarClassifiedReply(targetID, uce.classifiedsLists); | ||
388 | return; | ||
389 | } | ||
390 | } | ||
391 | } | ||
392 | |||
335 | string serverURI = string.Empty; | 393 | string serverURI = string.Empty; |
336 | GetUserProfileServerURI(targetID, out serverURI); | 394 | GetUserProfileServerURI(targetID, out serverURI); |
337 | if(string.IsNullOrWhiteSpace(serverURI)) | 395 | if(string.IsNullOrWhiteSpace(serverURI)) |
@@ -380,6 +438,13 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
380 | } | 438 | } |
381 | } | 439 | } |
382 | 440 | ||
441 | if(uce == null) | ||
442 | uce = new UserProfileCacheEntry(); | ||
443 | uce.classifiedsLists = classifieds; | ||
444 | |||
445 | lock(m_profilesCache) | ||
446 | m_profilesCache.AddOrUpdate(targetID, uce, PROFILECACHEEXPIRE); | ||
447 | |||
383 | remoteClient.SendAvatarClassifiedReply(targetID, classifieds); | 448 | remoteClient.SendAvatarClassifiedReply(targetID, classifieds); |
384 | } | 449 | } |
385 | 450 | ||
@@ -404,9 +469,29 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
404 | } | 469 | } |
405 | } | 470 | } |
406 | } | 471 | } |
407 | 472 | ||
473 | UserProfileCacheEntry uce = null; | ||
474 | lock(m_profilesCache) | ||
475 | { | ||
476 | if(m_profilesCache.TryGetValue(target, out uce) && uce != null) | ||
477 | { | ||
478 | if(uce.classifieds != null && uce.classifieds.ContainsKey(queryClassifiedID)) | ||
479 | { | ||
480 | ad = uce.classifieds[queryClassifiedID]; | ||
481 | Vector3 gPos = new Vector3(); | ||
482 | Vector3.TryParse(ad.GlobalPos, out gPos); | ||
483 | |||
484 | remoteClient.SendClassifiedInfoReply(ad.ClassifiedId, ad.CreatorId, (uint)ad.CreationDate, | ||
485 | (uint)ad.ExpirationDate, (uint)ad.Category, ad.Name, ad.Description, | ||
486 | ad.ParcelId, (uint)ad.ParentEstate, ad.SnapshotId, ad.SimName, | ||
487 | gPos, ad.ParcelName, ad.Flags, ad.Price); | ||
488 | return; | ||
489 | } | ||
490 | } | ||
491 | } | ||
492 | |||
408 | string serverURI = string.Empty; | 493 | string serverURI = string.Empty; |
409 | GetUserProfileServerURI(target, out serverURI); | 494 | bool foreign = GetUserProfileServerURI(target, out serverURI); |
410 | if(string.IsNullOrWhiteSpace(serverURI)) | 495 | if(string.IsNullOrWhiteSpace(serverURI)) |
411 | { | 496 | { |
412 | return; | 497 | return; |
@@ -424,6 +509,18 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
424 | if(ad.CreatorId == UUID.Zero) | 509 | if(ad.CreatorId == UUID.Zero) |
425 | return; | 510 | return; |
426 | 511 | ||
512 | if(foreign) | ||
513 | cacheForeignImage(target, ad.SnapshotId); | ||
514 | |||
515 | if(uce == null) | ||
516 | uce = new UserProfileCacheEntry(); | ||
517 | if(uce.classifieds == null) | ||
518 | uce.classifieds = new Dictionary<UUID, UserClassifiedAdd>(); | ||
519 | uce.classifieds[ad.ClassifiedId] = ad; | ||
520 | |||
521 | lock(m_profilesCache) | ||
522 | m_profilesCache.AddOrUpdate(ad.ClassifiedId, uce, PROFILECACHEEXPIRE); | ||
523 | |||
427 | Vector3 globalPos = new Vector3(); | 524 | Vector3 globalPos = new Vector3(); |
428 | Vector3.TryParse(ad.GlobalPos, out globalPos); | 525 | Vector3.TryParse(ad.GlobalPos, out globalPos); |
429 | 526 | ||
@@ -473,6 +570,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
473 | uint queryParentEstate, UUID querySnapshotID, Vector3 queryGlobalPos, byte queryclassifiedFlags, | 570 | uint queryParentEstate, UUID querySnapshotID, Vector3 queryGlobalPos, byte queryclassifiedFlags, |
474 | int queryclassifiedPrice, IClientAPI remoteClient) | 571 | int queryclassifiedPrice, IClientAPI remoteClient) |
475 | { | 572 | { |
573 | |||
476 | Scene s = (Scene)remoteClient.Scene; | 574 | Scene s = (Scene)remoteClient.Scene; |
477 | Vector3 pos = remoteClient.SceneAgent.AbsolutePosition; | 575 | Vector3 pos = remoteClient.SceneAgent.AbsolutePosition; |
478 | ILandObject land = s.LandChannel.GetLandObject(pos.X, pos.Y); | 576 | ILandObject land = s.LandChannel.GetLandObject(pos.X, pos.Y); |
@@ -486,6 +584,17 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
486 | return; | 584 | return; |
487 | } | 585 | } |
488 | 586 | ||
587 | // just flush cache for now | ||
588 | UserProfileCacheEntry uce = null; | ||
589 | lock(m_profilesCache) | ||
590 | { | ||
591 | if(m_profilesCache.TryGetValue(remoteClient.AgentId, out uce) && uce != null) | ||
592 | { | ||
593 | uce.classifieds = null; | ||
594 | uce.classifiedsLists = null; | ||
595 | } | ||
596 | } | ||
597 | |||
489 | OSDMap parameters = new OSDMap {{"creatorId", OSD.FromUUID(creatorId)}}; | 598 | OSDMap parameters = new OSDMap {{"creatorId", OSD.FromUUID(creatorId)}}; |
490 | OSD Params = (OSD)parameters; | 599 | OSD Params = (OSD)parameters; |
491 | if (!rpc.JsonRpcRequest(ref Params, "avatarclassifiedsrequest", serverURI, UUID.Random().ToString())) | 600 | if (!rpc.JsonRpcRequest(ref Params, "avatarclassifiedsrequest", serverURI, UUID.Random().ToString())) |
@@ -549,6 +658,17 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
549 | /// </param> | 658 | /// </param> |
550 | public void ClassifiedDelete(UUID queryClassifiedID, IClientAPI remoteClient) | 659 | public void ClassifiedDelete(UUID queryClassifiedID, IClientAPI remoteClient) |
551 | { | 660 | { |
661 | // just flush cache for now | ||
662 | UserProfileCacheEntry uce = null; | ||
663 | lock(m_profilesCache) | ||
664 | { | ||
665 | if(m_profilesCache.TryGetValue(remoteClient.AgentId, out uce) && uce != null) | ||
666 | { | ||
667 | uce.classifieds = null; | ||
668 | uce.classifiedsLists = null; | ||
669 | } | ||
670 | } | ||
671 | |||
552 | string serverURI = string.Empty; | 672 | string serverURI = string.Empty; |
553 | GetUserProfileServerURI(remoteClient.AgentId, out serverURI); | 673 | GetUserProfileServerURI(remoteClient.AgentId, out serverURI); |
554 | if(string.IsNullOrWhiteSpace(serverURI)) | 674 | if(string.IsNullOrWhiteSpace(serverURI)) |
@@ -605,6 +725,19 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
605 | return; | 725 | return; |
606 | } | 726 | } |
607 | 727 | ||
728 | UserProfileCacheEntry uce = null; | ||
729 | lock(m_profilesCache) | ||
730 | { | ||
731 | if(m_profilesCache.TryGetValue(targetId, out uce) && uce != null) | ||
732 | { | ||
733 | if(uce != null && uce.picksList != null) | ||
734 | { | ||
735 | remoteClient.SendAvatarPicksReply(targetId, uce.picksList); | ||
736 | return; | ||
737 | } | ||
738 | } | ||
739 | } | ||
740 | |||
608 | string serverURI = string.Empty; | 741 | string serverURI = string.Empty; |
609 | GetUserProfileServerURI(targetId, out serverURI); | 742 | GetUserProfileServerURI(targetId, out serverURI); |
610 | if(string.IsNullOrWhiteSpace(serverURI)) | 743 | if(string.IsNullOrWhiteSpace(serverURI)) |
@@ -637,6 +770,14 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
637 | string name = m["name"].AsString(); | 770 | string name = m["name"].AsString(); |
638 | picks[cid] = name; | 771 | picks[cid] = name; |
639 | } | 772 | } |
773 | |||
774 | if (uce == null) | ||
775 | uce = new UserProfileCacheEntry(); | ||
776 | uce.picksList = picks; | ||
777 | |||
778 | lock(m_profilesCache) | ||
779 | m_profilesCache.AddOrUpdate(targetId, uce, PROFILECACHEEXPIRE); | ||
780 | |||
640 | remoteClient.SendAvatarPicksReply(targetId, picks); | 781 | remoteClient.SendAvatarPicksReply(targetId, picks); |
641 | } | 782 | } |
642 | 783 | ||
@@ -667,8 +808,27 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
667 | if(!UUID.TryParse (args [1], out pick.PickId)) | 808 | if(!UUID.TryParse (args [1], out pick.PickId)) |
668 | return; | 809 | return; |
669 | 810 | ||
811 | IClientAPI remoteClient = (IClientAPI)sender; | ||
812 | UserProfileCacheEntry uce = null; | ||
813 | lock(m_profilesCache) | ||
814 | { | ||
815 | if(m_profilesCache.TryGetValue(targetID, out uce) && uce != null) | ||
816 | { | ||
817 | if(uce != null && uce.picks != null && uce.picks.ContainsKey(pick.PickId)) | ||
818 | { | ||
819 | pick = uce.picks[pick.PickId]; | ||
820 | Vector3 gPos = new Vector3(Vector3.Zero); | ||
821 | Vector3.TryParse(pick.GlobalPos, out gPos); | ||
822 | remoteClient.SendPickInfoReply(pick.PickId,pick.CreatorId,pick.TopPick,pick.ParcelId,pick.Name, | ||
823 | pick.Desc,pick.SnapshotId,pick.ParcelName,pick.OriginalName,pick.SimName, | ||
824 | gPos,pick.SortOrder,pick.Enabled); | ||
825 | return; | ||
826 | } | ||
827 | } | ||
828 | } | ||
829 | |||
670 | string serverURI = string.Empty; | 830 | string serverURI = string.Empty; |
671 | GetUserProfileServerURI (targetID, out serverURI); | 831 | bool foreign = GetUserProfileServerURI (targetID, out serverURI); |
672 | if(string.IsNullOrWhiteSpace(serverURI)) | 832 | if(string.IsNullOrWhiteSpace(serverURI)) |
673 | { | 833 | { |
674 | return; | 834 | return; |
@@ -676,8 +836,6 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
676 | 836 | ||
677 | string theirGatekeeperURI; | 837 | string theirGatekeeperURI; |
678 | GetUserGatekeeperURI(targetID, out theirGatekeeperURI); | 838 | GetUserGatekeeperURI(targetID, out theirGatekeeperURI); |
679 | |||
680 | IClientAPI remoteClient = (IClientAPI)sender; | ||
681 | 839 | ||
682 | object Pick = (object)pick; | 840 | object Pick = (object)pick; |
683 | if (!rpc.JsonRpcRequest (ref Pick, "pickinforequest", serverURI, UUID.Random ().ToString ())) { | 841 | if (!rpc.JsonRpcRequest (ref Pick, "pickinforequest", serverURI, UUID.Random ().ToString ())) { |
@@ -686,6 +844,8 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
686 | return; | 844 | return; |
687 | } | 845 | } |
688 | pick = (UserProfilePick)Pick; | 846 | pick = (UserProfilePick)Pick; |
847 | if(foreign) | ||
848 | cacheForeignImage(targetID, pick.SnapshotId); | ||
689 | 849 | ||
690 | Vector3 globalPos = new Vector3(Vector3.Zero); | 850 | Vector3 globalPos = new Vector3(Vector3.Zero); |
691 | Vector3.TryParse(pick.GlobalPos, out globalPos); | 851 | Vector3.TryParse(pick.GlobalPos, out globalPos); |
@@ -716,6 +876,16 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
716 | 876 | ||
717 | m_log.DebugFormat("[PROFILES]: PickInfoRequest: {0} : {1}", pick.Name.ToString(), pick.SnapshotId.ToString()); | 877 | m_log.DebugFormat("[PROFILES]: PickInfoRequest: {0} : {1}", pick.Name.ToString(), pick.SnapshotId.ToString()); |
718 | 878 | ||
879 | pick.GlobalPos = globalPos.ToString(); | ||
880 | if (uce == null) | ||
881 | uce = new UserProfileCacheEntry(); | ||
882 | if(uce.picks == null) | ||
883 | uce.picks = new Dictionary<UUID, UserProfilePick>(); | ||
884 | uce.picks[pick.PickId] = pick; | ||
885 | |||
886 | lock(m_profilesCache) | ||
887 | m_profilesCache.AddOrUpdate(targetID, uce, PROFILECACHEEXPIRE); | ||
888 | |||
719 | // Pull the rabbit out of the hat | 889 | // Pull the rabbit out of the hat |
720 | remoteClient.SendPickInfoReply(pick.PickId,pick.CreatorId,pick.TopPick,pick.ParcelId,pick.Name, | 890 | remoteClient.SendPickInfoReply(pick.PickId,pick.CreatorId,pick.TopPick,pick.ParcelId,pick.Name, |
721 | pick.Desc,pick.SnapshotId,pick.ParcelName,pick.OriginalName,pick.SimName, | 891 | pick.Desc,pick.SnapshotId,pick.ParcelName,pick.OriginalName,pick.SimName, |
@@ -757,6 +927,17 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
757 | //TODO: See how this works with NPC, May need to test | 927 | //TODO: See how this works with NPC, May need to test |
758 | m_log.DebugFormat("[PROFILES]: Start PickInfoUpdate Name: {0} PickId: {1} SnapshotId: {2}", name, pickID.ToString(), snapshotID.ToString()); | 928 | m_log.DebugFormat("[PROFILES]: Start PickInfoUpdate Name: {0} PickId: {1} SnapshotId: {2}", name, pickID.ToString(), snapshotID.ToString()); |
759 | 929 | ||
930 | // flush cache for now | ||
931 | UserProfileCacheEntry uce = null; | ||
932 | lock(m_profilesCache) | ||
933 | { | ||
934 | if(m_profilesCache.TryGetValue(remoteClient.AgentId, out uce) && uce != null) | ||
935 | { | ||
936 | uce.picks = null; | ||
937 | uce.picksList = null; | ||
938 | } | ||
939 | } | ||
940 | |||
760 | UserProfilePick pick = new UserProfilePick(); | 941 | UserProfilePick pick = new UserProfilePick(); |
761 | string serverURI = string.Empty; | 942 | string serverURI = string.Empty; |
762 | GetUserProfileServerURI(remoteClient.AgentId, out serverURI); | 943 | GetUserProfileServerURI(remoteClient.AgentId, out serverURI); |
@@ -791,7 +972,6 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
791 | avaPos.X, avaPos.Y, p.Scene.Name); | 972 | avaPos.X, avaPos.Y, p.Scene.Name); |
792 | } | 973 | } |
793 | 974 | ||
794 | |||
795 | pick.PickId = pickID; | 975 | pick.PickId = pickID; |
796 | pick.CreatorId = creatorID; | 976 | pick.CreatorId = creatorID; |
797 | pick.TopPick = topPick; | 977 | pick.TopPick = topPick; |
@@ -828,6 +1008,17 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
828 | /// </param> | 1008 | /// </param> |
829 | public void PickDelete(IClientAPI remoteClient, UUID queryPickID) | 1009 | public void PickDelete(IClientAPI remoteClient, UUID queryPickID) |
830 | { | 1010 | { |
1011 | // flush cache for now | ||
1012 | UserProfileCacheEntry uce = null; | ||
1013 | lock(m_profilesCache) | ||
1014 | { | ||
1015 | if(m_profilesCache.TryGetValue(remoteClient.AgentId, out uce) && uce != null) | ||
1016 | { | ||
1017 | uce.picks = null; | ||
1018 | uce.picksList = null; | ||
1019 | } | ||
1020 | } | ||
1021 | |||
831 | string serverURI = string.Empty; | 1022 | string serverURI = string.Empty; |
832 | GetUserProfileServerURI(remoteClient.AgentId, out serverURI); | 1023 | GetUserProfileServerURI(remoteClient.AgentId, out serverURI); |
833 | if(string.IsNullOrWhiteSpace(serverURI)) | 1024 | if(string.IsNullOrWhiteSpace(serverURI)) |
@@ -1025,6 +1216,16 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
1025 | /// </param> | 1216 | /// </param> |
1026 | public void AvatarInterestsUpdate(IClientAPI remoteClient, uint wantmask, string wanttext, uint skillsmask, string skillstext, string languages) | 1217 | public void AvatarInterestsUpdate(IClientAPI remoteClient, uint wantmask, string wanttext, uint skillsmask, string skillstext, string languages) |
1027 | { | 1218 | { |
1219 | // flush cache for now | ||
1220 | UserProfileCacheEntry uce = null; | ||
1221 | lock(m_profilesCache) | ||
1222 | { | ||
1223 | if(m_profilesCache.TryGetValue(remoteClient.AgentId, out uce) && uce != null) | ||
1224 | { | ||
1225 | uce.props = null; | ||
1226 | } | ||
1227 | } | ||
1228 | |||
1028 | UserProfileProperties prop = new UserProfileProperties(); | 1229 | UserProfileProperties prop = new UserProfileProperties(); |
1029 | 1230 | ||
1030 | prop.UserId = remoteClient.AgentId; | 1231 | prop.UserId = remoteClient.AgentId; |
@@ -1067,6 +1268,27 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
1067 | 0, "Getting into trouble", "Droidspeak"); | 1268 | 0, "Getting into trouble", "Droidspeak"); |
1068 | return; | 1269 | return; |
1069 | } | 1270 | } |
1271 | UserProfileProperties props; | ||
1272 | UserProfileCacheEntry uce = null; | ||
1273 | lock(m_profilesCache) | ||
1274 | { | ||
1275 | if(m_profilesCache.TryGetValue(avatarID, out uce) && uce != null) | ||
1276 | { | ||
1277 | if(uce.props != null) | ||
1278 | { | ||
1279 | props = uce.props; | ||
1280 | remoteClient.SendAvatarProperties(props.UserId, props.AboutText, | ||
1281 | uce.born, uce.membershipType , props.FirstLifeText, uce.flags, | ||
1282 | props.FirstLifeImageId, props.ImageId, props.WebUrl, props.PartnerId); | ||
1283 | |||
1284 | |||
1285 | remoteClient.SendAvatarInterestsReply(props.UserId, (uint)props.WantToMask, | ||
1286 | props.WantToText, (uint)props.SkillsMask, | ||
1287 | props.SkillsText, props.Language); | ||
1288 | return; | ||
1289 | } | ||
1290 | } | ||
1291 | } | ||
1070 | 1292 | ||
1071 | string serverURI = string.Empty; | 1293 | string serverURI = string.Empty; |
1072 | bool foreign = GetUserProfileServerURI(avatarID, out serverURI); | 1294 | bool foreign = GetUserProfileServerURI(avatarID, out serverURI); |
@@ -1118,13 +1340,13 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
1118 | } | 1340 | } |
1119 | } | 1341 | } |
1120 | 1342 | ||
1121 | UserProfileProperties props = new UserProfileProperties(); | 1343 | props = new UserProfileProperties(); |
1122 | props.UserId = avatarID; | 1344 | props.UserId = avatarID; |
1123 | 1345 | ||
1124 | string result = string.Empty; | 1346 | string result = string.Empty; |
1125 | if(!GetProfileData(ref props, foreign, out result)) | 1347 | if(!GetProfileData(ref props, foreign, serverURI, out result)) |
1126 | { | 1348 | { |
1127 | props.AboutText ="Profile not avaible at this time. User may still be unknown to this grid"; | 1349 | props.AboutText ="Profile not available at this time. User may still be unknown to this grid"; |
1128 | } | 1350 | } |
1129 | 1351 | ||
1130 | // if on same region force online | 1352 | // if on same region force online |
@@ -1134,10 +1356,19 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
1134 | if(!m_allowUserProfileWebURLs) | 1356 | if(!m_allowUserProfileWebURLs) |
1135 | props.WebUrl =""; | 1357 | props.WebUrl =""; |
1136 | 1358 | ||
1359 | if(uce == null) | ||
1360 | uce = new UserProfileCacheEntry(); | ||
1361 | uce.props = props; | ||
1362 | uce.born = born; | ||
1363 | uce.membershipType = membershipType; | ||
1364 | uce.flags = flags; | ||
1365 | |||
1366 | lock(m_profilesCache) | ||
1367 | m_profilesCache.AddOrUpdate(props.UserId, uce, PROFILECACHEEXPIRE); | ||
1368 | |||
1137 | remoteClient.SendAvatarProperties(props.UserId, props.AboutText, born, membershipType , props.FirstLifeText, flags, | 1369 | remoteClient.SendAvatarProperties(props.UserId, props.AboutText, born, membershipType , props.FirstLifeText, flags, |
1138 | props.FirstLifeImageId, props.ImageId, props.WebUrl, props.PartnerId); | 1370 | props.FirstLifeImageId, props.ImageId, props.WebUrl, props.PartnerId); |
1139 | 1371 | ||
1140 | |||
1141 | remoteClient.SendAvatarInterestsReply(props.UserId, (uint)props.WantToMask, props.WantToText, (uint)props.SkillsMask, | 1372 | remoteClient.SendAvatarInterestsReply(props.UserId, (uint)props.WantToMask, props.WantToText, (uint)props.SkillsMask, |
1142 | props.SkillsText, props.Language); | 1373 | props.SkillsText, props.Language); |
1143 | } | 1374 | } |
@@ -1155,6 +1386,16 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
1155 | { | 1386 | { |
1156 | if (remoteClient.AgentId == newProfile.ID) | 1387 | if (remoteClient.AgentId == newProfile.ID) |
1157 | { | 1388 | { |
1389 | // flush cache for now | ||
1390 | UserProfileCacheEntry uce = null; | ||
1391 | lock(m_profilesCache) | ||
1392 | { | ||
1393 | if(m_profilesCache.TryGetValue(remoteClient.AgentId, out uce) && uce != null) | ||
1394 | { | ||
1395 | uce.props = null; | ||
1396 | } | ||
1397 | } | ||
1398 | |||
1158 | UserProfileProperties prop = new UserProfileProperties(); | 1399 | UserProfileProperties prop = new UserProfileProperties(); |
1159 | 1400 | ||
1160 | prop.UserId = remoteClient.AgentId; | 1401 | prop.UserId = remoteClient.AgentId; |
@@ -1189,24 +1430,8 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
1189 | /// <returns> | 1430 | /// <returns> |
1190 | /// The profile data. | 1431 | /// The profile data. |
1191 | /// </returns> | 1432 | /// </returns> |
1192 | bool GetProfileData(ref UserProfileProperties properties, bool foreign, out string message) | 1433 | bool GetProfileData(ref UserProfileProperties properties, bool foreign, string serverURI, out string message) |
1193 | { | 1434 | { |
1194 | // Can't handle NPC yet... | ||
1195 | ScenePresence p = FindPresence(properties.UserId); | ||
1196 | |||
1197 | if (null != p) | ||
1198 | { | ||
1199 | if (p.PresenceType == PresenceType.Npc) | ||
1200 | { | ||
1201 | message = "Id points to NPC"; | ||
1202 | return false; | ||
1203 | } | ||
1204 | } | ||
1205 | |||
1206 | string serverURI = string.Empty; | ||
1207 | GetUserProfileServerURI(properties.UserId, out serverURI); | ||
1208 | // This is checking a friend on the home grid | ||
1209 | // Not HG friend | ||
1210 | if (String.IsNullOrEmpty(serverURI)) | 1435 | if (String.IsNullOrEmpty(serverURI)) |
1211 | { | 1436 | { |
1212 | message = "User profile service unknown at this time"; | 1437 | message = "User profile service unknown at this time"; |
@@ -1247,10 +1472,14 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
1247 | 1472 | ||
1248 | return false; | 1473 | return false; |
1249 | } | 1474 | } |
1250 | // else, continue below | ||
1251 | } | 1475 | } |
1252 | 1476 | ||
1253 | properties = (UserProfileProperties)Prop; | 1477 | properties = (UserProfileProperties)Prop; |
1478 | if(foreign) | ||
1479 | { | ||
1480 | cacheForeignImage(properties.UserId, properties.ImageId); | ||
1481 | cacheForeignImage(properties.UserId, properties.FirstLifeImageId); | ||
1482 | } | ||
1254 | 1483 | ||
1255 | message = "Success"; | 1484 | message = "Success"; |
1256 | return true; | 1485 | return true; |
@@ -1258,49 +1487,6 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
1258 | #endregion Avatar Properties | 1487 | #endregion Avatar Properties |
1259 | 1488 | ||
1260 | #region Utils | 1489 | #region Utils |
1261 | bool GetImageAssets(UUID avatarId) | ||
1262 | { | ||
1263 | string profileServerURI = string.Empty; | ||
1264 | string assetServerURI = string.Empty; | ||
1265 | |||
1266 | bool foreign = GetUserProfileServerURI(avatarId, out profileServerURI); | ||
1267 | |||
1268 | if(!foreign) | ||
1269 | return true; | ||
1270 | |||
1271 | assetServerURI = UserManagementModule.GetUserServerURL(avatarId, "AssetServerURI"); | ||
1272 | |||
1273 | if(string.IsNullOrEmpty(profileServerURI) || string.IsNullOrEmpty(assetServerURI)) | ||
1274 | return false; | ||
1275 | |||
1276 | OSDMap parameters= new OSDMap(); | ||
1277 | parameters.Add("avatarId", OSD.FromUUID(avatarId)); | ||
1278 | OSD Params = (OSD)parameters; | ||
1279 | if(!rpc.JsonRpcRequest(ref Params, "image_assets_request", profileServerURI, UUID.Random().ToString())) | ||
1280 | { | ||
1281 | return false; | ||
1282 | } | ||
1283 | |||
1284 | parameters = (OSDMap)Params; | ||
1285 | |||
1286 | if (parameters.ContainsKey("result")) | ||
1287 | { | ||
1288 | OSDArray list = (OSDArray)parameters["result"]; | ||
1289 | |||
1290 | foreach (OSD asset in list) | ||
1291 | { | ||
1292 | OSDString assetId = (OSDString)asset; | ||
1293 | |||
1294 | Scene.AssetService.Get(string.Format("{0}/{1}", assetServerURI, assetId.AsString())); | ||
1295 | } | ||
1296 | return true; | ||
1297 | } | ||
1298 | else | ||
1299 | { | ||
1300 | m_log.ErrorFormat("[PROFILES]: Problematic response for image_assets_request from {0}", profileServerURI); | ||
1301 | return false; | ||
1302 | } | ||
1303 | } | ||
1304 | 1490 | ||
1305 | /// <summary> | 1491 | /// <summary> |
1306 | /// Gets the user account data. | 1492 | /// Gets the user account data. |
@@ -1451,6 +1637,27 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
1451 | } | 1637 | } |
1452 | } | 1638 | } |
1453 | 1639 | ||
1640 | void cacheForeignImage(UUID agent, UUID imageID) | ||
1641 | { | ||
1642 | if(imageID == null || imageID == UUID.Zero) | ||
1643 | return; | ||
1644 | |||
1645 | string assetServerURI = UserManagementModule.GetUserServerURL(agent, "AssetServerURI"); | ||
1646 | if(string.IsNullOrWhiteSpace(assetServerURI)) | ||
1647 | return; | ||
1648 | |||
1649 | string imageIDstr = imageID.ToString(); | ||
1650 | |||
1651 | |||
1652 | if(m_assetCache != null && m_assetCache.Check(imageIDstr)) | ||
1653 | return; | ||
1654 | |||
1655 | if(Scene.AssetService.Get(imageIDstr) != null) | ||
1656 | return; | ||
1657 | |||
1658 | Scene.AssetService.Get(string.Format("{0}/{1}", assetServerURI, imageIDstr)); | ||
1659 | } | ||
1660 | |||
1454 | /// <summary> | 1661 | /// <summary> |
1455 | /// Finds the presence. | 1662 | /// Finds the presence. |
1456 | /// </summary> | 1663 | /// </summary> |
@@ -1519,9 +1726,8 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
1519 | webRequest.ContentType = "application/json-rpc"; | 1726 | webRequest.ContentType = "application/json-rpc"; |
1520 | webRequest.Method = "POST"; | 1727 | webRequest.Method = "POST"; |
1521 | 1728 | ||
1522 | Stream dataStream = webRequest.GetRequestStream(); | 1729 | using(Stream dataStream = webRequest.GetRequestStream()) |
1523 | dataStream.Write(content, 0, content.Length); | 1730 | dataStream.Write(content,0,content.Length); |
1524 | dataStream.Close(); | ||
1525 | 1731 | ||
1526 | WebResponse webResponse = null; | 1732 | WebResponse webResponse = null; |
1527 | try | 1733 | try |
@@ -1601,9 +1807,8 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles | |||
1601 | webRequest.ContentType = "application/json-rpc"; | 1807 | webRequest.ContentType = "application/json-rpc"; |
1602 | webRequest.Method = "POST"; | 1808 | webRequest.Method = "POST"; |
1603 | 1809 | ||
1604 | Stream dataStream = webRequest.GetRequestStream(); | 1810 | using(Stream dataStream = webRequest.GetRequestStream()) |
1605 | dataStream.Write(content, 0, content.Length); | 1811 | dataStream.Write(content,0,content.Length); |
1606 | dataStream.Close(); | ||
1607 | 1812 | ||
1608 | WebResponse webResponse = null; | 1813 | WebResponse webResponse = null; |
1609 | try | 1814 | try |