From 38e8853e5761d09a7e8f580dd277d9b99b834696 Mon Sep 17 00:00:00 2001 From: Homer Horwitz Date: Sat, 1 Nov 2008 22:09:48 +0000 Subject: Megapatch that fixes/adds: friend offer/deny/accept, friendship termination, on-/offline updates, calling cards for friends. This adds methods in the DB layer and changes the MessagingServer, so a full update (incl. UGAIM) is necessary to get it working. Older regions shouldn't break, nor should older UGAIM break newer regions, but friends/presence will only work with all concerned parts (UGAIM, source region and destination region) at this revision (or later). I added the DB code for MSSQL, too, but couldn't test that. BEWARE: May contain bugs. --- .../Communications/CommunicationsManager.cs | 21 ++++++++++++ .../Communications/IInterRegionCommunications.cs | 38 ++++++++++++++++++++++ .../Framework/Communications/IMessagingService.cs | 37 +++++++++++++++++++++ .../Framework/Communications/UserManagerBase.cs | 24 +++++++++++++- OpenSim/Framework/FriendListItem.cs | 2 +- OpenSim/Framework/FriendRegionInfo.cs | 37 +++++++++++++++++++++ OpenSim/Framework/IClientAPI.cs | 2 ++ OpenSim/Framework/IUserData.cs | 11 +++++++ OpenSim/Framework/NetworkServersInfo.cs | 4 +++ OpenSim/Framework/Servers/BaseHttpServer.cs | 13 +++++++- 10 files changed, 186 insertions(+), 3 deletions(-) create mode 100644 OpenSim/Framework/Communications/IMessagingService.cs create mode 100644 OpenSim/Framework/FriendRegionInfo.cs (limited to 'OpenSim/Framework') diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs index dfe0fdc..bb4a853 100644 --- a/OpenSim/Framework/Communications/CommunicationsManager.cs +++ b/OpenSim/Framework/Communications/CommunicationsManager.cs @@ -50,6 +50,12 @@ namespace OpenSim.Framework.Communications } protected IUserService m_userService; + public IMessagingService MessageService + { + get { return m_messageService; } + } + protected IMessagingService m_messageService; + public IGridServices GridService { get { return m_gridService; } @@ -370,6 +376,21 @@ namespace OpenSim.Framework.Communications return m_userService.GetUserFriendList(friendlistowner); } + public Dictionary GetFriendRegionInfos(List uuids) + { + return m_messageService.GetFriendRegionInfos(uuids); + } + + public List InformFriendsInOtherRegion(UUID agentId, ulong destRegionHandle, List friends, bool online) + { + return m_interRegion.InformFriendsInOtherRegion(agentId, destRegionHandle, friends, online); + } + + public bool TriggerTerminateFriend(ulong regionHandle, UUID agentID, UUID exFriendID) + { + return m_interRegion.TriggerTerminateFriend(regionHandle, agentID, exFriendID); + } + #endregion #region Packet Handlers diff --git a/OpenSim/Framework/Communications/IInterRegionCommunications.cs b/OpenSim/Framework/Communications/IInterRegionCommunications.cs index 3dd5561..6b589b9 100644 --- a/OpenSim/Framework/Communications/IInterRegionCommunications.cs +++ b/OpenSim/Framework/Communications/IInterRegionCommunications.cs @@ -25,6 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System.Collections.Generic; using OpenMetaverse; namespace OpenSim.Framework.Communications @@ -46,5 +47,42 @@ namespace OpenSim.Framework.Communications bool AcknowledgePrimCrossed(ulong regionHandle, UUID primID); bool TellRegionToCloseChildConnection(ulong regionHandle, UUID agentID); + + /// + /// Try to inform friends in the given region about online status of agent. + /// + /// + /// The of the agent. + /// + /// + /// The regionHandle of the region. + /// + /// + /// A List of s of friends to inform in the given region. + /// + /// + /// Is the agent online or offline + /// + /// + /// A list of friends that couldn't be reached on this region. + /// + List InformFriendsInOtherRegion(UUID agentId, ulong destRegionHandle, List friends, bool online); + + /// + /// Send TerminateFriend of exFriendID to agent agentID in region regionHandle. + /// + /// + /// The handle of the region agentID is in (hopefully). + /// + /// + /// The agent to send the packet to. + /// + /// + /// The ex-friends ID. + /// + /// + /// Whether the packet could be sent. False if the agent couldn't be found in the region. + /// + bool TriggerTerminateFriend(ulong regionHandle, UUID agentID, UUID exFriendID); } } diff --git a/OpenSim/Framework/Communications/IMessagingService.cs b/OpenSim/Framework/Communications/IMessagingService.cs new file mode 100644 index 0000000..5d4cbf8 --- /dev/null +++ b/OpenSim/Framework/Communications/IMessagingService.cs @@ -0,0 +1,37 @@ +/* + * 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 OpenSim 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 System.Collections.Generic; +using OpenMetaverse; + +namespace OpenSim.Framework.Communications +{ + public interface IMessagingService + { + Dictionary GetFriendRegionInfos (List uuids); + } +} diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index ba9cf27..7189eee 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs @@ -35,6 +35,7 @@ using OpenMetaverse; using OpenMetaverse.StructuredData; using log4net; using Nwc.XmlRpc; +using OpenSim.Framework; using OpenSim.Framework.Statistics; namespace OpenSim.Framework.Communications @@ -42,7 +43,7 @@ namespace OpenSim.Framework.Communications /// /// Base class for user management (create, read, etc) /// - public abstract class UserManagerBase : IUserService, IUserServiceAdmin, IAvatarService + public abstract class UserManagerBase : IUserService, IUserServiceAdmin, IAvatarService, IMessagingService { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); @@ -285,6 +286,27 @@ namespace OpenSim.Framework.Communications return null; } + public Dictionary GetFriendRegionInfos (List uuids) + { + foreach (IUserDataPlugin plugin in _plugins) + { + try + { + Dictionary result = plugin.GetFriendRegionInfos(uuids); + + if (result != null) + { + return result; + } + } + catch (Exception e) + { + m_log.Info("[USERSTORAGE]: Unable to GetFriendRegionInfos via " + plugin.Name + "(" + e.ToString() + ")"); + } + } + return null; + } + public void StoreWebLoginKey(UUID agentID, UUID webLoginKey) { foreach (IUserDataPlugin plugin in _plugins) diff --git a/OpenSim/Framework/FriendListItem.cs b/OpenSim/Framework/FriendListItem.cs index 2861ce2..a60bc22 100644 --- a/OpenSim/Framework/FriendListItem.cs +++ b/OpenSim/Framework/FriendListItem.cs @@ -35,9 +35,9 @@ namespace OpenSim.Framework public UUID FriendListOwner; // These are what the list owner gives the friend permission to do + public uint FriendListOwnerPerms; // These are what the friend gives the listowner permission to do - public uint FriendListOwnerPerms; public uint FriendPerms; public bool onlinestatus = false; diff --git a/OpenSim/Framework/FriendRegionInfo.cs b/OpenSim/Framework/FriendRegionInfo.cs new file mode 100644 index 0000000..04e00e8 --- /dev/null +++ b/OpenSim/Framework/FriendRegionInfo.cs @@ -0,0 +1,37 @@ +/* + * 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 OpenSim 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 System; + +namespace OpenSim.Framework +{ + public class FriendRegionInfo + { + public bool isOnline; + public ulong regionHandle; + } +} diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 538a2e7..94bf3aa 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -925,6 +925,8 @@ namespace OpenSim.Framework void SendAcceptCallingCard(UUID transactionID); void SendDeclineCallingCard(UUID transactionID); + void SendTerminateFriend(UUID exFriendID); + void KillEndDone(); } } diff --git a/OpenSim/Framework/IUserData.cs b/OpenSim/Framework/IUserData.cs index 4089253..07159cc 100644 --- a/OpenSim/Framework/IUserData.cs +++ b/OpenSim/Framework/IUserData.cs @@ -136,6 +136,17 @@ namespace OpenSim.Framework List GetUserFriendList(UUID friendlistowner); /// + /// Returns a list of + /// A of , mapping the s to s. + /// + Dictionary GetFriendRegionInfos(List uuids); + + /// /// Attempts to move currency units between accounts (NOT RELIABLE / TRUSTWORTHY. DONT TRY RUN YOUR OWN CURRENCY EXCHANGE WITH REAL VALUES) /// /// The account to transfer from diff --git a/OpenSim/Framework/NetworkServersInfo.cs b/OpenSim/Framework/NetworkServersInfo.cs index 9f3014d..49b8ef9 100644 --- a/OpenSim/Framework/NetworkServersInfo.cs +++ b/OpenSim/Framework/NetworkServersInfo.cs @@ -53,6 +53,7 @@ namespace OpenSim.Framework public string HttpSSLCN = ""; public uint httpSSLPort = 9001; + public string MessagingURL = String.Empty; public NetworkServersInfo() { @@ -102,6 +103,9 @@ namespace OpenSim.Framework "http://127.0.0.1:" + InventoryConfig.DefaultHttpPort.ToString()); secureInventoryServer = config.Configs["Network"].GetBoolean("secure_inventory_server", true); + + MessagingURL = config.Configs["Network"].GetString("messaging_server_url", + "http://127.0.0.1:" + MessageServerConfig.DefaultHttpPort); } } } diff --git a/OpenSim/Framework/Servers/BaseHttpServer.cs b/OpenSim/Framework/Servers/BaseHttpServer.cs index 871ea57..98b44db 100644 --- a/OpenSim/Framework/Servers/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/BaseHttpServer.cs @@ -586,7 +586,18 @@ namespace OpenSim.Framework.Servers XmlRpcMethod method; if (m_rpcHandlers.TryGetValue(methodName, out method)) { - xmlRpcResponse = method(xmlRprcRequest); + try + { + xmlRpcResponse = method(xmlRprcRequest); + } + catch(Exception e) + { + // if the registered XmlRpc method threw an exception, we pass a fault-code along + xmlRpcResponse = new XmlRpcResponse(); + // Code probably set in accordance with http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php + xmlRpcResponse.SetFault(-32603, String.Format("Requested method [{0}] threw exception: {1}", + methodName, e.Message)); + } // if the method wasn't found, we can't determine KeepAlive state anyway, so lets do it only here response.KeepAlive = m_rpcHandlersKeepAlive[methodName]; } -- cgit v1.1