aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenGridServices.UserServer/UserManager.cs
diff options
context:
space:
mode:
authorAdam Frisby2007-05-16 21:10:45 +0000
committerAdam Frisby2007-05-16 21:10:45 +0000
commitdc2acaa8a887e986644480237910308701c84c1a (patch)
treed5f292670f2295877cbece26ca43444dba82f03b /OpenGridServices.UserServer/UserManager.cs
parent* sing loud, sing proud, sing from the heart (diff)
downloadopensim-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 'OpenGridServices.UserServer/UserManager.cs')
-rw-r--r--OpenGridServices.UserServer/UserManager.cs102
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 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using OpenGrid.Framework.Data;
5using libsecondlife;
6using System.Reflection;
7
8using System.Xml;
9using Nwc.XmlRpc;
10using OpenSim.Framework.Sims;
11using OpenSim.Framework.Inventory;
12using OpenSim.Framework.Utilities;
13
14namespace 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}