aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/UserServer.Modules/UserLoginService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Grid/UserServer.Modules/UserLoginService.cs')
-rw-r--r--OpenSim/Grid/UserServer.Modules/UserLoginService.cs1200
1 files changed, 600 insertions, 600 deletions
diff --git a/OpenSim/Grid/UserServer.Modules/UserLoginService.cs b/OpenSim/Grid/UserServer.Modules/UserLoginService.cs
index 928753f..64ac463 100644
--- a/OpenSim/Grid/UserServer.Modules/UserLoginService.cs
+++ b/OpenSim/Grid/UserServer.Modules/UserLoginService.cs
@@ -1,600 +1,600 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the 12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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 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 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 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. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Reflection; 31using System.Reflection;
32using System.Text.RegularExpressions; 32using System.Text.RegularExpressions;
33using log4net; 33using log4net;
34using Nwc.XmlRpc; 34using Nwc.XmlRpc;
35using OpenMetaverse; 35using OpenMetaverse;
36using OpenSim.Data; 36using OpenSim.Data;
37using OpenSim.Framework; 37using OpenSim.Framework;
38using OpenSim.Framework.Communications; 38using OpenSim.Framework.Communications;
39using OpenSim.Framework.Communications.Cache; 39using OpenSim.Framework.Communications.Cache;
40using OpenSim.Framework.Communications.Capabilities; 40using OpenSim.Framework.Communications.Capabilities;
41using OpenSim.Framework.Servers; 41using OpenSim.Framework.Servers;
42 42
43namespace OpenSim.Grid.UserServer.Modules 43namespace OpenSim.Grid.UserServer.Modules
44{ 44{
45 public delegate void UserLoggedInAtLocation(UUID agentID, UUID sessionID, UUID RegionID, 45 public delegate void UserLoggedInAtLocation(UUID agentID, UUID sessionID, UUID RegionID,
46 ulong regionhandle, float positionX, float positionY, float positionZ, 46 ulong regionhandle, float positionX, float positionY, float positionZ,
47 string firstname, string lastname); 47 string firstname, string lastname);
48 48
49 /// <summary> 49 /// <summary>
50 /// Login service used in grid mode. 50 /// Login service used in grid mode.
51 /// </summary> 51 /// </summary>
52 public class UserLoginService : LoginService 52 public class UserLoginService : LoginService
53 { 53 {
54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55 55
56 protected IInterServiceInventoryServices m_inventoryService; 56 protected IInterServiceInventoryServices m_inventoryService;
57 57
58 public event UserLoggedInAtLocation OnUserLoggedInAtLocation; 58 public event UserLoggedInAtLocation OnUserLoggedInAtLocation;
59 59
60 private UserLoggedInAtLocation handlerUserLoggedInAtLocation; 60 private UserLoggedInAtLocation handlerUserLoggedInAtLocation;
61 61
62 public UserConfig m_config; 62 public UserConfig m_config;
63 private readonly IRegionProfileService m_regionProfileService; 63 private readonly IRegionProfileService m_regionProfileService;
64 64
65 protected BaseHttpServer m_httpServer; 65 protected BaseHttpServer m_httpServer;
66 66
67 public UserLoginService( 67 public UserLoginService(
68 UserManagerBase userManager, IInterServiceInventoryServices inventoryService, 68 UserManagerBase userManager, IInterServiceInventoryServices inventoryService,
69 LibraryRootFolder libraryRootFolder, 69 LibraryRootFolder libraryRootFolder,
70 UserConfig config, string welcomeMess, IRegionProfileService regionProfileService) 70 UserConfig config, string welcomeMess, IRegionProfileService regionProfileService)
71 : base(userManager, libraryRootFolder, welcomeMess) 71 : base(userManager, libraryRootFolder, welcomeMess)
72 { 72 {
73 m_config = config; 73 m_config = config;
74 m_inventoryService = inventoryService; 74 m_inventoryService = inventoryService;
75 m_regionProfileService = regionProfileService; 75 m_regionProfileService = regionProfileService;
76 } 76 }
77 77
78 public void RegisterHandlers(BaseHttpServer httpServer, bool registerLLSDHandler, bool registerOpenIDHandlers) 78 public void RegisterHandlers(BaseHttpServer httpServer, bool registerLLSDHandler, bool registerOpenIDHandlers)
79 { 79 {
80 m_httpServer = httpServer; 80 m_httpServer = httpServer;
81 81
82 m_httpServer.AddXmlRPCHandler("login_to_simulator", XmlRpcLoginMethod); 82 m_httpServer.AddXmlRPCHandler("login_to_simulator", XmlRpcLoginMethod);
83 m_httpServer.AddHTTPHandler("login", ProcessHTMLLogin); 83 m_httpServer.AddHTTPHandler("login", ProcessHTMLLogin);
84 m_httpServer.AddXmlRPCHandler("set_login_params", XmlRPCSetLoginParams); 84 m_httpServer.AddXmlRPCHandler("set_login_params", XmlRPCSetLoginParams);
85 85
86 if (registerLLSDHandler) 86 if (registerLLSDHandler)
87 { 87 {
88 m_httpServer.SetDefaultLLSDHandler(LLSDLoginMethod); 88 m_httpServer.SetDefaultLLSDHandler(LLSDLoginMethod);
89 } 89 }
90 90
91 if (registerOpenIDHandlers) 91 if (registerOpenIDHandlers)
92 { 92 {
93 // Handler for OpenID avatar identity pages 93 // Handler for OpenID avatar identity pages
94 m_httpServer.AddStreamHandler(new OpenIdStreamHandler("GET", "/users/", this)); 94 m_httpServer.AddStreamHandler(new OpenIdStreamHandler("GET", "/users/", this));
95 // Handlers for the OpenID endpoint server 95 // Handlers for the OpenID endpoint server
96 m_httpServer.AddStreamHandler(new OpenIdStreamHandler("POST", "/openid/server/", this)); 96 m_httpServer.AddStreamHandler(new OpenIdStreamHandler("POST", "/openid/server/", this));
97 m_httpServer.AddStreamHandler(new OpenIdStreamHandler("GET", "/openid/server/", this)); 97 m_httpServer.AddStreamHandler(new OpenIdStreamHandler("GET", "/openid/server/", this));
98 } 98 }
99 } 99 }
100 100
101 public void setloginlevel(int level) 101 public void setloginlevel(int level)
102 { 102 {
103 m_minLoginLevel = level; 103 m_minLoginLevel = level;
104 m_log.InfoFormat("[GRID]: Login Level set to {0} ", level); 104 m_log.InfoFormat("[GRID]: Login Level set to {0} ", level);
105 } 105 }
106 public void setwelcometext(string text) 106 public void setwelcometext(string text)
107 { 107 {
108 m_welcomeMessage = text; 108 m_welcomeMessage = text;
109 m_log.InfoFormat("[GRID]: Login text set to {0} ", text); 109 m_log.InfoFormat("[GRID]: Login text set to {0} ", text);
110 } 110 }
111 111
112 public override void LogOffUser(UserProfileData theUser, string message) 112 public override void LogOffUser(UserProfileData theUser, string message)
113 { 113 {
114 RegionProfileData SimInfo; 114 RegionProfileData SimInfo;
115 try 115 try
116 { 116 {
117 SimInfo = m_regionProfileService.RequestSimProfileData( 117 SimInfo = m_regionProfileService.RequestSimProfileData(
118 theUser.CurrentAgent.Handle, m_config.GridServerURL, 118 theUser.CurrentAgent.Handle, m_config.GridServerURL,
119 m_config.GridSendKey, m_config.GridRecvKey); 119 m_config.GridSendKey, m_config.GridRecvKey);
120 120
121 if (SimInfo == null) 121 if (SimInfo == null)
122 { 122 {
123 m_log.Error("[GRID]: Region user was in isn't currently logged in"); 123 m_log.Error("[GRID]: Region user was in isn't currently logged in");
124 return; 124 return;
125 } 125 }
126 } 126 }
127 catch (Exception) 127 catch (Exception)
128 { 128 {
129 m_log.Error("[GRID]: Unable to look up region to log user off"); 129 m_log.Error("[GRID]: Unable to look up region to log user off");
130 return; 130 return;
131 } 131 }
132 132
133 // Prepare notification 133 // Prepare notification
134 Hashtable SimParams = new Hashtable(); 134 Hashtable SimParams = new Hashtable();
135 SimParams["agent_id"] = theUser.ID.ToString(); 135 SimParams["agent_id"] = theUser.ID.ToString();
136 SimParams["region_secret"] = theUser.CurrentAgent.SecureSessionID.ToString(); 136 SimParams["region_secret"] = theUser.CurrentAgent.SecureSessionID.ToString();
137 SimParams["region_secret2"] = SimInfo.regionSecret; 137 SimParams["region_secret2"] = SimInfo.regionSecret;
138 //m_log.Info(SimInfo.regionSecret); 138 //m_log.Info(SimInfo.regionSecret);
139 SimParams["regionhandle"] = theUser.CurrentAgent.Handle.ToString(); 139 SimParams["regionhandle"] = theUser.CurrentAgent.Handle.ToString();
140 SimParams["message"] = message; 140 SimParams["message"] = message;
141 ArrayList SendParams = new ArrayList(); 141 ArrayList SendParams = new ArrayList();
142 SendParams.Add(SimParams); 142 SendParams.Add(SimParams);
143 143
144 m_log.InfoFormat( 144 m_log.InfoFormat(
145 "[ASSUMED CRASH]: Telling region {0} @ {1},{2} ({3}) that their agent is dead: {4}", 145 "[ASSUMED CRASH]: Telling region {0} @ {1},{2} ({3}) that their agent is dead: {4}",
146 SimInfo.regionName, SimInfo.regionLocX, SimInfo.regionLocY, SimInfo.httpServerURI, 146 SimInfo.regionName, SimInfo.regionLocX, SimInfo.regionLocY, SimInfo.httpServerURI,
147 theUser.FirstName + " " + theUser.SurName); 147 theUser.FirstName + " " + theUser.SurName);
148 148
149 try 149 try
150 { 150 {
151 XmlRpcRequest GridReq = new XmlRpcRequest("logoff_user", SendParams); 151 XmlRpcRequest GridReq = new XmlRpcRequest("logoff_user", SendParams);
152 XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000); 152 XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000);
153 153
154 if (GridResp.IsFault) 154 if (GridResp.IsFault)
155 { 155 {
156 m_log.ErrorFormat( 156 m_log.ErrorFormat(
157 "[LOGIN]: XMLRPC request for {0} failed, fault code: {1}, reason: {2}, This is likely an old region revision.", 157 "[LOGIN]: XMLRPC request for {0} failed, fault code: {1}, reason: {2}, This is likely an old region revision.",
158 SimInfo.httpServerURI, GridResp.FaultCode, GridResp.FaultString); 158 SimInfo.httpServerURI, GridResp.FaultCode, GridResp.FaultString);
159 } 159 }
160 } 160 }
161 catch (Exception) 161 catch (Exception)
162 { 162 {
163 m_log.Error("[LOGIN]: Error telling region to logout user!"); 163 m_log.Error("[LOGIN]: Error telling region to logout user!");
164 } 164 }
165 165
166 // Prepare notification 166 // Prepare notification
167 SimParams = new Hashtable(); 167 SimParams = new Hashtable();
168 SimParams["agent_id"] = theUser.ID.ToString(); 168 SimParams["agent_id"] = theUser.ID.ToString();
169 SimParams["region_secret"] = SimInfo.regionSecret; 169 SimParams["region_secret"] = SimInfo.regionSecret;
170 //m_log.Info(SimInfo.regionSecret); 170 //m_log.Info(SimInfo.regionSecret);
171 SimParams["regionhandle"] = theUser.CurrentAgent.Handle.ToString(); 171 SimParams["regionhandle"] = theUser.CurrentAgent.Handle.ToString();
172 SimParams["message"] = message; 172 SimParams["message"] = message;
173 SendParams = new ArrayList(); 173 SendParams = new ArrayList();
174 SendParams.Add(SimParams); 174 SendParams.Add(SimParams);
175 175
176 m_log.InfoFormat( 176 m_log.InfoFormat(
177 "[ASSUMED CRASH]: Telling region {0} @ {1},{2} ({3}) that their agent is dead: {4}", 177 "[ASSUMED CRASH]: Telling region {0} @ {1},{2} ({3}) that their agent is dead: {4}",
178 SimInfo.regionName, SimInfo.regionLocX, SimInfo.regionLocY, SimInfo.httpServerURI, 178 SimInfo.regionName, SimInfo.regionLocX, SimInfo.regionLocY, SimInfo.httpServerURI,
179 theUser.FirstName + " " + theUser.SurName); 179 theUser.FirstName + " " + theUser.SurName);
180 180
181 try 181 try
182 { 182 {
183 XmlRpcRequest GridReq = new XmlRpcRequest("logoff_user", SendParams); 183 XmlRpcRequest GridReq = new XmlRpcRequest("logoff_user", SendParams);
184 XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000); 184 XmlRpcResponse GridResp = GridReq.Send(SimInfo.httpServerURI, 6000);
185 185
186 if (GridResp.IsFault) 186 if (GridResp.IsFault)
187 { 187 {
188 m_log.ErrorFormat( 188 m_log.ErrorFormat(
189 "[LOGIN]: XMLRPC request for {0} failed, fault code: {1}, reason: {2}, This is likely an old region revision.", 189 "[LOGIN]: XMLRPC request for {0} failed, fault code: {1}, reason: {2}, This is likely an old region revision.",
190 SimInfo.httpServerURI, GridResp.FaultCode, GridResp.FaultString); 190 SimInfo.httpServerURI, GridResp.FaultCode, GridResp.FaultString);
191 } 191 }
192 } 192 }
193 catch (Exception) 193 catch (Exception)
194 { 194 {
195 m_log.Error("[LOGIN]: Error telling region to logout user!"); 195 m_log.Error("[LOGIN]: Error telling region to logout user!");
196 } 196 }
197 //base.LogOffUser(theUser); 197 //base.LogOffUser(theUser);
198 } 198 }
199 199
200 /// <summary> 200 /// <summary>
201 /// Customises the login response and fills in missing values. 201 /// Customises the login response and fills in missing values.
202 /// </summary> 202 /// </summary>
203 /// <param name="response">The existing response</param> 203 /// <param name="response">The existing response</param>
204 /// <param name="theUser">The user profile</param> 204 /// <param name="theUser">The user profile</param>
205 /// <param name="startLocationRequest">The requested start location</param> 205 /// <param name="startLocationRequest">The requested start location</param>
206 public override bool CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest) 206 public override bool CustomiseResponse(LoginResponse response, UserProfileData theUser, string startLocationRequest)
207 { 207 {
208 // add active gestures to login-response 208 // add active gestures to login-response
209 AddActiveGestures(response, theUser); 209 AddActiveGestures(response, theUser);
210 210
211 // HomeLocation 211 // HomeLocation
212 RegionProfileData homeInfo = null; 212 RegionProfileData homeInfo = null;
213 // use the homeRegionID if it is stored already. If not, use the regionHandle as before 213 // use the homeRegionID if it is stored already. If not, use the regionHandle as before
214 UUID homeRegionId = theUser.HomeRegionID; 214 UUID homeRegionId = theUser.HomeRegionID;
215 ulong homeRegionHandle = theUser.HomeRegion; 215 ulong homeRegionHandle = theUser.HomeRegion;
216 if (homeRegionId != UUID.Zero) 216 if (homeRegionId != UUID.Zero)
217 { 217 {
218 homeInfo = GetRegionInfo(homeRegionId); 218 homeInfo = GetRegionInfo(homeRegionId);
219 } 219 }
220 else 220 else
221 { 221 {
222 homeInfo = GetRegionInfo(homeRegionHandle); 222 homeInfo = GetRegionInfo(homeRegionHandle);
223 } 223 }
224 224
225 if (homeInfo != null) 225 if (homeInfo != null)
226 { 226 {
227 response.Home = 227 response.Home =
228 string.Format( 228 string.Format(
229 "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", 229 "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}",
230 (homeInfo.regionLocX*Constants.RegionSize), 230 (homeInfo.regionLocX*Constants.RegionSize),
231 (homeInfo.regionLocY*Constants.RegionSize), 231 (homeInfo.regionLocY*Constants.RegionSize),
232 theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, 232 theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z,
233 theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); 233 theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z);
234 } 234 }
235 else 235 else
236 { 236 {
237 // Emergency mode: Home-region isn't available, so we can't request the region info. 237 // Emergency mode: Home-region isn't available, so we can't request the region info.
238 // Use the stored home regionHandle instead. 238 // Use the stored home regionHandle instead.
239 // NOTE: If the home-region moves, this will be wrong until the users update their user-profile again 239 // NOTE: If the home-region moves, this will be wrong until the users update their user-profile again
240 ulong regionX = homeRegionHandle >> 32; 240 ulong regionX = homeRegionHandle >> 32;
241 ulong regionY = homeRegionHandle & 0xffffffff; 241 ulong regionY = homeRegionHandle & 0xffffffff;
242 response.Home = 242 response.Home =
243 string.Format( 243 string.Format(
244 "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", 244 "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}",
245 regionX, regionY, 245 regionX, regionY,
246 theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, 246 theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z,
247 theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); 247 theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z);
248 m_log.InfoFormat("[LOGIN] Home region of user {0} {1} is not available; using computed region position {2} {3}", 248 m_log.InfoFormat("[LOGIN] Home region of user {0} {1} is not available; using computed region position {2} {3}",
249 theUser.FirstName, theUser.SurName, 249 theUser.FirstName, theUser.SurName,
250 regionX, regionY); 250 regionX, regionY);
251 } 251 }
252 252
253 // StartLocation 253 // StartLocation
254 RegionProfileData regionInfo = null; 254 RegionProfileData regionInfo = null;
255 if (startLocationRequest == "home") 255 if (startLocationRequest == "home")
256 { 256 {
257 regionInfo = homeInfo; 257 regionInfo = homeInfo;
258 theUser.CurrentAgent.Position = theUser.HomeLocation; 258 theUser.CurrentAgent.Position = theUser.HomeLocation;
259 response.LookAt = "[r" + theUser.HomeLookAt.X.ToString() + ",r" + theUser.HomeLookAt.Y.ToString() + ",r" + theUser.HomeLookAt.Z.ToString() + "]"; 259 response.LookAt = "[r" + theUser.HomeLookAt.X.ToString() + ",r" + theUser.HomeLookAt.Y.ToString() + ",r" + theUser.HomeLookAt.Z.ToString() + "]";
260 } 260 }
261 else if (startLocationRequest == "last") 261 else if (startLocationRequest == "last")
262 { 262 {
263 UUID lastRegion = theUser.CurrentAgent.Region; 263 UUID lastRegion = theUser.CurrentAgent.Region;
264 regionInfo = GetRegionInfo(lastRegion); 264 regionInfo = GetRegionInfo(lastRegion);
265 response.LookAt = "[r" + theUser.CurrentAgent.LookAt.X.ToString() + ",r" + theUser.CurrentAgent.LookAt.Y.ToString() + ",r" + theUser.CurrentAgent.LookAt.Z.ToString() + "]"; 265 response.LookAt = "[r" + theUser.CurrentAgent.LookAt.X.ToString() + ",r" + theUser.CurrentAgent.LookAt.Y.ToString() + ",r" + theUser.CurrentAgent.LookAt.Z.ToString() + "]";
266 } 266 }
267 else 267 else
268 { 268 {
269 Regex reURI = new Regex(@"^uri:(?<region>[^&]+)&(?<x>\d+)&(?<y>\d+)&(?<z>\d+)$"); 269 Regex reURI = new Regex(@"^uri:(?<region>[^&]+)&(?<x>\d+)&(?<y>\d+)&(?<z>\d+)$");
270 Match uriMatch = reURI.Match(startLocationRequest); 270 Match uriMatch = reURI.Match(startLocationRequest);
271 if (uriMatch == null) 271 if (uriMatch == null)
272 { 272 {
273 m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, but can't process it", startLocationRequest); 273 m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, but can't process it", startLocationRequest);
274 } 274 }
275 else 275 else
276 { 276 {
277 string region = uriMatch.Groups["region"].ToString(); 277 string region = uriMatch.Groups["region"].ToString();
278 regionInfo = RequestClosestRegion(region); 278 regionInfo = RequestClosestRegion(region);
279 if (regionInfo == null) 279 if (regionInfo == null)
280 { 280 {
281 m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, can't locate region {1}", startLocationRequest, region); 281 m_log.InfoFormat("[LOGIN]: Got Custom Login URL {0}, can't locate region {1}", startLocationRequest, region);
282 } 282 }
283 else 283 else
284 { 284 {
285 theUser.CurrentAgent.Position = new Vector3(float.Parse(uriMatch.Groups["x"].Value), 285 theUser.CurrentAgent.Position = new Vector3(float.Parse(uriMatch.Groups["x"].Value),
286 float.Parse(uriMatch.Groups["y"].Value), float.Parse(uriMatch.Groups["z"].Value)); 286 float.Parse(uriMatch.Groups["y"].Value), float.Parse(uriMatch.Groups["z"].Value));
287 } 287 }
288 } 288 }
289 response.LookAt = "[r0,r1,r0]"; 289 response.LookAt = "[r0,r1,r0]";
290 // can be: last, home, safe, url 290 // can be: last, home, safe, url
291 response.StartLocation = "url"; 291 response.StartLocation = "url";
292 } 292 }
293 293
294 if ((regionInfo != null) && (PrepareLoginToRegion(regionInfo, theUser, response))) 294 if ((regionInfo != null) && (PrepareLoginToRegion(regionInfo, theUser, response)))
295 { 295 {
296 return true; 296 return true;
297 } 297 }
298 298
299 // StartLocation not available, send him to a nearby region instead 299 // StartLocation not available, send him to a nearby region instead
300 //regionInfo = RegionProfileData.RequestSimProfileData("", m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey); 300 //regionInfo = RegionProfileData.RequestSimProfileData("", m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey);
301 //m_log.InfoFormat("[LOGIN]: StartLocation not available sending to region {0}", regionInfo.regionName); 301 //m_log.InfoFormat("[LOGIN]: StartLocation not available sending to region {0}", regionInfo.regionName);
302 302
303 // Send him to default region instead 303 // Send him to default region instead
304 // Load information from the gridserver 304 // Load information from the gridserver
305 ulong defaultHandle = (((ulong) m_config.DefaultX * Constants.RegionSize) << 32) | 305 ulong defaultHandle = (((ulong) m_config.DefaultX * Constants.RegionSize) << 32) |
306 ((ulong) m_config.DefaultY * Constants.RegionSize); 306 ((ulong) m_config.DefaultY * Constants.RegionSize);
307 307
308 if ((regionInfo != null) && (defaultHandle == regionInfo.regionHandle)) 308 if ((regionInfo != null) && (defaultHandle == regionInfo.regionHandle))
309 { 309 {
310 m_log.ErrorFormat("[LOGIN]: Not trying the default region since this is the same as the selected region"); 310 m_log.ErrorFormat("[LOGIN]: Not trying the default region since this is the same as the selected region");
311 return false; 311 return false;
312 } 312 }
313 313
314 m_log.Error("[LOGIN]: Sending user to default region " + defaultHandle + " instead"); 314 m_log.Error("[LOGIN]: Sending user to default region " + defaultHandle + " instead");
315 regionInfo = GetRegionInfo(defaultHandle); 315 regionInfo = GetRegionInfo(defaultHandle);
316 316
317 // Customise the response 317 // Customise the response
318 //response.Home = 318 //response.Home =
319 // string.Format( 319 // string.Format(
320 // "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", 320 // "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}",
321 // (SimInfo.regionLocX * Constants.RegionSize), 321 // (SimInfo.regionLocX * Constants.RegionSize),
322 // (SimInfo.regionLocY*Constants.RegionSize), 322 // (SimInfo.regionLocY*Constants.RegionSize),
323 // theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z, 323 // theUser.HomeLocation.X, theUser.HomeLocation.Y, theUser.HomeLocation.Z,
324 // theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z); 324 // theUser.HomeLookAt.X, theUser.HomeLookAt.Y, theUser.HomeLookAt.Z);
325 theUser.CurrentAgent.Position = new Vector3(128,128,0); 325 theUser.CurrentAgent.Position = new Vector3(128,128,0);
326 response.StartLocation = "safe"; 326 response.StartLocation = "safe";
327 327
328 return PrepareLoginToRegion(regionInfo, theUser, response); 328 return PrepareLoginToRegion(regionInfo, theUser, response);
329 } 329 }
330 330
331 protected RegionProfileData RequestClosestRegion(string region) 331 protected RegionProfileData RequestClosestRegion(string region)
332 { 332 {
333 return m_regionProfileService.RequestSimProfileData(region, 333 return m_regionProfileService.RequestSimProfileData(region,
334 m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey); 334 m_config.GridServerURL, m_config.GridSendKey, m_config.GridRecvKey);
335 } 335 }
336 336
337 protected RegionProfileData GetRegionInfo(ulong homeRegionHandle) 337 protected RegionProfileData GetRegionInfo(ulong homeRegionHandle)
338 { 338 {
339 return m_regionProfileService.RequestSimProfileData(homeRegionHandle, 339 return m_regionProfileService.RequestSimProfileData(homeRegionHandle,
340 m_config.GridServerURL, m_config.GridSendKey, 340 m_config.GridServerURL, m_config.GridSendKey,
341 m_config.GridRecvKey); 341 m_config.GridRecvKey);
342 } 342 }
343 343
344 protected RegionProfileData GetRegionInfo(UUID homeRegionId) 344 protected RegionProfileData GetRegionInfo(UUID homeRegionId)
345 { 345 {
346 return m_regionProfileService.RequestSimProfileData(homeRegionId, 346 return m_regionProfileService.RequestSimProfileData(homeRegionId,
347 m_config.GridServerURL, m_config.GridSendKey, 347 m_config.GridServerURL, m_config.GridSendKey,
348 m_config.GridRecvKey); 348 m_config.GridRecvKey);
349 } 349 }
350 350
351 /// <summary> 351 /// <summary>
352 /// Add active gestures of the user to the login response. 352 /// Add active gestures of the user to the login response.
353 /// </summary> 353 /// </summary>
354 /// <param name="response"> 354 /// <param name="response">
355 /// A <see cref="LoginResponse"/> 355 /// A <see cref="LoginResponse"/>
356 /// </param> 356 /// </param>
357 /// <param name="theUser"> 357 /// <param name="theUser">
358 /// A <see cref="UserProfileData"/> 358 /// A <see cref="UserProfileData"/>
359 /// </param> 359 /// </param>
360 private void AddActiveGestures(LoginResponse response, UserProfileData theUser) 360 private void AddActiveGestures(LoginResponse response, UserProfileData theUser)
361 { 361 {
362 List<InventoryItemBase> gestures = m_inventoryService.GetActiveGestures(theUser.ID); 362 List<InventoryItemBase> gestures = m_inventoryService.GetActiveGestures(theUser.ID);
363 //m_log.DebugFormat("[LOGIN]: AddActiveGestures, found {0}", gestures == null ? 0 : gestures.Count); 363 //m_log.DebugFormat("[LOGIN]: AddActiveGestures, found {0}", gestures == null ? 0 : gestures.Count);
364 ArrayList list = new ArrayList(); 364 ArrayList list = new ArrayList();
365 if (gestures != null) 365 if (gestures != null)
366 { 366 {
367 foreach (InventoryItemBase gesture in gestures) 367 foreach (InventoryItemBase gesture in gestures)
368 { 368 {
369 Hashtable item = new Hashtable(); 369 Hashtable item = new Hashtable();
370 item["item_id"] = gesture.ID.ToString(); 370 item["item_id"] = gesture.ID.ToString();
371 item["asset_id"] = gesture.AssetID.ToString(); 371 item["asset_id"] = gesture.AssetID.ToString();
372 list.Add(item); 372 list.Add(item);
373 } 373 }
374 } 374 }
375 response.ActiveGestures = list; 375 response.ActiveGestures = list;
376 } 376 }
377 377
378 /// <summary> 378 /// <summary>
379 /// Prepare a login to the given region. This involves both telling the region to expect a connection 379 /// Prepare a login to the given region. This involves both telling the region to expect a connection
380 /// and appropriately customising the response to the user. 380 /// and appropriately customising the response to the user.
381 /// </summary> 381 /// </summary>
382 /// <param name="sim"></param> 382 /// <param name="sim"></param>
383 /// <param name="user"></param> 383 /// <param name="user"></param>
384 /// <param name="response"></param> 384 /// <param name="response"></param>
385 /// <returns>true if the region was successfully contacted, false otherwise</returns> 385 /// <returns>true if the region was successfully contacted, false otherwise</returns>
386 private bool PrepareLoginToRegion(RegionProfileData regionInfo, UserProfileData user, LoginResponse response) 386 private bool PrepareLoginToRegion(RegionProfileData regionInfo, UserProfileData user, LoginResponse response)
387 { 387 {
388 try 388 try
389 { 389 {
390 response.SimAddress = Util.GetHostFromURL(regionInfo.serverURI).ToString(); 390 response.SimAddress = Util.GetHostFromURL(regionInfo.serverURI).ToString();
391 response.SimPort = uint.Parse(regionInfo.serverURI.Split(new char[] { '/', ':' })[4]); 391 response.SimPort = uint.Parse(regionInfo.serverURI.Split(new char[] { '/', ':' })[4]);
392 response.RegionX = regionInfo.regionLocX; 392 response.RegionX = regionInfo.regionLocX;
393 response.RegionY = regionInfo.regionLocY; 393 response.RegionY = regionInfo.regionLocY;
394 394
395 string capsPath = CapsUtil.GetRandomCapsObjectPath(); 395 string capsPath = CapsUtil.GetRandomCapsObjectPath();
396 396
397 // Take off trailing / so that the caps path isn't //CAPS/someUUID 397 // Take off trailing / so that the caps path isn't //CAPS/someUUID
398 if (regionInfo.httpServerURI.EndsWith("/")) 398 if (regionInfo.httpServerURI.EndsWith("/"))
399 regionInfo.httpServerURI = regionInfo.httpServerURI.Substring(0, regionInfo.httpServerURI.Length - 1); 399 regionInfo.httpServerURI = regionInfo.httpServerURI.Substring(0, regionInfo.httpServerURI.Length - 1);
400 response.SeedCapability = regionInfo.httpServerURI + CapsUtil.GetCapsSeedPath(capsPath); 400 response.SeedCapability = regionInfo.httpServerURI + CapsUtil.GetCapsSeedPath(capsPath);
401 401
402 // Notify the target of an incoming user 402 // Notify the target of an incoming user
403 m_log.InfoFormat( 403 m_log.InfoFormat(
404 "[LOGIN]: Telling {0} @ {1},{2} ({3}) to prepare for client connection", 404 "[LOGIN]: Telling {0} @ {1},{2} ({3}) to prepare for client connection",
405 regionInfo.regionName, response.RegionX, response.RegionY, regionInfo.httpServerURI); 405 regionInfo.regionName, response.RegionX, response.RegionY, regionInfo.httpServerURI);
406 406
407 // Update agent with target sim 407 // Update agent with target sim
408 user.CurrentAgent.Region = regionInfo.UUID; 408 user.CurrentAgent.Region = regionInfo.UUID;
409 user.CurrentAgent.Handle = regionInfo.regionHandle; 409 user.CurrentAgent.Handle = regionInfo.regionHandle;
410 410
411 // Prepare notification 411 // Prepare notification
412 Hashtable loginParams = new Hashtable(); 412 Hashtable loginParams = new Hashtable();
413 loginParams["session_id"] = user.CurrentAgent.SessionID.ToString(); 413 loginParams["session_id"] = user.CurrentAgent.SessionID.ToString();
414 loginParams["secure_session_id"] = user.CurrentAgent.SecureSessionID.ToString(); 414 loginParams["secure_session_id"] = user.CurrentAgent.SecureSessionID.ToString();
415 loginParams["firstname"] = user.FirstName; 415 loginParams["firstname"] = user.FirstName;
416 loginParams["lastname"] = user.SurName; 416 loginParams["lastname"] = user.SurName;
417 loginParams["agent_id"] = user.ID.ToString(); 417 loginParams["agent_id"] = user.ID.ToString();
418 loginParams["circuit_code"] = (Int32) Convert.ToUInt32(response.CircuitCode); 418 loginParams["circuit_code"] = (Int32) Convert.ToUInt32(response.CircuitCode);
419 loginParams["startpos_x"] = user.CurrentAgent.Position.X.ToString(); 419 loginParams["startpos_x"] = user.CurrentAgent.Position.X.ToString();
420 loginParams["startpos_y"] = user.CurrentAgent.Position.Y.ToString(); 420 loginParams["startpos_y"] = user.CurrentAgent.Position.Y.ToString();
421 loginParams["startpos_z"] = user.CurrentAgent.Position.Z.ToString(); 421 loginParams["startpos_z"] = user.CurrentAgent.Position.Z.ToString();
422 loginParams["regionhandle"] = user.CurrentAgent.Handle.ToString(); 422 loginParams["regionhandle"] = user.CurrentAgent.Handle.ToString();
423 loginParams["caps_path"] = capsPath; 423 loginParams["caps_path"] = capsPath;
424 424
425 // Get appearance 425 // Get appearance
426 AvatarAppearance appearance = m_userManager.GetUserAppearance(user.ID); 426 AvatarAppearance appearance = m_userManager.GetUserAppearance(user.ID);
427 if (appearance != null) 427 if (appearance != null)
428 { 428 {
429 loginParams["appearance"] = appearance.ToHashTable(); 429 loginParams["appearance"] = appearance.ToHashTable();
430 m_log.DebugFormat("[LOGIN]: Found appearance for {0} {1}", user.FirstName, user.SurName); 430 m_log.DebugFormat("[LOGIN]: Found appearance for {0} {1}", user.FirstName, user.SurName);
431 } 431 }
432 else 432 else
433 { 433 {
434 m_log.DebugFormat("[LOGIN]: Appearance not for {0} {1}. Creating default.", user.FirstName, user.SurName); 434 m_log.DebugFormat("[LOGIN]: Appearance not for {0} {1}. Creating default.", user.FirstName, user.SurName);
435 appearance = new AvatarAppearance(user.ID); 435 appearance = new AvatarAppearance(user.ID);
436 } 436 }
437 437
438 ArrayList SendParams = new ArrayList(); 438 ArrayList SendParams = new ArrayList();
439 SendParams.Add(loginParams); 439 SendParams.Add(loginParams);
440 440
441 // Send 441 // Send
442 XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams); 442 XmlRpcRequest GridReq = new XmlRpcRequest("expect_user", SendParams);
443 XmlRpcResponse GridResp = GridReq.Send(regionInfo.httpServerURI, 6000); 443 XmlRpcResponse GridResp = GridReq.Send(regionInfo.httpServerURI, 6000);
444 444
445 if (!GridResp.IsFault) 445 if (!GridResp.IsFault)
446 { 446 {
447 bool responseSuccess = true; 447 bool responseSuccess = true;
448 448
449 if (GridResp.Value != null) 449 if (GridResp.Value != null)
450 { 450 {
451 Hashtable resp = (Hashtable) GridResp.Value; 451 Hashtable resp = (Hashtable) GridResp.Value;
452 if (resp.ContainsKey("success")) 452 if (resp.ContainsKey("success"))
453 { 453 {
454 if ((string) resp["success"] == "FALSE") 454 if ((string) resp["success"] == "FALSE")
455 { 455 {
456 responseSuccess = false; 456 responseSuccess = false;
457 } 457 }
458 } 458 }
459 } 459 }
460 if (responseSuccess) 460 if (responseSuccess)
461 { 461 {
462 handlerUserLoggedInAtLocation = OnUserLoggedInAtLocation; 462 handlerUserLoggedInAtLocation = OnUserLoggedInAtLocation;
463 if (handlerUserLoggedInAtLocation != null) 463 if (handlerUserLoggedInAtLocation != null)
464 { 464 {
465 handlerUserLoggedInAtLocation(user.ID, user.CurrentAgent.SessionID, 465 handlerUserLoggedInAtLocation(user.ID, user.CurrentAgent.SessionID,
466 user.CurrentAgent.Region, 466 user.CurrentAgent.Region,
467 user.CurrentAgent.Handle, 467 user.CurrentAgent.Handle,
468 user.CurrentAgent.Position.X, 468 user.CurrentAgent.Position.X,
469 user.CurrentAgent.Position.Y, 469 user.CurrentAgent.Position.Y,
470 user.CurrentAgent.Position.Z, 470 user.CurrentAgent.Position.Z,
471 user.FirstName, user.SurName); 471 user.FirstName, user.SurName);
472 } 472 }
473 } 473 }
474 else 474 else
475 { 475 {
476 m_log.ErrorFormat("[LOGIN]: Region responded that it is not available to receive clients"); 476 m_log.ErrorFormat("[LOGIN]: Region responded that it is not available to receive clients");
477 return false; 477 return false;
478 } 478 }
479 } 479 }
480 else 480 else
481 { 481 {
482 m_log.ErrorFormat("[LOGIN]: XmlRpc request to region failed with message {0}, code {1} ", GridResp.FaultString, GridResp.FaultCode); 482 m_log.ErrorFormat("[LOGIN]: XmlRpc request to region failed with message {0}, code {1} ", GridResp.FaultString, GridResp.FaultCode);
483 return false; 483 return false;
484 } 484 }
485 } 485 }
486 catch (Exception e) 486 catch (Exception e)
487 { 487 {
488 m_log.ErrorFormat("[LOGIN]: Region not available for login, {0}", e); 488 m_log.ErrorFormat("[LOGIN]: Region not available for login, {0}", e);
489 return false; 489 return false;
490 } 490 }
491 491
492 return true; 492 return true;
493 } 493 }
494 494
495 // See LoginService 495 // See LoginService
496 protected override InventoryData GetInventorySkeleton(UUID userID) 496 protected override InventoryData GetInventorySkeleton(UUID userID)
497 { 497 {
498 m_log.DebugFormat( 498 m_log.DebugFormat(
499 "[LOGIN]: Contacting inventory service at {0} for inventory skeleton of user {1}", 499 "[LOGIN]: Contacting inventory service at {0} for inventory skeleton of user {1}",
500 m_config.InventoryUrl, userID); 500 m_config.InventoryUrl, userID);
501 501
502 List<InventoryFolderBase> folders = m_inventoryService.GetInventorySkeleton(userID); 502 List<InventoryFolderBase> folders = m_inventoryService.GetInventorySkeleton(userID);
503 503
504 if (null == folders || folders.Count == 0) 504 if (null == folders || folders.Count == 0)
505 { 505 {
506 m_log.InfoFormat( 506 m_log.InfoFormat(
507 "[LOGIN]: A root inventory folder for user {0} was not found. Requesting creation.", userID); 507 "[LOGIN]: A root inventory folder for user {0} was not found. Requesting creation.", userID);
508 508
509 // Although the create user function creates a new agent inventory along with a new user profile, some 509 // Although the create user function creates a new agent inventory along with a new user profile, some
510 // tools are creating the user profile directly in the database without creating the inventory. At 510 // tools are creating the user profile directly in the database without creating the inventory. At
511 // this time we'll accomodate them by lazily creating the user inventory now if it doesn't already 511 // this time we'll accomodate them by lazily creating the user inventory now if it doesn't already
512 // exist. 512 // exist.
513 if (!m_inventoryService.CreateNewUserInventory(userID)) 513 if (!m_inventoryService.CreateNewUserInventory(userID))
514 { 514 {
515 throw new Exception( 515 throw new Exception(
516 String.Format( 516 String.Format(
517 "The inventory creation request for user {0} did not succeed." 517 "The inventory creation request for user {0} did not succeed."
518 + " Please contact your inventory service provider for more information.", 518 + " Please contact your inventory service provider for more information.",
519 userID)); 519 userID));
520 } 520 }
521 m_log.InfoFormat("[LOGIN]: A new inventory skeleton was successfully created for user {0}", userID); 521 m_log.InfoFormat("[LOGIN]: A new inventory skeleton was successfully created for user {0}", userID);
522 522
523 folders = m_inventoryService.GetInventorySkeleton(userID); 523 folders = m_inventoryService.GetInventorySkeleton(userID);
524 } 524 }
525 525
526 if (folders != null && folders.Count > 0) 526 if (folders != null && folders.Count > 0)
527 { 527 {
528 UUID rootID = UUID.Zero; 528 UUID rootID = UUID.Zero;
529 ArrayList AgentInventoryArray = new ArrayList(); 529 ArrayList AgentInventoryArray = new ArrayList();
530 Hashtable TempHash; 530 Hashtable TempHash;
531 531
532 foreach (InventoryFolderBase InvFolder in folders) 532 foreach (InventoryFolderBase InvFolder in folders)
533 { 533 {
534// m_log.DebugFormat("[LOGIN]: Received agent inventory folder {0}", InvFolder.name); 534// m_log.DebugFormat("[LOGIN]: Received agent inventory folder {0}", InvFolder.name);
535 535
536 if (InvFolder.ParentID == UUID.Zero) 536 if (InvFolder.ParentID == UUID.Zero)
537 { 537 {
538 rootID = InvFolder.ID; 538 rootID = InvFolder.ID;
539 } 539 }
540 TempHash = new Hashtable(); 540 TempHash = new Hashtable();
541 TempHash["name"] = InvFolder.Name; 541 TempHash["name"] = InvFolder.Name;
542 TempHash["parent_id"] = InvFolder.ParentID.ToString(); 542 TempHash["parent_id"] = InvFolder.ParentID.ToString();
543 TempHash["version"] = (Int32) InvFolder.Version; 543 TempHash["version"] = (Int32) InvFolder.Version;
544 TempHash["type_default"] = (Int32) InvFolder.Type; 544 TempHash["type_default"] = (Int32) InvFolder.Type;
545 TempHash["folder_id"] = InvFolder.ID.ToString(); 545 TempHash["folder_id"] = InvFolder.ID.ToString();
546 AgentInventoryArray.Add(TempHash); 546 AgentInventoryArray.Add(TempHash);
547 } 547 }
548 548
549 return new InventoryData(AgentInventoryArray, rootID); 549 return new InventoryData(AgentInventoryArray, rootID);
550 } 550 }
551 throw new Exception( 551 throw new Exception(
552 String.Format( 552 String.Format(
553 "A root inventory folder for user {0} could not be retrieved from the inventory service", 553 "A root inventory folder for user {0} could not be retrieved from the inventory service",
554 userID)); 554 userID));
555 } 555 }
556 556
557 public XmlRpcResponse XmlRPCSetLoginParams(XmlRpcRequest request) 557 public XmlRpcResponse XmlRPCSetLoginParams(XmlRpcRequest request)
558 { 558 {
559 XmlRpcResponse response = new XmlRpcResponse(); 559 XmlRpcResponse response = new XmlRpcResponse();
560 Hashtable requestData = (Hashtable) request.Params[0]; 560 Hashtable requestData = (Hashtable) request.Params[0];
561 UserProfileData userProfile; 561 UserProfileData userProfile;
562 Hashtable responseData = new Hashtable(); 562 Hashtable responseData = new Hashtable();
563 563
564 UUID uid; 564 UUID uid;
565 string pass = requestData["password"].ToString(); 565 string pass = requestData["password"].ToString();
566 566
567 if (!UUID.TryParse((string) requestData["avatar_uuid"], out uid)) 567 if (!UUID.TryParse((string) requestData["avatar_uuid"], out uid))
568 { 568 {
569 responseData["error"] = "No authorization"; 569 responseData["error"] = "No authorization";
570 response.Value = responseData; 570 response.Value = responseData;
571 return response; 571 return response;
572 } 572 }
573 573
574 userProfile = m_userManager.GetUserProfile(uid); 574 userProfile = m_userManager.GetUserProfile(uid);
575 575
576 if (userProfile == null || 576 if (userProfile == null ||
577 (!AuthenticateUser(userProfile, pass)) || 577 (!AuthenticateUser(userProfile, pass)) ||
578 userProfile.GodLevel < 200) 578 userProfile.GodLevel < 200)
579 { 579 {
580 responseData["error"] = "No authorization"; 580 responseData["error"] = "No authorization";
581 response.Value = responseData; 581 response.Value = responseData;
582 return response; 582 return response;
583 } 583 }
584 584
585 if (requestData.ContainsKey("login_level")) 585 if (requestData.ContainsKey("login_level"))
586 { 586 {
587 m_minLoginLevel = Convert.ToInt32(requestData["login_level"]); 587 m_minLoginLevel = Convert.ToInt32(requestData["login_level"]);
588 } 588 }
589 589
590 if (requestData.ContainsKey("login_motd")) 590 if (requestData.ContainsKey("login_motd"))
591 { 591 {
592 m_welcomeMessage = requestData["login_motd"].ToString(); 592 m_welcomeMessage = requestData["login_motd"].ToString();
593 } 593 }
594 594
595 response.Value = responseData; 595 response.Value = responseData;
596 return response; 596 return response;
597 } 597 }
598 598
599 } 599 }
600} 600}