clockwerk-opensim – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 vero 1 /*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27  
28 using System;
29 using Nini.Config;
30 using log4net;
31 using Mono.Addins;
32 using System.Reflection;
33 using OpenSim.Region.Framework.Interfaces;
34 using OpenSim.Region.Framework.Scenes;
35 using OpenSim.Services.Interfaces;
36 using OpenSim.Services.Connectors;
37  
38 using OpenMetaverse;
39  
40 namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts
41 {
42 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RemoteUserAccountServicesConnector")]
43 public class RemoteUserAccountServicesConnector : UserAccountServicesConnector,
44 ISharedRegionModule, IUserAccountService
45 {
46 private static readonly ILog m_log =
47 LogManager.GetLogger(
48 MethodBase.GetCurrentMethod().DeclaringType);
49  
50 private bool m_Enabled = false;
51 private UserAccountCache m_Cache;
52  
53 public Type ReplaceableInterface
54 {
55 get { return null; }
56 }
57  
58 public string Name
59 {
60 get { return "RemoteUserAccountServicesConnector"; }
61 }
62  
63 public override void Initialise(IConfigSource source)
64 {
65 IConfig moduleConfig = source.Configs["Modules"];
66 if (moduleConfig != null)
67 {
68 string name = moduleConfig.GetString("UserAccountServices", "");
69 if (name == Name)
70 {
71 IConfig userConfig = source.Configs["UserAccountService"];
72 if (userConfig == null)
73 {
74 m_log.Error("[USER CONNECTOR]: UserAccountService missing from OpenSim.ini");
75 return;
76 }
77  
78 m_Enabled = true;
79  
80 base.Initialise(source);
81 m_Cache = new UserAccountCache();
82  
83 m_log.Info("[USER CONNECTOR]: Remote users enabled");
84 }
85 }
86 }
87  
88 public void PostInitialise()
89 {
90 if (!m_Enabled)
91 return;
92 }
93  
94 public void Close()
95 {
96 if (!m_Enabled)
97 return;
98 }
99  
100 public void AddRegion(Scene scene)
101 {
102 if (!m_Enabled)
103 return;
104  
105 scene.RegisterModuleInterface<IUserAccountService>(this);
106 }
107  
108 public void RemoveRegion(Scene scene)
109 {
110 if (!m_Enabled)
111 return;
112 }
113  
114 public void RegionLoaded(Scene scene)
115 {
116 if (!m_Enabled)
117 return;
118 }
119  
120 #region Overwritten methods from IUserAccountService
121  
122 public override UserAccount GetUserAccount(UUID scopeID, UUID userID)
123 {
124 bool inCache = false;
125 UserAccount account = m_Cache.Get(userID, out inCache);
126 if (inCache)
127 return account;
128  
129 account = base.GetUserAccount(scopeID, userID);
130 m_Cache.Cache(userID, account);
131  
132 return account;
133 }
134  
135 public override UserAccount GetUserAccount(UUID scopeID, string firstName, string lastName)
136 {
137 bool inCache = false;
138 UserAccount account = m_Cache.Get(firstName + " " + lastName, out inCache);
139 if (inCache)
140 return account;
141  
142 account = base.GetUserAccount(scopeID, firstName, lastName);
143 if (account != null)
144 m_Cache.Cache(account.PrincipalID, account);
145  
146 return account;
147 }
148  
149 public override bool StoreUserAccount(UserAccount data)
150 {
151 // This remote connector refuses to serve this method
152 return false;
153 }
154  
155 #endregion
156 }
157 }