diff options
author | Adam Frisby | 2007-05-16 21:10:45 +0000 |
---|---|---|
committer | Adam Frisby | 2007-05-16 21:10:45 +0000 |
commit | dc2acaa8a887e986644480237910308701c84c1a (patch) | |
tree | d5f292670f2295877cbece26ca43444dba82f03b /OpenGridServices.UserServer/UserManager.cs | |
parent | * sing loud, sing proud, sing from the heart (diff) | |
download | opensim-SC-dc2acaa8a887e986644480237910308701c84c1a.zip opensim-SC-dc2acaa8a887e986644480237910308701c84c1a.tar.gz opensim-SC-dc2acaa8a887e986644480237910308701c84c1a.tar.bz2 opensim-SC-dc2acaa8a887e986644480237910308701c84c1a.tar.xz |
Let stuff be broken!
Diffstat (limited to '')
-rw-r--r-- | OpenGridServices.UserServer/UserManager.cs | 102 |
1 files changed, 102 insertions, 0 deletions
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 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using OpenGrid.Framework.Data; | ||
5 | using libsecondlife; | ||
6 | using System.Reflection; | ||
7 | |||
8 | using System.Xml; | ||
9 | using Nwc.XmlRpc; | ||
10 | using OpenSim.Framework.Sims; | ||
11 | using OpenSim.Framework.Inventory; | ||
12 | using OpenSim.Framework.Utilities; | ||
13 | |||
14 | namespace OpenGridServices.UserServer | ||
15 | { | ||
16 | public class UserManager | ||
17 | { | ||
18 | Dictionary<string, IUserData> _plugins = new Dictionary<string, IUserData>(); | ||
19 | |||
20 | /// <summary> | ||
21 | /// Adds a new user server plugin - user servers will be requested in the order they were loaded. | ||
22 | /// </summary> | ||
23 | /// <param name="FileName">The filename to the user server plugin DLL</param> | ||
24 | public void AddPlugin(string FileName) | ||
25 | { | ||
26 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Storage: Attempting to load " + FileName); | ||
27 | Assembly pluginAssembly = Assembly.LoadFrom(FileName); | ||
28 | |||
29 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Storage: Found " + pluginAssembly.GetTypes().Length + " interfaces."); | ||
30 | foreach (Type pluginType in pluginAssembly.GetTypes()) | ||
31 | { | ||
32 | if (!pluginType.IsAbstract) | ||
33 | { | ||
34 | Type typeInterface = pluginType.GetInterface("IUserData", true); | ||
35 | |||
36 | if (typeInterface != null) | ||
37 | { | ||
38 | IUserData plug = (IUserData)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); | ||
39 | plug.Initialise(); | ||
40 | this._plugins.Add(plug.getName(), plug); | ||
41 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Storage: Added IUserData Interface"); | ||
42 | } | ||
43 | |||
44 | typeInterface = null; | ||
45 | } | ||
46 | } | ||
47 | |||
48 | pluginAssembly = null; | ||
49 | } | ||
50 | |||
51 | public UserProfileData getUserProfile(LLUUID uuid) | ||
52 | { | ||
53 | foreach (KeyValuePair<string, IUserData> plugin in _plugins) | ||
54 | { | ||
55 | try | ||
56 | { | ||
57 | return plugin.Value.getUserByUUID(uuid); | ||
58 | } | ||
59 | catch (Exception e) | ||
60 | { | ||
61 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); | ||
62 | } | ||
63 | } | ||
64 | |||
65 | return null; | ||
66 | } | ||
67 | |||
68 | public UserProfileData getUserProfile(string name) | ||
69 | { | ||
70 | foreach (KeyValuePair<string, IUserData> plugin in _plugins) | ||
71 | { | ||
72 | try | ||
73 | { | ||
74 | return plugin.Value.getUserByName(name); | ||
75 | } | ||
76 | catch (Exception e) | ||
77 | { | ||
78 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); | ||
79 | } | ||
80 | } | ||
81 | |||
82 | return null; | ||
83 | } | ||
84 | |||
85 | public UserProfileData getUserProfile(string fname, string lname) | ||
86 | { | ||
87 | foreach (KeyValuePair<string, IUserData> plugin in _plugins) | ||
88 | { | ||
89 | try | ||
90 | { | ||
91 | return plugin.Value.getUserByName(fname,lname); | ||
92 | } | ||
93 | catch (Exception e) | ||
94 | { | ||
95 | OpenSim.Framework.Console.MainConsole.Instance.WriteLine(OpenSim.Framework.Console.LogPriority.LOW, "Unable to find user via " + plugin.Key + "(" + e.ToString() + ")"); | ||
96 | } | ||
97 | } | ||
98 | |||
99 | return null; | ||
100 | } | ||
101 | } | ||
102 | } | ||