From dc2acaa8a887e986644480237910308701c84c1a Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Wed, 16 May 2007 21:10:45 +0000 Subject: Let stuff be broken! --- OpenGridServices.UserServer/Main.cs | 6 ++ .../OpenGridServices.UserServer.csproj | 48 ++++++---- OpenGridServices.UserServer/UserManager.cs | 102 +++++++++++++++++++++ 3 files changed, 138 insertions(+), 18 deletions(-) create mode 100644 OpenGridServices.UserServer/UserManager.cs (limited to 'OpenGridServices.UserServer') diff --git a/OpenGridServices.UserServer/Main.cs b/OpenGridServices.UserServer/Main.cs index ed7b768..1c6ad8c 100644 --- a/OpenGridServices.UserServer/Main.cs +++ b/OpenGridServices.UserServer/Main.cs @@ -50,6 +50,8 @@ namespace OpenGridServices.UserServer private string ConfigDll = "OpenUser.Config.UserConfigDb4o.dll"; private UserConfig Cfg; + public UserManager m_userManager; // Replaces below. + private UserProfileManager m_userProfileManager; public Dictionary UserSessions = new Dictionary(); @@ -62,6 +64,7 @@ namespace OpenGridServices.UserServer Console.WriteLine("Starting...\n"); OpenUser_Main userserver = new OpenUser_Main(); + userserver.Startup(); userserver.Work(); } @@ -88,6 +91,9 @@ namespace OpenGridServices.UserServer Cfg = this.LoadConfigDll(this.ConfigDll); Cfg.InitConfig(); + MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Main.cs:Startup() - Establishing data connection"); + m_userManager = new UserManager(); + MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW,"Main.cs:Startup() - Creating user profile manager"); m_userProfileManager = new UserProfileManager(); m_userProfileManager.InitUserProfiles(); diff --git a/OpenGridServices.UserServer/OpenGridServices.UserServer.csproj b/OpenGridServices.UserServer/OpenGridServices.UserServer.csproj index 888b62d..75642b3 100644 --- a/OpenGridServices.UserServer/OpenGridServices.UserServer.csproj +++ b/OpenGridServices.UserServer/OpenGridServices.UserServer.csproj @@ -1,4 +1,4 @@ - + Local 8.0.50727 @@ -6,7 +6,8 @@ {66591469-0000-0000-0000-000000000000} Debug AnyCPU - + + OpenGridServices.UserServer @@ -15,9 +16,11 @@ IE50 false Exe - + + OpenGridServices.UserServer - + + @@ -28,7 +31,8 @@ TRACE;DEBUG - + + True 4096 False @@ -37,7 +41,8 @@ False False 4 - + + False @@ -46,7 +51,8 @@ TRACE - + + False 4096 True @@ -55,54 +61,59 @@ False False 4 - + + - + System.dll False - + System.Data.dll False - + System.Xml.dll False - + ..\bin\libsecondlife.dll False - + ..\bin\Db4objects.Db4o.dll False + + {62CDF671-0000-0000-0000-000000000000} + OpenGrid.Framework.Data + OpenSim.Framework {8ACA2445-0000-0000-0000-000000000000} {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False + False OpenSim.Framework.Console {A7CD0630-0000-0000-0000-000000000000} {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False + False OpenSim.Servers {8BB20F0A-0000-0000-0000-000000000000} {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False + False XMLRPC {8E81D43C-0000-0000-0000-000000000000} {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False + False @@ -112,6 +123,7 @@ Code + @@ -120,4 +132,4 @@ - + \ No newline at end of file diff --git a/OpenGridServices.UserServer/UserManager.cs b/OpenGridServices.UserServer/UserManager.cs new file mode 100644 index 0000000..7473685 --- /dev/null +++ b/OpenGridServices.UserServer/UserManager.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenGrid.Framework.Data; +using libsecondlife; +using System.Reflection; + +using System.Xml; +using Nwc.XmlRpc; +using OpenSim.Framework.Sims; +using OpenSim.Framework.Inventory; +using OpenSim.Framework.Utilities; + +namespace OpenGridServices.UserServer +{ + public class UserManager + { + Dictionary _plugins = new Dictionary(); + + /// + /// Adds a new user server plugin - user servers will be requested in the order they were loaded. + /// + /// The filename to the user server plugin DLL + public void AddPlugin(string FileName) + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Storage: Attempting to load " + FileName); + Assembly pluginAssembly = Assembly.LoadFrom(FileName); + + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Storage: Found " + pluginAssembly.GetTypes().Length + " interfaces."); + foreach (Type pluginType in pluginAssembly.GetTypes()) + { + if (!pluginType.IsAbstract) + { + Type typeInterface = pluginType.GetInterface("IUserData", true); + + if (typeInterface != null) + { + IUserData plug = (IUserData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); + plug.Initialise(); + this._plugins.Add(plug.getName(), plug); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Storage: Added IUserData Interface"); + } + + typeInterface = null; + } + } + + pluginAssembly = null; + } + + public UserProfileData getUserProfile(LLUUID uuid) + { + foreach (KeyValuePair plugin in _plugins) + { + try + { + return plugin.Value.getUserByUUID(uuid); + } + catch (Exception e) + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + } + } + + return null; + } + + public UserProfileData getUserProfile(string name) + { + foreach (KeyValuePair plugin in _plugins) + { + try + { + return plugin.Value.getUserByName(name); + } + catch (Exception e) + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + } + } + + return null; + } + + public UserProfileData getUserProfile(string fname, string lname) + { + foreach (KeyValuePair plugin in _plugins) + { + try + { + return plugin.Value.getUserByName(fname,lname); + } + catch (Exception e) + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); + } + } + + return null; + } + } +} -- cgit v1.1