diff --git a/OpenSim/Addons/OfflineIM/OfflineIMRegionModule.cs b/OpenSim/Addons/OfflineIM/OfflineIMRegionModule.cs index 050ebd20f0..5ef068a251 100644 --- a/OpenSim/Addons/OfflineIM/OfflineIMRegionModule.cs +++ b/OpenSim/Addons/OfflineIM/OfflineIMRegionModule.cs @@ -261,6 +261,11 @@ namespace OpenSim.OfflineIM return m_OfflineIMService.StoreMessage(im, out reason); } + public void DeleteMessages(UUID userID) + { + m_OfflineIMService.DeleteMessages(userID); + } + #endregion } } diff --git a/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRemoteConnector.cs b/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRemoteConnector.cs index 69feb762f9..f6b17e5a5d 100644 --- a/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRemoteConnector.cs +++ b/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRemoteConnector.cs @@ -117,6 +117,14 @@ namespace OpenSim.OfflineIM return true; } + public void DeleteMessages(UUID userID) + { + Dictionary sendData = new Dictionary(); + sendData["UserID"] = userID; + + MakeRequest("DELETE", sendData); + } + #endregion diff --git a/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRobustConnector.cs b/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRobustConnector.cs index 32c24db42d..13b0e7e6a8 100644 --- a/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRobustConnector.cs +++ b/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRobustConnector.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -96,13 +96,14 @@ namespace OpenSim.OfflineIM string method = request["METHOD"].ToString(); request.Remove("METHOD"); - m_log.DebugFormat("[OfflineIM.V2.Handler]: {0}", method); switch (method) { case "GET": return HandleGet(request); case "STORE": return HandleStore(request); + case "DELETE": + return HandleDelete(request); } m_log.DebugFormat("[OFFLINE IM HANDLER]: unknown method request: {0}", method); } @@ -159,6 +160,21 @@ namespace OpenSim.OfflineIM return Util.UTF8NoBomEncoding.GetBytes(xmlString); } + byte[] HandleDelete(Dictionary request) + { + if (!request.ContainsKey("UserID")) + { + return FailureResult(); + } + else + { + UUID userID = new UUID(request["UserID"].ToString()); + m_OfflineIMService.DeleteMessages(userID); + + return SuccessResult(); + } + } + #region Helpers private void NullResult(Dictionary result, string reason) diff --git a/OpenSim/Addons/OfflineIM/Service/OfflineIMService.cs b/OpenSim/Addons/OfflineIM/Service/OfflineIMService.cs index 6731923c3b..690c955660 100644 --- a/OpenSim/Addons/OfflineIM/Service/OfflineIMService.cs +++ b/OpenSim/Addons/OfflineIM/Service/OfflineIMService.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -91,7 +91,7 @@ namespace OpenSim.OfflineIM { reason = string.Empty; - // TODO Check limits + // Check limits UUID principalID = new UUID(im.toAgentID); long count = m_Database.GetCount("PrincipalID", principalID.ToString()); if (count >= MAX_IM) @@ -100,7 +100,7 @@ namespace OpenSim.OfflineIM return false; } - string imXml = string.Empty; + string imXml; using (MemoryStream mstream = new MemoryStream()) { XmlWriterSettings settings = new XmlWriterSettings(); @@ -110,22 +110,26 @@ namespace OpenSim.OfflineIM { m_serializer.Serialize(writer, im); writer.Flush(); - - mstream.Position = 0; - using (StreamReader sreader = new StreamReader(mstream)) - { - imXml = sreader.ReadToEnd(); - } } + + imXml = Util.UTF8.GetString(mstream.ToArray()); } OfflineIMData data = new OfflineIMData(); data.PrincipalID = principalID; + data.FromID = new UUID(im.fromAgentID); data.Data = new Dictionary(); data.Data["Message"] = imXml; return m_Database.Store(data); } + + public void DeleteMessages(UUID userID) + { + m_Database.Delete("PrincipalID", userID.ToString()); + m_Database.Delete("FromID", userID.ToString()); + } + } } diff --git a/OpenSim/Data/IOfflineIMData.cs b/OpenSim/Data/IOfflineIMData.cs index e780304ec8..58501a3b7d 100644 --- a/OpenSim/Data/IOfflineIMData.cs +++ b/OpenSim/Data/IOfflineIMData.cs @@ -1,4 +1,4 @@ -/* +/* * Copyright (c) Contributors, http://opensimulator.org/ * See CONTRIBUTORS.TXT for a full list of copyright holders. * @@ -34,6 +34,7 @@ namespace OpenSim.Data public class OfflineIMData { public UUID PrincipalID; + public UUID FromID; public Dictionary Data; } diff --git a/OpenSim/Data/MySQL/Resources/IM_Store.migrations b/OpenSim/Data/MySQL/Resources/IM_Store.migrations index 7cfcd43888..f73475ee33 100644 --- a/OpenSim/Data/MySQL/Resources/IM_Store.migrations +++ b/OpenSim/Data/MySQL/Resources/IM_Store.migrations @@ -21,4 +21,14 @@ INSERT INTO `im_offline` SELECT * from `diva_im_offline`; DROP TABLE `diva_im_offline`; DELETE FROM `migrations` WHERE name='diva_im_Store'; -COMMIT; \ No newline at end of file +COMMIT; + +:VERSION 3 # -------------------------- + +BEGIN; + +ALTER TABLE `im_offline` + ADD `FromID` char(36) NOT NULL default '' AFTER `PrincipalID`, + ADD KEY `FromID` (`FromID`); + +COMMIT; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs index 678f3dc3a5..4dcb99f0ac 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs @@ -174,7 +174,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation #endregion - #region ISimulation + #region ISimulationService public IScene GetScene(UUID regionId) { @@ -353,7 +353,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation return false; } - #endregion /* IInterregionComms */ + #endregion #region Misc diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs index f45f560a96..cc014307af 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs @@ -146,7 +146,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation #endregion - #region IInterregionComms + #region ISimulationService public IScene GetScene(UUID regionId) { @@ -279,6 +279,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation return false; } - #endregion /* IInterregionComms */ + #endregion } } diff --git a/OpenSim/Region/Framework/Interfaces/IInterregionComms.cs b/OpenSim/Region/Framework/Interfaces/IInterregionComms.cs deleted file mode 100644 index 2d6287f87d..0000000000 --- a/OpenSim/Region/Framework/Interfaces/IInterregionComms.cs +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) Contributors, http://opensimulator.org/ - * See CONTRIBUTORS.TXT for a full list of copyright holders. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the OpenSimulator Project nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -using OpenMetaverse; -using OpenSim.Framework; -using OpenSim.Region.Framework.Scenes; - -namespace OpenSim.Region.Framework.Interfaces -{ - public delegate bool ChildAgentUpdateReceived(AgentData data); - - public interface IInterregionCommsOut - { - #region Agents - - bool SendCreateChildAgent(ulong regionHandle, AgentCircuitData aCircuit, uint teleportFlags, out string reason); - - /// - /// Full child agent update. - /// - /// - /// - /// - bool SendChildAgentUpdate(ulong regionHandle, AgentData data); - - /// - /// Short child agent update, mostly for position. - /// - /// - /// - /// - bool SendChildAgentUpdate(ulong regionHandle, AgentPosition data); - - bool SendRetrieveRootAgent(ulong regionHandle, UUID id, out IAgentData agent); - - /// - /// Message from receiving region to departing region, telling it got contacted by the client. - /// When sent over REST, it invokes the opaque uri. - /// - /// - /// - /// - /// - bool SendReleaseAgent(ulong regionHandle, UUID id, string uri); - - /// - /// Close agent. - /// - /// - /// - /// - bool SendCloseAgent(ulong regionHandle, UUID id); - - #endregion Agents - - #region Objects - - /// - /// Create an object in the destination region. This message is used primarily for prim crossing. - /// - /// - /// - /// - /// - bool SendCreateObject(ulong regionHandle, SceneObjectGroup sog, bool isLocalCall); - - /// - /// Create an object from the user's inventory in the destination region. - /// This message is used primarily by clients. - /// - /// - /// - /// - /// - bool SendCreateObject(ulong regionHandle, UUID userID, UUID itemID); - - #endregion Objects - - } - - // This may not be needed, but having it here for now. - public interface IInterregionCommsIn - { - event ChildAgentUpdateReceived OnChildAgentUpdate; - } - -} diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 610bcd63be..a9fe556595 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -4410,18 +4410,6 @@ namespace OpenSim.Region.Framework.Scenes return sp; } - public virtual bool IncomingRetrieveRootAgent(UUID id, out IAgentData agent) - { - agent = null; - ScenePresence sp = GetScenePresence(id); - if ((sp != null) && (!sp.IsChildAgent)) - { - sp.IsChildAgent = true; - return sp.CopyAgent(out agent); - } - - return false; - } /// /// Authenticated close (via network) /// diff --git a/OpenSim/Services/Interfaces/IOfflineIMService.cs b/OpenSim/Services/Interfaces/IOfflineIMService.cs index 28489670fc..588aaafb6b 100644 --- a/OpenSim/Services/Interfaces/IOfflineIMService.cs +++ b/OpenSim/Services/Interfaces/IOfflineIMService.cs @@ -35,7 +35,14 @@ namespace OpenSim.Services.Interfaces public interface IOfflineIMService { List GetMessages(UUID principalID); + bool StoreMessage(GridInstantMessage im, out string reason); + + /// + /// Delete messages to or from this user (or group). + /// + /// A user or group ID + void DeleteMessages(UUID userID); } public class OfflineIMDataUtils