From d72769930aebb14ae4bfee9803adb13fbb44eb8b Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 8 May 2010 07:44:07 -0700 Subject: [PATCH 01/10] More cleaning on presence. Friends online/offline works again. --- .../RemoteController/RemoteAdminPlugin.cs | 6 +- .../Avatar/Friends/FriendsModule.cs | 87 +++++++++++-------- .../InstantMessage/MessageTransferModule.cs | 78 +++++++---------- .../Avatar/InstantMessage/PresenceModule.cs | 22 ++--- .../Shared/Api/Implementation/LSL_Api.cs | 4 +- .../SimianPresenceServiceConnector.cs | 12 --- .../Services/Interfaces/IPresenceService.cs | 28 ------ .../PresenceService/PresenceService.cs | 6 -- .../Tests/Clients/Presence/PresenceClient.cs | 12 +-- 9 files changed, 101 insertions(+), 154 deletions(-) diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index 13f9c9f04f..c5346d4ac0 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs @@ -1119,9 +1119,9 @@ namespace OpenSim.ApplicationPlugins.RemoteController } else { - PresenceInfo[] pinfos = m_app.SceneManager.CurrentOrFirstScene.PresenceService.GetAgents(new string[] { account.PrincipalID.ToString() }); - if (pinfos != null && pinfos.Length >= 1) - responseData["lastlogin"] = pinfos[0].Login; + GridUserInfo guinfo = m_app.SceneManager.CurrentOrFirstScene.GridUserService.GetGridUserInfo(account.PrincipalID.ToString()); + if (guinfo != null) + responseData["lastlogin"] = guinfo.Login; else responseData["lastlogin"] = 0; diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index febd4ca993..0c81f446f1 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs @@ -345,8 +345,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends UserAccount account = m_Scenes[0].UserAccountService.GetUserAccount(client.Scene.RegionInfo.ScopeID, new UUID(im.fromAgentID)); im.fromAgentName = account.FirstName + " " + account.LastName; + PresenceInfo presence = null; PresenceInfo[] presences = PresenceService.GetAgents(new string[] { fid }); - PresenceInfo presence = PresenceInfo.GetOnlinePresence(presences); + if (presences != null && presences.Length > 0) + presence = presences[0]; if (presence != null) im.offline = 0; @@ -380,13 +382,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends PresenceInfo[] presence = PresenceService.GetAgents(friendList.ToArray()); foreach (PresenceInfo pi in presence) - { - if (pi.Online) - { - online.Add(new UUID(pi.UserID)); - //m_log.DebugFormat("[XXX] {0} friend online {1}", userID, pi.UserID); - } - } + online.Add(new UUID(pi.UserID)); + //m_log.DebugFormat("[XXX] {0} friend online {1}", userID, pi.UserID); return online; } @@ -462,11 +459,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends // The friend is not here [as root]. Let's forward. PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); - PresenceInfo friendSession = PresenceInfo.GetOnlinePresence(friendSessions); - if (friendSession != null) + if (friendSessions != null && friendSessions.Length > 0) { - GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); - m_FriendsSimConnector.StatusNotify(region, userID, friendID, online); + PresenceInfo friendSession = friendSessions[0]; + if (friendSession != null) + { + GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); + m_FriendsSimConnector.StatusNotify(region, userID, friendID, online); + } } // Friend is not online. Ignore. @@ -504,13 +504,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends // The prospective friend is not here [as root]. Let's forward. PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); - PresenceInfo friendSession = PresenceInfo.GetOnlinePresence(friendSessions); - if (friendSession != null) + if (friendSessions != null && friendSessions.Length > 0) { - GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); - m_FriendsSimConnector.FriendshipOffered(region, agentID, friendID, im.message); + PresenceInfo friendSession = friendSessions[0]; + if (friendSession != null) + { + GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); + m_FriendsSimConnector.FriendshipOffered(region, agentID, friendID, im.message); + } } - // If the prospective friend is not online, he'll get the message upon login. } @@ -536,14 +538,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends // The friend is not here PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); - PresenceInfo friendSession = PresenceInfo.GetOnlinePresence(friendSessions); - if (friendSession != null) + if (friendSessions != null && friendSessions.Length > 0) { - GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); - m_FriendsSimConnector.FriendshipApproved(region, agentID, client.Name, friendID); - client.SendAgentOnline(new UUID[] { friendID }); + PresenceInfo friendSession = friendSessions[0]; + if (friendSession != null) + { + GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); + m_FriendsSimConnector.FriendshipApproved(region, agentID, client.Name, friendID); + client.SendAgentOnline(new UUID[] { friendID }); + } } - } private void OnDenyFriendRequest(IClientAPI client, UUID agentID, UUID friendID, List callingCardFolders) @@ -562,11 +566,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends return; PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { friendID.ToString() }); - PresenceInfo friendSession = PresenceInfo.GetOnlinePresence(friendSessions); - if (friendSession != null) + if (friendSessions != null && friendSessions.Length > 0) { - GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); - m_FriendsSimConnector.FriendshipDenied(region, agentID, client.Name, friendID); + PresenceInfo friendSession = friendSessions[0]; + if (friendSession != null) + { + GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); + m_FriendsSimConnector.FriendshipDenied(region, agentID, client.Name, friendID); + } } } @@ -589,11 +596,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends return; PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { exfriendID.ToString() }); - PresenceInfo friendSession = PresenceInfo.GetOnlinePresence(friendSessions); - if (friendSession != null) + if (friendSessions != null && friendSessions.Length > 0) { - GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); - m_FriendsSimConnector.FriendshipTerminated(region, agentID, exfriendID); + PresenceInfo friendSession = friendSessions[0]; + if (friendSession != null) + { + GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); + m_FriendsSimConnector.FriendshipTerminated(region, agentID, exfriendID); + } } } @@ -631,13 +641,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends return; PresenceInfo[] friendSessions = PresenceService.GetAgents(new string[] { target.ToString() }); - PresenceInfo friendSession = PresenceInfo.GetOnlinePresence(friendSessions); - if (friendSession != null) + if (friendSessions != null && friendSessions.Length > 0) { - GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); - // TODO: You might want to send the delta to save the lookup - // on the other end!! - m_FriendsSimConnector.GrantRights(region, requester, target, myFlags, rights); + PresenceInfo friendSession = friendSessions[0]; + if (friendSession != null) + { + GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); + // TODO: You might want to send the delta to save the lookup + // on the other end!! + m_FriendsSimConnector.GrantRights(region, requester, target, myFlags, rights); + } } } } diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs index ad050a1410..5d20e63646 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs @@ -471,7 +471,6 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage if (m_UserRegionMap.ContainsKey(toAgentID)) { upd = new PresenceInfo(); - upd.Online = true; upd.RegionID = m_UserRegionMap[toAgentID]; // We need to compare the current regionhandle with the previous region handle @@ -493,15 +492,8 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage { // Non-cached user agent lookup. PresenceInfo[] presences = PresenceService.GetAgents(new string[] { toAgentID.ToString() }); - if (presences != null) - { - foreach (PresenceInfo p in presences) - if (p.Online) - { - upd = presences[0]; - break; - } - } + if (presences != null && presences.Length > 0) + upd = presences[0]; if (upd != null) { @@ -525,61 +517,53 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage if (upd != null) { - if (upd.Online) + GridRegion reginfo = m_Scenes[0].GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, + upd.RegionID); + if (reginfo != null) { - GridRegion reginfo = m_Scenes[0].GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, - upd.RegionID); - if (reginfo != null) + Hashtable msgdata = ConvertGridInstantMessageToXMLRPC(im); + // Not actually used anymore, left in for compatibility + // Remove at next interface change + // + msgdata["region_handle"] = 0; + bool imresult = doIMSending(reginfo, msgdata); + if (imresult) { - Hashtable msgdata = ConvertGridInstantMessageToXMLRPC(im); - // Not actually used anymore, left in for compatibility - // Remove at next interface change - // - msgdata["region_handle"] = 0; - bool imresult = doIMSending(reginfo, msgdata); - if (imresult) + // IM delivery successful, so store the Agent's location in our local cache. + lock (m_UserRegionMap) { - // IM delivery successful, so store the Agent's location in our local cache. - lock (m_UserRegionMap) + if (m_UserRegionMap.ContainsKey(toAgentID)) { - if (m_UserRegionMap.ContainsKey(toAgentID)) - { - m_UserRegionMap[toAgentID] = upd.RegionID; - } - else - { - m_UserRegionMap.Add(toAgentID, upd.RegionID); - } + m_UserRegionMap[toAgentID] = upd.RegionID; + } + else + { + m_UserRegionMap.Add(toAgentID, upd.RegionID); } - result(true); - } - else - { - // try again, but lookup user this time. - // Warning, this must call the Async version - // of this method or we'll be making thousands of threads - // The version within the spawned thread is SendGridInstantMessageViaXMLRPCAsync - // The version that spawns the thread is SendGridInstantMessageViaXMLRPC - - // This is recursive!!!!! - SendGridInstantMessageViaXMLRPCAsync(im, result, - upd.RegionID); } + result(true); } else { - m_log.WarnFormat("[GRID INSTANT MESSAGE]: Unable to find region {0}", upd.RegionID); - HandleUndeliveredMessage(im, result); + // try again, but lookup user this time. + // Warning, this must call the Async version + // of this method or we'll be making thousands of threads + // The version within the spawned thread is SendGridInstantMessageViaXMLRPCAsync + // The version that spawns the thread is SendGridInstantMessageViaXMLRPC + + // This is recursive!!!!! + SendGridInstantMessageViaXMLRPCAsync(im, result, + upd.RegionID); } } else { + m_log.WarnFormat("[GRID INSTANT MESSAGE]: Unable to find region {0}", upd.RegionID); HandleUndeliveredMessage(im, result); } } else { - m_log.WarnFormat("[GRID INSTANT MESSAGE]: Unable to find user {0}", toAgentID); HandleUndeliveredMessage(im, result); } } diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs index bafad827a6..dd17f3c26b 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs @@ -133,20 +133,14 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage foreach (PresenceInfo pi in status) { UUID uuid = new UUID(pi.UserID); - if (pi.Online) - { - if (!online.Contains(uuid)) - { - online.Add(uuid); - if (offline.Contains(uuid)) - offline.Remove(uuid); - } - } - else - { - if (!online.Contains(uuid) && !offline.Contains(uuid)) - offline.Add(uuid); - } + if (!online.Contains(uuid)) + online.Add(uuid); + } + foreach (string s in args) + { + UUID uuid = new UUID(s); + if (!online.Contains(uuid) && !offline.Contains(uuid)) + offline.Add(uuid); } if (online.Count > 0) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index b2eb585b12..79b6be398a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -3884,8 +3884,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api UserAccount account = World.UserAccountService.GetUserAccount(World.RegionInfo.ScopeID, uuid); + PresenceInfo pinfo = null; PresenceInfo[] pinfos = World.PresenceService.GetAgents(new string[] { uuid.ToString() }); - PresenceInfo pinfo = PresenceInfo.GetOnlinePresence(pinfos); + if (pinfos != null && pinfos.Length > 0) + pinfo = pinfos[0]; if (pinfo == null) return UUID.Zero.ToString(); diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs index e48b7de3bf..b86c45c033 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs @@ -511,20 +511,8 @@ namespace OpenSim.Services.Connectors.SimianGrid PresenceInfo info = new PresenceInfo(); - info.Online = true; info.UserID = sessionResponse["UserID"].AsUUID().ToString(); info.RegionID = sessionResponse["SceneID"].AsUUID(); - info.Position = sessionResponse["ScenePosition"].AsVector3(); - info.LookAt = sessionResponse["SceneLookAt"].AsVector3(); - - if (userResponse != null && userResponse["User"] is OSDMap) - { - OSDMap user = (OSDMap)userResponse["User"]; - - info.Login = user["LastLoginDate"].AsDate(); - info.Logout = user["LastLogoutDate"].AsDate(); - DeserializeLocation(user["HomeLocation"].AsString(), out info.HomeRegionID, out info.HomePosition, out info.HomeLookAt); - } return info; } diff --git a/OpenSim/Services/Interfaces/IPresenceService.cs b/OpenSim/Services/Interfaces/IPresenceService.cs index abbae2c559..8d583fff73 100644 --- a/OpenSim/Services/Interfaces/IPresenceService.cs +++ b/OpenSim/Services/Interfaces/IPresenceService.cs @@ -36,14 +36,6 @@ namespace OpenSim.Services.Interfaces { public string UserID; public UUID RegionID; - public bool Online; - public DateTime Login; - public DateTime Logout; - public Vector3 Position; - public Vector3 LookAt; - public UUID HomeRegionID; - public Vector3 HomePosition; - public Vector3 HomeLookAt; public PresenceInfo() { @@ -65,26 +57,6 @@ namespace OpenSim.Services.Interfaces return result; } - - public static PresenceInfo[] GetOnlinePresences(PresenceInfo[] pinfos) - { - if (pinfos == null) - return null; - - List lst = new List(pinfos); - lst = lst.FindAll(delegate(PresenceInfo each) { return each.Online; }); - - return lst.ToArray(); - } - - public static PresenceInfo GetOnlinePresence(PresenceInfo[] pinfos) - { - pinfos = GetOnlinePresences(pinfos); - if (pinfos != null && pinfos.Length >= 1) - return pinfos[0]; - - return null; - } } public interface IPresenceService diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs index 7e7e98e417..19f636a1c1 100644 --- a/OpenSim/Services/PresenceService/PresenceService.cs +++ b/OpenSim/Services/PresenceService/PresenceService.cs @@ -115,10 +115,6 @@ namespace OpenSim.Services.PresenceService ret.UserID = data.UserID; ret.RegionID = data.RegionID; - if (data.Data.ContainsKey("Position")) - ret.Position = Vector3.Parse(data.Data["Position"]); - if (data.Data.ContainsKey("LookAt")) - ret.LookAt = Vector3.Parse(data.Data["LookAt"]); return ret; } @@ -138,8 +134,6 @@ namespace OpenSim.Services.PresenceService ret.UserID = d.UserID; ret.RegionID = d.RegionID; - ret.Position = Vector3.Parse(d.Data["Position"]); - ret.LookAt = Vector3.Parse(d.Data["LookAt"]); info.Add(ret); } diff --git a/OpenSim/Tests/Clients/Presence/PresenceClient.cs b/OpenSim/Tests/Clients/Presence/PresenceClient.cs index 0f6b80e209..fd3905adcb 100644 --- a/OpenSim/Tests/Clients/Presence/PresenceClient.cs +++ b/OpenSim/Tests/Clients/Presence/PresenceClient.cs @@ -73,8 +73,8 @@ namespace OpenSim.Tests.Clients.PresenceClient if (pinfo == null) m_log.InfoFormat("[PRESENCE CLIENT]: Unable to retrieve presence for {0}", user1); else - m_log.InfoFormat("[PRESENCE CLIENT]: Presence retrieved correctly: userID={0}; Online={1}; regionID={2}; homeRegion={3}", - pinfo.UserID, pinfo.Online, pinfo.RegionID, pinfo.HomeRegionID); + m_log.InfoFormat("[PRESENCE CLIENT]: Presence retrieved correctly: userID={0}; regionID={1}", + pinfo.UserID, pinfo.RegionID); System.Console.WriteLine("\n"); success = m_Connector.ReportAgent(session1, region1); @@ -86,8 +86,8 @@ namespace OpenSim.Tests.Clients.PresenceClient if (pinfo == null) m_log.InfoFormat("[PRESENCE CLIENT]: Unable to retrieve presence for {0} for second time", user1); else - m_log.InfoFormat("[PRESENCE CLIENT]: Presence retrieved correctly: userID={0}; Online={1}; regionID={2}; homeRegion={3}", - pinfo.UserID, pinfo.Online, pinfo.RegionID, pinfo.HomeRegionID); + m_log.InfoFormat("[PRESENCE CLIENT]: Presence retrieved correctly: userID={0}; regionID={2}", + pinfo.UserID, pinfo.RegionID); System.Console.WriteLine("\n"); success = m_Connector.LogoutAgent(session1); @@ -99,8 +99,8 @@ namespace OpenSim.Tests.Clients.PresenceClient if (pinfo == null) m_log.InfoFormat("[PRESENCE CLIENT]: Unable to retrieve presence for {0} for fourth time", user1); else - m_log.InfoFormat("[PRESENCE CLIENT]: Presence retrieved correctly: userID={0}; Online={1}; regionID={2}; homeRegion={3}", - pinfo.UserID, pinfo.Online, pinfo.RegionID, pinfo.HomeRegionID); + m_log.InfoFormat("[PRESENCE CLIENT]: Presence retrieved correctly: userID={0}; regionID={1}", + pinfo.UserID, pinfo.RegionID); System.Console.WriteLine("\n"); success = m_Connector.ReportAgent(session1, UUID.Random()); From c1fe07b02248b66d45fbbbd6f8e3db3fe3bdc157 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 8 May 2010 12:21:17 -0700 Subject: [PATCH 02/10] * Added missing loggout notification to home grid upon agents logging out in foreign grids. * Added missing config in StandaloneHypergrid.ini --- .../Framework/EntityTransfer/HGEntityTransferModule.cs | 8 ++++++++ OpenSim/Services/HypergridService/UserAgentService.cs | 4 ++++ bin/config-include/StandaloneHypergrid.ini | 3 +++ 3 files changed, 15 insertions(+) diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index 137dfec13b..7d26e3ff5f 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs @@ -245,6 +245,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer return; } + // Let's find out if this is a foreign user or a local user + UserAccount account = m_aScene.UserAccountService.GetUserAccount(m_aScene.RegionInfo.ScopeID, obj.AgentId); + if (account != null) + { + // local grid user + return; + } + AgentCircuitData aCircuit = ((Scene)(obj.Scene)).AuthenticateHandler.GetAgentCircuitData(obj.CircuitCode); if (aCircuit.ServiceURLs.ContainsKey("HomeURI")) diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs index 3af7ef9d3f..64f7e8aaca 100644 --- a/OpenSim/Services/HypergridService/UserAgentService.cs +++ b/OpenSim/Services/HypergridService/UserAgentService.cs @@ -185,6 +185,10 @@ namespace OpenSim.Services.HypergridService foreach (UUID session in travels) m_TravelingAgents.Remove(session); } + + GridUserInfo guinfo = m_GridUserService.GetGridUserInfo(userID.ToString()); + if (guinfo != null) + m_GridUserService.LoggedOut(userID.ToString(), guinfo.LastRegionID, guinfo.LastPosition, guinfo.LastLookAt); } // We need to prevent foreign users with the same UUID as a local user diff --git a/bin/config-include/StandaloneHypergrid.ini b/bin/config-include/StandaloneHypergrid.ini index 130e210a77..32b240b8b5 100644 --- a/bin/config-include/StandaloneHypergrid.ini +++ b/bin/config-include/StandaloneHypergrid.ini @@ -77,6 +77,9 @@ GridService = "OpenSim.Services.GridService.dll:GridService" InventoryService = "OpenSim.Services.InventoryService.dll:XInventoryService" +[GridUserService] + LocalServiceModule = "OpenSim.Services.UserAccountService.dll:GridUserService" + [FriendsService] LocalServiceModule = "OpenSim.Services.FriendsService.dll" ConnectionString = "URI=file:friends.db,version=3" From 9b22393cf308507dc751704c8b0d3e65ac1d4323 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 9 May 2010 17:02:22 +0100 Subject: [PATCH 03/10] Add a field asset_flags and a corresponding enum to the asset database. This CHANGES THE ASSET SERVER PROTOCOL and means you CAN NOT MIX PRIOR VERSIONS WITH LATER ONES. It may also eat your babies, yada, yada, yada. The usual cautions for migrations to the assets table apply. Coding: Can not guarantee nut free. --- OpenSim/Data/MySQL/MySQLAssetData.cs | 8 ++++--- .../Data/MySQL/Resources/007_AssetStore.sql | 5 +++++ OpenSim/Framework/AssetBase.cs | 22 +++++++++++++++++++ OpenSim/Services/AssetService/AssetService.cs | 1 + 4 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 OpenSim/Data/MySQL/Resources/007_AssetStore.sql diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index d55369a946..5a2af4f9ac 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -161,8 +161,8 @@ namespace OpenSim.Data.MySQL MySqlCommand cmd = new MySqlCommand( - "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, data)" + - "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?data)", + "replace INTO assets(id, name, description, assetType, local, temporary, create_time, access_time, asset_flags, data)" + + "VALUES(?id, ?name, ?description, ?assetType, ?local, ?temporary, ?create_time, ?access_time, ?asset_flags, ?data)", dbcon); string assetName = asset.Name; @@ -194,6 +194,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("?temporary", asset.Temporary); cmd.Parameters.AddWithValue("?create_time", now); cmd.Parameters.AddWithValue("?access_time", now); + cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags); cmd.Parameters.AddWithValue("?data", asset.Data); cmd.ExecuteNonQuery(); cmd.Dispose(); @@ -302,7 +303,7 @@ namespace OpenSim.Data.MySQL using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { dbcon.Open(); - MySqlCommand cmd = new MySqlCommand("SELECT name,description,assetType,temporary,id FROM assets LIMIT ?start, ?count", dbcon); + MySqlCommand cmd = new MySqlCommand("SELECT name,description,assetType,temporary,id,asset_flags FROM assets LIMIT ?start, ?count", dbcon); cmd.Parameters.AddWithValue("?start", start); cmd.Parameters.AddWithValue("?count", count); @@ -317,6 +318,7 @@ namespace OpenSim.Data.MySQL metadata.Description = (string)dbReader["description"]; metadata.Type = (sbyte)dbReader["assetType"]; metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); // Not sure if this is correct. + metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); metadata.FullID = new UUID((string)dbReader["id"]); // Current SHA1s are not stored/computed. diff --git a/OpenSim/Data/MySQL/Resources/007_AssetStore.sql b/OpenSim/Data/MySQL/Resources/007_AssetStore.sql new file mode 100644 index 0000000000..f06121abc1 --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/007_AssetStore.sql @@ -0,0 +1,5 @@ +BEGIN; + +ALTER TABLE assets ADD COLUMN asset_flags INTEGER NOT NULL DEFAULT 0; + +COMMIT; diff --git a/OpenSim/Framework/AssetBase.cs b/OpenSim/Framework/AssetBase.cs index 19ca232208..7ecf198bd8 100644 --- a/OpenSim/Framework/AssetBase.cs +++ b/OpenSim/Framework/AssetBase.cs @@ -33,6 +33,15 @@ using OpenMetaverse; namespace OpenSim.Framework { + [Flags] + public enum AssetFlags : int + { + Normal = 0, + Maptile = 1, + Rewritable = 2, + Collectable = 4 + } + /// /// Asset class. All Assets are reference by this class or a class derived from this class /// @@ -206,6 +215,12 @@ namespace OpenSim.Framework set { m_metadata.Temporary = value; } } + public AssetFlags Flags + { + get { return m_metadata.Flags; } + set { m_metadata.Flags = value; } + } + [XmlIgnore] public AssetMetadata Metadata { @@ -233,6 +248,7 @@ namespace OpenSim.Framework private bool m_local; private bool m_temporary; private string m_creatorid; + private AssetFlags m_flags; public UUID FullID { @@ -330,5 +346,11 @@ namespace OpenSim.Framework get { return m_creatorid; } set { m_creatorid = value; } } + + public AssetFlags Flags + { + get { return m_flags; } + set { m_flags = value; } + } } } diff --git a/OpenSim/Services/AssetService/AssetService.cs b/OpenSim/Services/AssetService/AssetService.cs index 4e512e729c..2114933ec7 100644 --- a/OpenSim/Services/AssetService/AssetService.cs +++ b/OpenSim/Services/AssetService/AssetService.cs @@ -181,6 +181,7 @@ namespace OpenSim.Services.AssetService MainConsole.Instance.Output(String.Format("Description: {0}", asset.Description)); MainConsole.Instance.Output(String.Format("Type: {0}", asset.Type)); MainConsole.Instance.Output(String.Format("Content-type: {0}", asset.Metadata.ContentType)); + MainConsole.Instance.Output(String.Format("Flags: {0}", asset.Metadata.Flags.ToString())); for (i = 0 ; i < 5 ; i++) { From 60357d3778c95a47481f790803b7af39c70cde9c Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 9 May 2010 17:56:52 +0100 Subject: [PATCH 04/10] Implement the "delete" path for assets. Adds a new option to allow remote asset deletion in robust handler. --- OpenSim/Data/AssetDataBase.cs | 1 + OpenSim/Data/IAssetData.cs | 1 + OpenSim/Data/MSSQL/MSSQLAssetData.cs | 4 ++++ OpenSim/Data/MySQL/MySQLAssetData.cs | 18 ++++++++++++++++++ OpenSim/Data/SQLite/SQLiteAssetData.cs | 5 +++++ OpenSim/Data/SQLiteLegacy/SQLiteAssetData.cs | 6 +++++- .../Handlers/Asset/AssetServerConnector.cs | 4 +++- .../Handlers/Asset/AssetServerDeleteHandler.cs | 8 +++++--- OpenSim/Services/AssetService/AssetService.cs | 11 +++++++++++ .../Tests/Common/Mock/MockAssetDataPlugin.cs | 7 ++++++- bin/Robust.ini.example | 1 + 11 files changed, 60 insertions(+), 6 deletions(-) diff --git a/OpenSim/Data/AssetDataBase.cs b/OpenSim/Data/AssetDataBase.cs index 5deb44e61e..e1a810c9af 100644 --- a/OpenSim/Data/AssetDataBase.cs +++ b/OpenSim/Data/AssetDataBase.cs @@ -48,5 +48,6 @@ namespace OpenSim.Data public abstract void Initialise(string connect); public abstract void Initialise(); public abstract void Dispose(); + public abstract bool Delete(string id); } } diff --git a/OpenSim/Data/IAssetData.cs b/OpenSim/Data/IAssetData.cs index 2149bcac0a..90d5eeb489 100644 --- a/OpenSim/Data/IAssetData.cs +++ b/OpenSim/Data/IAssetData.cs @@ -38,6 +38,7 @@ namespace OpenSim.Data bool ExistsAsset(UUID uuid); List FetchAssetMetadataSet(int start, int count); void Initialise(string connect); + bool Delete(string id); } public class AssetDataInitialiser : PluginInitialiserBase diff --git a/OpenSim/Data/MSSQL/MSSQLAssetData.cs b/OpenSim/Data/MSSQL/MSSQLAssetData.cs index d6ea26254a..8475b22022 100644 --- a/OpenSim/Data/MSSQL/MSSQLAssetData.cs +++ b/OpenSim/Data/MSSQL/MSSQLAssetData.cs @@ -322,6 +322,10 @@ namespace OpenSim.Data.MSSQL return retList; } + public override bool Delete(string id) + { + return false; + } #endregion } } diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 5a2af4f9ac..35eed56813 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -338,6 +338,24 @@ namespace OpenSim.Data.MySQL return retList; } + public override bool Delete(string id) + { + lock (m_dbLock) + { + using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) + { + dbcon.Open(); + MySqlCommand cmd = new MySqlCommand("delete from assets where id=?id"); + cmd.Parameters.AddWithValue("?id", id); + cmd.ExecuteNonQuery(); + + cmd.Dispose(); + } + } + + return true; + } + #endregion } } diff --git a/OpenSim/Data/SQLite/SQLiteAssetData.cs b/OpenSim/Data/SQLite/SQLiteAssetData.cs index 636bf8645b..9b938fab73 100644 --- a/OpenSim/Data/SQLite/SQLiteAssetData.cs +++ b/OpenSim/Data/SQLite/SQLiteAssetData.cs @@ -338,6 +338,11 @@ namespace OpenSim.Data.SQLite get { return "SQLite Asset storage engine"; } } + public override bool Delete(string id) + { + return false; + } + #endregion } } diff --git a/OpenSim/Data/SQLiteLegacy/SQLiteAssetData.cs b/OpenSim/Data/SQLiteLegacy/SQLiteAssetData.cs index 0d63deacd8..df509023eb 100644 --- a/OpenSim/Data/SQLiteLegacy/SQLiteAssetData.cs +++ b/OpenSim/Data/SQLiteLegacy/SQLiteAssetData.cs @@ -338,6 +338,10 @@ namespace OpenSim.Data.SQLiteLegacy get { return "SQLite Asset storage engine"; } } + public override bool Delete(string id) + { + return false; + } #endregion } -} \ No newline at end of file +} diff --git a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs index f7eb292091..b6425f4c49 100644 --- a/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs +++ b/OpenSim/Server/Handlers/Asset/AssetServerConnector.cs @@ -59,9 +59,11 @@ namespace OpenSim.Server.Handlers.Asset m_AssetService = ServerUtils.LoadPlugin(assetService, args); + bool allowDelete = serverConfig.GetBoolean("AllowRemoteDelete", false); + server.AddStreamHandler(new AssetServerGetHandler(m_AssetService)); server.AddStreamHandler(new AssetServerPostHandler(m_AssetService)); - server.AddStreamHandler(new AssetServerDeleteHandler(m_AssetService)); + server.AddStreamHandler(new AssetServerDeleteHandler(m_AssetService, allowDelete)); } } } diff --git a/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs b/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs index f33bb90fde..8014fb5354 100644 --- a/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs +++ b/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs @@ -47,11 +47,13 @@ namespace OpenSim.Server.Handlers.Asset // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private IAssetService m_AssetService; + protected bool m_allowDelete; - public AssetServerDeleteHandler(IAssetService service) : + public AssetServerDeleteHandler(IAssetService service, bool allowDelete) : base("DELETE", "/assets") { m_AssetService = service; + m_allowDelete = allowDelete; } public override byte[] Handle(string path, Stream request, @@ -61,9 +63,9 @@ namespace OpenSim.Server.Handlers.Asset string[] p = SplitParams(path); - if (p.Length > 0) + if (p.Length > 0 && m_allowDelete) { - // result = m_AssetService.Delete(p[0]); + result = m_AssetService.Delete(p[0]); } XmlSerializer xs = new XmlSerializer(typeof(bool)); diff --git a/OpenSim/Services/AssetService/AssetService.cs b/OpenSim/Services/AssetService/AssetService.cs index 2114933ec7..4fc38f3173 100644 --- a/OpenSim/Services/AssetService/AssetService.cs +++ b/OpenSim/Services/AssetService/AssetService.cs @@ -156,6 +156,17 @@ namespace OpenSim.Services.AssetService public bool Delete(string id) { + UUID assetID; + if (!UUID.TryParse(id, out assetID)) + return false; + + AssetBase asset = m_Database.GetAsset(assetID); + if (asset == null) + return false; + + if ((int)(asset.Flags & AssetFlags.Maptile) != 0) + return m_Database.Delete(id); + return false; } diff --git a/OpenSim/Tests/Common/Mock/MockAssetDataPlugin.cs b/OpenSim/Tests/Common/Mock/MockAssetDataPlugin.cs index cc1dfbf02a..4a15cf2d64 100644 --- a/OpenSim/Tests/Common/Mock/MockAssetDataPlugin.cs +++ b/OpenSim/Tests/Common/Mock/MockAssetDataPlugin.cs @@ -60,5 +60,10 @@ namespace OpenSim.Tests.Common.Mock } public List FetchAssetMetadataSet(int start, int count) { return new List(count); } + + public bool Delete(string id) + { + return false; + } } -} \ No newline at end of file +} diff --git a/bin/Robust.ini.example b/bin/Robust.ini.example index 502a8e656a..f1b91269a7 100644 --- a/bin/Robust.ini.example +++ b/bin/Robust.ini.example @@ -40,6 +40,7 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003 LocalServiceModule = "OpenSim.Services.AssetService.dll:AssetService" DefaultAssetLoader = "OpenSim.Framework.AssetLoader.Filesystem.dll" AssetLoaderArgs = "assets/AssetSets.xml" + AllowRemoteDelete = "false" ; * This configuration loads the inventory server modules. It duplicates ; * the function of the legacy inventory server From bc6995f92123ff29fdfd6f811d3d252d99284527 Mon Sep 17 00:00:00 2001 From: Melanie Date: Sun, 9 May 2010 18:02:36 +0100 Subject: [PATCH 05/10] Add Delete handler to SQLite (NG) --- OpenSim/Data/SQLite/SQLiteAssetData.cs | 31 +++++++++++++------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/OpenSim/Data/SQLite/SQLiteAssetData.cs b/OpenSim/Data/SQLite/SQLiteAssetData.cs index 9b938fab73..2783ba1556 100644 --- a/OpenSim/Data/SQLite/SQLiteAssetData.cs +++ b/OpenSim/Data/SQLite/SQLiteAssetData.cs @@ -207,20 +207,6 @@ namespace OpenSim.Data.SQLite } } - /// - /// Delete an asset from database - /// - /// - public void DeleteAsset(UUID uuid) - { - using (SqliteCommand cmd = new SqliteCommand(DeleteAssetSQL, m_conn)) - { - cmd.Parameters.Add(new SqliteParameter(":UUID", uuid.ToString())); - - cmd.ExecuteNonQuery(); - } - } - /// /// /// @@ -340,7 +326,22 @@ namespace OpenSim.Data.SQLite public override bool Delete(string id) { - return false; + UUID assetID; + + if (!UUID.TryParse(id, out assetID)) + return false; + + lock (this) + { + using (SqliteCommand cmd = new SqliteCommand(DeleteAssetSQL, m_conn)) + { + cmd.Parameters.Add(new SqliteParameter(":UUID", assetID.ToString())); + + cmd.ExecuteNonQuery(); + } + } + + return true; } #endregion From b233a4b2cab3a39f9edc17130cd7c2f2f807d6bb Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 9 May 2010 13:39:56 -0700 Subject: [PATCH 06/10] * Fixed spamming the assets table with map tiles. The tile image ID is now stored in regionsettings. Upon generation of a new tile image, the old one is deleted. Tested for SQLite and MySql standalone. * Fixed small bug with map search where the local sim regions weren't found. --- OpenSim/Data/MySQL/MySQLAssetData.cs | 5 +-- OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 6 +++- .../Data/MySQL/Resources/033_RegionStore.sql | 3 ++ OpenSim/Data/Null/NullRegionData.cs | 8 +++-- .../Data/SQLite/Resources/005_AssetStore.sql | 5 +++ .../Data/SQLite/Resources/019_RegionStore.sql | 5 +++ OpenSim/Data/SQLite/SQLiteAssetData.cs | 10 ++++-- OpenSim/Data/SQLite/SQLiteRegionData.cs | 3 ++ OpenSim/Framework/AssetBase.cs | 8 ++--- OpenSim/Region/Application/OpenSimBase.cs | 2 +- .../Avatar/Assets/GetTextureModule.cs | 2 ++ .../Grid/RemoteGridServiceConnector.cs | 4 ++- .../World/WorldMap/WorldMapModule.cs | 31 +++++++++---------- .../Framework/Interfaces/IWorldMapModule.cs | 2 +- OpenSim/Region/Framework/Scenes/Scene.cs | 6 ++-- OpenSim/Services/AssetService/AssetService.cs | 5 +++ OpenSim/Services/GridService/GridService.cs | 3 +- 17 files changed, 72 insertions(+), 36 deletions(-) create mode 100644 OpenSim/Data/MySQL/Resources/033_RegionStore.sql create mode 100644 OpenSim/Data/SQLite/Resources/005_AssetStore.sql create mode 100644 OpenSim/Data/SQLite/Resources/019_RegionStore.sql diff --git a/OpenSim/Data/MySQL/MySQLAssetData.cs b/OpenSim/Data/MySQL/MySQLAssetData.cs index 35eed56813..13f5fa2ac6 100644 --- a/OpenSim/Data/MySQL/MySQLAssetData.cs +++ b/OpenSim/Data/MySQL/MySQLAssetData.cs @@ -111,7 +111,7 @@ namespace OpenSim.Data.MySQL dbcon.Open(); using (MySqlCommand cmd = new MySqlCommand( - "SELECT name, description, assetType, local, temporary, data FROM assets WHERE id=?id", + "SELECT name, description, assetType, local, temporary, asset_flags, data FROM assets WHERE id=?id", dbcon)) { cmd.Parameters.AddWithValue("?id", assetID.ToString()); @@ -133,6 +133,7 @@ namespace OpenSim.Data.MySQL asset.Local = false; asset.Temporary = Convert.ToBoolean(dbReader["temporary"]); + asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); } } } @@ -345,7 +346,7 @@ namespace OpenSim.Data.MySQL using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) { dbcon.Open(); - MySqlCommand cmd = new MySqlCommand("delete from assets where id=?id"); + MySqlCommand cmd = new MySqlCommand("delete from assets where id=?id", dbcon); cmd.Parameters.AddWithValue("?id", id); cmd.ExecuteNonQuery(); diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index a395ddc3e7..8c83ef13f7 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs @@ -989,7 +989,8 @@ namespace OpenSim.Data.MySQL "?TerrainLowerLimit, ?UseEstateSun, ?FixedSun, " + "?SunPosition, ?Covenant, ?Sandbox, " + "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + - "?LoadedCreationDateTime, ?LoadedCreationID)"; + "?LoadedCreationDateTime, ?LoadedCreationID)" + + "?map_tile_ID, ?TerrainImageID"; FillRegionSettingsCommand(cmd, rs); @@ -1276,6 +1277,8 @@ namespace OpenSim.Data.MySQL else newSettings.LoadedCreationID = (String) row["loaded_creation_id"]; + newSettings.TerrainImageID = new UUID((String)row["map_tile_ID"]); + return newSettings; } @@ -1596,6 +1599,7 @@ namespace OpenSim.Data.MySQL cmd.Parameters.AddWithValue("Covenant", settings.Covenant.ToString()); cmd.Parameters.AddWithValue("LoadedCreationDateTime", settings.LoadedCreationDateTime); cmd.Parameters.AddWithValue("LoadedCreationID", settings.LoadedCreationID); + cmd.Parameters.AddWithValue("TerrainImageID", settings.TerrainImageID); } diff --git a/OpenSim/Data/MySQL/Resources/033_RegionStore.sql b/OpenSim/Data/MySQL/Resources/033_RegionStore.sql new file mode 100644 index 0000000000..2832b413ff --- /dev/null +++ b/OpenSim/Data/MySQL/Resources/033_RegionStore.sql @@ -0,0 +1,3 @@ +BEGIN; +ALTER TABLE regionsettings ADD map_tile_ID CHAR(36) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000'; +COMMIT; diff --git a/OpenSim/Data/Null/NullRegionData.cs b/OpenSim/Data/Null/NullRegionData.cs index 30ad747d25..d596698127 100644 --- a/OpenSim/Data/Null/NullRegionData.cs +++ b/OpenSim/Data/Null/NullRegionData.cs @@ -40,7 +40,7 @@ namespace OpenSim.Data.Null { private static NullRegionData Instance = null; -// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); Dictionary m_regionData = new Dictionary(); @@ -62,12 +62,14 @@ namespace OpenSim.Data.Null { if (regionName.Contains("%")) { - if (r.RegionName.Contains(regionName.Replace("%", ""))) + string cleanname = regionName.Replace("%", ""); + m_log.DebugFormat("[NULL REGION DATA]: comparing {0} to {1}", cleanname.ToLower(), r.RegionName.ToLower()); + if (r.RegionName.ToLower().Contains(cleanname.ToLower())) ret.Add(r); } else { - if (r.RegionName == regionName) + if (r.RegionName.ToLower() == regionName.ToLower()) ret.Add(r); } } diff --git a/OpenSim/Data/SQLite/Resources/005_AssetStore.sql b/OpenSim/Data/SQLite/Resources/005_AssetStore.sql new file mode 100644 index 0000000000..f06121abc1 --- /dev/null +++ b/OpenSim/Data/SQLite/Resources/005_AssetStore.sql @@ -0,0 +1,5 @@ +BEGIN; + +ALTER TABLE assets ADD COLUMN asset_flags INTEGER NOT NULL DEFAULT 0; + +COMMIT; diff --git a/OpenSim/Data/SQLite/Resources/019_RegionStore.sql b/OpenSim/Data/SQLite/Resources/019_RegionStore.sql new file mode 100644 index 0000000000..d62f8484b8 --- /dev/null +++ b/OpenSim/Data/SQLite/Resources/019_RegionStore.sql @@ -0,0 +1,5 @@ +BEGIN; + +ALTER TABLE regionsettings ADD COLUMN map_tile_ID varchar(36) NOT NULL default '00000000-0000-0000-0000-000000000000'; + +COMMIT; \ No newline at end of file diff --git a/OpenSim/Data/SQLite/SQLiteAssetData.cs b/OpenSim/Data/SQLite/SQLiteAssetData.cs index 2783ba1556..7d6df8d627 100644 --- a/OpenSim/Data/SQLite/SQLiteAssetData.cs +++ b/OpenSim/Data/SQLite/SQLiteAssetData.cs @@ -46,8 +46,8 @@ namespace OpenSim.Data.SQLite private const string SelectAssetSQL = "select * from assets where UUID=:UUID"; private const string SelectAssetMetadataSQL = "select Name, Description, Type, Temporary, UUID from assets limit :start, :count"; private const string DeleteAssetSQL = "delete from assets where UUID=:UUID"; - private const string InsertAssetSQL = "insert into assets(UUID, Name, Description, Type, Local, Temporary, Data) values(:UUID, :Name, :Description, :Type, :Local, :Temporary, :Data)"; - private const string UpdateAssetSQL = "update assets set Name=:Name, Description=:Description, Type=:Type, Local=:Local, Temporary=:Temporary, Data=:Data where UUID=:UUID"; + private const string InsertAssetSQL = "insert into assets(UUID, Name, Description, Type, Local, Temporary, asset_flags, Data) values(:UUID, :Name, :Description, :Type, :Local, :Temporary, :Flags, :Data)"; + private const string UpdateAssetSQL = "update assets set Name=:Name, Description=:Description, Type=:Type, Local=:Local, Temporary=:Temporary, asset_flags=:Flags, Data=:Data where UUID=:UUID"; private const string assetSelect = "select * from assets"; private SqliteConnection m_conn; @@ -136,6 +136,7 @@ namespace OpenSim.Data.SQLite cmd.Parameters.Add(new SqliteParameter(":Type", asset.Type)); cmd.Parameters.Add(new SqliteParameter(":Local", asset.Local)); cmd.Parameters.Add(new SqliteParameter(":Temporary", asset.Temporary)); + cmd.Parameters.Add(new SqliteParameter(":Flags", asset.Flags)); cmd.Parameters.Add(new SqliteParameter(":Data", asset.Data)); cmd.ExecuteNonQuery(); @@ -154,6 +155,7 @@ namespace OpenSim.Data.SQLite cmd.Parameters.Add(new SqliteParameter(":Type", asset.Type)); cmd.Parameters.Add(new SqliteParameter(":Local", asset.Local)); cmd.Parameters.Add(new SqliteParameter(":Temporary", asset.Temporary)); + cmd.Parameters.Add(new SqliteParameter(":Flags", asset.Flags)); cmd.Parameters.Add(new SqliteParameter(":Data", asset.Data)); cmd.ExecuteNonQuery(); @@ -227,7 +229,8 @@ namespace OpenSim.Data.SQLite asset.Description = (String) row["Description"]; asset.Local = Convert.ToBoolean(row["Local"]); asset.Temporary = Convert.ToBoolean(row["Temporary"]); - asset.Data = (byte[]) row["Data"]; + asset.Flags = (AssetFlags)Convert.ToInt32(row["asset_flags"]); + asset.Data = (byte[])row["Data"]; return asset; } @@ -240,6 +243,7 @@ namespace OpenSim.Data.SQLite metadata.Description = (string) row["Description"]; metadata.Type = Convert.ToSByte(row["Type"]); metadata.Temporary = Convert.ToBoolean(row["Temporary"]); // Not sure if this is correct. + metadata.Flags = (AssetFlags)Convert.ToInt32(row["asset_flags"]); // Current SHA1s are not stored/computed. metadata.SHA1 = new byte[] {}; diff --git a/OpenSim/Data/SQLite/SQLiteRegionData.cs b/OpenSim/Data/SQLite/SQLiteRegionData.cs index 997664a45c..85703dc2ca 100644 --- a/OpenSim/Data/SQLite/SQLiteRegionData.cs +++ b/OpenSim/Data/SQLite/SQLiteRegionData.cs @@ -1156,6 +1156,7 @@ namespace OpenSim.Data.SQLite createCol(regionsettings, "fixed_sun", typeof (Int32)); createCol(regionsettings, "sun_position", typeof (Double)); createCol(regionsettings, "covenant", typeof(String)); + createCol(regionsettings, "map_tile_ID", typeof(String)); regionsettings.PrimaryKey = new DataColumn[] { regionsettings.Columns["regionUUID"] }; return regionsettings; } @@ -1474,6 +1475,7 @@ namespace OpenSim.Data.SQLite newSettings.FixedSun = Convert.ToBoolean(row["fixed_sun"]); newSettings.SunPosition = Convert.ToDouble(row["sun_position"]); newSettings.Covenant = new UUID((String) row["covenant"]); + newSettings.TerrainImageID = new UUID((String)row["map_tile_ID"]); return newSettings; } @@ -1792,6 +1794,7 @@ namespace OpenSim.Data.SQLite row["fixed_sun"] = settings.FixedSun; row["sun_position"] = settings.SunPosition; row["covenant"] = settings.Covenant.ToString(); + row["map_tile_ID"] = settings.TerrainImageID.ToString(); } /// diff --git a/OpenSim/Framework/AssetBase.cs b/OpenSim/Framework/AssetBase.cs index 7ecf198bd8..53d28be088 100644 --- a/OpenSim/Framework/AssetBase.cs +++ b/OpenSim/Framework/AssetBase.cs @@ -36,10 +36,10 @@ namespace OpenSim.Framework [Flags] public enum AssetFlags : int { - Normal = 0, - Maptile = 1, - Rewritable = 2, - Collectable = 4 + Normal = 0, // Immutable asset + Maptile = 1, // What it says + Rewritable = 2, // Content can be rewritten + Collectable = 4 // Can be GC'ed after some time } /// diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 06ffa917f5..83be61ee63 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -349,7 +349,7 @@ namespace OpenSim // moved these here as the terrain texture has to be created after the modules are initialized // and has to happen before the region is registered with the grid. - scene.CreateTerrainTexture(false); + scene.CreateTerrainTexture(); // TODO : Try setting resource for region xstats here on scene MainServer.Instance.AddStreamHandler(new Region.Framework.Scenes.RegionStatsHandler(regionInfo)); diff --git a/OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs b/OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs index 53d2cefeac..f8e3d595c9 100644 --- a/OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Assets/GetTextureModule.cs @@ -121,6 +121,7 @@ namespace OpenSim.Region.CoreModules.Avatar.ObjectCaps UUID textureID; if (!String.IsNullOrEmpty(textureStr) && UUID.TryParse(textureStr, out textureID)) { + //m_log.DebugFormat("[GETTEXTURE]: {0}", textureID); AssetBase texture; if (!String.IsNullOrEmpty(REDIRECT_URL)) @@ -167,6 +168,7 @@ namespace OpenSim.Region.CoreModules.Avatar.ObjectCaps private void SendTexture(OSHttpRequest request, OSHttpResponse response, AssetBase texture) { string range = request.Headers.GetOne("Range"); + //m_log.DebugFormat("[GETTEXTURE]: Range {0}", range); if (!String.IsNullOrEmpty(range)) { // Range request diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs index d44ddf4b1a..46741a58ec 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs @@ -197,7 +197,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid if (grinfo != null) { //m_log.DebugFormat("[REMOTE GRID CONNECTOR]: Remote GetRegionsByName {0} found {1} regions", name, grinfo.Count); - rinfo.AddRange(grinfo); + foreach (GridRegion r in grinfo) + if (rinfo.Find(delegate(GridRegion gr) { return gr.RegionID == r.RegionID; }) == null) + rinfo.Add(r); } return rinfo; diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index 2b0e83f52f..ac6a633413 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -1000,7 +1000,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap return responsemap; } - public void LazySaveGeneratedMaptile(byte[] data, bool temporary) + public void RegenerateMaptile(byte[] data) { // Overwrites the local Asset cache with new maptile data // Assets are single write, this causes the asset server to ignore this update, @@ -1010,7 +1010,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap // map tile while protecting the (grid) asset database from bloat caused by a new asset each // time a mapimage is generated! - UUID lastMapRegionUUID = m_scene.RegionInfo.lastMapUUID; + UUID lastMapRegionUUID = m_scene.RegionInfo.RegionSettings.TerrainImageID; int lastMapRefresh = 0; int twoDays = 172800; @@ -1030,21 +1030,9 @@ namespace OpenSim.Region.CoreModules.World.WorldMap { } - UUID TerrainImageUUID = UUID.Random(); + m_log.Debug("[MAPTILE]: STORING MAPTILE IMAGE"); - if (lastMapRegionUUID == UUID.Zero || (lastMapRefresh + RefreshSeconds) < Util.UnixTimeSinceEpoch()) - { - m_scene.RegionInfo.SaveLastMapUUID(TerrainImageUUID); - - m_log.Debug("[MAPTILE]: STORING MAPTILE IMAGE"); - } - else - { - TerrainImageUUID = lastMapRegionUUID; - m_log.Debug("[MAPTILE]: REUSING OLD MAPTILE IMAGE ID"); - } - - m_scene.RegionInfo.RegionSettings.TerrainImageID = TerrainImageUUID; + m_scene.RegionInfo.RegionSettings.TerrainImageID = UUID.Random(); AssetBase asset = new AssetBase( m_scene.RegionInfo.RegionSettings.TerrainImageID, @@ -1053,8 +1041,17 @@ namespace OpenSim.Region.CoreModules.World.WorldMap m_scene.RegionInfo.RegionID.ToString()); asset.Data = data; asset.Description = m_scene.RegionInfo.RegionName; - asset.Temporary = temporary; + asset.Temporary = false; + asset.Flags = AssetFlags.Maptile; + + // Store the new one + m_log.DebugFormat("[WORLDMAP]: Storing map tile {0}", asset.ID); m_scene.AssetService.Store(asset); + m_scene.RegionInfo.RegionSettings.Save(); + + // Delete the old one + m_log.DebugFormat("[WORLDMAP]: Deleting old map tile {0}", lastMapRegionUUID); + m_scene.AssetService.Delete(lastMapRegionUUID.ToString()); } private void MakeRootAgent(ScenePresence avatar) diff --git a/OpenSim/Region/Framework/Interfaces/IWorldMapModule.cs b/OpenSim/Region/Framework/Interfaces/IWorldMapModule.cs index de1bcd4382..ac6afed9ce 100644 --- a/OpenSim/Region/Framework/Interfaces/IWorldMapModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IWorldMapModule.cs @@ -29,6 +29,6 @@ namespace OpenSim.Region.Framework.Interfaces { public interface IWorldMapModule { - void LazySaveGeneratedMaptile(byte[] data, bool temporary); + void RegenerateMaptile(byte[] data); } } diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index c0fa7b4289..edbef4c884 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1823,7 +1823,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// Create a terrain texture for this scene /// - public void CreateTerrainTexture(bool temporary) + public void CreateTerrainTexture() { //create a texture asset of the terrain IMapImageGenerator terrain = RequestModuleInterface(); @@ -1841,7 +1841,9 @@ namespace OpenSim.Region.Framework.Scenes IWorldMapModule mapModule = RequestModuleInterface(); if (mapModule != null) - mapModule.LazySaveGeneratedMaptile(data, temporary); + mapModule.RegenerateMaptile(data); + else + m_log.DebugFormat("[SCENE]: MapModule is null, can't save maptile"); } } diff --git a/OpenSim/Services/AssetService/AssetService.cs b/OpenSim/Services/AssetService/AssetService.cs index 4fc38f3173..470a4ddcc5 100644 --- a/OpenSim/Services/AssetService/AssetService.cs +++ b/OpenSim/Services/AssetService/AssetService.cs @@ -156,6 +156,7 @@ namespace OpenSim.Services.AssetService public bool Delete(string id) { + m_log.DebugFormat("[ASSET SERVICE]: Deleting asset {0}", id); UUID assetID; if (!UUID.TryParse(id, out assetID)) return false; @@ -165,7 +166,11 @@ namespace OpenSim.Services.AssetService return false; if ((int)(asset.Flags & AssetFlags.Maptile) != 0) + { return m_Database.Delete(id); + } + else + m_log.DebugFormat("[ASSET SERVICE]: Request to delete asset {0}, but flags are not Maptile", id); return false; } diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 4089fcee18..7c9864270c 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -324,6 +324,7 @@ namespace OpenSim.Services.GridService if (rdatas != null) { + m_log.DebugFormat("[GRID SERVICE]: Found {0} regions", rdatas.Count); foreach (RegionData rdata in rdatas) { if (count++ < maxNumber) @@ -331,7 +332,7 @@ namespace OpenSim.Services.GridService } } - if (m_AllowHypergridMapSearch && (rdatas == null || (rdatas != null && rdatas.Count == 0) && name.Contains("."))) + if (m_AllowHypergridMapSearch && (rdatas == null || (rdatas != null && rdatas.Count == 0)) && name.Contains(".")) { GridRegion r = m_HypergridLinker.LinkRegion(scopeID, name); if (r != null) From 9cf6b81256b6c92cb5d5fb7a6db697f7784191e4 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 9 May 2010 14:02:02 -0700 Subject: [PATCH 07/10] Yey for unit tests. The previous commit had a couple of bugs on SQL statements. Fixed here. --- OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 4 ++-- OpenSim/Data/SQLite/SQLiteAssetData.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index 8c83ef13f7..d2892e9354 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs @@ -989,8 +989,8 @@ namespace OpenSim.Data.MySQL "?TerrainLowerLimit, ?UseEstateSun, ?FixedSun, " + "?SunPosition, ?Covenant, ?Sandbox, " + "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + - "?LoadedCreationDateTime, ?LoadedCreationID)" + - "?map_tile_ID, ?TerrainImageID"; + "?LoadedCreationDateTime, ?LoadedCreationID, " + + "?map_tile_ID)"; FillRegionSettingsCommand(cmd, rs); diff --git a/OpenSim/Data/SQLite/SQLiteAssetData.cs b/OpenSim/Data/SQLite/SQLiteAssetData.cs index 7d6df8d627..7081f99054 100644 --- a/OpenSim/Data/SQLite/SQLiteAssetData.cs +++ b/OpenSim/Data/SQLite/SQLiteAssetData.cs @@ -44,7 +44,7 @@ namespace OpenSim.Data.SQLite // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private const string SelectAssetSQL = "select * from assets where UUID=:UUID"; - private const string SelectAssetMetadataSQL = "select Name, Description, Type, Temporary, UUID from assets limit :start, :count"; + private const string SelectAssetMetadataSQL = "select Name, Description, Type, Temporary, asset_flags, UUID from assets limit :start, :count"; private const string DeleteAssetSQL = "delete from assets where UUID=:UUID"; private const string InsertAssetSQL = "insert into assets(UUID, Name, Description, Type, Local, Temporary, asset_flags, Data) values(:UUID, :Name, :Description, :Type, :Local, :Temporary, :Flags, :Data)"; private const string UpdateAssetSQL = "update assets set Name=:Name, Description=:Description, Type=:Type, Local=:Local, Temporary=:Temporary, asset_flags=:Flags, Data=:Data where UUID=:UUID"; From 6f2f0fa0cad4c2668826f2684f5b8c2d9b30f243 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 9 May 2010 14:12:59 -0700 Subject: [PATCH 08/10] OK, this really fixes it, I promise. --- OpenSim/Data/MySQL/MySQLLegacyRegionData.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs index d2892e9354..07371e7473 100644 --- a/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs +++ b/OpenSim/Data/MySQL/MySQLLegacyRegionData.cs @@ -975,7 +975,7 @@ namespace OpenSim.Data.MySQL "use_estate_sun, fixed_sun, sun_position, " + "covenant, Sandbox, sunvectorx, sunvectory, " + "sunvectorz, loaded_creation_datetime, " + - "loaded_creation_id) values (?RegionUUID, ?BlockTerraform, " + + "loaded_creation_id, map_tile_ID) values (?RegionUUID, ?BlockTerraform, " + "?BlockFly, ?AllowDamage, ?RestrictPushing, " + "?AllowLandResell, ?AllowLandJoinDivide, " + "?BlockShowInSearch, ?AgentLimit, ?ObjectBonus, " + @@ -990,7 +990,7 @@ namespace OpenSim.Data.MySQL "?SunPosition, ?Covenant, ?Sandbox, " + "?SunVectorX, ?SunVectorY, ?SunVectorZ, " + "?LoadedCreationDateTime, ?LoadedCreationID, " + - "?map_tile_ID)"; + "?TerrainImageID)"; FillRegionSettingsCommand(cmd, rs); From 89c762209c9d8fb4cf74c0e89f33caf0f4962f44 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 10 May 2010 03:57:17 +0100 Subject: [PATCH 09/10] Fix a null ref on region crossing --- .../Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 79b6be398a..7a9a92d175 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -5596,7 +5596,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llGetLandOwnerAt(LSL_Vector pos) { m_host.AddScriptLPS(1); - return World.LandChannel.GetLandObject((float)pos.x, (float)pos.y).LandData.OwnerID.ToString(); + ILandObject land = World.LandChannel.GetLandObject((float)pos.x, (float)pos.y); + if (land == null) + return UUID.Zero.ToString(); + return land.LandData.OwnerID.ToString(); } /// From 31dc77d8a1452d7635a7ae167fb0066fcf99a115 Mon Sep 17 00:00:00 2001 From: Melanie Date: Mon, 10 May 2010 04:02:56 +0100 Subject: [PATCH 10/10] Return agents when angle is PI Fixes Mantis #4703 --- .../Shared/Api/Implementation/Plugins/SensorRepeat.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs index 4d7ead6553..5c2abd5e9d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs @@ -472,6 +472,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins sensedEntities.Add(new SensedEntity(dis, presence.UUID)); } } + else + { + sensedEntities.Add(new SensedEntity(dis, presence.UUID)); + } } });