From 7cf970fb27297d9550d4bdb1d520e9c6ff0a381d Mon Sep 17 00:00:00 2001 From: BlueWall Date: Tue, 21 Feb 2012 14:21:03 -0500 Subject: V3 Support: This starts V3 support by adding a profile server url to the login response. This requires viewer support - which is also being worked on. --- OpenSim/Services/LLLoginService/LLLoginResponse.cs | 20 +++++++++++++++++++- OpenSim/Services/LLLoginService/LLLoginService.cs | 4 +++- 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/LLLoginService/LLLoginResponse.cs b/OpenSim/Services/LLLoginService/LLLoginResponse.cs index 1a874c8..b6f6d31 100644 --- a/OpenSim/Services/LLLoginService/LLLoginResponse.cs +++ b/OpenSim/Services/LLLoginService/LLLoginResponse.cs @@ -168,6 +168,9 @@ namespace OpenSim.Services.LLLoginService // Web map private string mapTileURL; + // Web Profiles + private string profileURL; + private string searchURL; // Error Flags @@ -220,7 +223,7 @@ namespace OpenSim.Services.LLLoginService public LLLoginResponse(UserAccount account, AgentCircuitData aCircuit, GridUserInfo pinfo, GridRegion destination, List invSkel, FriendInfo[] friendsList, ILibraryService libService, string where, string startlocation, Vector3 position, Vector3 lookAt, List gestures, string message, - GridRegion home, IPEndPoint clientIP, string mapTileURL, string searchURL, string currency) + GridRegion home, IPEndPoint clientIP, string mapTileURL, string profileURL, string searchURL, string currency) : this() { FillOutInventoryData(invSkel, libService); @@ -237,6 +240,8 @@ namespace OpenSim.Services.LLLoginService BuddList = ConvertFriendListItem(friendsList); StartLocation = where; MapTileURL = mapTileURL; + ProfileURL = profileURL; + SearchURL = searchURL; Currency = currency; @@ -384,6 +389,7 @@ namespace OpenSim.Services.LLLoginService InitialOutfitHash["gender"] = "female"; initialOutfit.Add(InitialOutfitHash); mapTileURL = String.Empty; + profileURL = String.Empty; searchURL = String.Empty; currency = String.Empty; @@ -456,6 +462,9 @@ namespace OpenSim.Services.LLLoginService if (mapTileURL != String.Empty) responseData["map-server-url"] = mapTileURL; + if (profileURL != String.Empty) + responseData["profile-server-url"] = profileURL; + if (m_buddyList != null) { responseData["buddy-list"] = m_buddyList.ToArray(); @@ -561,6 +570,9 @@ namespace OpenSim.Services.LLLoginService if (mapTileURL != String.Empty) map["map-server-url"] = OSD.FromString(mapTileURL); + if (profileURL != String.Empty) + map["profile-server-url"] = OSD.FromString(profileURL); + if (searchURL != String.Empty) map["search"] = OSD.FromString(searchURL); @@ -933,6 +945,12 @@ namespace OpenSim.Services.LLLoginService set { mapTileURL = value; } } + public string ProfileURL + { + get { return profileURL; } + set { profileURL = value; } + } + public string SearchURL { get { return searchURL; } diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs index 5dff512..02e62c8 100644 --- a/OpenSim/Services/LLLoginService/LLLoginService.cs +++ b/OpenSim/Services/LLLoginService/LLLoginService.cs @@ -74,6 +74,7 @@ namespace OpenSim.Services.LLLoginService protected string m_GatekeeperURL; protected bool m_AllowRemoteSetLoginLevel; protected string m_MapTileURL; + protected string m_ProfileURL; protected string m_SearchURL; protected string m_Currency; @@ -108,6 +109,7 @@ namespace OpenSim.Services.LLLoginService m_MinLoginLevel = m_LoginServerConfig.GetInt("MinLoginLevel", 0); m_GatekeeperURL = m_LoginServerConfig.GetString("GatekeeperURI", string.Empty); m_MapTileURL = m_LoginServerConfig.GetString("MapTileURL", string.Empty); + m_ProfileURL = m_LoginServerConfig.GetString("ProfileServerURL", string.Empty); m_SearchURL = m_LoginServerConfig.GetString("SearchURL", string.Empty); m_Currency = m_LoginServerConfig.GetString("Currency", string.Empty); @@ -413,7 +415,7 @@ namespace OpenSim.Services.LLLoginService // Finally, fill out the response and return it // LLLoginResponse response = new LLLoginResponse(account, aCircuit, guinfo, destination, inventorySkel, friendsList, m_LibraryService, - where, startLocation, position, lookAt, gestures, m_WelcomeMessage, home, clientIP, m_MapTileURL, m_SearchURL, m_Currency); + where, startLocation, position, lookAt, gestures, m_WelcomeMessage, home, clientIP, m_MapTileURL, m_ProfileURL, m_SearchURL, m_Currency); m_log.DebugFormat("[LLOGIN SERVICE]: All clear. Sending login response to client."); return response; -- cgit v1.1 From 165ae251ec132da30dc58513101e4ec438df8d2f Mon Sep 17 00:00:00 2001 From: BlueWall Date: Wed, 22 Feb 2012 16:36:28 -0500 Subject: V3 Support The V3 webapps need SSO capability and use OpenID. We need to send both our OpenID server url and a token for the user in the login response. --- OpenSim/Services/LLLoginService/LLLoginResponse.cs | 20 +++++++++++++++++++- OpenSim/Services/LLLoginService/LLLoginService.cs | 4 +++- 2 files changed, 22 insertions(+), 2 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/LLLoginService/LLLoginResponse.cs b/OpenSim/Services/LLLoginService/LLLoginResponse.cs index b6f6d31..844c5ae 100644 --- a/OpenSim/Services/LLLoginService/LLLoginResponse.cs +++ b/OpenSim/Services/LLLoginService/LLLoginResponse.cs @@ -171,6 +171,9 @@ namespace OpenSim.Services.LLLoginService // Web Profiles private string profileURL; + // OpenID + private string openIDURL; + private string searchURL; // Error Flags @@ -223,7 +226,7 @@ namespace OpenSim.Services.LLLoginService public LLLoginResponse(UserAccount account, AgentCircuitData aCircuit, GridUserInfo pinfo, GridRegion destination, List invSkel, FriendInfo[] friendsList, ILibraryService libService, string where, string startlocation, Vector3 position, Vector3 lookAt, List gestures, string message, - GridRegion home, IPEndPoint clientIP, string mapTileURL, string profileURL, string searchURL, string currency) + GridRegion home, IPEndPoint clientIP, string mapTileURL, string profileURL, string openIDURL, string searchURL, string currency) : this() { FillOutInventoryData(invSkel, libService); @@ -241,6 +244,7 @@ namespace OpenSim.Services.LLLoginService StartLocation = where; MapTileURL = mapTileURL; ProfileURL = profileURL; + OpenIDURL = openIDURL; SearchURL = searchURL; Currency = currency; @@ -390,6 +394,7 @@ namespace OpenSim.Services.LLLoginService initialOutfit.Add(InitialOutfitHash); mapTileURL = String.Empty; profileURL = String.Empty; + openIDURL = String.Empty; searchURL = String.Empty; currency = String.Empty; @@ -465,6 +470,10 @@ namespace OpenSim.Services.LLLoginService if (profileURL != String.Empty) responseData["profile-server-url"] = profileURL; + // We need to send an openid_token back in the response too + if (openIDURL != String.Empty) + responseData["openid_url"] = openIDURL; + if (m_buddyList != null) { responseData["buddy-list"] = m_buddyList.ToArray(); @@ -573,6 +582,9 @@ namespace OpenSim.Services.LLLoginService if (profileURL != String.Empty) map["profile-server-url"] = OSD.FromString(profileURL); + if (openIDURL != String.Empty) + map["openid_url"] = OSD.FromString(openIDURL); + if (searchURL != String.Empty) map["search"] = OSD.FromString(searchURL); @@ -951,6 +963,12 @@ namespace OpenSim.Services.LLLoginService set { profileURL = value; } } + public string OpenIDURL + { + get { return openIDURL; } + set { openIDURL = value; } + } + public string SearchURL { get { return searchURL; } diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs index 02e62c8..f7b38d4 100644 --- a/OpenSim/Services/LLLoginService/LLLoginService.cs +++ b/OpenSim/Services/LLLoginService/LLLoginService.cs @@ -75,6 +75,7 @@ namespace OpenSim.Services.LLLoginService protected bool m_AllowRemoteSetLoginLevel; protected string m_MapTileURL; protected string m_ProfileURL; + protected string m_OpenIDURL; protected string m_SearchURL; protected string m_Currency; @@ -110,6 +111,7 @@ namespace OpenSim.Services.LLLoginService m_GatekeeperURL = m_LoginServerConfig.GetString("GatekeeperURI", string.Empty); m_MapTileURL = m_LoginServerConfig.GetString("MapTileURL", string.Empty); m_ProfileURL = m_LoginServerConfig.GetString("ProfileServerURL", string.Empty); + m_OpenIDURL = m_LoginServerConfig.GetString("OpenIDServerURL", String.Empty); m_SearchURL = m_LoginServerConfig.GetString("SearchURL", string.Empty); m_Currency = m_LoginServerConfig.GetString("Currency", string.Empty); @@ -415,7 +417,7 @@ namespace OpenSim.Services.LLLoginService // Finally, fill out the response and return it // LLLoginResponse response = new LLLoginResponse(account, aCircuit, guinfo, destination, inventorySkel, friendsList, m_LibraryService, - where, startLocation, position, lookAt, gestures, m_WelcomeMessage, home, clientIP, m_MapTileURL, m_ProfileURL, m_SearchURL, m_Currency); + where, startLocation, position, lookAt, gestures, m_WelcomeMessage, home, clientIP, m_MapTileURL, m_ProfileURL, m_OpenIDURL, m_SearchURL, m_Currency); m_log.DebugFormat("[LLOGIN SERVICE]: All clear. Sending login response to client."); return response; -- cgit v1.1 From dd63cd165631886806233958526f994baf60e855 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 2 Mar 2012 02:23:35 +0000 Subject: Start by adding XAssetService as a copy of the existing AssetService. This is the start of exploring the creation of a bundled OpenSimulator asset service that does de-duplication and possibly file storage of assets. Along the lines of coyled's SRAS, but not intended to replace, merely to act as a more performant bundled default. Might end up nicking stuff from kcozen's patch at http://opensimulator.org/mantis/view.php?id=5429 More details at http://opensimulator.org/wiki/Feature_Proposals/Deduplicating_Asset_Service Feedback and discussion welcome as commits are made. --- OpenSim/Services/AssetService/XAssetService.cs | 213 +++++++++++++++++++++++++ 1 file changed, 213 insertions(+) create mode 100644 OpenSim/Services/AssetService/XAssetService.cs (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/AssetService/XAssetService.cs b/OpenSim/Services/AssetService/XAssetService.cs new file mode 100644 index 0000000..d161c58 --- /dev/null +++ b/OpenSim/Services/AssetService/XAssetService.cs @@ -0,0 +1,213 @@ +/* + * 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 System; +using System.Collections.Generic; +using System.IO; +using System.Reflection; +using Nini.Config; +using log4net; +using OpenSim.Framework; +using OpenSim.Data; +using OpenSim.Services.Interfaces; +using OpenMetaverse; + +namespace OpenSim.Services.AssetService +{ + /// + /// This will be developed into a de-duplicating asset service. + /// XXX: Currently it's a just a copy of the existing AssetService. so please don't attempt to use it. + /// + public class XAssetService : AssetServiceBase, IAssetService + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + protected static XAssetService m_RootInstance; + + public XAssetService(IConfigSource config) : base(config) + { + if (m_RootInstance == null) + { + m_RootInstance = this; + + if (m_AssetLoader != null) + { + IConfig assetConfig = config.Configs["AssetService"]; + if (assetConfig == null) + throw new Exception("No AssetService configuration"); + + string loaderArgs = assetConfig.GetString("AssetLoaderArgs", + String.Empty); + + bool assetLoaderEnabled = assetConfig.GetBoolean("AssetLoaderEnabled", true); + + if (assetLoaderEnabled) + { + m_log.DebugFormat("[XASSET SERVICE]: Loading default asset set from {0}", loaderArgs); + + m_AssetLoader.ForEachDefaultXmlAsset( + loaderArgs, + delegate(AssetBase a) + { + AssetBase existingAsset = Get(a.ID); +// AssetMetadata existingMetadata = GetMetadata(a.ID); + + if (existingAsset == null || Util.SHA1Hash(existingAsset.Data) != Util.SHA1Hash(a.Data)) + { +// m_log.DebugFormat("[ASSET]: Storing {0} {1}", a.Name, a.ID); + Store(a); + } + }); + } + + m_log.Debug("[XASSET SERVICE]: Local asset service enabled"); + } + } + } + + public virtual AssetBase Get(string id) + { +// m_log.DebugFormat("[ASSET SERVICE]: Get asset for {0}", id); + + UUID assetID; + + if (!UUID.TryParse(id, out assetID)) + { + m_log.WarnFormat("[XASSET SERVICE]: Could not parse requested asset id {0}", id); + return null; + } + + try + { + return m_Database.GetAsset(assetID); + } + catch (Exception e) + { + m_log.ErrorFormat("[XASSET SERVICE]: Exception getting asset {0} {1}", assetID, e); + return null; + } + } + + public virtual AssetBase GetCached(string id) + { + return Get(id); + } + + public virtual AssetMetadata GetMetadata(string id) + { +// m_log.DebugFormat("[XASSET SERVICE]: Get asset metadata for {0}", id); + + UUID assetID; + + if (!UUID.TryParse(id, out assetID)) + return null; + + AssetBase asset = m_Database.GetAsset(assetID); + if (asset != null) + return asset.Metadata; + + return null; + } + + public virtual byte[] GetData(string id) + { +// m_log.DebugFormat("[XASSET SERVICE]: Get asset data for {0}", id); + + UUID assetID; + + if (!UUID.TryParse(id, out assetID)) + return null; + + AssetBase asset = m_Database.GetAsset(assetID); + return asset.Data; + } + + public virtual bool Get(string id, Object sender, AssetRetrieved handler) + { + //m_log.DebugFormat("[XASSET SERVICE]: Get asset async {0}", id); + + UUID assetID; + + if (!UUID.TryParse(id, out assetID)) + return false; + + AssetBase asset = m_Database.GetAsset(assetID); + + //m_log.DebugFormat("[XASSET SERVICE]: Got asset {0}", asset); + + handler(id, sender, asset); + + return true; + } + + public virtual string Store(AssetBase asset) + { + if (!m_Database.ExistsAsset(asset.FullID)) + { +// m_log.DebugFormat( +// "[XASSET SERVICE]: Storing asset {0} {1}, bytes {2}", asset.Name, asset.FullID, asset.Data.Length); + m_Database.StoreAsset(asset); + } +// else +// { +// m_log.DebugFormat( +// "[XASSET SERVICE]: Not storing asset {0} {1}, bytes {2} as it already exists", asset.Name, asset.FullID, asset.Data.Length); +// } + + return asset.ID; + } + + public bool UpdateContent(string id, byte[] data) + { + return false; + } + + public virtual bool Delete(string id) + { + m_log.DebugFormat("[XASSET SERVICE]: Deleting asset {0}", 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); + } + else + { + m_log.DebugFormat("[XASSET SERVICE]: Request to delete asset {0}, but flags are not Maptile", id); + } + + return false; + } + } +} + -- cgit v1.1 From d242d47e5cf1274225091e843e065366a3620c14 Mon Sep 17 00:00:00 2001 From: BlueWall Date: Fri, 2 Mar 2012 15:05:06 -0500 Subject: OpenID auth needs hashing before authenticating --- OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs index 48eb3f8..5f1bde1 100644 --- a/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs +++ b/OpenSim/Services/AuthenticationService/PasswordAuthenticationService.cs @@ -80,7 +80,7 @@ namespace OpenSim.Services.AuthenticationService { string hashed = Util.Md5Hash(password + ":" + data.Data["passwordSalt"].ToString()); - //m_log.DebugFormat("[PASS AUTH]: got {0}; hashed = {1}; stored = {2}", password, hashed, data.Data["passwordHash"].ToString()); + m_log.DebugFormat("[PASS AUTH]: got {0}; hashed = {1}; stored = {2}", password, hashed, data.Data["passwordHash"].ToString()); if (data.Data["passwordHash"].ToString() == hashed) { -- cgit v1.1 From 749c3fef8ad2d3af97fcd9ab9c72740675e46715 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 8 Mar 2012 01:51:37 +0000 Subject: Change "help" to display categories/module list then "help " to display commands in a category. This is to deal with the hundred lines of command splurge when one previously typed "help" Modelled somewhat on the mysql console One can still type help to get per command help at any point. Categories capitalized to avoid conflict with the all-lowercase commands (except for commander system, as of yet). Does not affect command parsing or any other aspects of the console apart from the help system. Backwards compatible with existing modules. --- OpenSim/Services/GridService/GridService.cs | 4 ++-- OpenSim/Services/LLLoginService/LLLoginService.cs | 6 +++--- OpenSim/Services/UserAccountService/UserAccountService.cs | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 89f0716..3dc87bc 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs @@ -84,14 +84,14 @@ namespace OpenSim.Services.GridService if (MainConsole.Instance != null) { - MainConsole.Instance.Commands.AddCommand("grid", true, + MainConsole.Instance.Commands.AddCommand("Regions", true, "show region", "show region ", "Show details on a region", String.Empty, HandleShowRegion); - MainConsole.Instance.Commands.AddCommand("grid", true, + MainConsole.Instance.Commands.AddCommand("Regions", true, "set region flags", "set region flags ", "Set database flags for region", diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs index f7b38d4..db8a9cb 100644 --- a/OpenSim/Services/LLLoginService/LLLoginService.cs +++ b/OpenSim/Services/LLLoginService/LLLoginService.cs @@ -893,16 +893,16 @@ namespace OpenSim.Services.LLLoginService private void RegisterCommands() { //MainConsole.Instance.Commands.AddCommand - MainConsole.Instance.Commands.AddCommand("loginservice", false, "login level", + MainConsole.Instance.Commands.AddCommand("Users", false, "login level", "login level ", "Set the minimum user level to log in", HandleLoginCommand); - MainConsole.Instance.Commands.AddCommand("loginservice", false, "login reset", + MainConsole.Instance.Commands.AddCommand("Users", false, "login reset", "login reset", "Reset the login level to allow all users", HandleLoginCommand); - MainConsole.Instance.Commands.AddCommand("loginservice", false, "login text", + MainConsole.Instance.Commands.AddCommand("Users", false, "login text", "login text ", "Set the text users will see on login", HandleLoginCommand); diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs index 4a29690..6f1d745 100644 --- a/OpenSim/Services/UserAccountService/UserAccountService.cs +++ b/OpenSim/Services/UserAccountService/UserAccountService.cs @@ -89,17 +89,17 @@ namespace OpenSim.Services.UserAccountService if (m_RootInstance == null && MainConsole.Instance != null) { m_RootInstance = this; - MainConsole.Instance.Commands.AddCommand("UserService", false, + MainConsole.Instance.Commands.AddCommand("Users", false, "create user", "create user [ [ [ [ []]]]]", "Create a new user", HandleCreateUser); - MainConsole.Instance.Commands.AddCommand("UserService", false, + MainConsole.Instance.Commands.AddCommand("Users", false, "reset user password", "reset user password [ [ []]]", "Reset a user password", HandleResetUserPassword); - MainConsole.Instance.Commands.AddCommand("UserService", false, + MainConsole.Instance.Commands.AddCommand("Users", false, "set user level", "set user level [ [ []]]", "Set user level. If >= 200 and 'allow_grid_gods = true' in OpenSim.ini, " @@ -107,7 +107,7 @@ namespace OpenSim.Services.UserAccountService + "It will also affect the 'login level' command. ", HandleSetUserLevel); - MainConsole.Instance.Commands.AddCommand("UserService", false, + MainConsole.Instance.Commands.AddCommand("Users", false, "show account", "show account ", "Show account details for the given user", HandleShowAccount); -- cgit v1.1 From 9c8ef96301a0ff11dd5faa191b7fd49e7d1bf79d Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 8 Mar 2012 15:55:43 -0800 Subject: Fixes mantis #5923 --- OpenSim/Services/HypergridService/GatekeeperService.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/HypergridService/GatekeeperService.cs b/OpenSim/Services/HypergridService/GatekeeperService.cs index 0a59f86..4e38687 100644 --- a/OpenSim/Services/HypergridService/GatekeeperService.cs +++ b/OpenSim/Services/HypergridService/GatekeeperService.cs @@ -296,9 +296,10 @@ namespace OpenSim.Services.HypergridService aCircuit.firstname = account.FirstName; aCircuit.lastname = account.LastName; } - if (account == null && !aCircuit.lastname.StartsWith("@")) + if (account == null) { - aCircuit.firstname = aCircuit.firstname + "." + aCircuit.lastname; + if (!aCircuit.lastname.StartsWith("@")) + aCircuit.firstname = aCircuit.firstname + "." + aCircuit.lastname; try { Uri uri = new Uri(aCircuit.ServiceURLs["HomeURI"].ToString()); -- cgit v1.1 From 8a34d1b710349b955b118d616f6ddabc76ae7f1f Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 8 Mar 2012 18:28:46 -0800 Subject: HG inventory/asset transfers: serialize asset posts. I'm using the same pattern as suggested in the patch mantis #5921. Testing it in this smaller context to see how it works. --- .../Connectors/Asset/HGAssetServiceConnector.cs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/Asset/HGAssetServiceConnector.cs b/OpenSim/Services/Connectors/Asset/HGAssetServiceConnector.cs index bb5d51f..c395178 100644 --- a/OpenSim/Services/Connectors/Asset/HGAssetServiceConnector.cs +++ b/OpenSim/Services/Connectors/Asset/HGAssetServiceConnector.cs @@ -45,6 +45,24 @@ namespace OpenSim.Services.Connectors LogManager.GetLogger( MethodBase.GetCurrentMethod().DeclaringType); + private Dictionary m_endpointSerializer = new Dictionary(); + private object EndPointLock(IAssetService connector) + { + lock (m_endpointSerializer) + { + object eplock = null; + + if (! m_endpointSerializer.TryGetValue(connector, out eplock)) + { + eplock = new object(); + m_endpointSerializer.Add(connector, eplock); + // m_log.WarnFormat("[WEB UTIL] add a new host to end point serializer {0}",endpoint); + } + + return eplock; + } + } + private Dictionary m_connectors = new Dictionary(); public HGAssetServiceConnector(IConfigSource source) @@ -197,7 +215,8 @@ namespace OpenSim.Services.Connectors IAssetService connector = GetConnector(url); // Restore the assetID to a simple UUID asset.ID = assetID; - return connector.Store(asset); + lock (EndPointLock(connector)) + return connector.Store(asset); } return String.Empty; -- cgit v1.1 From a58152bd2af64493e655d6f559bc366c38433187 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 9 Mar 2012 12:59:24 -0800 Subject: More on inventory transfer hold ups: - Added an inventory cache for caching root and system folders - Synchronized the remote inventory connector, so that all the remote inventory calls are serialized This will not make much difference in the hold ups. We'd have to move the FireAndForget high up to AddInventoryItem, but that opens up a can of worms regarding the notification of the recipient... the recipient would be notified of the offer before the items are effectively in his inventory, which could lead to surprises. --- OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs b/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs index a662abb..39e983b 100644 --- a/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs +++ b/OpenSim/Services/Connectors/Inventory/XInventoryConnector.cs @@ -48,6 +48,8 @@ namespace OpenSim.Services.Connectors private string m_ServerURI = String.Empty; + private object m_Lock = new object(); + public XInventoryServicesConnector() { } @@ -514,9 +516,11 @@ namespace OpenSim.Services.Connectors { sendData["METHOD"] = method; - string reply = SynchronousRestFormsRequester.MakeRequest("POST", - m_ServerURI + "/xinventory", - ServerUtils.BuildQueryString(sendData)); + string reply = string.Empty; + lock (m_Lock) + reply = SynchronousRestFormsRequester.MakeRequest("POST", + m_ServerURI + "/xinventory", + ServerUtils.BuildQueryString(sendData)); Dictionary replyData = ServerUtils.ParseXmlResponse( reply); -- cgit v1.1 From e0dd38f6722e891cfc91c8d795604b7b78c0bc81 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Mon, 12 Mar 2012 10:07:04 -0700 Subject: Rename the stream extension method WebUtil.CopyTo() to WebUtil.CopyStream(). .NET 4.0 added the method Stream.CopyTo(stream, bufferSize). For .NET 3.5 and before, WebUtil defined an extension method for Stream with the signature Stream.CopyTo(stream, maxBytesToCopy). The meaning of the second parameter is different in the two forms and depending on which compiler and/or runtime you use, you could get one form or the other. Crashes ensue. This change renames the WebUtil stream copy method to something that cannot be confused with the new CopyTo method defined in .NET 4.0. --- OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs index 99523a1..6bfc5cc 100644 --- a/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs +++ b/OpenSim/Services/Connectors/SimianGrid/SimianAssetServiceConnector.cs @@ -477,7 +477,7 @@ namespace OpenSim.Services.Connectors.SimianGrid // Grab the asset data from the response stream using (MemoryStream stream = new MemoryStream()) { - responseStream.CopyTo(stream, 4096); + responseStream.CopyStream(stream, Int32.MaxValue); asset.Data = stream.ToArray(); } } -- cgit v1.1 From d1256536b500a0d72eb643635d10c65980ea2588 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 17 Mar 2012 21:27:28 -0700 Subject: Added GetUUID(first, last) on UserAgentsService so that we can finally make direct user connections. --- .../Hypergrid/UserAgentServiceConnector.cs | 61 +++++++++++++++++++++- .../Services/HypergridService/UserAgentService.cs | 10 ++++ OpenSim/Services/Interfaces/IHypergridServices.cs | 2 + 3 files changed, 72 insertions(+), 1 deletion(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs index 5b27cf6..bf86035 100644 --- a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs @@ -789,13 +789,72 @@ namespace OpenSim.Services.Connectors.Hypergrid } catch { - m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on LocateUser response."); + m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on GetUUI response."); // reason = "Exception: " + e.Message; } return uui; } + public UUID GetUUID(String first, String last) + { + Hashtable hash = new Hashtable(); + hash["first"] = first; + hash["last"] = last; + + IList paramList = new ArrayList(); + paramList.Add(hash); + + XmlRpcRequest request = new XmlRpcRequest("get_uuid", paramList); + // string reason = string.Empty; + + // Send and get reply + UUID uuid = UUID.Zero; + XmlRpcResponse response = null; + try + { + response = request.Send(m_ServerURL, 10000); + } + catch + { + m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetUUID", m_ServerURL); + // reason = "Exception: " + e.Message; + return uuid; + } + + if (response.IsFault) + { + m_log.ErrorFormat("[USER AGENT CONNECTOR]: remote call to {0} for GetUUID returned an error: {1}", m_ServerURL, response.FaultString); + // reason = "XMLRPC Fault"; + return uuid; + } + + hash = (Hashtable)response.Value; + //foreach (Object o in hash) + // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); + try + { + if (hash == null) + { + m_log.ErrorFormat("[USER AGENT CONNECTOR]: GetUUDI Got null response from {0}! THIS IS BAAAAD", m_ServerURL); + // reason = "Internal error 1"; + return uuid; + } + + // Here's the actual response + if (hash.ContainsKey("UUID")) + UUID.TryParse(hash["UUID"].ToString(), out uuid); + + } + catch + { + m_log.ErrorFormat("[USER AGENT CONNECTOR]: Got exception on UUID response."); + // reason = "Exception: " + e.Message; + } + + return uuid; + } + private bool GetBoolResponse(XmlRpcRequest request, out string reason) { //m_log.Debug("[USER AGENT CONNECTOR]: GetBoolResponse from/to " + m_ServerURL); diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs index f681df4..5eca801 100644 --- a/OpenSim/Services/HypergridService/UserAgentService.cs +++ b/OpenSim/Services/HypergridService/UserAgentService.cs @@ -566,6 +566,16 @@ namespace OpenSim.Services.HypergridService return string.Empty; } + + public UUID GetUUID(String first, String last) + { + // Let's see if it's a local user + UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, first, last); + if (account != null) + return account.PrincipalID; + else + return UUID.Zero; + } } class TravelingAgentInfo diff --git a/OpenSim/Services/Interfaces/IHypergridServices.cs b/OpenSim/Services/Interfaces/IHypergridServices.cs index 5b293ac..0cd44f7 100644 --- a/OpenSim/Services/Interfaces/IHypergridServices.cs +++ b/OpenSim/Services/Interfaces/IHypergridServices.cs @@ -62,6 +62,8 @@ namespace OpenSim.Services.Interfaces // on behalf of the userID string GetUUI(UUID userID, UUID targetUserID); + UUID GetUUID(String first, String last); + // Returns the local friends online List StatusNotification(List friends, UUID userID, bool online); //List GetOnlineFriends(UUID userID, List friends); -- cgit v1.1 From ab54ce1907e26935bfb847742d4f5aa95d34aca0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 19 Mar 2012 00:18:04 +0000 Subject: Fix configuration problems where XAssetDatabasePlugin was picked up accidentally. The asset data plugin now implements IXAssetData rather than IAssetData so the ordinary AssetService should no longer pick it up. This replaces the changes in 92b1ade. There is no longer any need to adjust your StandaloneCommon.ini/Robust.ini/Robust.HG.ini files. This may explain very recent issues in the last few weeks where textures have been disappearing or turning white (as they were going to different places). Unfortunately, you will need to rollback to an earlier database backup or reupload the textures. --- OpenSim/Services/AssetService/XAssetService.cs | 2 +- OpenSim/Services/AssetService/XAssetServiceBase.cs | 94 ++++++++++++++++++++++ 2 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 OpenSim/Services/AssetService/XAssetServiceBase.cs (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/AssetService/XAssetService.cs b/OpenSim/Services/AssetService/XAssetService.cs index d161c58..05eb125 100644 --- a/OpenSim/Services/AssetService/XAssetService.cs +++ b/OpenSim/Services/AssetService/XAssetService.cs @@ -42,7 +42,7 @@ namespace OpenSim.Services.AssetService /// This will be developed into a de-duplicating asset service. /// XXX: Currently it's a just a copy of the existing AssetService. so please don't attempt to use it. /// - public class XAssetService : AssetServiceBase, IAssetService + public class XAssetService : XAssetServiceBase, IAssetService { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); diff --git a/OpenSim/Services/AssetService/XAssetServiceBase.cs b/OpenSim/Services/AssetService/XAssetServiceBase.cs new file mode 100644 index 0000000..0c5c2c3 --- /dev/null +++ b/OpenSim/Services/AssetService/XAssetServiceBase.cs @@ -0,0 +1,94 @@ +/* + * 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 System; +using System.Reflection; +using Nini.Config; +using OpenSim.Framework; +using OpenSim.Data; +using OpenSim.Services.Interfaces; +using OpenSim.Services.Base; + +namespace OpenSim.Services.AssetService +{ + public class XAssetServiceBase : ServiceBase + { + protected IXAssetDataPlugin m_Database = null; + protected IAssetLoader m_AssetLoader = null; + + public XAssetServiceBase(IConfigSource config) : base(config) + { + string dllName = String.Empty; + string connString = String.Empty; + + // + // Try reading the [AssetService] section first, if it exists + // + IConfig assetConfig = config.Configs["AssetService"]; + if (assetConfig != null) + { + dllName = assetConfig.GetString("StorageProvider", dllName); + connString = assetConfig.GetString("ConnectionString", connString); + } + + // + // Try reading the [DatabaseService] section, if it exists + // + IConfig dbConfig = config.Configs["DatabaseService"]; + if (dbConfig != null) + { + if (dllName == String.Empty) + dllName = dbConfig.GetString("StorageProvider", String.Empty); + if (connString == String.Empty) + connString = dbConfig.GetString("ConnectionString", String.Empty); + } + + // + // We tried, but this doesn't exist. We can't proceed. + // + if (dllName.Equals(String.Empty)) + throw new Exception("No StorageProvider configured"); + + m_Database = LoadPlugin(dllName); + if (m_Database == null) + throw new Exception("Could not find a storage interface in the given module"); + + m_Database.Initialise(connString); + + string loaderName = assetConfig.GetString("DefaultAssetLoader", + String.Empty); + + if (loaderName != String.Empty) + { + m_AssetLoader = LoadPlugin(loaderName); + + if (m_AssetLoader == null) + throw new Exception("Asset loader could not be loaded"); + } + } + } +} \ No newline at end of file -- cgit v1.1 From 4cbaf053cf96c8a4f3469cbceedbf3dbb001912d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 20 Mar 2012 00:53:33 +0000 Subject: Fix small typo --- OpenSim/Services/UserAccountService/UserAccountService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs index 6f1d745..a281b3b 100644 --- a/OpenSim/Services/UserAccountService/UserAccountService.cs +++ b/OpenSim/Services/UserAccountService/UserAccountService.cs @@ -521,7 +521,7 @@ namespace OpenSim.Services.UserAccountService else { m_log.DebugFormat( - "[USER ACCOUNT SERVICE]; Created user inventory for {0} {1}", firstName, lastName); + "[USER ACCOUNT SERVICE]: Created user inventory for {0} {1}", firstName, lastName); } if (m_CreateDefaultAvatarEntries) -- cgit v1.1 From d08ad6459a03a6a5a6a551fd2b275f1c7da94d8e Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 20 Mar 2012 17:14:19 -0700 Subject: HG Friends: allow the establishment of HG friendships without requiring co-presence in the same sim. Using avatar picker, users can now search for names such as "first.last@grid.com:9000", find them, and request friendship. Friendship requests are stored if target user is offline. TESTED ON STANDALONE ONLY. --- .../Connectors/Friends/FriendsSimConnector.cs | 20 +- .../Hypergrid/HGFriendsServiceConnector.cs | 67 ++++- .../Services/HypergridService/HGFriendsService.cs | 301 +++++++++++++++++++++ OpenSim/Services/Interfaces/IHypergridServices.cs | 11 + 4 files changed, 388 insertions(+), 11 deletions(-) create mode 100644 OpenSim/Services/HypergridService/HGFriendsService.cs (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs b/OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs index eea9853..3fd0c53 100644 --- a/OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs +++ b/OpenSim/Services/Connectors/Friends/FriendsSimConnector.cs @@ -43,8 +43,18 @@ namespace OpenSim.Services.Connectors.Friends { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + protected virtual string ServicePath() + { + return "friends"; + } + public bool FriendshipOffered(GridRegion region, UUID userID, UUID friendID, string message) { + return FriendshipOffered(region, userID, friendID, message, String.Empty); + } + + public virtual bool FriendshipOffered(GridRegion region, UUID userID, UUID friendID, string message, string userName) + { Dictionary sendData = new Dictionary(); //sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString(); //sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString(); @@ -53,9 +63,10 @@ namespace OpenSim.Services.Connectors.Friends sendData["FromID"] = userID.ToString(); sendData["ToID"] = friendID.ToString(); sendData["Message"] = message; + if (userName != String.Empty) + sendData["FromName"] = userName; return Call(region, sendData); - } public bool FriendshipApproved(GridRegion region, UUID userID, string userName, UUID friendID) @@ -138,8 +149,11 @@ namespace OpenSim.Services.Connectors.Friends if (region == null) return false; - m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: region: {0}", region.ExternalHostName + ":" + region.HttpPort); - string uri = "http://" + region.ExternalHostName + ":" + region.HttpPort + "/friends"; + string path = ServicePath(); + if (!region.ServerURI.EndsWith("/")) + path = "/" + path; + string uri = region.ServerURI + path; + m_log.DebugFormat("[FRIENDS SIM CONNECTOR]: calling {0}", uri); try { diff --git a/OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs index af4b0da..e3f3260 100644 --- a/OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs @@ -40,7 +40,7 @@ using OpenMetaverse; namespace OpenSim.Services.Connectors.Hypergrid { - public class HGFriendsServicesConnector + public class HGFriendsServicesConnector : FriendsSimConnector { private static readonly ILog m_log = LogManager.GetLogger( @@ -66,6 +66,11 @@ namespace OpenSim.Services.Connectors.Hypergrid m_SessionID = sessionID; } + protected override string ServicePath() + { + return "hgfriends"; + } + #region IFriendsService public uint GetFriendPerms(UUID PrincipalID, UUID friendID) @@ -187,23 +192,69 @@ namespace OpenSim.Services.Connectors.Hypergrid { Dictionary replyData = ServerUtils.ParseXmlResponse(reply); - if ((replyData != null) && replyData.ContainsKey("Result") && (replyData["Result"] != null)) + if (replyData.ContainsKey("RESULT")) { - bool success = false; - Boolean.TryParse(replyData["Result"].ToString(), out success); - return success; + if (replyData["RESULT"].ToString().ToLower() == "true") + return true; + else + return false; } else - m_log.DebugFormat("[HGFRIENDS CONNECTOR]: Delete {0} {1} received null response", - PrincipalID, Friend); + m_log.DebugFormat("[HGFRIENDS CONNECTOR]: reply data does not contain result field"); + } else - m_log.DebugFormat("[HGFRIENDS CONNECTOR]: DeleteFriend received null reply"); + m_log.DebugFormat("[HGFRIENDS CONNECTOR]: received empty reply"); return false; } + public bool ValidateFriendshipOffered(UUID fromID, UUID toID) + { + FriendInfo finfo = new FriendInfo(); + finfo.PrincipalID = fromID; + finfo.Friend = toID.ToString(); + + Dictionary sendData = finfo.ToKeyValuePairs(); + + sendData["METHOD"] = "validate_friendship_offered"; + + string reply = string.Empty; + string uri = m_ServerURI + "/hgfriends"; + try + { + reply = SynchronousRestFormsRequester.MakeRequest("POST", + uri, + ServerUtils.BuildQueryString(sendData)); + } + catch (Exception e) + { + m_log.DebugFormat("[HGFRIENDS CONNECTOR]: Exception when contacting friends server at {0}: {1}", uri, e.Message); + return false; + } + + if (reply != string.Empty) + { + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + + if (replyData.ContainsKey("RESULT")) + { + if (replyData["RESULT"].ToString().ToLower() == "true") + return true; + else + return false; + } + else + m_log.DebugFormat("[HGFRIENDS CONNECTOR]: reply data does not contain result field"); + + } + else + m_log.DebugFormat("[HGFRIENDS CONNECTOR]: received empty reply"); + + return false; + + } #endregion } } \ No newline at end of file diff --git a/OpenSim/Services/HypergridService/HGFriendsService.cs b/OpenSim/Services/HypergridService/HGFriendsService.cs new file mode 100644 index 0000000..19ee3e2 --- /dev/null +++ b/OpenSim/Services/HypergridService/HGFriendsService.cs @@ -0,0 +1,301 @@ +/* + * 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 System; +using System.Collections.Generic; +using System.Net; +using System.Reflection; + +using OpenSim.Framework; +using OpenSim.Services.Connectors.Friends; +using OpenSim.Services.Connectors.Hypergrid; +using OpenSim.Services.Interfaces; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; +using OpenSim.Server.Base; +using FriendInfo = OpenSim.Services.Interfaces.FriendInfo; + +using OpenMetaverse; +using log4net; +using Nini.Config; + +namespace OpenSim.Services.HypergridService +{ + /// + /// W2W social networking + /// + public class HGFriendsService : IHGFriendsService + { + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + + static bool m_Initialized = false; + + protected static IGridUserService m_GridUserService; + protected static IGridService m_GridService; + protected static IGatekeeperService m_GatekeeperService; + protected static IFriendsService m_FriendsService; + protected static IPresenceService m_PresenceService; + protected static IUserAccountService m_UserAccountService; + protected static IFriendsSimConnector m_FriendsLocalSimConnector; // standalone, points to HGFriendsModule + protected static FriendsSimConnector m_FriendsSimConnector; // grid + + private static string m_ConfigName = "HGFriendsService"; + + public HGFriendsService(IConfigSource config, String configName, IFriendsSimConnector localSimConn) + { + if (m_FriendsLocalSimConnector == null) + m_FriendsLocalSimConnector = localSimConn; + + if (!m_Initialized) + { + m_Initialized = true; + + if (configName != String.Empty) + m_ConfigName = configName; + + Object[] args = new Object[] { config }; + + IConfig serverConfig = config.Configs[m_ConfigName]; + if (serverConfig == null) + throw new Exception(String.Format("No section {0} in config file", m_ConfigName)); + + string theService = serverConfig.GetString("FriendsService", string.Empty); + if (theService == String.Empty) + throw new Exception("No FriendsService in config file " + m_ConfigName); + m_FriendsService = ServerUtils.LoadPlugin(theService, args); + + theService = serverConfig.GetString("UserAccountService", string.Empty); + if (theService == String.Empty) + throw new Exception("No UserAccountService in " + m_ConfigName); + m_UserAccountService = ServerUtils.LoadPlugin(theService, args); + + theService = serverConfig.GetString("GridService", string.Empty); + if (theService == String.Empty) + throw new Exception("No GridService in " + m_ConfigName); + m_GridService = ServerUtils.LoadPlugin(theService, args); + + theService = serverConfig.GetString("PresenceService", string.Empty); + if (theService == String.Empty) + throw new Exception("No PresenceService in " + m_ConfigName); + m_PresenceService = ServerUtils.LoadPlugin(theService, args); + + m_FriendsSimConnector = new FriendsSimConnector(); + + m_log.DebugFormat("[HGFRIENDS SERVICE]: Starting..."); + + } + } + + #region IHGFriendsService + + public int GetFriendPerms(UUID userID, UUID friendID) + { + FriendInfo[] friendsInfo = m_FriendsService.GetFriends(userID); + foreach (FriendInfo finfo in friendsInfo) + { + if (finfo.Friend.StartsWith(friendID.ToString())) + return finfo.TheirFlags; + } + return -1; + } + + public bool NewFriendship(FriendInfo friend, bool verified) + { + UUID friendID; + string tmp = string.Empty, url = String.Empty, first = String.Empty, last = String.Empty; + if (!Util.ParseUniversalUserIdentifier(friend.Friend, out friendID, out url, out first, out last, out tmp)) + return false; + + m_log.DebugFormat("[HGFRIENDS SERVICE]: New friendship {0} {1} ({2})", friend.PrincipalID, friend.Friend, verified); + + // Does the friendship already exist? + FriendInfo[] finfos = m_FriendsService.GetFriends(friend.PrincipalID); + foreach (FriendInfo finfo in finfos) + { + if (finfo.Friend.StartsWith(friendID.ToString())) + return false; + } + // Verified user session. But the user needs to confirm friendship when he gets home + if (verified) + return m_FriendsService.StoreFriend(friend.PrincipalID.ToString(), friend.Friend, 0); + + // Does the reverted friendship exist? meaning that this user initiated the request + finfos = m_FriendsService.GetFriends(friendID); + bool userInitiatedOffer = false; + foreach (FriendInfo finfo in finfos) + { + if (friend.Friend.StartsWith(finfo.PrincipalID.ToString()) && finfo.Friend.StartsWith(friend.PrincipalID.ToString()) && finfo.TheirFlags == -1) + { + userInitiatedOffer = true; + // Let's delete the existing friendship relations that was stored + m_FriendsService.Delete(friendID, finfo.Friend); + break; + } + } + + if (userInitiatedOffer) + { + m_FriendsService.StoreFriend(friend.PrincipalID.ToString(), friend.Friend, 1); + m_FriendsService.StoreFriend(friend.Friend, friend.PrincipalID.ToString(), 1); + // notify the user + ForwardToSim("ApproveFriendshipRequest", friendID, Util.UniversalName(first, last, url), "", friend.PrincipalID, ""); + return true; + } + return false; + } + + public bool DeleteFriendship(FriendInfo friend, string secret) + { + FriendInfo[] finfos = m_FriendsService.GetFriends(friend.PrincipalID); + foreach (FriendInfo finfo in finfos) + { + // We check the secret here. Or if the friendship request was initiated here, and was declined + if (finfo.Friend.StartsWith(friend.Friend) && finfo.Friend.EndsWith(secret)) + { + m_log.DebugFormat("[HGFRIENDS SERVICE]: Delete friendship {0} {1}", friend.PrincipalID, friend.Friend); + m_FriendsService.Delete(friend.PrincipalID, finfo.Friend); + m_FriendsService.Delete(finfo.Friend, friend.PrincipalID.ToString()); + + return true; + } + } + + return false; + } + + public bool FriendshipOffered(UUID fromID, string fromName, UUID toID, string message) + { + UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, toID); + if (account == null) + return false; + + // OK, we have that user here. + // So let's send back the call, but start a thread to continue + // with the verification and the actual action. + + Util.FireAndForget(delegate { ProcessFriendshipOffered(fromID, fromName, toID, message); }); + + return true; + } + + public bool ValidateFriendshipOffered(UUID fromID, UUID toID) + { + FriendInfo[] finfos = m_FriendsService.GetFriends(toID.ToString()); + foreach (FriendInfo fi in finfos) + { + if (fi.Friend.StartsWith(fromID.ToString()) && fi.TheirFlags == -1) + return true; + } + return false; + } + + #endregion IHGFriendsService + + #region Aux + + private void ProcessFriendshipOffered(UUID fromID, String fromName, UUID toID, String message) + { + // Great, it's a genuine request. Let's proceed. + // But now we need to confirm that the requester is who he says he is + // before we act on the friendship request. + + if (!fromName.Contains("@")) + return; + + string[] parts = fromName.Split(new char[] {'@'}); + if (parts.Length != 2) + return; + + string uriStr = "http://" + parts[1]; + try + { + new Uri(uriStr); + } + catch (UriFormatException) + { + return; + } + + UserAgentServiceConnector uasConn = new UserAgentServiceConnector(uriStr); + Dictionary servers = uasConn.GetServerURLs(fromID); + if (!servers.ContainsKey("FriendsServerURI")) + return; + + HGFriendsServicesConnector friendsConn = new HGFriendsServicesConnector(servers["FriendsServerURI"].ToString()); + if (!friendsConn.ValidateFriendshipOffered(fromID, toID)) + { + m_log.WarnFormat("[HGFRIENDS SERVICE]: Friendship request from {0} to {1} is invalid. Impersonations?", fromID, toID); + return; + } + + string fromUUI = Util.UniversalIdentifier(fromID, parts[0], "@" + parts[1], uriStr); + // OK, we're good! + ForwardToSim("FriendshipOffered", fromID, fromName, fromUUI, toID, message); + } + + private bool ForwardToSim(string op, UUID fromID, string name, String fromUUI, UUID toID, string message) + { + PresenceInfo session = null; + GridRegion region = null; + PresenceInfo[] sessions = m_PresenceService.GetAgents(new string[] { toID.ToString() }); + if (sessions != null && sessions.Length > 0) + session = sessions[0]; + if (session != null) + region = m_GridService.GetRegionByUUID(UUID.Zero, session.RegionID); + + switch (op) + { + case "FriendshipOffered": + // Let's store backwards + string secret = UUID.Random().ToString().Substring(0, 8); + m_FriendsService.StoreFriend(toID.ToString(), fromUUI + ";" + secret, 0); + if (m_FriendsLocalSimConnector != null) // standalone + { + GridInstantMessage im = new GridInstantMessage(null, fromID, name, toID, + (byte)InstantMessageDialog.FriendshipOffered, message, false, Vector3.Zero); + // !! HACK + im.imSessionID = im.fromAgentID; + return m_FriendsLocalSimConnector.LocalFriendshipOffered(toID, im); + } + else if (region != null) // grid + return m_FriendsSimConnector.FriendshipOffered(region, fromID, toID, message, name); + break; + case "ApproveFriendshipRequest": + if (m_FriendsLocalSimConnector != null) // standalone + return m_FriendsLocalSimConnector.LocalFriendshipApproved(fromID, name, toID); + else if (region != null) //grid + return m_FriendsSimConnector.FriendshipApproved(region, fromID, name, toID); + break; + } + + return false; + } + + #endregion Aux + } +} diff --git a/OpenSim/Services/Interfaces/IHypergridServices.cs b/OpenSim/Services/Interfaces/IHypergridServices.cs index 0cd44f7..f48b8a9 100644 --- a/OpenSim/Services/Interfaces/IHypergridServices.cs +++ b/OpenSim/Services/Interfaces/IHypergridServices.cs @@ -81,6 +81,17 @@ namespace OpenSim.Services.Interfaces public interface IFriendsSimConnector { bool StatusNotify(UUID userID, UUID friendID, bool online); + bool LocalFriendshipOffered(UUID toID, GridInstantMessage im); + bool LocalFriendshipApproved(UUID userID, string userName, UUID friendID); + } + + public interface IHGFriendsService + { + int GetFriendPerms(UUID userID, UUID friendID); + bool NewFriendship(FriendInfo finfo, bool verified); + bool DeleteFriendship(FriendInfo finfo, string secret); + bool FriendshipOffered(UUID from, string fromName, UUID to, string message); + bool ValidateFriendshipOffered(UUID fromID, UUID toID); } public interface IInstantMessageSimConnector -- cgit v1.1 From 4a9ca3ca8ff18f4fcf05c3983db5e6b1d49c97ee Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 21 Mar 2012 10:35:06 -0700 Subject: HG Friends: reroute the status notifications to the HGFriends service, so that they can scale better. They were previously being handled by the UAS; that is still there, but it's now obsolete and will be removed in a future release. --- .../Hypergrid/HGFriendsServiceConnector.cs | 52 ++++++++++ .../Hypergrid/UserAgentServiceConnector.cs | 1 + .../Services/HypergridService/HGFriendsService.cs | 107 +++++++++++++++++++++ .../Services/HypergridService/UserAgentService.cs | 2 + OpenSim/Services/Interfaces/IHypergridServices.cs | 4 +- 5 files changed, 165 insertions(+), 1 deletion(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs index e3f3260..e984a54 100644 --- a/OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/HGFriendsServiceConnector.cs @@ -255,6 +255,58 @@ namespace OpenSim.Services.Connectors.Hypergrid return false; } + + public List StatusNotification(List friends, UUID userID, bool online) + { + Dictionary sendData = new Dictionary(); + List friendsOnline = new List(); + + sendData["METHOD"] = "statusnotification"; + sendData["userID"] = userID.ToString(); + sendData["online"] = online.ToString(); + int i = 0; + foreach (string s in friends) + { + sendData["friend_" + i.ToString()] = s; + i++; + } + + string reply = string.Empty; + string uri = m_ServerURI + "/hgfriends"; + try + { + reply = SynchronousRestFormsRequester.MakeRequest("POST", + uri, + ServerUtils.BuildQueryString(sendData)); + } + catch (Exception e) + { + m_log.DebugFormat("[HGFRIENDS CONNECTOR]: Exception when contacting friends server at {0}: {1}", uri, e.Message); + return friendsOnline; + } + + if (reply != string.Empty) + { + Dictionary replyData = ServerUtils.ParseXmlResponse(reply); + + // Here is the actual response + foreach (string key in replyData.Keys) + { + if (key.StartsWith("friend_") && replyData[key] != null) + { + UUID uuid; + if (UUID.TryParse(replyData[key].ToString(), out uuid)) + friendsOnline.Add(uuid); + } + } + } + else + m_log.DebugFormat("[HGFRIENDS CONNECTOR]: Received empty reply from remote StatusNotify"); + + return friendsOnline; + + } + #endregion } } \ No newline at end of file diff --git a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs index bf86035..2f263ae 100644 --- a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs @@ -417,6 +417,7 @@ namespace OpenSim.Services.Connectors.Hypergrid GetBoolResponse(request, out reason); } + [Obsolete] public List StatusNotification(List friends, UUID userID, bool online) { Hashtable hash = new Hashtable(); diff --git a/OpenSim/Services/HypergridService/HGFriendsService.cs b/OpenSim/Services/HypergridService/HGFriendsService.cs index 19ee3e2..39524ab 100644 --- a/OpenSim/Services/HypergridService/HGFriendsService.cs +++ b/OpenSim/Services/HypergridService/HGFriendsService.cs @@ -214,6 +214,91 @@ namespace OpenSim.Services.HypergridService return false; } + public List StatusNotification(List friends, UUID foreignUserID, bool online) + { + if (m_FriendsService == null || m_PresenceService == null) + { + m_log.WarnFormat("[HGFRIENDS SERVICE]: Unable to perform status notifications because friends or presence services are missing"); + return new List(); + } + + // Let's unblock the caller right now, and take it from here async + + List localFriendsOnline = new List(); + + m_log.DebugFormat("[HGFRIENDS SERVICE]: Status notification: foreign user {0} wants to notify {1} local friends of {2} status", + foreignUserID, friends.Count, (online ? "online" : "offline")); + + // First, let's double check that the reported friends are, indeed, friends of that user + // And let's check that the secret matches + List usersToBeNotified = new List(); + foreach (string uui in friends) + { + UUID localUserID; + string secret = string.Empty, tmp = string.Empty; + if (Util.ParseUniversalUserIdentifier(uui, out localUserID, out tmp, out tmp, out tmp, out secret)) + { + FriendInfo[] friendInfos = m_FriendsService.GetFriends(localUserID); + foreach (FriendInfo finfo in friendInfos) + { + if (finfo.Friend.StartsWith(foreignUserID.ToString()) && finfo.Friend.EndsWith(secret)) + { + // great! + usersToBeNotified.Add(localUserID.ToString()); + } + } + } + } + + // Now, let's send the notifications + //m_log.DebugFormat("[HGFRIENDS SERVICE]: Status notification: user has {0} local friends", usersToBeNotified.Count); + + // First, let's send notifications to local users who are online in the home grid + PresenceInfo[] friendSessions = m_PresenceService.GetAgents(usersToBeNotified.ToArray()); + if (friendSessions != null && friendSessions.Length > 0) + { + PresenceInfo friendSession = null; + foreach (PresenceInfo pinfo in friendSessions) + if (pinfo.RegionID != UUID.Zero) // let's guard against traveling agents + { + friendSession = pinfo; + break; + } + + if (friendSession != null) + { + ForwardStatusNotificationToSim(friendSession.RegionID, foreignUserID, friendSession.UserID, online); + usersToBeNotified.Remove(friendSession.UserID.ToString()); + UUID id; + if (UUID.TryParse(friendSession.UserID, out id)) + localFriendsOnline.Add(id); + + } + } + + // Lastly, let's notify the rest who may be online somewhere else + foreach (string user in usersToBeNotified) + { + UUID id = new UUID(user); + //m_UserAgentService.LocateUser(id); + //etc... + //if (m_TravelingAgents.ContainsKey(id) && m_TravelingAgents[id].GridExternalName != m_GridName) + //{ + // string url = m_TravelingAgents[id].GridExternalName; + // // forward + //} + //m_log.WarnFormat("[HGFRIENDS SERVICE]: User {0} is visiting another grid. HG Status notifications still not implemented.", user); + } + + // and finally, let's send the online friends + if (online) + { + return localFriendsOnline; + } + else + return new List(); + } + #endregion IHGFriendsService #region Aux @@ -296,6 +381,28 @@ namespace OpenSim.Services.HypergridService return false; } + protected void ForwardStatusNotificationToSim(UUID regionID, UUID foreignUserID, string user, bool online) + { + UUID userID; + if (UUID.TryParse(user, out userID)) + { + if (m_FriendsLocalSimConnector != null) + { + m_log.DebugFormat("[HGFRIENDS SERVICE]: Local Notify, user {0} is {1}", foreignUserID, (online ? "online" : "offline")); + m_FriendsLocalSimConnector.StatusNotify(foreignUserID, userID, online); + } + else + { + GridRegion region = m_GridService.GetRegionByUUID(UUID.Zero /* !!! */, regionID); + if (region != null) + { + m_log.DebugFormat("[HGFRIENDS SERVICE]: Remote Notify to region {0}, user {1} is {2}", region.RegionName, foreignUserID, (online ? "online" : "offline")); + m_FriendsSimConnector.StatusNotify(region, foreignUserID, userID, online); + } + } + } + } + #endregion Aux } } diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs index 5eca801..6a5007f 100644 --- a/OpenSim/Services/HypergridService/UserAgentService.cs +++ b/OpenSim/Services/HypergridService/UserAgentService.cs @@ -334,6 +334,7 @@ namespace OpenSim.Services.HypergridService return false; } + [Obsolete] public List StatusNotification(List friends, UUID foreignUserID, bool online) { if (m_FriendsService == null || m_PresenceService == null) @@ -414,6 +415,7 @@ namespace OpenSim.Services.HypergridService return new List(); } + [Obsolete] protected void ForwardStatusNotificationToSim(UUID regionID, UUID foreignUserID, string user, bool online) { UUID userID; diff --git a/OpenSim/Services/Interfaces/IHypergridServices.cs b/OpenSim/Services/Interfaces/IHypergridServices.cs index f48b8a9..3dc877a 100644 --- a/OpenSim/Services/Interfaces/IHypergridServices.cs +++ b/OpenSim/Services/Interfaces/IHypergridServices.cs @@ -65,8 +65,8 @@ namespace OpenSim.Services.Interfaces UUID GetUUID(String first, String last); // Returns the local friends online + [Obsolete] List StatusNotification(List friends, UUID userID, bool online); - //List GetOnlineFriends(UUID userID, List friends); bool IsAgentComingHome(UUID sessionID, string thisGridExternalName); bool VerifyAgent(UUID sessionID, string token); @@ -92,6 +92,8 @@ namespace OpenSim.Services.Interfaces bool DeleteFriendship(FriendInfo finfo, string secret); bool FriendshipOffered(UUID from, string fromName, UUID to, string message); bool ValidateFriendshipOffered(UUID fromID, UUID toID); + // Returns the local friends online + List StatusNotification(List friends, UUID userID, bool online); } public interface IInstantMessageSimConnector -- cgit v1.1 From 5170cd75775eb85922783fa8afe4f8025c054189 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 21 Mar 2012 11:22:39 -0700 Subject: Updated the UserAccountsClient a little bit, plus some more sanity checks on the service connector. --- .../Connectors/UserAccounts/UserAccountServiceConnector.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.cs b/OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.cs index 609dafe..6d5ce28 100644 --- a/OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.cs +++ b/OpenSim/Services/Connectors/UserAccounts/UserAccountServiceConnector.cs @@ -197,8 +197,15 @@ namespace OpenSim.Services.Connectors Dictionary structData = data.ToKeyValuePairs(); - foreach (KeyValuePair kvp in structData) + foreach (KeyValuePair kvp in structData) + { + if (kvp.Value == null) + { + m_log.DebugFormat("[ACCOUNTS CONNECTOR]: Null value for {0}", kvp.Key); + continue; + } sendData[kvp.Key] = kvp.Value.ToString(); + } return SendAndGetBoolReply(sendData); } -- cgit v1.1 From 8131a24cde3f3877b3b8dd850871c57c17b2b216 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 27 Mar 2012 10:08:13 -0700 Subject: Send the config section name up to the service classes themselves (XInventory and Assets). --- OpenSim/Services/AssetService/AssetService.cs | 11 ++++-- OpenSim/Services/AssetService/AssetServiceBase.cs | 15 ++++++-- .../Services/HypergridService/HGAssetService.cs | 4 +-- .../HypergridService/HGInventoryService.cs | 40 ++++------------------ .../Services/InventoryService/XInventoryService.cs | 12 +++++-- 5 files changed, 38 insertions(+), 44 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/AssetService/AssetService.cs b/OpenSim/Services/AssetService/AssetService.cs index 4f4cbf6..137a9b0 100644 --- a/OpenSim/Services/AssetService/AssetService.cs +++ b/OpenSim/Services/AssetService/AssetService.cs @@ -46,7 +46,12 @@ namespace OpenSim.Services.AssetService protected static AssetService m_RootInstance; - public AssetService(IConfigSource config) : base(config) + public AssetService(IConfigSource config) + : this(config, "AssetService") + { + } + + public AssetService(IConfigSource config, string configName) : base(config, configName) { if (m_RootInstance == null) { @@ -54,9 +59,9 @@ namespace OpenSim.Services.AssetService if (m_AssetLoader != null) { - IConfig assetConfig = config.Configs["AssetService"]; + IConfig assetConfig = config.Configs[m_ConfigName]; if (assetConfig == null) - throw new Exception("No AssetService configuration"); + throw new Exception("No " + m_ConfigName + " configuration"); string loaderArgs = assetConfig.GetString("AssetLoaderArgs", String.Empty); diff --git a/OpenSim/Services/AssetService/AssetServiceBase.cs b/OpenSim/Services/AssetService/AssetServiceBase.cs index 86752f9..177c565 100644 --- a/OpenSim/Services/AssetService/AssetServiceBase.cs +++ b/OpenSim/Services/AssetService/AssetServiceBase.cs @@ -39,16 +39,25 @@ namespace OpenSim.Services.AssetService { protected IAssetDataPlugin m_Database = null; protected IAssetLoader m_AssetLoader = null; + protected string m_ConfigName = "AssetService"; - public AssetServiceBase(IConfigSource config) : base(config) + public AssetServiceBase(IConfigSource config) + : this(config, "AssetService") { + } + + public AssetServiceBase(IConfigSource config, string configName) : base(config) + { + if (configName != string.Empty) + m_ConfigName = configName; + string dllName = String.Empty; string connString = String.Empty; // - // Try reading the [AssetService] section first, if it exists + // Try reading the [AssetService] section, if it exists // - IConfig assetConfig = config.Configs["AssetService"]; + IConfig assetConfig = config.Configs[m_ConfigName]; if (assetConfig != null) { dllName = assetConfig.GetString("StorageProvider", dllName); diff --git a/OpenSim/Services/HypergridService/HGAssetService.cs b/OpenSim/Services/HypergridService/HGAssetService.cs index 22e233a..db98166 100644 --- a/OpenSim/Services/HypergridService/HGAssetService.cs +++ b/OpenSim/Services/HypergridService/HGAssetService.cs @@ -58,10 +58,10 @@ namespace OpenSim.Services.HypergridService private UserAccountCache m_Cache; - public HGAssetService(IConfigSource config) : base(config) + public HGAssetService(IConfigSource config, string configName) : base(config, configName) { m_log.Debug("[HGAsset Service]: Starting"); - IConfig assetConfig = config.Configs["HGAssetService"]; + IConfig assetConfig = config.Configs[configName]; if (assetConfig == null) throw new Exception("No HGAssetService configuration"); diff --git a/OpenSim/Services/HypergridService/HGInventoryService.cs b/OpenSim/Services/HypergridService/HGInventoryService.cs index 41d5a7a..a1287fd 100644 --- a/OpenSim/Services/HypergridService/HGInventoryService.cs +++ b/OpenSim/Services/HypergridService/HGInventoryService.cs @@ -60,36 +60,19 @@ namespace OpenSim.Services.HypergridService private UserAccountCache m_Cache; - public HGInventoryService(IConfigSource config) - : base(config) + public HGInventoryService(IConfigSource config, string configName) + : base(config, configName) { m_log.Debug("[HGInventory Service]: Starting"); - - string dllName = String.Empty; - string connString = String.Empty; - //string realm = "Inventory"; // OSG version doesn't use this - - // - // Try reading the [DatabaseService] section, if it exists - // - IConfig dbConfig = config.Configs["DatabaseService"]; - if (dbConfig != null) - { - if (dllName == String.Empty) - dllName = dbConfig.GetString("StorageProvider", String.Empty); - if (connString == String.Empty) - connString = dbConfig.GetString("ConnectionString", String.Empty); - } + if (configName != string.Empty) + m_ConfigName = configName; // // Try reading the [InventoryService] section, if it exists // - IConfig invConfig = config.Configs["HGInventoryService"]; + IConfig invConfig = config.Configs[m_ConfigName]; if (invConfig != null) - { - dllName = invConfig.GetString("StorageProvider", dllName); - connString = invConfig.GetString("ConnectionString", connString); - + { // realm = authConfig.GetString("Realm", realm); string userAccountsDll = invConfig.GetString("UserAccountsService", string.Empty); if (userAccountsDll == string.Empty) @@ -108,17 +91,6 @@ namespace OpenSim.Services.HypergridService m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService); } - // - // We tried, but this doesn't exist. We can't proceed. - // - if (dllName == String.Empty) - throw new Exception("No StorageProvider configured"); - - m_Database = LoadPlugin(dllName, - new Object[] {connString, String.Empty}); - if (m_Database == null) - throw new Exception("Could not find a storage interface in the given module"); - m_log.Debug("[HG INVENTORY SERVICE]: Starting..."); } diff --git a/OpenSim/Services/InventoryService/XInventoryService.cs b/OpenSim/Services/InventoryService/XInventoryService.cs index 1648b51..8c57d17 100644 --- a/OpenSim/Services/InventoryService/XInventoryService.cs +++ b/OpenSim/Services/InventoryService/XInventoryService.cs @@ -46,9 +46,17 @@ namespace OpenSim.Services.InventoryService protected IXInventoryData m_Database; protected bool m_AllowDelete = true; + protected string m_ConfigName = "InventoryService"; - public XInventoryService(IConfigSource config) : base(config) + public XInventoryService(IConfigSource config) + : this(config, "InventoryService") { + } + public XInventoryService(IConfigSource config, string configName) : base(config) + { + if (configName != string.Empty) + m_ConfigName = configName; + string dllName = String.Empty; string connString = String.Empty; //string realm = "Inventory"; // OSG version doesn't use this @@ -56,7 +64,7 @@ namespace OpenSim.Services.InventoryService // // Try reading the [InventoryService] section first, if it exists // - IConfig authConfig = config.Configs["InventoryService"]; + IConfig authConfig = config.Configs[m_ConfigName]; if (authConfig != null) { dllName = authConfig.GetString("StorageProvider", dllName); -- cgit v1.1