From 134f86e8d5c414409631b25b8c6f0ee45fbd8631 Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Thu, 3 Nov 2016 21:44:39 +1000 Subject: Initial update to OpenSim 0.8.2.1 source code. --- .../UserAccountService/AgentPreferencesService.cs | 82 +++++++++++++ .../AgentPreferencesServiceBase.cs | 73 ++++++++++++ .../Services/UserAccountService/GridUserService.cs | 127 +++++++++++++++++++-- .../UserAccountService/GridUserServiceBase.cs | 10 +- .../UserAccountService/Properties/AssemblyInfo.cs | 4 +- .../UserAccountService/UserAccountService.cs | 56 ++++++++- 6 files changed, 330 insertions(+), 22 deletions(-) create mode 100644 OpenSim/Services/UserAccountService/AgentPreferencesService.cs create mode 100644 OpenSim/Services/UserAccountService/AgentPreferencesServiceBase.cs (limited to 'OpenSim/Services/UserAccountService') diff --git a/OpenSim/Services/UserAccountService/AgentPreferencesService.cs b/OpenSim/Services/UserAccountService/AgentPreferencesService.cs new file mode 100644 index 0000000..1808ee5 --- /dev/null +++ b/OpenSim/Services/UserAccountService/AgentPreferencesService.cs @@ -0,0 +1,82 @@ +/* + * 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.Reflection; +using log4net; +using Nini.Config; +using OpenMetaverse; +using OpenSim.Data; +using OpenSim.Framework; +using OpenSim.Services.Interfaces; + +namespace OpenSim.Services.UserAccountService +{ + public class AgentPreferencesService : AgentPreferencesServiceBase, IAgentPreferencesService + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + public AgentPreferencesService(IConfigSource config) : base(config) + { + m_log.Debug("[AGENT PREFERENCES SERVICE]: Starting agent preferences service"); + } + + public AgentPrefs GetAgentPreferences(UUID principalID) + { + AgentPreferencesData d = m_Database.GetPrefs(principalID); + AgentPrefs prefs = (d == null) ? new AgentPrefs(principalID) : new AgentPrefs(d.Data); + return prefs; + } + + public bool StoreAgentPreferences(AgentPrefs data) + { + AgentPreferencesData d = new AgentPreferencesData(); + d.Data = new Dictionary(); + d.Data["PrincipalID"] = data.PrincipalID.ToString(); + d.Data["AccessPrefs"] = data.AccessPrefs; + d.Data["HoverHeight"] = data.HoverHeight.ToString(); + d.Data["Language"] = data.Language; + d.Data["LanguageIsPublic"] = (data.LanguageIsPublic ? "1" : "0"); + d.Data["PermEveryone"] = data.PermEveryone.ToString(); + d.Data["PermGroup"] = data.PermGroup.ToString(); + d.Data["PermNextOwner"] = data.PermNextOwner.ToString(); + return m_Database.Store(d); + } + + public string GetLang(UUID principalID) + { + AgentPrefs data = GetAgentPreferences(principalID); + if (data != null) + { + if (data.LanguageIsPublic) + return data.Language; + } + return "en-us"; + } + } +} diff --git a/OpenSim/Services/UserAccountService/AgentPreferencesServiceBase.cs b/OpenSim/Services/UserAccountService/AgentPreferencesServiceBase.cs new file mode 100644 index 0000000..5974349 --- /dev/null +++ b/OpenSim/Services/UserAccountService/AgentPreferencesServiceBase.cs @@ -0,0 +1,73 @@ +/* + * 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.Data; +using OpenSim.Services.Interfaces; +using OpenSim.Services.Base; + +namespace OpenSim.Services.UserAccountService +{ + public class AgentPreferencesServiceBase: ServiceBase + { + protected IAgentPreferencesData m_Database = null; + + public AgentPreferencesServiceBase(IConfigSource config) : base(config) + { + string dllName = String.Empty; + string connString = String.Empty; + string realm = "AgentPrefs"; + + IConfig dbConfig = config.Configs["DatabaseService"]; + if (dbConfig != null) + { + dllName = dbConfig.GetString("StorageProvider", String.Empty); + connString = dbConfig.GetString("ConnectionString", String.Empty); + } + + IConfig userConfig = config.Configs["AgentPreferencesService"]; + if (userConfig == null) + throw new Exception("No AgentPreferencesService configuration"); + + dllName = userConfig.GetString("StorageProvider", dllName); + + if (dllName == String.Empty) + throw new Exception("No StorageProvider configured"); + + connString = userConfig.GetString("ConnectionString", connString); + + realm = userConfig.GetString("Realm", realm); + + m_Database = LoadPlugin(dllName, new Object[] {connString, realm}); + + if (m_Database == null) + throw new Exception("Could not find a storage interface in the given module"); + } + } +} diff --git a/OpenSim/Services/UserAccountService/GridUserService.cs b/OpenSim/Services/UserAccountService/GridUserService.cs index 43fa04b..80a9d9d 100644 --- a/OpenSim/Services/UserAccountService/GridUserService.cs +++ b/OpenSim/Services/UserAccountService/GridUserService.cs @@ -43,15 +43,117 @@ namespace OpenSim.Services.UserAccountService public class GridUserService : GridUserServiceBase, IGridUserService { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static bool m_Initialized; public GridUserService(IConfigSource config) : base(config) { - m_log.Debug("[USER GRID SERVICE]: Starting user grid service"); + m_log.Debug("[GRID USER SERVICE]: Starting user grid service"); + + if (!m_Initialized) + { + m_Initialized = true; + + MainConsole.Instance.Commands.AddCommand( + "Users", false, + "show grid user", + "show grid user ", + "Show grid user entry or entries that match or start with the given ID. This will normally be a UUID.", + "This is for debug purposes to see what data is found for a particular user id.", + HandleShowGridUser); + + MainConsole.Instance.Commands.AddCommand( + "Users", false, + "show grid users online", + "show grid users online", + "Show number of grid users registered as online.", + "This number may not be accurate as a region may crash or not be cleanly shutdown and leave grid users shown as online\n." + + "For this reason, users online for more than 5 days are not currently counted", + HandleShowGridUsersOnline); + } + } + + protected void HandleShowGridUser(string module, string[] cmdparams) + { + if (cmdparams.Length != 4) + { + MainConsole.Instance.Output("Usage: show grid user "); + return; + } + + GridUserData[] data = m_Database.GetAll(cmdparams[3]); + + foreach (GridUserData gu in data) + { + ConsoleDisplayList cdl = new ConsoleDisplayList(); + + cdl.AddRow("User ID", gu.UserID); + + foreach (KeyValuePair kvp in gu.Data) + cdl.AddRow(kvp.Key, kvp.Value); + + MainConsole.Instance.Output(cdl.ToString()); + } + + MainConsole.Instance.OutputFormat("Entries: {0}", data.Length); + } + + protected void HandleShowGridUsersOnline(string module, string[] cmdparams) + { +// if (cmdparams.Length != 4) +// { +// MainConsole.Instance.Output("Usage: show grid users online"); +// return; +// } + +// int onlineCount; + int onlineRecentlyCount = 0; + + DateTime now = DateTime.UtcNow; + + foreach (GridUserData gu in m_Database.GetAll("")) + { + if (bool.Parse(gu.Data["Online"])) + { +// onlineCount++; + + int unixLoginTime = int.Parse(gu.Data["Login"]); + + if ((now - Util.ToDateTime(unixLoginTime)).Days < 5) + onlineRecentlyCount++; + } + } + + MainConsole.Instance.OutputFormat("Users online: {0}", onlineRecentlyCount); + } + + private GridUserData GetGridUserData(string userID) + { + GridUserData d = null; + if (userID.Length > 36) // it's a UUI + { + d = m_Database.Get(userID); + } + else // it's a UUID + { + GridUserData[] ds = m_Database.GetAll(userID); + if (ds == null) + return null; + + if (ds.Length > 0) + { + d = ds[0]; + foreach (GridUserData dd in ds) + if (dd.UserID.Length > d.UserID.Length) // find the longest + d = dd; + } + } + + return d; } public virtual GridUserInfo GetGridUserInfo(string userID) { - GridUserData d = m_Database.Get(userID); + GridUserData d = GetGridUserData(userID); if (d == null) return null; @@ -73,7 +175,7 @@ namespace OpenSim.Services.UserAccountService return info; } - public GridUserInfo[] GetGridUserInfo(string[] userIDs) + public virtual GridUserInfo[] GetGridUserInfo(string[] userIDs) { List ret = new List(); @@ -86,7 +188,8 @@ namespace OpenSim.Services.UserAccountService public GridUserInfo LoggedIn(string userID) { m_log.DebugFormat("[GRID USER SERVICE]: User {0} is online", userID); - GridUserData d = m_Database.Get(userID); + + GridUserData d = GetGridUserData(userID); if (d == null) { @@ -104,8 +207,9 @@ namespace OpenSim.Services.UserAccountService public bool LoggedOut(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt) { - m_log.DebugFormat("[GRID USER SERVICE]: User {0} is offline", userID); - GridUserData d = m_Database.Get(userID); + m_log.InfoFormat("[GRID USER SERVICE]: User {0} is offline", userID); + + GridUserData d = GetGridUserData(userID); if (d == null) { @@ -124,7 +228,8 @@ namespace OpenSim.Services.UserAccountService public bool SetHome(string userID, UUID homeID, Vector3 homePosition, Vector3 homeLookAt) { - GridUserData d = m_Database.Get(userID); + GridUserData d = GetGridUserData(userID); + if (d == null) { d = new GridUserData(); @@ -140,8 +245,10 @@ namespace OpenSim.Services.UserAccountService public bool SetLastPosition(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt) { - //m_log.DebugFormat("[Grid User Service]: SetLastPosition for {0}", userID); - GridUserData d = m_Database.Get(userID); +// m_log.DebugFormat("[GRID USER SERVICE]: SetLastPosition for {0}", userID); + + GridUserData d = GetGridUserData(userID); + if (d == null) { d = new GridUserData(); @@ -155,4 +262,4 @@ namespace OpenSim.Services.UserAccountService return m_Database.Store(d); } } -} +} \ No newline at end of file diff --git a/OpenSim/Services/UserAccountService/GridUserServiceBase.cs b/OpenSim/Services/UserAccountService/GridUserServiceBase.cs index 990cb63..8c5f5df 100644 --- a/OpenSim/Services/UserAccountService/GridUserServiceBase.cs +++ b/OpenSim/Services/UserAccountService/GridUserServiceBase.cs @@ -60,12 +60,12 @@ namespace OpenSim.Services.UserAccountService // // [GridUsetService] section overrides [DatabaseService], if it exists // - IConfig presenceConfig = config.Configs["GridUserService"]; - if (presenceConfig != null) + IConfig usersConfig = config.Configs["GridUserService"]; + if (usersConfig != null) { - dllName = presenceConfig.GetString("StorageProvider", dllName); - connString = presenceConfig.GetString("ConnectionString", connString); - realm = presenceConfig.GetString("Realm", realm); + dllName = usersConfig.GetString("StorageProvider", dllName); + connString = usersConfig.GetString("ConnectionString", connString); + realm = usersConfig.GetString("Realm", realm); } // diff --git a/OpenSim/Services/UserAccountService/Properties/AssemblyInfo.cs b/OpenSim/Services/UserAccountService/Properties/AssemblyInfo.cs index 24e1d16..6ca07a6 100644 --- a/OpenSim/Services/UserAccountService/Properties/AssemblyInfo.cs +++ b/OpenSim/Services/UserAccountService/Properties/AssemblyInfo.cs @@ -29,5 +29,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("0.7.5.*")] -[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: AssemblyVersion("0.8.3.*")] + diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs index 5b4d040..2e19ece 100644 --- a/OpenSim/Services/UserAccountService/UserAccountService.cs +++ b/OpenSim/Services/UserAccountService/UserAccountService.cs @@ -36,6 +36,7 @@ using OpenSim.Framework; using OpenSim.Services.Interfaces; using OpenSim.Framework.Console; using GridRegion = OpenSim.Services.Interfaces.GridRegion; +using PermissionMask = OpenSim.Framework.PermissionMask; namespace OpenSim.Services.UserAccountService { @@ -97,7 +98,12 @@ namespace OpenSim.Services.UserAccountService MainConsole.Instance.Commands.AddCommand("Users", false, "reset user password", "reset user password [ [ []]]", - "Reset a user password", HandleResetUserPassword); + "Reset a user password", HandleResetUserPassword); + + MainConsole.Instance.Commands.AddCommand("Users", false, + "reset user email", + "reset user email [ [ []]]", + "Reset a user email address", HandleResetUserEmail); MainConsole.Instance.Commands.AddCommand("Users", false, "set user level", @@ -255,6 +261,10 @@ namespace OpenSim.Services.UserAccountService return MakeUserAccount(d[0]); } + public void InvalidateCache(UUID userID) + { + } + public bool StoreUserAccount(UserAccount data) { // m_log.DebugFormat( @@ -415,6 +425,43 @@ namespace OpenSim.Services.UserAccountService MainConsole.Instance.OutputFormat("Password reset for user {0} {1}", firstName, lastName); } + protected void HandleResetUserEmail(string module, string[] cmdparams) + { + string firstName; + string lastName; + string newEmail; + + if (cmdparams.Length < 4) + firstName = MainConsole.Instance.CmdPrompt("First name"); + else firstName = cmdparams[3]; + + if (cmdparams.Length < 5) + lastName = MainConsole.Instance.CmdPrompt("Last name"); + else lastName = cmdparams[4]; + + if (cmdparams.Length < 6) + newEmail = MainConsole.Instance.PasswdPrompt("New Email"); + else newEmail = cmdparams[5]; + + UserAccount account = GetUserAccount(UUID.Zero, firstName, lastName); + if (account == null) + { + MainConsole.Instance.OutputFormat("No such user as {0} {1}", firstName, lastName); + return; + } + + bool success = false; + + account.Email = newEmail; + + success = StoreUserAccount(account); + if (!success) + MainConsole.Instance.OutputFormat("Unable to set Email for account {0} {1}.", firstName, lastName); + else + MainConsole.Instance.OutputFormat("User Email set for user {0} {1} to {2}", firstName, lastName, account.Email); + } + + protected void HandleSetUserLevel(string module, string[] cmdparams) { string firstName; @@ -475,7 +522,6 @@ namespace OpenSim.Services.UserAccountService { account.ServiceURLs = new Dictionary(); account.ServiceURLs["HomeURI"] = string.Empty; - account.ServiceURLs["GatekeeperURI"] = string.Empty; account.ServiceURLs["InventoryServerURI"] = string.Empty; account.ServiceURLs["AssetServerURI"] = string.Empty; } @@ -549,7 +595,7 @@ namespace OpenSim.Services.UserAccountService { m_log.DebugFormat("[USER ACCOUNT SERVICE]: Creating default appearance items for {0}", principalID); - InventoryFolderBase bodyPartsFolder = m_InventoryService.GetFolderForType(principalID, AssetType.Bodypart); + InventoryFolderBase bodyPartsFolder = m_InventoryService.GetFolderForType(principalID, FolderType.BodyPart); InventoryItemBase eyes = new InventoryItemBase(UUID.Random(), principalID); eyes.AssetID = new UUID("4bb6fa4d-1cd2-498a-a84c-95c1a0e745a7"); @@ -611,7 +657,7 @@ namespace OpenSim.Services.UserAccountService hair.Flags = (uint)WearableType.Hair; m_InventoryService.AddItem(hair); - InventoryFolderBase clothingFolder = m_InventoryService.GetFolderForType(principalID, AssetType.Clothing); + InventoryFolderBase clothingFolder = m_InventoryService.GetFolderForType(principalID, FolderType.Clothing); InventoryItemBase shirt = new InventoryItemBase(UUID.Random(), principalID); shirt.AssetID = AvatarWearable.DEFAULT_SHIRT_ASSET; @@ -665,4 +711,4 @@ namespace OpenSim.Services.UserAccountService } } } -} \ No newline at end of file +} -- cgit v1.1