aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Hypergrid
diff options
context:
space:
mode:
authorDiva Canto2010-01-10 10:40:07 -0800
committerDiva Canto2010-01-10 10:40:07 -0800
commit1e1b2ab221851efc414678b7ea52ef2ca788ce9f (patch)
tree29b6aa80e54a9c18529ae14e7d185fe67582d151 /OpenSim/Region/CoreModules/Hypergrid
parentAdd a "LockedOut" flag to allow locking a region out via the grid server. (diff)
downloadopensim-SC_OLD-1e1b2ab221851efc414678b7ea52ef2ca788ce9f.zip
opensim-SC_OLD-1e1b2ab221851efc414678b7ea52ef2ca788ce9f.tar.gz
opensim-SC_OLD-1e1b2ab221851efc414678b7ea52ef2ca788ce9f.tar.bz2
opensim-SC_OLD-1e1b2ab221851efc414678b7ea52ef2ca788ce9f.tar.xz
* OMG! All but one references to UserProfileCacheService have been rerouted!
* HG is seriously broken here * Compiles. Untested.
Diffstat (limited to 'OpenSim/Region/CoreModules/Hypergrid')
-rw-r--r--OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs326
1 files changed, 0 insertions, 326 deletions
diff --git a/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs b/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs
deleted file mode 100644
index 46ee3c0..0000000
--- a/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs
+++ /dev/null
@@ -1,326 +0,0 @@
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
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Net;
32using System.Reflection;
33using System.Text.RegularExpressions;
34using log4net;
35using Nini.Config;
36using OpenMetaverse;
37using Nwc.XmlRpc;
38using OpenSim.Framework;
39using OpenSim.Framework.Communications;
40using OpenSim.Framework.Communications.Services;
41using OpenSim.Framework.Communications.Cache;
42using OpenSim.Framework.Capabilities;
43using OpenSim.Framework.Servers.HttpServer;
44using OpenSim.Region.Framework.Scenes;
45using OpenSim.Region.Framework.Interfaces;
46
47namespace OpenSim.Region.CoreModules.Hypergrid
48{
49 public class HGStandaloneLoginModule : IRegionModule, ILoginServiceToRegionsConnector
50 {
51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52
53 protected List<Scene> m_scenes = new List<Scene>();
54 protected Scene m_firstScene;
55
56 protected bool m_enabled = false; // Module is only enabled if running in standalone mode
57
58 public bool RegionLoginsEnabled
59 {
60 get
61 {
62 if (m_firstScene != null)
63 {
64 return m_firstScene.SceneGridService.RegionLoginsEnabled;
65 }
66 else
67 {
68 return false;
69 }
70 }
71 }
72
73 protected HGLoginAuthService m_loginService;
74
75 #region IRegionModule Members
76
77 public void Initialise(Scene scene, IConfigSource source)
78 {
79 if (m_firstScene == null)
80 {
81 m_firstScene = scene;
82
83 IConfig startupConfig = source.Configs["Startup"];
84 if (startupConfig != null)
85 {
86 m_enabled = !startupConfig.GetBoolean("gridmode", false);
87 }
88
89 if (m_enabled)
90 {
91 m_log.Debug("[HGLogin]: HGlogin module enabled");
92 bool authenticate = true;
93 string welcomeMessage = "Welcome to OpenSim";
94 IConfig standaloneConfig = source.Configs["StandAlone"];
95 if (standaloneConfig != null)
96 {
97 authenticate = standaloneConfig.GetBoolean("accounts_authenticate", true);
98 welcomeMessage = standaloneConfig.GetString("welcome_message");
99 }
100
101 //TODO: fix casting.
102 LibraryRootFolder rootFolder = m_firstScene.CommsManager.UserProfileCacheService.LibraryRoot as LibraryRootFolder;
103
104 IHttpServer httpServer = MainServer.Instance;
105
106 //TODO: fix the casting of the user service, maybe by registering the userManagerBase with scenes, or refactoring so we just need a IUserService reference
107 m_loginService
108 = new HGLoginAuthService(
109 (UserManagerBase)m_firstScene.CommsManager.UserAdminService,
110 welcomeMessage,
111 m_firstScene.CommsManager.InterServiceInventoryService,
112 m_firstScene.CommsManager.NetworkServersInfo,
113 authenticate,
114 rootFolder,
115 this);
116
117 httpServer.AddXmlRPCHandler("hg_login", m_loginService.XmlRpcLoginMethod);
118 httpServer.AddXmlRPCHandler("check_auth_session", m_loginService.XmlRPCCheckAuthSession, false);
119 httpServer.AddXmlRPCHandler("get_avatar_appearance", XmlRPCGetAvatarAppearance);
120 httpServer.AddXmlRPCHandler("update_avatar_appearance", XmlRPCUpdateAvatarAppearance);
121
122 }
123 }
124
125 if (m_enabled)
126 {
127 AddScene(scene);
128 }
129 }
130
131 public void PostInitialise()
132 {
133
134 }
135
136 public void Close()
137 {
138
139 }
140
141 public string Name
142 {
143 get { return "HGStandaloneLoginModule"; }
144 }
145
146 public bool IsSharedModule
147 {
148 get { return true; }
149 }
150
151 #endregion
152
153 protected void AddScene(Scene scene)
154 {
155 lock (m_scenes)
156 {
157 if (!m_scenes.Contains(scene))
158 {
159 m_scenes.Add(scene);
160 }
161 }
162 }
163
164 public bool NewUserConnection(ulong regionHandle, AgentCircuitData agent, out string reason)
165 {
166 reason = String.Empty;
167 return true;
168 }
169
170 public void LogOffUserFromGrid(ulong regionHandle, UUID AvatarID, UUID RegionSecret, string message)
171 {
172 Scene scene;
173 if (TryGetRegion(regionHandle, out scene))
174 {
175 scene.HandleLogOffUserFromGrid(AvatarID, RegionSecret, message);
176 }
177 }
178
179 public RegionInfo RequestNeighbourInfo(ulong regionhandle)
180 {
181 Scene scene;
182 if (TryGetRegion(regionhandle, out scene))
183 {
184 return scene.RegionInfo;
185 }
186 return null;
187 }
188
189 public RegionInfo RequestClosestRegion(string region)
190 {
191 Scene scene;
192 if (TryGetRegion(region, out scene))
193 {
194 return scene.RegionInfo;
195 }
196 else if (m_scenes.Count > 0)
197 {
198 return m_scenes[0].RegionInfo;
199 }
200 return null;
201 }
202
203 public RegionInfo RequestNeighbourInfo(UUID regionID)
204 {
205 Scene scene;
206 if (TryGetRegion(regionID, out scene))
207 {
208 return scene.RegionInfo;
209 }
210 return null;
211 }
212
213 protected bool TryGetRegion(ulong regionHandle, out Scene scene)
214 {
215 lock (m_scenes)
216 {
217 foreach (Scene nextScene in m_scenes)
218 {
219 if (nextScene.RegionInfo.RegionHandle == regionHandle)
220 {
221 scene = nextScene;
222 return true;
223 }
224 }
225 }
226
227 scene = null;
228 return false;
229 }
230
231 protected bool TryGetRegion(UUID regionID, out Scene scene)
232 {
233 lock (m_scenes)
234 {
235 foreach (Scene nextScene in m_scenes)
236 {
237 if (nextScene.RegionInfo.RegionID == regionID)
238 {
239 scene = nextScene;
240 return true;
241 }
242 }
243 }
244
245 scene = null;
246 return false;
247 }
248
249 protected bool TryGetRegion(string regionName, out Scene scene)
250 {
251 lock (m_scenes)
252 {
253 foreach (Scene nextScene in m_scenes)
254 {
255 if (nextScene.RegionInfo.RegionName.Equals(regionName, StringComparison.InvariantCultureIgnoreCase))
256 {
257 scene = nextScene;
258 return true;
259 }
260 }
261 }
262
263 scene = null;
264 return false;
265 }
266
267 public XmlRpcResponse XmlRPCGetAvatarAppearance(XmlRpcRequest request, IPEndPoint remoteClient)
268 {
269 XmlRpcResponse response = new XmlRpcResponse();
270 Hashtable requestData = (Hashtable)request.Params[0];
271 AvatarAppearance appearance;
272 Hashtable responseData;
273 if (requestData.Contains("owner"))
274 {
275 appearance = m_firstScene.CommsManager.AvatarService.GetUserAppearance(new UUID((string)requestData["owner"]));
276 if (appearance == null)
277 {
278 responseData = new Hashtable();
279 responseData["error_type"] = "no appearance";
280 responseData["error_desc"] = "There was no appearance found for this avatar";
281 }
282 else
283 {
284 responseData = appearance.ToHashTable();
285 }
286 }
287 else
288 {
289 responseData = new Hashtable();
290 responseData["error_type"] = "unknown_avatar";
291 responseData["error_desc"] = "The avatar appearance requested is not in the database";
292 }
293
294 response.Value = responseData;
295 return response;
296 }
297
298 public XmlRpcResponse XmlRPCUpdateAvatarAppearance(XmlRpcRequest request, IPEndPoint remoteClient)
299 {
300 XmlRpcResponse response = new XmlRpcResponse();
301 Hashtable requestData = (Hashtable)request.Params[0];
302 Hashtable responseData;
303 if (requestData.Contains("owner"))
304 {
305 AvatarAppearance appearance = new AvatarAppearance(requestData);
306
307 // TODO: Sometime in the future we may have a database layer that is capable of updating appearance when
308 // the TextureEntry is null. When that happens, this check can be removed
309 if (appearance.Texture != null)
310 m_firstScene.CommsManager.AvatarService.UpdateUserAppearance(new UUID((string)requestData["owner"]), appearance);
311
312 responseData = new Hashtable();
313 responseData["returnString"] = "TRUE";
314 }
315 else
316 {
317 responseData = new Hashtable();
318 responseData["error_type"] = "unknown_avatar";
319 responseData["error_desc"] = "The avatar appearance requested is not in the database";
320 }
321 response.Value = responseData;
322 return response;
323 }
324 }
325
326}