diff --git a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs index 9e12d94849..29a9e149de 100644 --- a/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs +++ b/OpenSim/Framework/Communications/Cache/UserProfileCacheService.cs @@ -139,9 +139,16 @@ namespace OpenSim.Framework.Communications.Cache else { UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(fname, lname); - + if (userProfile != null) + { + if ((userProfile.UserAssetURI == null || userProfile.UserAssetURI == "") && m_commsManager.NetworkServersInfo != null) + userProfile.UserAssetURI = m_commsManager.NetworkServersInfo.AssetURL; + if ((userProfile.UserInventoryURI == null || userProfile.UserInventoryURI == "") && m_commsManager.NetworkServersInfo != null) + userProfile.UserInventoryURI = m_commsManager.NetworkServersInfo.InventoryURL; + return AddToCaches(userProfile); + } else return null; } @@ -169,7 +176,14 @@ namespace OpenSim.Framework.Communications.Cache { UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(userID); if (userProfile != null) + { + if ((userProfile.UserAssetURI == null || userProfile.UserAssetURI == "") && m_commsManager.NetworkServersInfo != null) + userProfile.UserAssetURI = m_commsManager.NetworkServersInfo.AssetURL; + if ((userProfile.UserInventoryURI == null || userProfile.UserInventoryURI == "") && m_commsManager.NetworkServersInfo != null) + userProfile.UserInventoryURI = m_commsManager.NetworkServersInfo.InventoryURL; + return AddToCaches(userProfile); + } else return null; } diff --git a/OpenSim/Framework/Communications/Clients/AuthClient.cs b/OpenSim/Framework/Communications/Clients/AuthClient.cs index 6b4bfec83f..adae637c0d 100644 --- a/OpenSim/Framework/Communications/Clients/AuthClient.cs +++ b/OpenSim/Framework/Communications/Clients/AuthClient.cs @@ -136,7 +136,7 @@ namespace OpenSim.Framework.Communications.Clients } Hashtable responseData = (Hashtable)UserResp.Value; - if (responseData.ContainsKey("auth_session") && responseData["auth_session"].ToString() == "TRUE") + if (responseData != null && responseData.ContainsKey("auth_session") && responseData["auth_session"] != null && responseData["auth_session"].ToString() == "TRUE") { //System.Console.WriteLine("[Authorization]: userserver reported authorized session for user " + userID); return true; diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserDataPlugin.cs b/OpenSim/Region/Communications/OGS1/OGS1UserDataPlugin.cs index 2f9a45f3d8..776d5d14ce 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1UserDataPlugin.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1UserDataPlugin.cs @@ -655,9 +655,12 @@ namespace OpenSim.Region.Communications.OGS1 userData.Email = (string)data["email"]; userData.ID = new UUID((string)data["uuid"]); userData.Created = Convert.ToInt32(data["profile_created"]); - userData.UserInventoryURI = (string)data["server_inventory"]; - userData.UserAssetURI = (string)data["server_asset"]; - userData.FirstLifeAboutText = (string)data["profile_firstlife_about"]; + if (data.Contains("server_inventory") && data["server_inventory"] != null) + userData.UserInventoryURI = (string)data["server_inventory"]; + if (data.Contains("server_asset") && data["server_asset"] != null) + userData.UserAssetURI = (string)data["server_asset"]; + if (data.Contains("profile_firstlife_about") && data["profile_firstlife_about"] != null) + userData.FirstLifeAboutText = (string)data["profile_firstlife_about"]; userData.FirstLifeImage = new UUID((string)data["profile_firstlife_image"]); userData.CanDoMask = Convert.ToUInt32((string)data["profile_can_do"]); userData.WantDoMask = Convert.ToUInt32(data["profile_want_do"]); diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs index f2d8579c83..4d347cdfbc 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs @@ -155,7 +155,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid ((ISharedRegionModule)m_GridServiceConnector).AddRegion(scene); // Yikes!! Remove this as soon as user services get refactored - LocalAssetServerURI = scene.CommsManager.NetworkServersInfo.UserURL; + LocalAssetServerURI = scene.CommsManager.NetworkServersInfo.AssetURL; LocalInventoryServerURI = scene.CommsManager.NetworkServersInfo.InventoryURL; LocalUserServerURI = scene.CommsManager.NetworkServersInfo.UserURL; HGNetworkServersInfo.Init(LocalAssetServerURI, LocalInventoryServerURI, LocalUserServerURI); diff --git a/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs b/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs index 963909545d..76dac6107e 100644 --- a/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs +++ b/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs @@ -45,6 +45,10 @@ namespace OpenSim.Region.DataSnapshot.Providers private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private bool m_stale = true; + private static UUID m_DefaultImage = new UUID("89556747-24cb-43ed-920b-47caed15465f"); + private static UUID m_BlankImage = new UUID("5748decc-f629-461c-9a36-a35a221fe21f"); + + public void Initialize(Scene scene, DataSnapshotManager parent) { m_scene = scene; @@ -142,6 +146,19 @@ namespace OpenSim.Region.DataSnapshot.Providers node.InnerText = land.LandData.GlobalID.ToString(); xmlobject.AppendChild(node); + node = nodeFactory.CreateNode(XmlNodeType.Element, "location", ""); + Vector3 loc = obj.AbsolutePosition; + node.InnerText = loc.X.ToString() + "/" + loc.Y.ToString() + "/" + loc.Z.ToString(); + xmlobject.AppendChild(node); + + string bestImage = GuessImage(obj); + if (bestImage != string.Empty) + { + node = nodeFactory.CreateNode(XmlNodeType.Element, "image", ""); + node.InnerText = bestImage; + xmlobject.AppendChild(node); + } + parent.AppendChild(xmlobject); } } @@ -173,5 +190,58 @@ namespace OpenSim.Region.DataSnapshot.Providers } public event ProviderStale OnStale; + + /// + /// Guesses the best image, based on a simple heuristic. It guesses only for boxes. + /// We're optimizing for boxes, because those are the most common objects + /// marked "Show in search" -- boxes with content inside.For other shapes, + /// it's really hard to tell which texture should be grabbed. + /// + /// + /// + private string GuessImage(SceneObjectGroup sog) + { + string bestguess = string.Empty; + Dictionary counts = new Dictionary(); + if (sog.RootPart.Shape != null && sog.RootPart.Shape.ProfileShape == ProfileShape.Square && + sog.RootPart.Shape.Textures != null && sog.RootPart.Shape.Textures.FaceTextures != null) + { + if (sog.RootPart.Shape.Textures.DefaultTexture.TextureID != UUID.Zero && + sog.RootPart.Shape.Textures.DefaultTexture.TextureID != m_DefaultImage && + sog.RootPart.Shape.Textures.DefaultTexture.TextureID != m_BlankImage && + sog.RootPart.Shape.Textures.DefaultTexture.RGBA.A < 50) + { + counts[sog.RootPart.Shape.Textures.DefaultTexture.TextureID] = 8; + } + + foreach (Primitive.TextureEntryFace tentry in sog.RootPart.Shape.Textures.FaceTextures) + { + if (tentry != null) + { + if (tentry.TextureID != UUID.Zero && tentry.TextureID != m_DefaultImage && tentry.TextureID != m_BlankImage && tentry.RGBA.A < 50) + { + int c = 0; + counts.TryGetValue(tentry.TextureID, out c); + counts[tentry.TextureID] = c + 1; + // decrease the default texture count + if (counts.ContainsKey(sog.RootPart.Shape.Textures.DefaultTexture.TextureID)) + counts[sog.RootPart.Shape.Textures.DefaultTexture.TextureID] = counts[sog.RootPart.Shape.Textures.DefaultTexture.TextureID] - 1; + } + } + } + + // Let's pick the most unique texture + int min = 9999; + foreach (KeyValuePair kv in counts) + { + if (kv.Value < min && kv.Value >= 1) + { + bestguess = kv.Key.ToString(); + min = kv.Value; + } + } + } + return bestguess; + } } }