aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/UserServer.Modules
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Grid/UserServer.Modules/MessageServersConnector.cs1018
-rw-r--r--OpenSim/Grid/UserServer.Modules/OpenIdService.cs674
-rw-r--r--OpenSim/Grid/UserServer.Modules/UserDataBaseService.cs222
-rw-r--r--OpenSim/Grid/UserServer.Modules/UserLoginService.cs1200
-rw-r--r--OpenSim/Grid/UserServer.Modules/UserManager.cs1372
-rw-r--r--OpenSim/Grid/UserServer.Modules/UserServerAvatarAppearanceModule.cs248
-rw-r--r--OpenSim/Grid/UserServer.Modules/UserServerFriendsModule.cs346
7 files changed, 2540 insertions, 2540 deletions
diff --git a/OpenSim/Grid/UserServer.Modules/MessageServersConnector.cs b/OpenSim/Grid/UserServer.Modules/MessageServersConnector.cs
index b98c614..59e9805 100644
--- a/OpenSim/Grid/UserServer.Modules/MessageServersConnector.cs
+++ b/OpenSim/Grid/UserServer.Modules/MessageServersConnector.cs
@@ -1,509 +1,509 @@
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.Collections; 28using System.Collections;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Net; 30using System.Net;
31using System.Reflection; 31using System.Reflection;
32using System.Threading; 32using System.Threading;
33using log4net; 33using log4net;
34using Nwc.XmlRpc; 34using Nwc.XmlRpc;
35using OpenMetaverse; 35using OpenMetaverse;
36using OpenSim.Framework; 36using OpenSim.Framework;
37using OpenSim.Framework.Servers; 37using OpenSim.Framework.Servers;
38 38
39namespace OpenSim.Grid.UserServer.Modules 39namespace OpenSim.Grid.UserServer.Modules
40{ 40{
41 public enum NotificationRequest : int 41 public enum NotificationRequest : int
42 { 42 {
43 Login = 0, 43 Login = 0,
44 Logout = 1, 44 Logout = 1,
45 Shutdown = 2 45 Shutdown = 2
46 } 46 }
47 47
48 public struct PresenceNotification 48 public struct PresenceNotification
49 { 49 {
50 public NotificationRequest request; 50 public NotificationRequest request;
51 public UUID agentID; 51 public UUID agentID;
52 public UUID sessionID; 52 public UUID sessionID;
53 public UUID RegionID; 53 public UUID RegionID;
54 public ulong regionhandle; 54 public ulong regionhandle;
55 public float positionX; 55 public float positionX;
56 public float positionY; 56 public float positionY;
57 public float positionZ; 57 public float positionZ;
58 public string firstname; 58 public string firstname;
59 public string lastname; 59 public string lastname;
60 } 60 }
61 61
62 public delegate void AgentLocationDelegate(UUID agentID, UUID regionID, ulong regionHandle); 62 public delegate void AgentLocationDelegate(UUID agentID, UUID regionID, ulong regionHandle);
63 public delegate void AgentLeavingDelegate(UUID agentID, UUID regionID, ulong regionHandle); 63 public delegate void AgentLeavingDelegate(UUID agentID, UUID regionID, ulong regionHandle);
64 public delegate void RegionStartupDelegate(UUID regionID); 64 public delegate void RegionStartupDelegate(UUID regionID);
65 public delegate void RegionShutdownDelegate(UUID regionID); 65 public delegate void RegionShutdownDelegate(UUID regionID);
66 66
67 67
68 public class MessageServersConnector 68 public class MessageServersConnector
69 { 69 {
70 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 70 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
71 71
72 public Dictionary<string, MessageServerInfo> MessageServers; 72 public Dictionary<string, MessageServerInfo> MessageServers;
73 73
74 private BaseHttpServer m_httpServer; 74 private BaseHttpServer m_httpServer;
75 75
76 private BlockingQueue<PresenceNotification> m_NotifyQueue = 76 private BlockingQueue<PresenceNotification> m_NotifyQueue =
77 new BlockingQueue<PresenceNotification>(); 77 new BlockingQueue<PresenceNotification>();
78 78
79 Thread m_NotifyThread; 79 Thread m_NotifyThread;
80 80
81 public event AgentLocationDelegate OnAgentLocation; 81 public event AgentLocationDelegate OnAgentLocation;
82 public event AgentLeavingDelegate OnAgentLeaving; 82 public event AgentLeavingDelegate OnAgentLeaving;
83 public event RegionStartupDelegate OnRegionStartup; 83 public event RegionStartupDelegate OnRegionStartup;
84 public event RegionShutdownDelegate OnRegionShutdown; 84 public event RegionShutdownDelegate OnRegionShutdown;
85 85
86 public MessageServersConnector() 86 public MessageServersConnector()
87 { 87 {
88 MessageServers = new Dictionary<string, MessageServerInfo>(); 88 MessageServers = new Dictionary<string, MessageServerInfo>();
89 m_NotifyThread = new Thread(new ThreadStart(NotifyQueueRunner)); 89 m_NotifyThread = new Thread(new ThreadStart(NotifyQueueRunner));
90 m_NotifyThread.Start(); 90 m_NotifyThread.Start();
91 } 91 }
92 92
93 public void Initialise() 93 public void Initialise()
94 { 94 {
95 95
96 } 96 }
97 97
98 public void PostInitialise() 98 public void PostInitialise()
99 { 99 {
100 100
101 } 101 }
102 102
103 public void RegisterHandlers(BaseHttpServer httpServer) 103 public void RegisterHandlers(BaseHttpServer httpServer)
104 { 104 {
105 m_httpServer = httpServer; 105 m_httpServer = httpServer;
106 106
107 m_httpServer.AddXmlRPCHandler("region_startup", RegionStartup); 107 m_httpServer.AddXmlRPCHandler("region_startup", RegionStartup);
108 m_httpServer.AddXmlRPCHandler("region_shutdown", RegionShutdown); 108 m_httpServer.AddXmlRPCHandler("region_shutdown", RegionShutdown);
109 m_httpServer.AddXmlRPCHandler("agent_location", AgentLocation); 109 m_httpServer.AddXmlRPCHandler("agent_location", AgentLocation);
110 m_httpServer.AddXmlRPCHandler("agent_leaving", AgentLeaving); 110 m_httpServer.AddXmlRPCHandler("agent_leaving", AgentLeaving);
111 // Message Server ---> User Server 111 // Message Server ---> User Server
112 m_httpServer.AddXmlRPCHandler("register_messageserver", XmlRPCRegisterMessageServer); 112 m_httpServer.AddXmlRPCHandler("register_messageserver", XmlRPCRegisterMessageServer);
113 m_httpServer.AddXmlRPCHandler("agent_change_region", XmlRPCUserMovedtoRegion); 113 m_httpServer.AddXmlRPCHandler("agent_change_region", XmlRPCUserMovedtoRegion);
114 m_httpServer.AddXmlRPCHandler("deregister_messageserver", XmlRPCDeRegisterMessageServer); 114 m_httpServer.AddXmlRPCHandler("deregister_messageserver", XmlRPCDeRegisterMessageServer);
115 } 115 }
116 116
117 public void RegisterMessageServer(string URI, MessageServerInfo serverData) 117 public void RegisterMessageServer(string URI, MessageServerInfo serverData)
118 { 118 {
119 lock (MessageServers) 119 lock (MessageServers)
120 { 120 {
121 if (!MessageServers.ContainsKey(URI)) 121 if (!MessageServers.ContainsKey(URI))
122 MessageServers.Add(URI, serverData); 122 MessageServers.Add(URI, serverData);
123 } 123 }
124 } 124 }
125 125
126 public void DeRegisterMessageServer(string URI) 126 public void DeRegisterMessageServer(string URI)
127 { 127 {
128 lock (MessageServers) 128 lock (MessageServers)
129 { 129 {
130 if (MessageServers.ContainsKey(URI)) 130 if (MessageServers.ContainsKey(URI))
131 MessageServers.Remove(URI); 131 MessageServers.Remove(URI);
132 } 132 }
133 } 133 }
134 134
135 public void AddResponsibleRegion(string URI, ulong regionhandle) 135 public void AddResponsibleRegion(string URI, ulong regionhandle)
136 { 136 {
137 if (!MessageServers.ContainsKey(URI)) 137 if (!MessageServers.ContainsKey(URI))
138 { 138 {
139 m_log.Warn("[MSGSERVER]: Got addResponsibleRegion Request for a MessageServer that isn't registered"); 139 m_log.Warn("[MSGSERVER]: Got addResponsibleRegion Request for a MessageServer that isn't registered");
140 } 140 }
141 else 141 else
142 { 142 {
143 MessageServerInfo msginfo = MessageServers["URI"]; 143 MessageServerInfo msginfo = MessageServers["URI"];
144 msginfo.responsibleForRegions.Add(regionhandle); 144 msginfo.responsibleForRegions.Add(regionhandle);
145 MessageServers["URI"] = msginfo; 145 MessageServers["URI"] = msginfo;
146 } 146 }
147 } 147 }
148 public void RemoveResponsibleRegion(string URI, ulong regionhandle) 148 public void RemoveResponsibleRegion(string URI, ulong regionhandle)
149 { 149 {
150 if (!MessageServers.ContainsKey(URI)) 150 if (!MessageServers.ContainsKey(URI))
151 { 151 {
152 m_log.Warn("[MSGSERVER]: Got RemoveResponsibleRegion Request for a MessageServer that isn't registered"); 152 m_log.Warn("[MSGSERVER]: Got RemoveResponsibleRegion Request for a MessageServer that isn't registered");
153 } 153 }
154 else 154 else
155 { 155 {
156 MessageServerInfo msginfo = MessageServers["URI"]; 156 MessageServerInfo msginfo = MessageServers["URI"];
157 if (msginfo.responsibleForRegions.Contains(regionhandle)) 157 if (msginfo.responsibleForRegions.Contains(regionhandle))
158 { 158 {
159 msginfo.responsibleForRegions.Remove(regionhandle); 159 msginfo.responsibleForRegions.Remove(regionhandle);
160 MessageServers["URI"] = msginfo; 160 MessageServers["URI"] = msginfo;
161 } 161 }
162 } 162 }
163 163
164 } 164 }
165 public XmlRpcResponse XmlRPCRegisterMessageServer(XmlRpcRequest request) 165 public XmlRpcResponse XmlRPCRegisterMessageServer(XmlRpcRequest request)
166 { 166 {
167 XmlRpcResponse response = new XmlRpcResponse(); 167 XmlRpcResponse response = new XmlRpcResponse();
168 Hashtable requestData = (Hashtable)request.Params[0]; 168 Hashtable requestData = (Hashtable)request.Params[0];
169 Hashtable responseData = new Hashtable(); 169 Hashtable responseData = new Hashtable();
170 170
171 if (requestData.Contains("uri")) 171 if (requestData.Contains("uri"))
172 { 172 {
173 string URI = (string)requestData["uri"]; 173 string URI = (string)requestData["uri"];
174 string sendkey=(string)requestData["sendkey"]; 174 string sendkey=(string)requestData["sendkey"];
175 string recvkey=(string)requestData["recvkey"]; 175 string recvkey=(string)requestData["recvkey"];
176 MessageServerInfo m = new MessageServerInfo(); 176 MessageServerInfo m = new MessageServerInfo();
177 m.URI = URI; 177 m.URI = URI;
178 m.sendkey = sendkey; 178 m.sendkey = sendkey;
179 m.recvkey = recvkey; 179 m.recvkey = recvkey;
180 RegisterMessageServer(URI, m); 180 RegisterMessageServer(URI, m);
181 responseData["responsestring"] = "TRUE"; 181 responseData["responsestring"] = "TRUE";
182 response.Value = responseData; 182 response.Value = responseData;
183 } 183 }
184 return response; 184 return response;
185 } 185 }
186 public XmlRpcResponse XmlRPCDeRegisterMessageServer(XmlRpcRequest request) 186 public XmlRpcResponse XmlRPCDeRegisterMessageServer(XmlRpcRequest request)
187 { 187 {
188 XmlRpcResponse response = new XmlRpcResponse(); 188 XmlRpcResponse response = new XmlRpcResponse();
189 Hashtable requestData = (Hashtable)request.Params[0]; 189 Hashtable requestData = (Hashtable)request.Params[0];
190 Hashtable responseData = new Hashtable(); 190 Hashtable responseData = new Hashtable();
191 191
192 if (requestData.Contains("uri")) 192 if (requestData.Contains("uri"))
193 { 193 {
194 string URI = (string)requestData["uri"]; 194 string URI = (string)requestData["uri"];
195 195
196 DeRegisterMessageServer(URI); 196 DeRegisterMessageServer(URI);
197 responseData["responsestring"] = "TRUE"; 197 responseData["responsestring"] = "TRUE";
198 response.Value = responseData; 198 response.Value = responseData;
199 } 199 }
200 return response; 200 return response;
201 } 201 }
202 public XmlRpcResponse XmlRPCUserMovedtoRegion(XmlRpcRequest request) 202 public XmlRpcResponse XmlRPCUserMovedtoRegion(XmlRpcRequest request)
203 { 203 {
204 XmlRpcResponse response = new XmlRpcResponse(); 204 XmlRpcResponse response = new XmlRpcResponse();
205 Hashtable requestData = (Hashtable)request.Params[0]; 205 Hashtable requestData = (Hashtable)request.Params[0];
206 Hashtable responseData = new Hashtable(); 206 Hashtable responseData = new Hashtable();
207 207
208 if (requestData.Contains("fromuri")) 208 if (requestData.Contains("fromuri"))
209 { 209 {
210 // string sURI = (string)requestData["fromuri"]; 210 // string sURI = (string)requestData["fromuri"];
211 // string sagentID = (string)requestData["agentid"]; 211 // string sagentID = (string)requestData["agentid"];
212 // string ssessionID = (string)requestData["sessionid"]; 212 // string ssessionID = (string)requestData["sessionid"];
213 // string scurrentRegionID = (string)requestData["regionid"]; 213 // string scurrentRegionID = (string)requestData["regionid"];
214 // string sregionhandle = (string)requestData["regionhandle"]; 214 // string sregionhandle = (string)requestData["regionhandle"];
215 // string scurrentpos = (string)requestData["currentpos"]; 215 // string scurrentpos = (string)requestData["currentpos"];
216 //Vector3.TryParse((string)reader["currentPos"], out retval.currentPos); 216 //Vector3.TryParse((string)reader["currentPos"], out retval.currentPos);
217 // TODO: Okay now raise event so the user server can pass this data to the Usermanager 217 // TODO: Okay now raise event so the user server can pass this data to the Usermanager
218 218
219 responseData["responsestring"] = "TRUE"; 219 responseData["responsestring"] = "TRUE";
220 response.Value = responseData; 220 response.Value = responseData;
221 } 221 }
222 return response; 222 return response;
223 } 223 }
224 224
225 public void TellMessageServersAboutUser(UUID agentID, UUID sessionID, UUID RegionID, 225 public void TellMessageServersAboutUser(UUID agentID, UUID sessionID, UUID RegionID,
226 ulong regionhandle, float positionX, float positionY, 226 ulong regionhandle, float positionX, float positionY,
227 float positionZ, string firstname, string lastname) 227 float positionZ, string firstname, string lastname)
228 { 228 {
229 PresenceNotification notification = new PresenceNotification(); 229 PresenceNotification notification = new PresenceNotification();
230 230
231 notification.request = NotificationRequest.Login; 231 notification.request = NotificationRequest.Login;
232 notification.agentID = agentID; 232 notification.agentID = agentID;
233 notification.sessionID = sessionID; 233 notification.sessionID = sessionID;
234 notification.RegionID = RegionID; 234 notification.RegionID = RegionID;
235 notification.regionhandle = regionhandle; 235 notification.regionhandle = regionhandle;
236 notification.positionX = positionX; 236 notification.positionX = positionX;
237 notification.positionY = positionY; 237 notification.positionY = positionY;
238 notification.positionZ = positionZ; 238 notification.positionZ = positionZ;
239 notification.firstname = firstname; 239 notification.firstname = firstname;
240 notification.lastname = lastname; 240 notification.lastname = lastname;
241 241
242 m_NotifyQueue.Enqueue(notification); 242 m_NotifyQueue.Enqueue(notification);
243 } 243 }
244 244
245 private void TellMessageServersAboutUserInternal(UUID agentID, UUID sessionID, UUID RegionID, 245 private void TellMessageServersAboutUserInternal(UUID agentID, UUID sessionID, UUID RegionID,
246 ulong regionhandle, float positionX, float positionY, 246 ulong regionhandle, float positionX, float positionY,
247 float positionZ, string firstname, string lastname) 247 float positionZ, string firstname, string lastname)
248 { 248 {
249 // Loop over registered Message Servers (AND THERE WILL BE MORE THEN ONE :D) 249 // Loop over registered Message Servers (AND THERE WILL BE MORE THEN ONE :D)
250 lock (MessageServers) 250 lock (MessageServers)
251 { 251 {
252 if (MessageServers.Count > 0) 252 if (MessageServers.Count > 0)
253 { 253 {
254 m_log.Info("[MSGCONNECTOR]: Sending login notice to registered message servers"); 254 m_log.Info("[MSGCONNECTOR]: Sending login notice to registered message servers");
255 } 255 }
256// else 256// else
257// { 257// {
258// m_log.Debug("[MSGCONNECTOR]: No Message Servers registered, ignoring"); 258// m_log.Debug("[MSGCONNECTOR]: No Message Servers registered, ignoring");
259// } 259// }
260 foreach (MessageServerInfo serv in MessageServers.Values) 260 foreach (MessageServerInfo serv in MessageServers.Values)
261 { 261 {
262 NotifyMessageServerAboutUser(serv, agentID, sessionID, RegionID, 262 NotifyMessageServerAboutUser(serv, agentID, sessionID, RegionID,
263 regionhandle, positionX, positionY, positionZ, 263 regionhandle, positionX, positionY, positionZ,
264 firstname, lastname); 264 firstname, lastname);
265 } 265 }
266 } 266 }
267 } 267 }
268 268
269 private void TellMessageServersAboutUserLogoffInternal(UUID agentID) 269 private void TellMessageServersAboutUserLogoffInternal(UUID agentID)
270 { 270 {
271 lock (MessageServers) 271 lock (MessageServers)
272 { 272 {
273 if (MessageServers.Count > 0) 273 if (MessageServers.Count > 0)
274 { 274 {
275 m_log.Info("[MSGCONNECTOR]: Sending logoff notice to registered message servers"); 275 m_log.Info("[MSGCONNECTOR]: Sending logoff notice to registered message servers");
276 } 276 }
277 else 277 else
278 { 278 {
279// m_log.Debug("[MSGCONNECTOR]: No Message Servers registered, ignoring"); 279// m_log.Debug("[MSGCONNECTOR]: No Message Servers registered, ignoring");
280 } 280 }
281 foreach (MessageServerInfo serv in MessageServers.Values) 281 foreach (MessageServerInfo serv in MessageServers.Values)
282 { 282 {
283 NotifyMessageServerAboutUserLogoff(serv,agentID); 283 NotifyMessageServerAboutUserLogoff(serv,agentID);
284 } 284 }
285 } 285 }
286 } 286 }
287 287
288 private void TellMessageServersAboutRegionShutdownInternal(UUID regionID) 288 private void TellMessageServersAboutRegionShutdownInternal(UUID regionID)
289 { 289 {
290 lock (MessageServers) 290 lock (MessageServers)
291 { 291 {
292 if (MessageServers.Count > 0) 292 if (MessageServers.Count > 0)
293 { 293 {
294 m_log.Info("[MSGCONNECTOR]: Sending region down notice to registered message servers"); 294 m_log.Info("[MSGCONNECTOR]: Sending region down notice to registered message servers");
295 } 295 }
296 else 296 else
297 { 297 {
298// m_log.Debug("[MSGCONNECTOR]: No Message Servers registered, ignoring"); 298// m_log.Debug("[MSGCONNECTOR]: No Message Servers registered, ignoring");
299 } 299 }
300 foreach (MessageServerInfo serv in MessageServers.Values) 300 foreach (MessageServerInfo serv in MessageServers.Values)
301 { 301 {
302 NotifyMessageServerAboutRegionShutdown(serv,regionID); 302 NotifyMessageServerAboutRegionShutdown(serv,regionID);
303 } 303 }
304 } 304 }
305 } 305 }
306 306
307 public void TellMessageServersAboutUserLogoff(UUID agentID) 307 public void TellMessageServersAboutUserLogoff(UUID agentID)
308 { 308 {
309 PresenceNotification notification = new PresenceNotification(); 309 PresenceNotification notification = new PresenceNotification();
310 310
311 notification.request = NotificationRequest.Logout; 311 notification.request = NotificationRequest.Logout;
312 notification.agentID = agentID; 312 notification.agentID = agentID;
313 313
314 m_NotifyQueue.Enqueue(notification); 314 m_NotifyQueue.Enqueue(notification);
315 } 315 }
316 316
317 public void TellMessageServersAboutRegionShutdown(UUID regionID) 317 public void TellMessageServersAboutRegionShutdown(UUID regionID)
318 { 318 {
319 PresenceNotification notification = new PresenceNotification(); 319 PresenceNotification notification = new PresenceNotification();
320 320
321 notification.request = NotificationRequest.Shutdown; 321 notification.request = NotificationRequest.Shutdown;
322 notification.RegionID = regionID; 322 notification.RegionID = regionID;
323 323
324 m_NotifyQueue.Enqueue(notification); 324 m_NotifyQueue.Enqueue(notification);
325 } 325 }
326 326
327 private void NotifyMessageServerAboutUserLogoff(MessageServerInfo serv, UUID agentID) 327 private void NotifyMessageServerAboutUserLogoff(MessageServerInfo serv, UUID agentID)
328 { 328 {
329 Hashtable reqparams = new Hashtable(); 329 Hashtable reqparams = new Hashtable();
330 reqparams["sendkey"] = serv.sendkey; 330 reqparams["sendkey"] = serv.sendkey;
331 reqparams["agentid"] = agentID.ToString(); 331 reqparams["agentid"] = agentID.ToString();
332 ArrayList SendParams = new ArrayList(); 332 ArrayList SendParams = new ArrayList();
333 SendParams.Add(reqparams); 333 SendParams.Add(reqparams);
334 334
335 XmlRpcRequest GridReq = new XmlRpcRequest("logout_of_simulator", SendParams); 335 XmlRpcRequest GridReq = new XmlRpcRequest("logout_of_simulator", SendParams);
336 try 336 try
337 { 337 {
338 GridReq.Send(serv.URI, 6000); 338 GridReq.Send(serv.URI, 6000);
339 } 339 }
340 catch (WebException) 340 catch (WebException)
341 { 341 {
342 m_log.Warn("[MSGCONNECTOR]: Unable to notify Message Server about log out. Other users might still think this user is online"); 342 m_log.Warn("[MSGCONNECTOR]: Unable to notify Message Server about log out. Other users might still think this user is online");
343 } 343 }
344 m_log.Info("[LOGOUT]: Notified : " + serv.URI + " about user logout"); 344 m_log.Info("[LOGOUT]: Notified : " + serv.URI + " about user logout");
345 } 345 }
346 346
347 private void NotifyMessageServerAboutRegionShutdown(MessageServerInfo serv, UUID regionID) 347 private void NotifyMessageServerAboutRegionShutdown(MessageServerInfo serv, UUID regionID)
348 { 348 {
349 Hashtable reqparams = new Hashtable(); 349 Hashtable reqparams = new Hashtable();
350 reqparams["sendkey"] = serv.sendkey; 350 reqparams["sendkey"] = serv.sendkey;
351 reqparams["regionid"] = regionID.ToString(); 351 reqparams["regionid"] = regionID.ToString();
352 ArrayList SendParams = new ArrayList(); 352 ArrayList SendParams = new ArrayList();
353 SendParams.Add(reqparams); 353 SendParams.Add(reqparams);
354 354
355 XmlRpcRequest GridReq = new XmlRpcRequest("process_region_shutdown", SendParams); 355 XmlRpcRequest GridReq = new XmlRpcRequest("process_region_shutdown", SendParams);
356 try 356 try
357 { 357 {
358 GridReq.Send(serv.URI, 6000); 358 GridReq.Send(serv.URI, 6000);
359 } 359 }
360 catch (WebException) 360 catch (WebException)
361 { 361 {
362 m_log.Warn("[MSGCONNECTOR]: Unable to notify Message Server about region shutdown."); 362 m_log.Warn("[MSGCONNECTOR]: Unable to notify Message Server about region shutdown.");
363 } 363 }
364 m_log.Info("[REGION UPDOWN]: Notified : " + serv.URI + " about region state change"); 364 m_log.Info("[REGION UPDOWN]: Notified : " + serv.URI + " about region state change");
365 } 365 }
366 366
367 private void NotifyMessageServerAboutUser(MessageServerInfo serv, 367 private void NotifyMessageServerAboutUser(MessageServerInfo serv,
368 UUID agentID, UUID sessionID, UUID RegionID, 368 UUID agentID, UUID sessionID, UUID RegionID,
369 ulong regionhandle, float positionX, float positionY, float positionZ, 369 ulong regionhandle, float positionX, float positionY, float positionZ,
370 string firstname, string lastname) 370 string firstname, string lastname)
371 { 371 {
372 Hashtable reqparams = new Hashtable(); 372 Hashtable reqparams = new Hashtable();
373 reqparams["sendkey"] = serv.sendkey; 373 reqparams["sendkey"] = serv.sendkey;
374 reqparams["agentid"] = agentID.ToString(); 374 reqparams["agentid"] = agentID.ToString();
375 reqparams["sessionid"] = sessionID.ToString(); 375 reqparams["sessionid"] = sessionID.ToString();
376 reqparams["regionid"] = RegionID.ToString(); 376 reqparams["regionid"] = RegionID.ToString();
377 reqparams["regionhandle"] = regionhandle.ToString(); 377 reqparams["regionhandle"] = regionhandle.ToString();
378 reqparams["positionx"] = positionX.ToString(); 378 reqparams["positionx"] = positionX.ToString();
379 reqparams["positiony"] = positionY.ToString(); 379 reqparams["positiony"] = positionY.ToString();
380 reqparams["positionz"] = positionZ.ToString(); 380 reqparams["positionz"] = positionZ.ToString();
381 reqparams["firstname"] = firstname; 381 reqparams["firstname"] = firstname;
382 reqparams["lastname"] = lastname; 382 reqparams["lastname"] = lastname;
383 383
384 //reqparams["position"] = Position.ToString(); 384 //reqparams["position"] = Position.ToString();
385 385
386 ArrayList SendParams = new ArrayList(); 386 ArrayList SendParams = new ArrayList();
387 SendParams.Add(reqparams); 387 SendParams.Add(reqparams);
388 388
389 XmlRpcRequest GridReq = new XmlRpcRequest("login_to_simulator", SendParams); 389 XmlRpcRequest GridReq = new XmlRpcRequest("login_to_simulator", SendParams);
390 try 390 try
391 { 391 {
392 GridReq.Send(serv.URI, 6000); 392 GridReq.Send(serv.URI, 6000);
393 m_log.Info("[LOGIN]: Notified : " + serv.URI + " about user login"); 393 m_log.Info("[LOGIN]: Notified : " + serv.URI + " about user login");
394 } 394 }
395 catch (WebException) 395 catch (WebException)
396 { 396 {
397 m_log.Warn("[MSGCONNECTOR]: Unable to notify Message Server about login. Presence might be borked for this user"); 397 m_log.Warn("[MSGCONNECTOR]: Unable to notify Message Server about login. Presence might be borked for this user");
398 } 398 }
399 399
400 } 400 }
401 401
402 private void NotifyQueueRunner() 402 private void NotifyQueueRunner()
403 { 403 {
404 while (true) 404 while (true)
405 { 405 {
406 PresenceNotification presence = m_NotifyQueue.Dequeue(); 406 PresenceNotification presence = m_NotifyQueue.Dequeue();
407 407
408 if (presence.request == NotificationRequest.Shutdown) 408 if (presence.request == NotificationRequest.Shutdown)
409 { 409 {
410 TellMessageServersAboutRegionShutdownInternal(presence.RegionID); 410 TellMessageServersAboutRegionShutdownInternal(presence.RegionID);
411 } 411 }
412 412
413 if (presence.request == NotificationRequest.Login) 413 if (presence.request == NotificationRequest.Login)
414 { 414 {
415 TellMessageServersAboutUserInternal(presence.agentID, 415 TellMessageServersAboutUserInternal(presence.agentID,
416 presence.sessionID, presence.RegionID, 416 presence.sessionID, presence.RegionID,
417 presence.regionhandle, presence.positionX, 417 presence.regionhandle, presence.positionX,
418 presence.positionY, presence.positionZ, 418 presence.positionY, presence.positionZ,
419 presence.firstname, presence.lastname); 419 presence.firstname, presence.lastname);
420 } 420 }
421 421
422 if (presence.request == NotificationRequest.Logout) 422 if (presence.request == NotificationRequest.Logout)
423 { 423 {
424 TellMessageServersAboutUserLogoffInternal(presence.agentID); 424 TellMessageServersAboutUserLogoffInternal(presence.agentID);
425 } 425 }
426 } 426 }
427 } 427 }
428 428
429 public XmlRpcResponse RegionStartup(XmlRpcRequest request) 429 public XmlRpcResponse RegionStartup(XmlRpcRequest request)
430 { 430 {
431 Hashtable requestData = (Hashtable)request.Params[0]; 431 Hashtable requestData = (Hashtable)request.Params[0];
432 Hashtable result = new Hashtable(); 432 Hashtable result = new Hashtable();
433 433
434 UUID regionID; 434 UUID regionID;
435 if (UUID.TryParse((string)requestData["RegionUUID"], out regionID)) 435 if (UUID.TryParse((string)requestData["RegionUUID"], out regionID))
436 { 436 {
437 if (OnRegionStartup != null) 437 if (OnRegionStartup != null)
438 OnRegionStartup(regionID); 438 OnRegionStartup(regionID);
439 439
440 result["responsestring"] = "TRUE"; 440 result["responsestring"] = "TRUE";
441 } 441 }
442 442
443 XmlRpcResponse response = new XmlRpcResponse(); 443 XmlRpcResponse response = new XmlRpcResponse();
444 response.Value = result; 444 response.Value = result;
445 return response; 445 return response;
446 } 446 }
447 447
448 public XmlRpcResponse RegionShutdown(XmlRpcRequest request) 448 public XmlRpcResponse RegionShutdown(XmlRpcRequest request)
449 { 449 {
450 Hashtable requestData = (Hashtable)request.Params[0]; 450 Hashtable requestData = (Hashtable)request.Params[0];
451 Hashtable result = new Hashtable(); 451 Hashtable result = new Hashtable();
452 452
453 UUID regionID; 453 UUID regionID;
454 if (UUID.TryParse((string)requestData["RegionUUID"], out regionID)) 454 if (UUID.TryParse((string)requestData["RegionUUID"], out regionID))
455 { 455 {
456 if (OnRegionShutdown != null) 456 if (OnRegionShutdown != null)
457 OnRegionShutdown(regionID); 457 OnRegionShutdown(regionID);
458 458
459 result["responsestring"] = "TRUE"; 459 result["responsestring"] = "TRUE";
460 } 460 }
461 461
462 XmlRpcResponse response = new XmlRpcResponse(); 462 XmlRpcResponse response = new XmlRpcResponse();
463 response.Value = result; 463 response.Value = result;
464 return response; 464 return response;
465 } 465 }
466 466
467 public XmlRpcResponse AgentLocation(XmlRpcRequest request) 467 public XmlRpcResponse AgentLocation(XmlRpcRequest request)
468 { 468 {
469 Hashtable requestData = (Hashtable)request.Params[0]; 469 Hashtable requestData = (Hashtable)request.Params[0];
470 Hashtable result = new Hashtable(); 470 Hashtable result = new Hashtable();
471 471
472 UUID agentID; 472 UUID agentID;
473 UUID regionID; 473 UUID regionID;
474 ulong regionHandle; 474 ulong regionHandle;
475 if (UUID.TryParse((string)requestData["AgentID"], out agentID) && UUID.TryParse((string)requestData["RegionUUID"], out regionID) && ulong.TryParse((string)requestData["RegionHandle"], out regionHandle)) 475 if (UUID.TryParse((string)requestData["AgentID"], out agentID) && UUID.TryParse((string)requestData["RegionUUID"], out regionID) && ulong.TryParse((string)requestData["RegionHandle"], out regionHandle))
476 { 476 {
477 if (OnAgentLocation != null) 477 if (OnAgentLocation != null)
478 OnAgentLocation(agentID, regionID, regionHandle); 478 OnAgentLocation(agentID, regionID, regionHandle);
479 479
480 result["responsestring"] = "TRUE"; 480 result["responsestring"] = "TRUE";
481 } 481 }
482 482
483 XmlRpcResponse response = new XmlRpcResponse(); 483 XmlRpcResponse response = new XmlRpcResponse();
484 response.Value = result; 484 response.Value = result;
485 return response; 485 return response;
486 } 486 }
487 487
488 public XmlRpcResponse AgentLeaving(XmlRpcRequest request) 488 public XmlRpcResponse AgentLeaving(XmlRpcRequest request)
489 { 489 {
490 Hashtable requestData = (Hashtable)request.Params[0]; 490 Hashtable requestData = (Hashtable)request.Params[0];
491 Hashtable result = new Hashtable(); 491 Hashtable result = new Hashtable();
492 492
493 UUID agentID; 493 UUID agentID;
494 UUID regionID; 494 UUID regionID;
495 ulong regionHandle; 495 ulong regionHandle;
496 if (UUID.TryParse((string)requestData["AgentID"], out agentID) && UUID.TryParse((string)requestData["RegionUUID"], out regionID) && ulong.TryParse((string)requestData["RegionHandle"], out regionHandle)) 496 if (UUID.TryParse((string)requestData["AgentID"], out agentID) && UUID.TryParse((string)requestData["RegionUUID"], out regionID) && ulong.TryParse((string)requestData["RegionHandle"], out regionHandle))
497 { 497 {
498 if (OnAgentLeaving != null) 498 if (OnAgentLeaving != null)
499 OnAgentLeaving(agentID, regionID, regionHandle); 499 OnAgentLeaving(agentID, regionID, regionHandle);
500 500
501 result["responsestring"] = "TRUE"; 501 result["responsestring"] = "TRUE";
502 } 502 }
503 503
504 XmlRpcResponse response = new XmlRpcResponse(); 504 XmlRpcResponse response = new XmlRpcResponse();
505 response.Value = result; 505 response.Value = result;
506 return response; 506 return response;
507 } 507 }
508 } 508 }
509} 509}
diff --git a/OpenSim/Grid/UserServer.Modules/OpenIdService.cs b/OpenSim/Grid/UserServer.Modules/OpenIdService.cs
index 5c8501f..28a8fdb 100644
--- a/OpenSim/Grid/UserServer.Modules/OpenIdService.cs
+++ b/OpenSim/Grid/UserServer.Modules/OpenIdService.cs
@@ -1,337 +1,337 @@
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.Generic; 29using System.Collections.Generic;
30using System.Collections.Specialized; 30using System.Collections.Specialized;
31using System.IO; 31using System.IO;
32using System.Net; 32using System.Net;
33using System.Web; 33using System.Web;
34using DotNetOpenId; 34using DotNetOpenId;
35using DotNetOpenId.Provider; 35using DotNetOpenId.Provider;
36using OpenSim.Framework; 36using OpenSim.Framework;
37using OpenSim.Framework.Servers; 37using OpenSim.Framework.Servers;
38 38
39namespace OpenSim.Grid.UserServer.Modules 39namespace OpenSim.Grid.UserServer.Modules
40{ 40{
41 /// <summary> 41 /// <summary>
42 /// Temporary, in-memory store for OpenID associations 42 /// Temporary, in-memory store for OpenID associations
43 /// </summary> 43 /// </summary>
44 public class ProviderMemoryStore : IAssociationStore<AssociationRelyingPartyType> 44 public class ProviderMemoryStore : IAssociationStore<AssociationRelyingPartyType>
45 { 45 {
46 private class AssociationItem 46 private class AssociationItem
47 { 47 {
48 public AssociationRelyingPartyType DistinguishingFactor; 48 public AssociationRelyingPartyType DistinguishingFactor;
49 public string Handle; 49 public string Handle;
50 public DateTime Expires; 50 public DateTime Expires;
51 public byte[] PrivateData; 51 public byte[] PrivateData;
52 } 52 }
53 53
54 Dictionary<string, AssociationItem> m_store = new Dictionary<string, AssociationItem>(); 54 Dictionary<string, AssociationItem> m_store = new Dictionary<string, AssociationItem>();
55 SortedList<DateTime, AssociationItem> m_sortedStore = new SortedList<DateTime, AssociationItem>(); 55 SortedList<DateTime, AssociationItem> m_sortedStore = new SortedList<DateTime, AssociationItem>();
56 object m_syncRoot = new object(); 56 object m_syncRoot = new object();
57 57
58 #region IAssociationStore<AssociationRelyingPartyType> Members 58 #region IAssociationStore<AssociationRelyingPartyType> Members
59 59
60 public void StoreAssociation(AssociationRelyingPartyType distinguishingFactor, Association assoc) 60 public void StoreAssociation(AssociationRelyingPartyType distinguishingFactor, Association assoc)
61 { 61 {
62 AssociationItem item = new AssociationItem(); 62 AssociationItem item = new AssociationItem();
63 item.DistinguishingFactor = distinguishingFactor; 63 item.DistinguishingFactor = distinguishingFactor;
64 item.Handle = assoc.Handle; 64 item.Handle = assoc.Handle;
65 item.Expires = assoc.Expires.ToLocalTime(); 65 item.Expires = assoc.Expires.ToLocalTime();
66 item.PrivateData = assoc.SerializePrivateData(); 66 item.PrivateData = assoc.SerializePrivateData();
67 67
68 lock (m_syncRoot) 68 lock (m_syncRoot)
69 { 69 {
70 m_store[item.Handle] = item; 70 m_store[item.Handle] = item;
71 m_sortedStore[item.Expires] = item; 71 m_sortedStore[item.Expires] = item;
72 } 72 }
73 } 73 }
74 74
75 public Association GetAssociation(AssociationRelyingPartyType distinguishingFactor) 75 public Association GetAssociation(AssociationRelyingPartyType distinguishingFactor)
76 { 76 {
77 lock (m_syncRoot) 77 lock (m_syncRoot)
78 { 78 {
79 if (m_sortedStore.Count > 0) 79 if (m_sortedStore.Count > 0)
80 { 80 {
81 AssociationItem item = m_sortedStore.Values[m_sortedStore.Count - 1]; 81 AssociationItem item = m_sortedStore.Values[m_sortedStore.Count - 1];
82 return Association.Deserialize(item.Handle, item.Expires.ToUniversalTime(), item.PrivateData); 82 return Association.Deserialize(item.Handle, item.Expires.ToUniversalTime(), item.PrivateData);
83 } 83 }
84 else 84 else
85 { 85 {
86 return null; 86 return null;
87 } 87 }
88 } 88 }
89 } 89 }
90 90
91 public Association GetAssociation(AssociationRelyingPartyType distinguishingFactor, string handle) 91 public Association GetAssociation(AssociationRelyingPartyType distinguishingFactor, string handle)
92 { 92 {
93 AssociationItem item; 93 AssociationItem item;
94 bool success = false; 94 bool success = false;
95 lock (m_syncRoot) 95 lock (m_syncRoot)
96 success = m_store.TryGetValue(handle, out item); 96 success = m_store.TryGetValue(handle, out item);
97 97
98 if (success) 98 if (success)
99 return Association.Deserialize(item.Handle, item.Expires.ToUniversalTime(), item.PrivateData); 99 return Association.Deserialize(item.Handle, item.Expires.ToUniversalTime(), item.PrivateData);
100 else 100 else
101 return null; 101 return null;
102 } 102 }
103 103
104 public bool RemoveAssociation(AssociationRelyingPartyType distinguishingFactor, string handle) 104 public bool RemoveAssociation(AssociationRelyingPartyType distinguishingFactor, string handle)
105 { 105 {
106 lock (m_syncRoot) 106 lock (m_syncRoot)
107 { 107 {
108 for (int i = 0; i < m_sortedStore.Values.Count; i++) 108 for (int i = 0; i < m_sortedStore.Values.Count; i++)
109 { 109 {
110 AssociationItem item = m_sortedStore.Values[i]; 110 AssociationItem item = m_sortedStore.Values[i];
111 if (item.Handle == handle) 111 if (item.Handle == handle)
112 { 112 {
113 m_sortedStore.RemoveAt(i); 113 m_sortedStore.RemoveAt(i);
114 break; 114 break;
115 } 115 }
116 } 116 }
117 117
118 return m_store.Remove(handle); 118 return m_store.Remove(handle);
119 } 119 }
120 } 120 }
121 121
122 public void ClearExpiredAssociations() 122 public void ClearExpiredAssociations()
123 { 123 {
124 lock (m_syncRoot) 124 lock (m_syncRoot)
125 { 125 {
126 List<AssociationItem> itemsCopy = new List<AssociationItem>(m_sortedStore.Values); 126 List<AssociationItem> itemsCopy = new List<AssociationItem>(m_sortedStore.Values);
127 DateTime now = DateTime.Now; 127 DateTime now = DateTime.Now;
128 128
129 for (int i = 0; i < itemsCopy.Count; i++) 129 for (int i = 0; i < itemsCopy.Count; i++)
130 { 130 {
131 AssociationItem item = itemsCopy[i]; 131 AssociationItem item = itemsCopy[i];
132 132
133 if (item.Expires <= now) 133 if (item.Expires <= now)
134 { 134 {
135 m_sortedStore.RemoveAt(i); 135 m_sortedStore.RemoveAt(i);
136 m_store.Remove(item.Handle); 136 m_store.Remove(item.Handle);
137 } 137 }
138 } 138 }
139 } 139 }
140 } 140 }
141 141
142 #endregion 142 #endregion
143 } 143 }
144 144
145 public class OpenIdStreamHandler : IStreamHandler 145 public class OpenIdStreamHandler : IStreamHandler
146 { 146 {
147 #region HTML 147 #region HTML
148 148
149 /// <summary>Login form used to authenticate OpenID requests</summary> 149 /// <summary>Login form used to authenticate OpenID requests</summary>
150 const string LOGIN_PAGE = 150 const string LOGIN_PAGE =
151@"<html> 151@"<html>
152<head><title>OpenSim OpenID Login</title></head> 152<head><title>OpenSim OpenID Login</title></head>
153<body> 153<body>
154<h3>OpenSim Login</h3> 154<h3>OpenSim Login</h3>
155<form method=""post""> 155<form method=""post"">
156<label for=""first"">First Name:</label> <input readonly type=""text"" name=""first"" id=""first"" value=""{0}""/> 156<label for=""first"">First Name:</label> <input readonly type=""text"" name=""first"" id=""first"" value=""{0}""/>
157<label for=""last"">Last Name:</label> <input readonly type=""text"" name=""last"" id=""last"" value=""{1}""/> 157<label for=""last"">Last Name:</label> <input readonly type=""text"" name=""last"" id=""last"" value=""{1}""/>
158<label for=""pass"">Password:</label> <input type=""password"" name=""pass"" id=""pass""/> 158<label for=""pass"">Password:</label> <input type=""password"" name=""pass"" id=""pass""/>
159<input type=""submit"" value=""Login""> 159<input type=""submit"" value=""Login"">
160</form> 160</form>
161</body> 161</body>
162</html>"; 162</html>";
163 163
164 /// <summary>Page shown for a valid OpenID identity</summary> 164 /// <summary>Page shown for a valid OpenID identity</summary>
165 const string OPENID_PAGE = 165 const string OPENID_PAGE =
166@"<html> 166@"<html>
167<head> 167<head>
168<title>{2} {3}</title> 168<title>{2} {3}</title>
169<link rel=""openid2.provider openid.server"" href=""{0}://{1}/openid/server/""/> 169<link rel=""openid2.provider openid.server"" href=""{0}://{1}/openid/server/""/>
170</head> 170</head>
171<body>OpenID identifier for {2} {3}</body> 171<body>OpenID identifier for {2} {3}</body>
172</html> 172</html>
173"; 173";
174 174
175 /// <summary>Page shown for an invalid OpenID identity</summary> 175 /// <summary>Page shown for an invalid OpenID identity</summary>
176 const string INVALID_OPENID_PAGE = 176 const string INVALID_OPENID_PAGE =
177@"<html><head><title>Identity not found</title></head> 177@"<html><head><title>Identity not found</title></head>
178<body>Invalid OpenID identity</body></html>"; 178<body>Invalid OpenID identity</body></html>";
179 179
180 /// <summary>Page shown if the OpenID endpoint is requested directly</summary> 180 /// <summary>Page shown if the OpenID endpoint is requested directly</summary>
181 const string ENDPOINT_PAGE = 181 const string ENDPOINT_PAGE =
182@"<html><head><title>OpenID Endpoint</title></head><body> 182@"<html><head><title>OpenID Endpoint</title></head><body>
183This is an OpenID server endpoint, not a human-readable resource. 183This is an OpenID server endpoint, not a human-readable resource.
184For more information, see <a href='http://openid.net/'>http://openid.net/</a>. 184For more information, see <a href='http://openid.net/'>http://openid.net/</a>.
185</body></html>"; 185</body></html>";
186 186
187 #endregion HTML 187 #endregion HTML
188 188
189 public string ContentType { get { return m_contentType; } } 189 public string ContentType { get { return m_contentType; } }
190 public string HttpMethod { get { return m_httpMethod; } } 190 public string HttpMethod { get { return m_httpMethod; } }
191 public string Path { get { return m_path; } } 191 public string Path { get { return m_path; } }
192 192
193 string m_contentType; 193 string m_contentType;
194 string m_httpMethod; 194 string m_httpMethod;
195 string m_path; 195 string m_path;
196 UserLoginService m_loginService; 196 UserLoginService m_loginService;
197 ProviderMemoryStore m_openidStore = new ProviderMemoryStore(); 197 ProviderMemoryStore m_openidStore = new ProviderMemoryStore();
198 198
199 /// <summary> 199 /// <summary>
200 /// Constructor 200 /// Constructor
201 /// </summary> 201 /// </summary>
202 public OpenIdStreamHandler(string httpMethod, string path, UserLoginService loginService) 202 public OpenIdStreamHandler(string httpMethod, string path, UserLoginService loginService)
203 { 203 {
204 m_loginService = loginService; 204 m_loginService = loginService;
205 m_httpMethod = httpMethod; 205 m_httpMethod = httpMethod;
206 m_path = path; 206 m_path = path;
207 207
208 m_contentType = "text/html"; 208 m_contentType = "text/html";
209 } 209 }
210 210
211 /// <summary> 211 /// <summary>
212 /// Handles all GET and POST requests for OpenID identifier pages and endpoint 212 /// Handles all GET and POST requests for OpenID identifier pages and endpoint
213 /// server communication 213 /// server communication
214 /// </summary> 214 /// </summary>
215 public void Handle(string path, Stream request, Stream response, OSHttpRequest httpRequest, OSHttpResponse httpResponse) 215 public void Handle(string path, Stream request, Stream response, OSHttpRequest httpRequest, OSHttpResponse httpResponse)
216 { 216 {
217 Uri providerEndpoint = new Uri(String.Format("{0}://{1}{2}", httpRequest.Url.Scheme, httpRequest.Url.Authority, httpRequest.Url.AbsolutePath)); 217 Uri providerEndpoint = new Uri(String.Format("{0}://{1}{2}", httpRequest.Url.Scheme, httpRequest.Url.Authority, httpRequest.Url.AbsolutePath));
218 218
219 // Defult to returning HTML content 219 // Defult to returning HTML content
220 m_contentType = "text/html"; 220 m_contentType = "text/html";
221 221
222 try 222 try
223 { 223 {
224 NameValueCollection postQuery = HttpUtility.ParseQueryString(new StreamReader(httpRequest.InputStream).ReadToEnd()); 224 NameValueCollection postQuery = HttpUtility.ParseQueryString(new StreamReader(httpRequest.InputStream).ReadToEnd());
225 NameValueCollection getQuery = HttpUtility.ParseQueryString(httpRequest.Url.Query); 225 NameValueCollection getQuery = HttpUtility.ParseQueryString(httpRequest.Url.Query);
226 NameValueCollection openIdQuery = (postQuery.GetValues("openid.mode") != null ? postQuery : getQuery); 226 NameValueCollection openIdQuery = (postQuery.GetValues("openid.mode") != null ? postQuery : getQuery);
227 227
228 OpenIdProvider provider = new OpenIdProvider(m_openidStore, providerEndpoint, httpRequest.Url, openIdQuery); 228 OpenIdProvider provider = new OpenIdProvider(m_openidStore, providerEndpoint, httpRequest.Url, openIdQuery);
229 229
230 if (provider.Request != null) 230 if (provider.Request != null)
231 { 231 {
232 if (!provider.Request.IsResponseReady && provider.Request is IAuthenticationRequest) 232 if (!provider.Request.IsResponseReady && provider.Request is IAuthenticationRequest)
233 { 233 {
234 IAuthenticationRequest authRequest = (IAuthenticationRequest)provider.Request; 234 IAuthenticationRequest authRequest = (IAuthenticationRequest)provider.Request;
235 string[] passwordValues = postQuery.GetValues("pass"); 235 string[] passwordValues = postQuery.GetValues("pass");
236 236
237 UserProfileData profile; 237 UserProfileData profile;
238 if (TryGetProfile(new Uri(authRequest.ClaimedIdentifier.ToString()), out profile)) 238 if (TryGetProfile(new Uri(authRequest.ClaimedIdentifier.ToString()), out profile))
239 { 239 {
240 // Check for form POST data 240 // Check for form POST data
241 if (passwordValues != null && passwordValues.Length == 1) 241 if (passwordValues != null && passwordValues.Length == 1)
242 { 242 {
243 if (profile != null && m_loginService.AuthenticateUser(profile, passwordValues[0])) 243 if (profile != null && m_loginService.AuthenticateUser(profile, passwordValues[0]))
244 authRequest.IsAuthenticated = true; 244 authRequest.IsAuthenticated = true;
245 else 245 else
246 authRequest.IsAuthenticated = false; 246 authRequest.IsAuthenticated = false;
247 } 247 }
248 else 248 else
249 { 249 {
250 // Authentication was requested, send the client a login form 250 // Authentication was requested, send the client a login form
251 using (StreamWriter writer = new StreamWriter(response)) 251 using (StreamWriter writer = new StreamWriter(response))
252 writer.Write(String.Format(LOGIN_PAGE, profile.FirstName, profile.SurName)); 252 writer.Write(String.Format(LOGIN_PAGE, profile.FirstName, profile.SurName));
253 return; 253 return;
254 } 254 }
255 } 255 }
256 else 256 else
257 { 257 {
258 // Cannot find an avatar matching the claimed identifier 258 // Cannot find an avatar matching the claimed identifier
259 authRequest.IsAuthenticated = false; 259 authRequest.IsAuthenticated = false;
260 } 260 }
261 } 261 }
262 262
263 // Add OpenID headers to the response 263 // Add OpenID headers to the response
264 foreach (string key in provider.Request.Response.Headers.Keys) 264 foreach (string key in provider.Request.Response.Headers.Keys)
265 httpResponse.AddHeader(key, provider.Request.Response.Headers[key]); 265 httpResponse.AddHeader(key, provider.Request.Response.Headers[key]);
266 266
267 string[] contentTypeValues = provider.Request.Response.Headers.GetValues("Content-Type"); 267 string[] contentTypeValues = provider.Request.Response.Headers.GetValues("Content-Type");
268 if (contentTypeValues != null && contentTypeValues.Length == 1) 268 if (contentTypeValues != null && contentTypeValues.Length == 1)
269 m_contentType = contentTypeValues[0]; 269 m_contentType = contentTypeValues[0];
270 270
271 // Set the response code and document body based on the OpenID result 271 // Set the response code and document body based on the OpenID result
272 httpResponse.StatusCode = (int)provider.Request.Response.Code; 272 httpResponse.StatusCode = (int)provider.Request.Response.Code;
273 response.Write(provider.Request.Response.Body, 0, provider.Request.Response.Body.Length); 273 response.Write(provider.Request.Response.Body, 0, provider.Request.Response.Body.Length);
274 response.Close(); 274 response.Close();
275 } 275 }
276 else if (httpRequest.Url.AbsolutePath.Contains("/openid/server")) 276 else if (httpRequest.Url.AbsolutePath.Contains("/openid/server"))
277 { 277 {
278 // Standard HTTP GET was made on the OpenID endpoint, send the client the default error page 278 // Standard HTTP GET was made on the OpenID endpoint, send the client the default error page
279 using (StreamWriter writer = new StreamWriter(response)) 279 using (StreamWriter writer = new StreamWriter(response))
280 writer.Write(ENDPOINT_PAGE); 280 writer.Write(ENDPOINT_PAGE);
281 } 281 }
282 else 282 else
283 { 283 {
284 // Try and lookup this avatar 284 // Try and lookup this avatar
285 UserProfileData profile; 285 UserProfileData profile;
286 if (TryGetProfile(httpRequest.Url, out profile)) 286 if (TryGetProfile(httpRequest.Url, out profile))
287 { 287 {
288 using (StreamWriter writer = new StreamWriter(response)) 288 using (StreamWriter writer = new StreamWriter(response))
289 { 289 {
290 // TODO: Print out a full profile page for this avatar 290 // TODO: Print out a full profile page for this avatar
291 writer.Write(String.Format(OPENID_PAGE, httpRequest.Url.Scheme, 291 writer.Write(String.Format(OPENID_PAGE, httpRequest.Url.Scheme,
292 httpRequest.Url.Authority, profile.FirstName, profile.SurName)); 292 httpRequest.Url.Authority, profile.FirstName, profile.SurName));
293 } 293 }
294 } 294 }
295 else 295 else
296 { 296 {
297 // Couldn't parse an avatar name, or couldn't find the avatar in the user server 297 // Couldn't parse an avatar name, or couldn't find the avatar in the user server
298 using (StreamWriter writer = new StreamWriter(response)) 298 using (StreamWriter writer = new StreamWriter(response))
299 writer.Write(INVALID_OPENID_PAGE); 299 writer.Write(INVALID_OPENID_PAGE);
300 } 300 }
301 } 301 }
302 } 302 }
303 catch (Exception ex) 303 catch (Exception ex)
304 { 304 {
305 httpResponse.StatusCode = (int)HttpStatusCode.InternalServerError; 305 httpResponse.StatusCode = (int)HttpStatusCode.InternalServerError;
306 using (StreamWriter writer = new StreamWriter(response)) 306 using (StreamWriter writer = new StreamWriter(response))
307 writer.Write(ex.Message); 307 writer.Write(ex.Message);
308 } 308 }
309 } 309 }
310 310
311 /// <summary> 311 /// <summary>
312 /// Parse a URL with a relative path of the form /users/First_Last and try to 312 /// Parse a URL with a relative path of the form /users/First_Last and try to
313 /// retrieve the profile matching that avatar name 313 /// retrieve the profile matching that avatar name
314 /// </summary> 314 /// </summary>
315 /// <param name="requestUrl">URL to parse for an avatar name</param> 315 /// <param name="requestUrl">URL to parse for an avatar name</param>
316 /// <param name="profile">Profile data for the avatar</param> 316 /// <param name="profile">Profile data for the avatar</param>
317 /// <returns>True if the parse and lookup were successful, otherwise false</returns> 317 /// <returns>True if the parse and lookup were successful, otherwise false</returns>
318 bool TryGetProfile(Uri requestUrl, out UserProfileData profile) 318 bool TryGetProfile(Uri requestUrl, out UserProfileData profile)
319 { 319 {
320 if (requestUrl.Segments.Length == 3 && requestUrl.Segments[1] == "users/") 320 if (requestUrl.Segments.Length == 3 && requestUrl.Segments[1] == "users/")
321 { 321 {
322 // Parse the avatar name from the path 322 // Parse the avatar name from the path
323 string username = requestUrl.Segments[requestUrl.Segments.Length - 1]; 323 string username = requestUrl.Segments[requestUrl.Segments.Length - 1];
324 string[] name = username.Split('_'); 324 string[] name = username.Split('_');
325 325
326 if (name.Length == 2) 326 if (name.Length == 2)
327 { 327 {
328 profile = m_loginService.GetTheUser(name[0], name[1]); 328 profile = m_loginService.GetTheUser(name[0], name[1]);
329 return (profile != null); 329 return (profile != null);
330 } 330 }
331 } 331 }
332 332
333 profile = null; 333 profile = null;
334 return false; 334 return false;
335 } 335 }
336 } 336 }
337} 337}
diff --git a/OpenSim/Grid/UserServer.Modules/UserDataBaseService.cs b/OpenSim/Grid/UserServer.Modules/UserDataBaseService.cs
index ef59cac..80f2f7b 100644
--- a/OpenSim/Grid/UserServer.Modules/UserDataBaseService.cs
+++ b/OpenSim/Grid/UserServer.Modules/UserDataBaseService.cs
@@ -1,111 +1,111 @@
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 log4net; 32using log4net;
33using Nwc.XmlRpc; 33using Nwc.XmlRpc;
34using OpenMetaverse; 34using OpenMetaverse;
35using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Framework.Communications; 36using OpenSim.Framework.Communications;
37using OpenSim.Framework.Servers; 37using OpenSim.Framework.Servers;
38using OpenSim.Grid.Framework; 38using OpenSim.Grid.Framework;
39 39
40namespace OpenSim.Grid.UserServer.Modules 40namespace OpenSim.Grid.UserServer.Modules
41{ 41{
42 public class UserDataBaseService : UserManagerBase 42 public class UserDataBaseService : UserManagerBase
43 { 43 {
44 protected IUGAIMCore m_core; 44 protected IUGAIMCore m_core;
45 45
46 public UserDataBaseService() 46 public UserDataBaseService()
47 : base(null) 47 : base(null)
48 { 48 {
49 } 49 }
50 50
51 public UserDataBaseService(IInterServiceInventoryServices interServiceInventoryService) 51 public UserDataBaseService(IInterServiceInventoryServices interServiceInventoryService)
52 : base(interServiceInventoryService) 52 : base(interServiceInventoryService)
53 { 53 {
54 } 54 }
55 55
56 public void Initialise(IUGAIMCore core) 56 public void Initialise(IUGAIMCore core)
57 { 57 {
58 m_core = core; 58 m_core = core;
59 59
60 //we only need core components so we can request them from here 60 //we only need core components so we can request them from here
61 IInterServiceInventoryServices inventoryService; 61 IInterServiceInventoryServices inventoryService;
62 if (m_core.TryGet<IInterServiceInventoryServices>(out inventoryService)) 62 if (m_core.TryGet<IInterServiceInventoryServices>(out inventoryService))
63 { 63 {
64 m_interServiceInventoryService = inventoryService; 64 m_interServiceInventoryService = inventoryService;
65 } 65 }
66 66
67 UserConfig cfg; 67 UserConfig cfg;
68 if (m_core.TryGet<UserConfig>(out cfg)) 68 if (m_core.TryGet<UserConfig>(out cfg))
69 { 69 {
70 AddPlugin(cfg.DatabaseProvider, cfg.DatabaseConnect); 70 AddPlugin(cfg.DatabaseProvider, cfg.DatabaseConnect);
71 } 71 }
72 72
73 m_core.RegisterInterface<UserDataBaseService>(this); 73 m_core.RegisterInterface<UserDataBaseService>(this);
74 } 74 }
75 75
76 public void PostInitialise() 76 public void PostInitialise()
77 { 77 {
78 } 78 }
79 79
80 public void RegisterHandlers(BaseHttpServer httpServer) 80 public void RegisterHandlers(BaseHttpServer httpServer)
81 { 81 {
82 } 82 }
83 83
84 public UserAgentData GetUserAgentData(UUID AgentID) 84 public UserAgentData GetUserAgentData(UUID AgentID)
85 { 85 {
86 UserProfileData userProfile = GetUserProfile(AgentID); 86 UserProfileData userProfile = GetUserProfile(AgentID);
87 87
88 if (userProfile != null) 88 if (userProfile != null)
89 { 89 {
90 return userProfile.CurrentAgent; 90 return userProfile.CurrentAgent;
91 } 91 }
92 92
93 return null; 93 return null;
94 } 94 }
95 95
96 public override UserProfileData SetupMasterUser(string firstName, string lastName) 96 public override UserProfileData SetupMasterUser(string firstName, string lastName)
97 { 97 {
98 throw new Exception("The method or operation is not implemented."); 98 throw new Exception("The method or operation is not implemented.");
99 } 99 }
100 100
101 public override UserProfileData SetupMasterUser(string firstName, string lastName, string password) 101 public override UserProfileData SetupMasterUser(string firstName, string lastName, string password)
102 { 102 {
103 throw new Exception("The method or operation is not implemented."); 103 throw new Exception("The method or operation is not implemented.");
104 } 104 }
105 105
106 public override UserProfileData SetupMasterUser(UUID uuid) 106 public override UserProfileData SetupMasterUser(UUID uuid)
107 { 107 {
108 throw new Exception("The method or operation is not implemented."); 108 throw new Exception("The method or operation is not implemented.");
109 } 109 }
110 } 110 }
111} 111}
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}
diff --git a/OpenSim/Grid/UserServer.Modules/UserManager.cs b/OpenSim/Grid/UserServer.Modules/UserManager.cs
index dd9f495..c6c3a1a 100644
--- a/OpenSim/Grid/UserServer.Modules/UserManager.cs
+++ b/OpenSim/Grid/UserServer.Modules/UserManager.cs
@@ -1,686 +1,686 @@
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 log4net; 32using log4net;
33using Nwc.XmlRpc; 33using Nwc.XmlRpc;
34using OpenMetaverse; 34using OpenMetaverse;
35using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Framework.Communications; 36using OpenSim.Framework.Communications;
37using OpenSim.Framework.Servers; 37using OpenSim.Framework.Servers;
38 38
39namespace OpenSim.Grid.UserServer.Modules 39namespace OpenSim.Grid.UserServer.Modules
40{ 40{
41 public delegate void logOffUser(UUID AgentID); 41 public delegate void logOffUser(UUID AgentID);
42 42
43 public class UserManager 43 public class UserManager
44 { 44 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 46
47 public event logOffUser OnLogOffUser; 47 public event logOffUser OnLogOffUser;
48 private logOffUser handlerLogOffUser; 48 private logOffUser handlerLogOffUser;
49 49
50 private UserDataBaseService m_userDataBaseService; 50 private UserDataBaseService m_userDataBaseService;
51 private BaseHttpServer m_httpServer; 51 private BaseHttpServer m_httpServer;
52 52
53 /// <summary> 53 /// <summary>
54 /// 54 ///
55 /// </summary> 55 /// </summary>
56 /// <param name="userDataBaseService"></param> 56 /// <param name="userDataBaseService"></param>
57 public UserManager( UserDataBaseService userDataBaseService) 57 public UserManager( UserDataBaseService userDataBaseService)
58 { 58 {
59 m_userDataBaseService = userDataBaseService; 59 m_userDataBaseService = userDataBaseService;
60 } 60 }
61 61
62 public void Initialise() 62 public void Initialise()
63 { 63 {
64 64
65 } 65 }
66 66
67 public void PostInitialise() 67 public void PostInitialise()
68 { 68 {
69 69
70 } 70 }
71 71
72 public void RegisterHandlers(BaseHttpServer httpServer) 72 public void RegisterHandlers(BaseHttpServer httpServer)
73 { 73 {
74 m_httpServer = httpServer; 74 m_httpServer = httpServer;
75 75
76 m_httpServer.AddXmlRPCHandler("get_user_by_name", XmlRPCGetUserMethodName); 76 m_httpServer.AddXmlRPCHandler("get_user_by_name", XmlRPCGetUserMethodName);
77 m_httpServer.AddXmlRPCHandler("get_user_by_uuid", XmlRPCGetUserMethodUUID); 77 m_httpServer.AddXmlRPCHandler("get_user_by_uuid", XmlRPCGetUserMethodUUID);
78 m_httpServer.AddXmlRPCHandler("get_avatar_picker_avatar", XmlRPCGetAvatarPickerAvatar); 78 m_httpServer.AddXmlRPCHandler("get_avatar_picker_avatar", XmlRPCGetAvatarPickerAvatar);
79 79
80 m_httpServer.AddXmlRPCHandler("update_user_current_region", XmlRPCAtRegion); 80 m_httpServer.AddXmlRPCHandler("update_user_current_region", XmlRPCAtRegion);
81 m_httpServer.AddXmlRPCHandler("logout_of_simulator", XmlRPCLogOffUserMethodUUID); 81 m_httpServer.AddXmlRPCHandler("logout_of_simulator", XmlRPCLogOffUserMethodUUID);
82 m_httpServer.AddXmlRPCHandler("get_agent_by_uuid", XmlRPCGetAgentMethodUUID); 82 m_httpServer.AddXmlRPCHandler("get_agent_by_uuid", XmlRPCGetAgentMethodUUID);
83 m_httpServer.AddXmlRPCHandler("check_auth_session", XmlRPCCheckAuthSession); 83 m_httpServer.AddXmlRPCHandler("check_auth_session", XmlRPCCheckAuthSession);
84 84
85 m_httpServer.AddXmlRPCHandler("update_user_profile", XmlRpcResponseXmlRPCUpdateUserProfile); 85 m_httpServer.AddXmlRPCHandler("update_user_profile", XmlRpcResponseXmlRPCUpdateUserProfile);
86 86
87 m_httpServer.AddStreamHandler(new RestStreamHandler("DELETE", "/usersessions/", RestDeleteUserSessionMethod)); 87 m_httpServer.AddStreamHandler(new RestStreamHandler("DELETE", "/usersessions/", RestDeleteUserSessionMethod));
88 } 88 }
89 89
90 /// <summary> 90 /// <summary>
91 /// Deletes an active agent session 91 /// Deletes an active agent session
92 /// </summary> 92 /// </summary>
93 /// <param name="request">The request</param> 93 /// <param name="request">The request</param>
94 /// <param name="path">The path (eg /bork/narf/test)</param> 94 /// <param name="path">The path (eg /bork/narf/test)</param>
95 /// <param name="param">Parameters sent</param> 95 /// <param name="param">Parameters sent</param>
96 /// <param name="httpRequest">HTTP request header object</param> 96 /// <param name="httpRequest">HTTP request header object</param>
97 /// <param name="httpResponse">HTTP response header object</param> 97 /// <param name="httpResponse">HTTP response header object</param>
98 /// <returns>Success "OK" else error</returns> 98 /// <returns>Success "OK" else error</returns>
99 public string RestDeleteUserSessionMethod(string request, string path, string param, 99 public string RestDeleteUserSessionMethod(string request, string path, string param,
100 OSHttpRequest httpRequest, OSHttpResponse httpResponse) 100 OSHttpRequest httpRequest, OSHttpResponse httpResponse)
101 { 101 {
102 // TODO! Important! 102 // TODO! Important!
103 103
104 return "OK"; 104 return "OK";
105 } 105 }
106 106
107 /// <summary> 107 /// <summary>
108 /// Returns an error message that the user could not be found in the database 108 /// Returns an error message that the user could not be found in the database
109 /// </summary> 109 /// </summary>
110 /// <returns>XML string consisting of a error element containing individual error(s)</returns> 110 /// <returns>XML string consisting of a error element containing individual error(s)</returns>
111 public XmlRpcResponse CreateUnknownUserErrorResponse() 111 public XmlRpcResponse CreateUnknownUserErrorResponse()
112 { 112 {
113 XmlRpcResponse response = new XmlRpcResponse(); 113 XmlRpcResponse response = new XmlRpcResponse();
114 Hashtable responseData = new Hashtable(); 114 Hashtable responseData = new Hashtable();
115 responseData["error_type"] = "unknown_user"; 115 responseData["error_type"] = "unknown_user";
116 responseData["error_desc"] = "The user requested is not in the database"; 116 responseData["error_desc"] = "The user requested is not in the database";
117 117
118 response.Value = responseData; 118 response.Value = responseData;
119 return response; 119 return response;
120 } 120 }
121 121
122 public XmlRpcResponse AvatarPickerListtoXmlRPCResponse(UUID queryID, List<AvatarPickerAvatar> returnUsers) 122 public XmlRpcResponse AvatarPickerListtoXmlRPCResponse(UUID queryID, List<AvatarPickerAvatar> returnUsers)
123 { 123 {
124 XmlRpcResponse response = new XmlRpcResponse(); 124 XmlRpcResponse response = new XmlRpcResponse();
125 Hashtable responseData = new Hashtable(); 125 Hashtable responseData = new Hashtable();
126 // Query Result Information 126 // Query Result Information
127 responseData["queryid"] = queryID.ToString(); 127 responseData["queryid"] = queryID.ToString();
128 responseData["avcount"] = returnUsers.Count.ToString(); 128 responseData["avcount"] = returnUsers.Count.ToString();
129 129
130 for (int i = 0; i < returnUsers.Count; i++) 130 for (int i = 0; i < returnUsers.Count; i++)
131 { 131 {
132 responseData["avatarid" + i] = returnUsers[i].AvatarID.ToString(); 132 responseData["avatarid" + i] = returnUsers[i].AvatarID.ToString();
133 responseData["firstname" + i] = returnUsers[i].firstName; 133 responseData["firstname" + i] = returnUsers[i].firstName;
134 responseData["lastname" + i] = returnUsers[i].lastName; 134 responseData["lastname" + i] = returnUsers[i].lastName;
135 } 135 }
136 response.Value = responseData; 136 response.Value = responseData;
137 137
138 return response; 138 return response;
139 } 139 }
140 140
141 /// <summary> 141 /// <summary>
142 /// Converts a user profile to an XML element which can be returned 142 /// Converts a user profile to an XML element which can be returned
143 /// </summary> 143 /// </summary>
144 /// <param name="profile">The user profile</param> 144 /// <param name="profile">The user profile</param>
145 /// <returns>A string containing an XML Document of the user profile</returns> 145 /// <returns>A string containing an XML Document of the user profile</returns>
146 public XmlRpcResponse ProfileToXmlRPCResponse(UserProfileData profile) 146 public XmlRpcResponse ProfileToXmlRPCResponse(UserProfileData profile)
147 { 147 {
148 XmlRpcResponse response = new XmlRpcResponse(); 148 XmlRpcResponse response = new XmlRpcResponse();
149 Hashtable responseData = new Hashtable(); 149 Hashtable responseData = new Hashtable();
150 150
151 // Account information 151 // Account information
152 responseData["firstname"] = profile.FirstName; 152 responseData["firstname"] = profile.FirstName;
153 responseData["lastname"] = profile.SurName; 153 responseData["lastname"] = profile.SurName;
154 responseData["uuid"] = profile.ID.ToString(); 154 responseData["uuid"] = profile.ID.ToString();
155 // Server Information 155 // Server Information
156 responseData["server_inventory"] = profile.UserInventoryURI; 156 responseData["server_inventory"] = profile.UserInventoryURI;
157 responseData["server_asset"] = profile.UserAssetURI; 157 responseData["server_asset"] = profile.UserAssetURI;
158 // Profile Information 158 // Profile Information
159 responseData["profile_about"] = profile.AboutText; 159 responseData["profile_about"] = profile.AboutText;
160 responseData["profile_firstlife_about"] = profile.FirstLifeAboutText; 160 responseData["profile_firstlife_about"] = profile.FirstLifeAboutText;
161 responseData["profile_firstlife_image"] = profile.FirstLifeImage.ToString(); 161 responseData["profile_firstlife_image"] = profile.FirstLifeImage.ToString();
162 responseData["profile_can_do"] = profile.CanDoMask.ToString(); 162 responseData["profile_can_do"] = profile.CanDoMask.ToString();
163 responseData["profile_want_do"] = profile.WantDoMask.ToString(); 163 responseData["profile_want_do"] = profile.WantDoMask.ToString();
164 responseData["profile_image"] = profile.Image.ToString(); 164 responseData["profile_image"] = profile.Image.ToString();
165 responseData["profile_created"] = profile.Created.ToString(); 165 responseData["profile_created"] = profile.Created.ToString();
166 responseData["profile_lastlogin"] = profile.LastLogin.ToString(); 166 responseData["profile_lastlogin"] = profile.LastLogin.ToString();
167 // Home region information 167 // Home region information
168 responseData["home_coordinates_x"] = profile.HomeLocation.X.ToString(); 168 responseData["home_coordinates_x"] = profile.HomeLocation.X.ToString();
169 responseData["home_coordinates_y"] = profile.HomeLocation.Y.ToString(); 169 responseData["home_coordinates_y"] = profile.HomeLocation.Y.ToString();
170 responseData["home_coordinates_z"] = profile.HomeLocation.Z.ToString(); 170 responseData["home_coordinates_z"] = profile.HomeLocation.Z.ToString();
171 171
172 responseData["home_region"] = profile.HomeRegion.ToString(); 172 responseData["home_region"] = profile.HomeRegion.ToString();
173 responseData["home_region_id"] = profile.HomeRegionID.ToString(); 173 responseData["home_region_id"] = profile.HomeRegionID.ToString();
174 174
175 responseData["home_look_x"] = profile.HomeLookAt.X.ToString(); 175 responseData["home_look_x"] = profile.HomeLookAt.X.ToString();
176 responseData["home_look_y"] = profile.HomeLookAt.Y.ToString(); 176 responseData["home_look_y"] = profile.HomeLookAt.Y.ToString();
177 responseData["home_look_z"] = profile.HomeLookAt.Z.ToString(); 177 responseData["home_look_z"] = profile.HomeLookAt.Z.ToString();
178 178
179 responseData["user_flags"] = profile.UserFlags.ToString(); 179 responseData["user_flags"] = profile.UserFlags.ToString();
180 responseData["god_level"] = profile.GodLevel.ToString(); 180 responseData["god_level"] = profile.GodLevel.ToString();
181 responseData["custom_type"] = profile.CustomType; 181 responseData["custom_type"] = profile.CustomType;
182 responseData["partner"] = profile.Partner.ToString(); 182 responseData["partner"] = profile.Partner.ToString();
183 response.Value = responseData; 183 response.Value = responseData;
184 184
185 return response; 185 return response;
186 } 186 }
187 187
188 #region XMLRPC User Methods 188 #region XMLRPC User Methods
189 189
190 public XmlRpcResponse XmlRPCGetAvatarPickerAvatar(XmlRpcRequest request) 190 public XmlRpcResponse XmlRPCGetAvatarPickerAvatar(XmlRpcRequest request)
191 { 191 {
192 // XmlRpcResponse response = new XmlRpcResponse(); 192 // XmlRpcResponse response = new XmlRpcResponse();
193 Hashtable requestData = (Hashtable) request.Params[0]; 193 Hashtable requestData = (Hashtable) request.Params[0];
194 List<AvatarPickerAvatar> returnAvatar = new List<AvatarPickerAvatar>(); 194 List<AvatarPickerAvatar> returnAvatar = new List<AvatarPickerAvatar>();
195 UUID queryID = new UUID(UUID.Zero.ToString()); 195 UUID queryID = new UUID(UUID.Zero.ToString());
196 196
197 if (requestData.Contains("avquery") && requestData.Contains("queryid")) 197 if (requestData.Contains("avquery") && requestData.Contains("queryid"))
198 { 198 {
199 queryID = new UUID((string) requestData["queryid"]); 199 queryID = new UUID((string) requestData["queryid"]);
200 returnAvatar = m_userDataBaseService.GenerateAgentPickerRequestResponse(queryID, (string) requestData["avquery"]); 200 returnAvatar = m_userDataBaseService.GenerateAgentPickerRequestResponse(queryID, (string) requestData["avquery"]);
201 } 201 }
202 202
203 m_log.InfoFormat("[AVATARINFO]: Servicing Avatar Query: " + (string) requestData["avquery"]); 203 m_log.InfoFormat("[AVATARINFO]: Servicing Avatar Query: " + (string) requestData["avquery"]);
204 return AvatarPickerListtoXmlRPCResponse(queryID, returnAvatar); 204 return AvatarPickerListtoXmlRPCResponse(queryID, returnAvatar);
205 } 205 }
206 206
207 public XmlRpcResponse XmlRPCAtRegion(XmlRpcRequest request) 207 public XmlRpcResponse XmlRPCAtRegion(XmlRpcRequest request)
208 { 208 {
209 XmlRpcResponse response = new XmlRpcResponse(); 209 XmlRpcResponse response = new XmlRpcResponse();
210 Hashtable requestData = (Hashtable) request.Params[0]; 210 Hashtable requestData = (Hashtable) request.Params[0];
211 Hashtable responseData = new Hashtable(); 211 Hashtable responseData = new Hashtable();
212 string returnstring = "FALSE"; 212 string returnstring = "FALSE";
213 213
214 if (requestData.Contains("avatar_id") && requestData.Contains("region_handle") && 214 if (requestData.Contains("avatar_id") && requestData.Contains("region_handle") &&
215 requestData.Contains("region_uuid")) 215 requestData.Contains("region_uuid"))
216 { 216 {
217 // ulong cregionhandle = 0; 217 // ulong cregionhandle = 0;
218 UUID regionUUID; 218 UUID regionUUID;
219 UUID avatarUUID; 219 UUID avatarUUID;
220 220
221 UUID.TryParse((string) requestData["avatar_id"], out avatarUUID); 221 UUID.TryParse((string) requestData["avatar_id"], out avatarUUID);
222 UUID.TryParse((string) requestData["region_uuid"], out regionUUID); 222 UUID.TryParse((string) requestData["region_uuid"], out regionUUID);
223 223
224 if (avatarUUID != UUID.Zero) 224 if (avatarUUID != UUID.Zero)
225 { 225 {
226 UserProfileData userProfile = m_userDataBaseService.GetUserProfile(avatarUUID); 226 UserProfileData userProfile = m_userDataBaseService.GetUserProfile(avatarUUID);
227 userProfile.CurrentAgent.Region = regionUUID; 227 userProfile.CurrentAgent.Region = regionUUID;
228 userProfile.CurrentAgent.Handle = (ulong) Convert.ToInt64((string) requestData["region_handle"]); 228 userProfile.CurrentAgent.Handle = (ulong) Convert.ToInt64((string) requestData["region_handle"]);
229 //userProfile.CurrentAgent. 229 //userProfile.CurrentAgent.
230 m_userDataBaseService.CommitAgent(ref userProfile); 230 m_userDataBaseService.CommitAgent(ref userProfile);
231 //setUserProfile(userProfile); 231 //setUserProfile(userProfile);
232 232
233 233
234 returnstring = "TRUE"; 234 returnstring = "TRUE";
235 } 235 }
236 } 236 }
237 responseData.Add("returnString", returnstring); 237 responseData.Add("returnString", returnstring);
238 response.Value = responseData; 238 response.Value = responseData;
239 return response; 239 return response;
240 } 240 }
241 241
242 public XmlRpcResponse XmlRPCGetUserMethodName(XmlRpcRequest request) 242 public XmlRpcResponse XmlRPCGetUserMethodName(XmlRpcRequest request)
243 { 243 {
244 // XmlRpcResponse response = new XmlRpcResponse(); 244 // XmlRpcResponse response = new XmlRpcResponse();
245 Hashtable requestData = (Hashtable) request.Params[0]; 245 Hashtable requestData = (Hashtable) request.Params[0];
246 UserProfileData userProfile; 246 UserProfileData userProfile;
247 if (requestData.Contains("avatar_name")) 247 if (requestData.Contains("avatar_name"))
248 { 248 {
249 string query = (string) requestData["avatar_name"]; 249 string query = (string) requestData["avatar_name"];
250 250
251 // Regex objAlphaNumericPattern = new Regex("[^a-zA-Z0-9]"); 251 // Regex objAlphaNumericPattern = new Regex("[^a-zA-Z0-9]");
252 252
253 string[] querysplit = query.Split(' '); 253 string[] querysplit = query.Split(' ');
254 254
255 if (querysplit.Length == 2) 255 if (querysplit.Length == 2)
256 { 256 {
257 userProfile = m_userDataBaseService.GetUserProfile(querysplit[0], querysplit[1]); 257 userProfile = m_userDataBaseService.GetUserProfile(querysplit[0], querysplit[1]);
258 if (userProfile == null) 258 if (userProfile == null)
259 { 259 {
260 return CreateUnknownUserErrorResponse(); 260 return CreateUnknownUserErrorResponse();
261 } 261 }
262 } 262 }
263 else 263 else
264 { 264 {
265 return CreateUnknownUserErrorResponse(); 265 return CreateUnknownUserErrorResponse();
266 } 266 }
267 } 267 }
268 else 268 else
269 { 269 {
270 return CreateUnknownUserErrorResponse(); 270 return CreateUnknownUserErrorResponse();
271 } 271 }
272 272
273 return ProfileToXmlRPCResponse(userProfile); 273 return ProfileToXmlRPCResponse(userProfile);
274 } 274 }
275 275
276 public XmlRpcResponse XmlRPCGetUserMethodUUID(XmlRpcRequest request) 276 public XmlRpcResponse XmlRPCGetUserMethodUUID(XmlRpcRequest request)
277 { 277 {
278 // XmlRpcResponse response = new XmlRpcResponse(); 278 // XmlRpcResponse response = new XmlRpcResponse();
279 Hashtable requestData = (Hashtable) request.Params[0]; 279 Hashtable requestData = (Hashtable) request.Params[0];
280 UserProfileData userProfile; 280 UserProfileData userProfile;
281 //CFK: this clogs the UserServer log and is not necessary at this time. 281 //CFK: this clogs the UserServer log and is not necessary at this time.
282 //CFK: m_log.Debug("METHOD BY UUID CALLED"); 282 //CFK: m_log.Debug("METHOD BY UUID CALLED");
283 if (requestData.Contains("avatar_uuid")) 283 if (requestData.Contains("avatar_uuid"))
284 { 284 {
285 try 285 try
286 { 286 {
287 UUID guess = new UUID((string) requestData["avatar_uuid"]); 287 UUID guess = new UUID((string) requestData["avatar_uuid"]);
288 288
289 userProfile = m_userDataBaseService.GetUserProfile(guess); 289 userProfile = m_userDataBaseService.GetUserProfile(guess);
290 } 290 }
291 catch (FormatException) 291 catch (FormatException)
292 { 292 {
293 return CreateUnknownUserErrorResponse(); 293 return CreateUnknownUserErrorResponse();
294 } 294 }
295 295
296 if (userProfile == null) 296 if (userProfile == null)
297 { 297 {
298 return CreateUnknownUserErrorResponse(); 298 return CreateUnknownUserErrorResponse();
299 } 299 }
300 } 300 }
301 else 301 else
302 { 302 {
303 return CreateUnknownUserErrorResponse(); 303 return CreateUnknownUserErrorResponse();
304 } 304 }
305 305
306 return ProfileToXmlRPCResponse(userProfile); 306 return ProfileToXmlRPCResponse(userProfile);
307 } 307 }
308 308
309 public XmlRpcResponse XmlRPCGetAgentMethodUUID(XmlRpcRequest request) 309 public XmlRpcResponse XmlRPCGetAgentMethodUUID(XmlRpcRequest request)
310 { 310 {
311 XmlRpcResponse response = new XmlRpcResponse(); 311 XmlRpcResponse response = new XmlRpcResponse();
312 Hashtable requestData = (Hashtable) request.Params[0]; 312 Hashtable requestData = (Hashtable) request.Params[0];
313 UserProfileData userProfile; 313 UserProfileData userProfile;
314 //CFK: this clogs the UserServer log and is not necessary at this time. 314 //CFK: this clogs the UserServer log and is not necessary at this time.
315 //CFK: m_log.Debug("METHOD BY UUID CALLED"); 315 //CFK: m_log.Debug("METHOD BY UUID CALLED");
316 if (requestData.Contains("avatar_uuid")) 316 if (requestData.Contains("avatar_uuid"))
317 { 317 {
318 UUID guess; 318 UUID guess;
319 319
320 UUID.TryParse((string) requestData["avatar_uuid"], out guess); 320 UUID.TryParse((string) requestData["avatar_uuid"], out guess);
321 321
322 if (guess == UUID.Zero) 322 if (guess == UUID.Zero)
323 { 323 {
324 return CreateUnknownUserErrorResponse(); 324 return CreateUnknownUserErrorResponse();
325 } 325 }
326 326
327 userProfile = m_userDataBaseService.GetUserProfile(guess); 327 userProfile = m_userDataBaseService.GetUserProfile(guess);
328 328
329 if (userProfile == null) 329 if (userProfile == null)
330 { 330 {
331 return CreateUnknownUserErrorResponse(); 331 return CreateUnknownUserErrorResponse();
332 } 332 }
333 333
334 // no agent??? 334 // no agent???
335 if (userProfile.CurrentAgent == null) 335 if (userProfile.CurrentAgent == null)
336 { 336 {
337 return CreateUnknownUserErrorResponse(); 337 return CreateUnknownUserErrorResponse();
338 } 338 }
339 Hashtable responseData = new Hashtable(); 339 Hashtable responseData = new Hashtable();
340 340
341 responseData["handle"] = userProfile.CurrentAgent.Handle.ToString(); 341 responseData["handle"] = userProfile.CurrentAgent.Handle.ToString();
342 responseData["session"] = userProfile.CurrentAgent.SessionID.ToString(); 342 responseData["session"] = userProfile.CurrentAgent.SessionID.ToString();
343 if (userProfile.CurrentAgent.AgentOnline) 343 if (userProfile.CurrentAgent.AgentOnline)
344 responseData["agent_online"] = "TRUE"; 344 responseData["agent_online"] = "TRUE";
345 else 345 else
346 responseData["agent_online"] = "FALSE"; 346 responseData["agent_online"] = "FALSE";
347 347
348 response.Value = responseData; 348 response.Value = responseData;
349 } 349 }
350 else 350 else
351 { 351 {
352 return CreateUnknownUserErrorResponse(); 352 return CreateUnknownUserErrorResponse();
353 } 353 }
354 354
355 return response; 355 return response;
356 } 356 }
357 357
358 public XmlRpcResponse XmlRPCCheckAuthSession(XmlRpcRequest request) 358 public XmlRpcResponse XmlRPCCheckAuthSession(XmlRpcRequest request)
359 { 359 {
360 XmlRpcResponse response = new XmlRpcResponse(); 360 XmlRpcResponse response = new XmlRpcResponse();
361 Hashtable requestData = (Hashtable) request.Params[0]; 361 Hashtable requestData = (Hashtable) request.Params[0];
362 UserProfileData userProfile; 362 UserProfileData userProfile;
363 363
364 string authed = "FALSE"; 364 string authed = "FALSE";
365 if (requestData.Contains("avatar_uuid") && requestData.Contains("session_id")) 365 if (requestData.Contains("avatar_uuid") && requestData.Contains("session_id"))
366 { 366 {
367 UUID guess_aid; 367 UUID guess_aid;
368 UUID guess_sid; 368 UUID guess_sid;
369 369
370 UUID.TryParse((string) requestData["avatar_uuid"], out guess_aid); 370 UUID.TryParse((string) requestData["avatar_uuid"], out guess_aid);
371 if (guess_aid == UUID.Zero) 371 if (guess_aid == UUID.Zero)
372 { 372 {
373 return CreateUnknownUserErrorResponse(); 373 return CreateUnknownUserErrorResponse();
374 } 374 }
375 UUID.TryParse((string) requestData["session_id"], out guess_sid); 375 UUID.TryParse((string) requestData["session_id"], out guess_sid);
376 if (guess_sid == UUID.Zero) 376 if (guess_sid == UUID.Zero)
377 { 377 {
378 return CreateUnknownUserErrorResponse(); 378 return CreateUnknownUserErrorResponse();
379 } 379 }
380 userProfile = m_userDataBaseService.GetUserProfile(guess_aid); 380 userProfile = m_userDataBaseService.GetUserProfile(guess_aid);
381 if (userProfile != null && userProfile.CurrentAgent != null && 381 if (userProfile != null && userProfile.CurrentAgent != null &&
382 userProfile.CurrentAgent.SessionID == guess_sid) 382 userProfile.CurrentAgent.SessionID == guess_sid)
383 { 383 {
384 authed = "TRUE"; 384 authed = "TRUE";
385 } 385 }
386 m_log.InfoFormat("[UserManager]: CheckAuthSession TRUE for user {0}", guess_aid); 386 m_log.InfoFormat("[UserManager]: CheckAuthSession TRUE for user {0}", guess_aid);
387 } 387 }
388 else 388 else
389 { 389 {
390 m_log.InfoFormat("[UserManager]: CheckAuthSession FALSE"); 390 m_log.InfoFormat("[UserManager]: CheckAuthSession FALSE");
391 return CreateUnknownUserErrorResponse(); 391 return CreateUnknownUserErrorResponse();
392 } 392 }
393 Hashtable responseData = new Hashtable(); 393 Hashtable responseData = new Hashtable();
394 responseData["auth_session"] = authed; 394 responseData["auth_session"] = authed;
395 response.Value = responseData; 395 response.Value = responseData;
396 return response; 396 return response;
397 } 397 }
398 398
399 public XmlRpcResponse XmlRpcResponseXmlRPCUpdateUserProfile(XmlRpcRequest request) 399 public XmlRpcResponse XmlRpcResponseXmlRPCUpdateUserProfile(XmlRpcRequest request)
400 { 400 {
401 m_log.Debug("[UserManager]: Got request to update user profile"); 401 m_log.Debug("[UserManager]: Got request to update user profile");
402 XmlRpcResponse response = new XmlRpcResponse(); 402 XmlRpcResponse response = new XmlRpcResponse();
403 Hashtable requestData = (Hashtable) request.Params[0]; 403 Hashtable requestData = (Hashtable) request.Params[0];
404 Hashtable responseData = new Hashtable(); 404 Hashtable responseData = new Hashtable();
405 405
406 if (!requestData.Contains("avatar_uuid")) 406 if (!requestData.Contains("avatar_uuid"))
407 { 407 {
408 return CreateUnknownUserErrorResponse(); 408 return CreateUnknownUserErrorResponse();
409 } 409 }
410 410
411 UUID UserUUID = new UUID((string) requestData["avatar_uuid"]); 411 UUID UserUUID = new UUID((string) requestData["avatar_uuid"]);
412 UserProfileData userProfile = m_userDataBaseService.GetUserProfile(UserUUID); 412 UserProfileData userProfile = m_userDataBaseService.GetUserProfile(UserUUID);
413 if (null == userProfile) 413 if (null == userProfile)
414 { 414 {
415 return CreateUnknownUserErrorResponse(); 415 return CreateUnknownUserErrorResponse();
416 } 416 }
417 // don't know how yet. 417 // don't know how yet.
418 if (requestData.Contains("AllowPublish")) 418 if (requestData.Contains("AllowPublish"))
419 { 419 {
420 } 420 }
421 if (requestData.Contains("FLImageID")) 421 if (requestData.Contains("FLImageID"))
422 { 422 {
423 userProfile.FirstLifeImage = new UUID((string) requestData["FLImageID"]); 423 userProfile.FirstLifeImage = new UUID((string) requestData["FLImageID"]);
424 } 424 }
425 if (requestData.Contains("ImageID")) 425 if (requestData.Contains("ImageID"))
426 { 426 {
427 userProfile.Image = new UUID((string) requestData["ImageID"]); 427 userProfile.Image = new UUID((string) requestData["ImageID"]);
428 } 428 }
429 // dont' know how yet 429 // dont' know how yet
430 if (requestData.Contains("MaturePublish")) 430 if (requestData.Contains("MaturePublish"))
431 { 431 {
432 } 432 }
433 if (requestData.Contains("AboutText")) 433 if (requestData.Contains("AboutText"))
434 { 434 {
435 userProfile.AboutText = (string) requestData["AboutText"]; 435 userProfile.AboutText = (string) requestData["AboutText"];
436 } 436 }
437 if (requestData.Contains("FLAboutText")) 437 if (requestData.Contains("FLAboutText"))
438 { 438 {
439 userProfile.FirstLifeAboutText = (string) requestData["FLAboutText"]; 439 userProfile.FirstLifeAboutText = (string) requestData["FLAboutText"];
440 } 440 }
441 // not in DB yet. 441 // not in DB yet.
442 if (requestData.Contains("ProfileURL")) 442 if (requestData.Contains("ProfileURL"))
443 { 443 {
444 } 444 }
445 if (requestData.Contains("home_region")) 445 if (requestData.Contains("home_region"))
446 { 446 {
447 try 447 try
448 { 448 {
449 userProfile.HomeRegion = Convert.ToUInt64((string) requestData["home_region"]); 449 userProfile.HomeRegion = Convert.ToUInt64((string) requestData["home_region"]);
450 } 450 }
451 catch (ArgumentException) 451 catch (ArgumentException)
452 { 452 {
453 m_log.Error("[PROFILE]:Failed to set home region, Invalid Argument"); 453 m_log.Error("[PROFILE]:Failed to set home region, Invalid Argument");
454 } 454 }
455 catch (FormatException) 455 catch (FormatException)
456 { 456 {
457 m_log.Error("[PROFILE]:Failed to set home region, Invalid Format"); 457 m_log.Error("[PROFILE]:Failed to set home region, Invalid Format");
458 } 458 }
459 catch (OverflowException) 459 catch (OverflowException)
460 { 460 {
461 m_log.Error("[PROFILE]:Failed to set home region, Value was too large"); 461 m_log.Error("[PROFILE]:Failed to set home region, Value was too large");
462 } 462 }
463 } 463 }
464 if (requestData.Contains("home_region_id")) 464 if (requestData.Contains("home_region_id"))
465 { 465 {
466 UUID regionID; 466 UUID regionID;
467 UUID.TryParse((string) requestData["home_region_id"], out regionID); 467 UUID.TryParse((string) requestData["home_region_id"], out regionID);
468 userProfile.HomeRegionID = regionID; 468 userProfile.HomeRegionID = regionID;
469 } 469 }
470 if (requestData.Contains("home_pos_x")) 470 if (requestData.Contains("home_pos_x"))
471 { 471 {
472 try 472 try
473 { 473 {
474 userProfile.HomeLocationX = (float) Convert.ToDecimal((string) requestData["home_pos_x"]); 474 userProfile.HomeLocationX = (float) Convert.ToDecimal((string) requestData["home_pos_x"]);
475 } 475 }
476 catch (InvalidCastException) 476 catch (InvalidCastException)
477 { 477 {
478 m_log.Error("[PROFILE]:Failed to set home postion x"); 478 m_log.Error("[PROFILE]:Failed to set home postion x");
479 } 479 }
480 } 480 }
481 if (requestData.Contains("home_pos_y")) 481 if (requestData.Contains("home_pos_y"))
482 { 482 {
483 try 483 try
484 { 484 {
485 userProfile.HomeLocationY = (float) Convert.ToDecimal((string) requestData["home_pos_y"]); 485 userProfile.HomeLocationY = (float) Convert.ToDecimal((string) requestData["home_pos_y"]);
486 } 486 }
487 catch (InvalidCastException) 487 catch (InvalidCastException)
488 { 488 {
489 m_log.Error("[PROFILE]:Failed to set home postion y"); 489 m_log.Error("[PROFILE]:Failed to set home postion y");
490 } 490 }
491 } 491 }
492 if (requestData.Contains("home_pos_z")) 492 if (requestData.Contains("home_pos_z"))
493 { 493 {
494 try 494 try
495 { 495 {
496 userProfile.HomeLocationZ = (float) Convert.ToDecimal((string) requestData["home_pos_z"]); 496 userProfile.HomeLocationZ = (float) Convert.ToDecimal((string) requestData["home_pos_z"]);
497 } 497 }
498 catch (InvalidCastException) 498 catch (InvalidCastException)
499 { 499 {
500 m_log.Error("[PROFILE]:Failed to set home postion z"); 500 m_log.Error("[PROFILE]:Failed to set home postion z");
501 } 501 }
502 } 502 }
503 if (requestData.Contains("home_look_x")) 503 if (requestData.Contains("home_look_x"))
504 { 504 {
505 try 505 try
506 { 506 {
507 userProfile.HomeLookAtX = (float) Convert.ToDecimal((string) requestData["home_look_x"]); 507 userProfile.HomeLookAtX = (float) Convert.ToDecimal((string) requestData["home_look_x"]);
508 } 508 }
509 catch (InvalidCastException) 509 catch (InvalidCastException)
510 { 510 {
511 m_log.Error("[PROFILE]:Failed to set home lookat x"); 511 m_log.Error("[PROFILE]:Failed to set home lookat x");
512 } 512 }
513 } 513 }
514 if (requestData.Contains("home_look_y")) 514 if (requestData.Contains("home_look_y"))
515 { 515 {
516 try 516 try
517 { 517 {
518 userProfile.HomeLookAtY = (float) Convert.ToDecimal((string) requestData["home_look_y"]); 518 userProfile.HomeLookAtY = (float) Convert.ToDecimal((string) requestData["home_look_y"]);
519 } 519 }
520 catch (InvalidCastException) 520 catch (InvalidCastException)
521 { 521 {
522 m_log.Error("[PROFILE]:Failed to set home lookat y"); 522 m_log.Error("[PROFILE]:Failed to set home lookat y");
523 } 523 }
524 } 524 }
525 if (requestData.Contains("home_look_z")) 525 if (requestData.Contains("home_look_z"))
526 { 526 {
527 try 527 try
528 { 528 {
529 userProfile.HomeLookAtZ = (float) Convert.ToDecimal((string) requestData["home_look_z"]); 529 userProfile.HomeLookAtZ = (float) Convert.ToDecimal((string) requestData["home_look_z"]);
530 } 530 }
531 catch (InvalidCastException) 531 catch (InvalidCastException)
532 { 532 {
533 m_log.Error("[PROFILE]:Failed to set home lookat z"); 533 m_log.Error("[PROFILE]:Failed to set home lookat z");
534 } 534 }
535 } 535 }
536 if (requestData.Contains("user_flags")) 536 if (requestData.Contains("user_flags"))
537 { 537 {
538 try 538 try
539 { 539 {
540 userProfile.UserFlags = Convert.ToInt32((string) requestData["user_flags"]); 540 userProfile.UserFlags = Convert.ToInt32((string) requestData["user_flags"]);
541 } 541 }
542 catch (InvalidCastException) 542 catch (InvalidCastException)
543 { 543 {
544 m_log.Error("[PROFILE]:Failed to set user flags"); 544 m_log.Error("[PROFILE]:Failed to set user flags");
545 } 545 }
546 } 546 }
547 if (requestData.Contains("god_level")) 547 if (requestData.Contains("god_level"))
548 { 548 {
549 try 549 try
550 { 550 {
551 userProfile.GodLevel = Convert.ToInt32((string) requestData["god_level"]); 551 userProfile.GodLevel = Convert.ToInt32((string) requestData["god_level"]);
552 } 552 }
553 catch (InvalidCastException) 553 catch (InvalidCastException)
554 { 554 {
555 m_log.Error("[PROFILE]:Failed to set god level"); 555 m_log.Error("[PROFILE]:Failed to set god level");
556 } 556 }
557 } 557 }
558 if (requestData.Contains("custom_type")) 558 if (requestData.Contains("custom_type"))
559 { 559 {
560 try 560 try
561 { 561 {
562 userProfile.CustomType = (string) requestData["custom_type"]; 562 userProfile.CustomType = (string) requestData["custom_type"];
563 } 563 }
564 catch (InvalidCastException) 564 catch (InvalidCastException)
565 { 565 {
566 m_log.Error("[PROFILE]:Failed to set custom type"); 566 m_log.Error("[PROFILE]:Failed to set custom type");
567 } 567 }
568 } 568 }
569 if (requestData.Contains("partner")) 569 if (requestData.Contains("partner"))
570 { 570 {
571 try 571 try
572 { 572 {
573 userProfile.Partner = new UUID((string) requestData["partner"]); 573 userProfile.Partner = new UUID((string) requestData["partner"]);
574 } 574 }
575 catch (InvalidCastException) 575 catch (InvalidCastException)
576 { 576 {
577 m_log.Error("[PROFILE]:Failed to set partner"); 577 m_log.Error("[PROFILE]:Failed to set partner");
578 } 578 }
579 } 579 }
580 else 580 else
581 { 581 {
582 userProfile.Partner = UUID.Zero; 582 userProfile.Partner = UUID.Zero;
583 } 583 }
584 584
585 // call plugin! 585 // call plugin!
586 bool ret = m_userDataBaseService.UpdateUserProfile(userProfile); 586 bool ret = m_userDataBaseService.UpdateUserProfile(userProfile);
587 responseData["returnString"] = ret.ToString(); 587 responseData["returnString"] = ret.ToString();
588 response.Value = responseData; 588 response.Value = responseData;
589 return response; 589 return response;
590 } 590 }
591 591
592 public XmlRpcResponse XmlRPCLogOffUserMethodUUID(XmlRpcRequest request) 592 public XmlRpcResponse XmlRPCLogOffUserMethodUUID(XmlRpcRequest request)
593 { 593 {
594 XmlRpcResponse response = new XmlRpcResponse(); 594 XmlRpcResponse response = new XmlRpcResponse();
595 Hashtable requestData = (Hashtable) request.Params[0]; 595 Hashtable requestData = (Hashtable) request.Params[0];
596 596
597 if (requestData.Contains("avatar_uuid")) 597 if (requestData.Contains("avatar_uuid"))
598 { 598 {
599 try 599 try
600 { 600 {
601 UUID userUUID = new UUID((string)requestData["avatar_uuid"]); 601 UUID userUUID = new UUID((string)requestData["avatar_uuid"]);
602 UUID RegionID = new UUID((string)requestData["region_uuid"]); 602 UUID RegionID = new UUID((string)requestData["region_uuid"]);
603 ulong regionhandle = (ulong)Convert.ToInt64((string)requestData["region_handle"]); 603 ulong regionhandle = (ulong)Convert.ToInt64((string)requestData["region_handle"]);
604 Vector3 position = new Vector3( 604 Vector3 position = new Vector3(
605 (float)Convert.ToDecimal((string)requestData["region_pos_x"]), 605 (float)Convert.ToDecimal((string)requestData["region_pos_x"]),
606 (float)Convert.ToDecimal((string)requestData["region_pos_y"]), 606 (float)Convert.ToDecimal((string)requestData["region_pos_y"]),
607 (float)Convert.ToDecimal((string)requestData["region_pos_z"])); 607 (float)Convert.ToDecimal((string)requestData["region_pos_z"]));
608 Vector3 lookat = new Vector3( 608 Vector3 lookat = new Vector3(
609 (float)Convert.ToDecimal((string)requestData["lookat_x"]), 609 (float)Convert.ToDecimal((string)requestData["lookat_x"]),
610 (float)Convert.ToDecimal((string)requestData["lookat_y"]), 610 (float)Convert.ToDecimal((string)requestData["lookat_y"]),
611 (float)Convert.ToDecimal((string)requestData["lookat_z"])); 611 (float)Convert.ToDecimal((string)requestData["lookat_z"]));
612 612
613 handlerLogOffUser = OnLogOffUser; 613 handlerLogOffUser = OnLogOffUser;
614 if (handlerLogOffUser != null) 614 if (handlerLogOffUser != null)
615 handlerLogOffUser(userUUID); 615 handlerLogOffUser(userUUID);
616 616
617 m_userDataBaseService.LogOffUser(userUUID, RegionID, regionhandle, position, lookat); 617 m_userDataBaseService.LogOffUser(userUUID, RegionID, regionhandle, position, lookat);
618 } 618 }
619 catch (FormatException) 619 catch (FormatException)
620 { 620 {
621 m_log.Warn("[LOGOUT]: Error in Logout XMLRPC Params"); 621 m_log.Warn("[LOGOUT]: Error in Logout XMLRPC Params");
622 return response; 622 return response;
623 } 623 }
624 } 624 }
625 else 625 else
626 { 626 {
627 return CreateUnknownUserErrorResponse(); 627 return CreateUnknownUserErrorResponse();
628 } 628 }
629 629
630 return response; 630 return response;
631 } 631 }
632 632
633 #endregion 633 #endregion
634 634
635 635
636 public void HandleAgentLocation(UUID agentID, UUID regionID, ulong regionHandle) 636 public void HandleAgentLocation(UUID agentID, UUID regionID, ulong regionHandle)
637 { 637 {
638 UserProfileData userProfile = m_userDataBaseService.GetUserProfile(agentID); 638 UserProfileData userProfile = m_userDataBaseService.GetUserProfile(agentID);
639 if (userProfile != null) 639 if (userProfile != null)
640 { 640 {
641 userProfile.CurrentAgent.Region = regionID; 641 userProfile.CurrentAgent.Region = regionID;
642 userProfile.CurrentAgent.Handle = regionHandle; 642 userProfile.CurrentAgent.Handle = regionHandle;
643 m_userDataBaseService.CommitAgent(ref userProfile); 643 m_userDataBaseService.CommitAgent(ref userProfile);
644 } 644 }
645 } 645 }
646 646
647 public void HandleAgentLeaving(UUID agentID, UUID regionID, ulong regionHandle) 647 public void HandleAgentLeaving(UUID agentID, UUID regionID, ulong regionHandle)
648 { 648 {
649 UserProfileData userProfile = m_userDataBaseService.GetUserProfile(agentID); 649 UserProfileData userProfile = m_userDataBaseService.GetUserProfile(agentID);
650 if (userProfile != null) 650 if (userProfile != null)
651 { 651 {
652 if (userProfile.CurrentAgent.Region == regionID) 652 if (userProfile.CurrentAgent.Region == regionID)
653 { 653 {
654 UserAgentData userAgent = userProfile.CurrentAgent; 654 UserAgentData userAgent = userProfile.CurrentAgent;
655 if (userAgent != null && userAgent.AgentOnline) 655 if (userAgent != null && userAgent.AgentOnline)
656 { 656 {
657 userAgent.AgentOnline = false; 657 userAgent.AgentOnline = false;
658 userAgent.LogoutTime = Util.UnixTimeSinceEpoch(); 658 userAgent.LogoutTime = Util.UnixTimeSinceEpoch();
659 if (regionID != UUID.Zero) 659 if (regionID != UUID.Zero)
660 { 660 {
661 userAgent.Region = regionID; 661 userAgent.Region = regionID;
662 } 662 }
663 userAgent.Handle = regionHandle; 663 userAgent.Handle = regionHandle;
664 userProfile.LastLogin = userAgent.LogoutTime; 664 userProfile.LastLogin = userAgent.LogoutTime;
665 665
666 m_userDataBaseService.CommitAgent(ref userProfile); 666 m_userDataBaseService.CommitAgent(ref userProfile);
667 667
668 handlerLogOffUser = OnLogOffUser; 668 handlerLogOffUser = OnLogOffUser;
669 if (handlerLogOffUser != null) 669 if (handlerLogOffUser != null)
670 handlerLogOffUser(agentID); 670 handlerLogOffUser(agentID);
671 } 671 }
672 } 672 }
673 } 673 }
674 } 674 }
675 675
676 public void HandleRegionStartup(UUID regionID) 676 public void HandleRegionStartup(UUID regionID)
677 { 677 {
678 m_userDataBaseService.LogoutUsers(regionID); 678 m_userDataBaseService.LogoutUsers(regionID);
679 } 679 }
680 680
681 public void HandleRegionShutdown(UUID regionID) 681 public void HandleRegionShutdown(UUID regionID)
682 { 682 {
683 m_userDataBaseService.LogoutUsers(regionID); 683 m_userDataBaseService.LogoutUsers(regionID);
684 } 684 }
685 } 685 }
686} 686}
diff --git a/OpenSim/Grid/UserServer.Modules/UserServerAvatarAppearanceModule.cs b/OpenSim/Grid/UserServer.Modules/UserServerAvatarAppearanceModule.cs
index 1c8c0c8..a1497b4 100644
--- a/OpenSim/Grid/UserServer.Modules/UserServerAvatarAppearanceModule.cs
+++ b/OpenSim/Grid/UserServer.Modules/UserServerAvatarAppearanceModule.cs
@@ -1,124 +1,124 @@
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 log4net; 32using log4net;
33using Nwc.XmlRpc; 33using Nwc.XmlRpc;
34using OpenMetaverse; 34using OpenMetaverse;
35using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Framework.Communications; 36using OpenSim.Framework.Communications;
37using OpenSim.Framework.Servers; 37using OpenSim.Framework.Servers;
38 38
39namespace OpenSim.Grid.UserServer.Modules 39namespace OpenSim.Grid.UserServer.Modules
40{ 40{
41 public class UserServerAvatarAppearanceModule 41 public class UserServerAvatarAppearanceModule
42 { 42 {
43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44 44
45 private UserDataBaseService m_userDataBaseService; 45 private UserDataBaseService m_userDataBaseService;
46 private BaseHttpServer m_httpServer; 46 private BaseHttpServer m_httpServer;
47 47
48 public UserServerAvatarAppearanceModule(UserDataBaseService userDataBaseService) 48 public UserServerAvatarAppearanceModule(UserDataBaseService userDataBaseService)
49 { 49 {
50 m_userDataBaseService = userDataBaseService; 50 m_userDataBaseService = userDataBaseService;
51 } 51 }
52 52
53 public void Initialise() 53 public void Initialise()
54 { 54 {
55 55
56 } 56 }
57 57
58 public void PostInitialise() 58 public void PostInitialise()
59 { 59 {
60 60
61 } 61 }
62 62
63 public void RegisterHandlers(BaseHttpServer httpServer) 63 public void RegisterHandlers(BaseHttpServer httpServer)
64 { 64 {
65 m_httpServer = httpServer; 65 m_httpServer = httpServer;
66 66
67 m_httpServer.AddXmlRPCHandler("get_avatar_appearance", XmlRPCGetAvatarAppearance); 67 m_httpServer.AddXmlRPCHandler("get_avatar_appearance", XmlRPCGetAvatarAppearance);
68 m_httpServer.AddXmlRPCHandler("update_avatar_appearance", XmlRPCUpdateAvatarAppearance); 68 m_httpServer.AddXmlRPCHandler("update_avatar_appearance", XmlRPCUpdateAvatarAppearance);
69 } 69 }
70 70
71 public XmlRpcResponse XmlRPCGetAvatarAppearance(XmlRpcRequest request) 71 public XmlRpcResponse XmlRPCGetAvatarAppearance(XmlRpcRequest request)
72 { 72 {
73 XmlRpcResponse response = new XmlRpcResponse(); 73 XmlRpcResponse response = new XmlRpcResponse();
74 Hashtable requestData = (Hashtable)request.Params[0]; 74 Hashtable requestData = (Hashtable)request.Params[0];
75 AvatarAppearance appearance; 75 AvatarAppearance appearance;
76 Hashtable responseData; 76 Hashtable responseData;
77 if (requestData.Contains("owner")) 77 if (requestData.Contains("owner"))
78 { 78 {
79 appearance = m_userDataBaseService.GetUserAppearance(new UUID((string)requestData["owner"])); 79 appearance = m_userDataBaseService.GetUserAppearance(new UUID((string)requestData["owner"]));
80 if (appearance == null) 80 if (appearance == null)
81 { 81 {
82 responseData = new Hashtable(); 82 responseData = new Hashtable();
83 responseData["error_type"] = "no appearance"; 83 responseData["error_type"] = "no appearance";
84 responseData["error_desc"] = "There was no appearance found for this avatar"; 84 responseData["error_desc"] = "There was no appearance found for this avatar";
85 } 85 }
86 else 86 else
87 { 87 {
88 responseData = appearance.ToHashTable(); 88 responseData = appearance.ToHashTable();
89 } 89 }
90 } 90 }
91 else 91 else
92 { 92 {
93 responseData = new Hashtable(); 93 responseData = new Hashtable();
94 responseData["error_type"] = "unknown_avatar"; 94 responseData["error_type"] = "unknown_avatar";
95 responseData["error_desc"] = "The avatar appearance requested is not in the database"; 95 responseData["error_desc"] = "The avatar appearance requested is not in the database";
96 } 96 }
97 97
98 response.Value = responseData; 98 response.Value = responseData;
99 return response; 99 return response;
100 } 100 }
101 101
102 public XmlRpcResponse XmlRPCUpdateAvatarAppearance(XmlRpcRequest request) 102 public XmlRpcResponse XmlRPCUpdateAvatarAppearance(XmlRpcRequest request)
103 { 103 {
104 XmlRpcResponse response = new XmlRpcResponse(); 104 XmlRpcResponse response = new XmlRpcResponse();
105 Hashtable requestData = (Hashtable)request.Params[0]; 105 Hashtable requestData = (Hashtable)request.Params[0];
106 Hashtable responseData; 106 Hashtable responseData;
107 if (requestData.Contains("owner")) 107 if (requestData.Contains("owner"))
108 { 108 {
109 AvatarAppearance appearance = new AvatarAppearance(requestData); 109 AvatarAppearance appearance = new AvatarAppearance(requestData);
110 m_userDataBaseService.UpdateUserAppearance(new UUID((string)requestData["owner"]), appearance); 110 m_userDataBaseService.UpdateUserAppearance(new UUID((string)requestData["owner"]), appearance);
111 responseData = new Hashtable(); 111 responseData = new Hashtable();
112 responseData["returnString"] = "TRUE"; 112 responseData["returnString"] = "TRUE";
113 } 113 }
114 else 114 else
115 { 115 {
116 responseData = new Hashtable(); 116 responseData = new Hashtable();
117 responseData["error_type"] = "unknown_avatar"; 117 responseData["error_type"] = "unknown_avatar";
118 responseData["error_desc"] = "The avatar appearance requested is not in the database"; 118 responseData["error_desc"] = "The avatar appearance requested is not in the database";
119 } 119 }
120 response.Value = responseData; 120 response.Value = responseData;
121 return response; 121 return response;
122 } 122 }
123 } 123 }
124} 124}
diff --git a/OpenSim/Grid/UserServer.Modules/UserServerFriendsModule.cs b/OpenSim/Grid/UserServer.Modules/UserServerFriendsModule.cs
index fec2dc0..9711a4b 100644
--- a/OpenSim/Grid/UserServer.Modules/UserServerFriendsModule.cs
+++ b/OpenSim/Grid/UserServer.Modules/UserServerFriendsModule.cs
@@ -1,173 +1,173 @@
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 log4net; 32using log4net;
33using Nwc.XmlRpc; 33using Nwc.XmlRpc;
34using OpenMetaverse; 34using OpenMetaverse;
35using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Framework.Communications; 36using OpenSim.Framework.Communications;
37using OpenSim.Framework.Servers; 37using OpenSim.Framework.Servers;
38 38
39namespace OpenSim.Grid.UserServer.Modules 39namespace OpenSim.Grid.UserServer.Modules
40{ 40{
41 public class UserServerFriendsModule 41 public class UserServerFriendsModule
42 { 42 {
43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44 44
45 private UserDataBaseService m_userDataBaseService; 45 private UserDataBaseService m_userDataBaseService;
46 46
47 private BaseHttpServer m_httpServer; 47 private BaseHttpServer m_httpServer;
48 48
49 public UserServerFriendsModule(UserDataBaseService userDataBaseService) 49 public UserServerFriendsModule(UserDataBaseService userDataBaseService)
50 { 50 {
51 m_userDataBaseService = userDataBaseService; 51 m_userDataBaseService = userDataBaseService;
52 } 52 }
53 53
54 public void Initialise() 54 public void Initialise()
55 { 55 {
56 56
57 } 57 }
58 58
59 public void PostInitialise() 59 public void PostInitialise()
60 { 60 {
61 61
62 } 62 }
63 63
64 public void RegisterHandlers(BaseHttpServer httpServer) 64 public void RegisterHandlers(BaseHttpServer httpServer)
65 { 65 {
66 m_httpServer = httpServer; 66 m_httpServer = httpServer;
67 67
68 m_httpServer.AddXmlRPCHandler("add_new_user_friend", XmlRpcResponseXmlRPCAddUserFriend); 68 m_httpServer.AddXmlRPCHandler("add_new_user_friend", XmlRpcResponseXmlRPCAddUserFriend);
69 m_httpServer.AddXmlRPCHandler("remove_user_friend", XmlRpcResponseXmlRPCRemoveUserFriend); 69 m_httpServer.AddXmlRPCHandler("remove_user_friend", XmlRpcResponseXmlRPCRemoveUserFriend);
70 m_httpServer.AddXmlRPCHandler("update_user_friend_perms", XmlRpcResponseXmlRPCUpdateUserFriendPerms); 70 m_httpServer.AddXmlRPCHandler("update_user_friend_perms", XmlRpcResponseXmlRPCUpdateUserFriendPerms);
71 m_httpServer.AddXmlRPCHandler("get_user_friend_list", XmlRpcResponseXmlRPCGetUserFriendList); 71 m_httpServer.AddXmlRPCHandler("get_user_friend_list", XmlRpcResponseXmlRPCGetUserFriendList);
72 } 72 }
73 73
74 public XmlRpcResponse FriendListItemListtoXmlRPCResponse(List<FriendListItem> returnUsers) 74 public XmlRpcResponse FriendListItemListtoXmlRPCResponse(List<FriendListItem> returnUsers)
75 { 75 {
76 XmlRpcResponse response = new XmlRpcResponse(); 76 XmlRpcResponse response = new XmlRpcResponse();
77 Hashtable responseData = new Hashtable(); 77 Hashtable responseData = new Hashtable();
78 // Query Result Information 78 // Query Result Information
79 79
80 responseData["avcount"] = returnUsers.Count.ToString(); 80 responseData["avcount"] = returnUsers.Count.ToString();
81 81
82 for (int i = 0; i < returnUsers.Count; i++) 82 for (int i = 0; i < returnUsers.Count; i++)
83 { 83 {
84 responseData["ownerID" + i] = returnUsers[i].FriendListOwner.ToString(); 84 responseData["ownerID" + i] = returnUsers[i].FriendListOwner.ToString();
85 responseData["friendID" + i] = returnUsers[i].Friend.ToString(); 85 responseData["friendID" + i] = returnUsers[i].Friend.ToString();
86 responseData["ownerPerms" + i] = returnUsers[i].FriendListOwnerPerms.ToString(); 86 responseData["ownerPerms" + i] = returnUsers[i].FriendListOwnerPerms.ToString();
87 responseData["friendPerms" + i] = returnUsers[i].FriendPerms.ToString(); 87 responseData["friendPerms" + i] = returnUsers[i].FriendPerms.ToString();
88 } 88 }
89 response.Value = responseData; 89 response.Value = responseData;
90 90
91 return response; 91 return response;
92 } 92 }
93 93
94 public XmlRpcResponse XmlRpcResponseXmlRPCAddUserFriend(XmlRpcRequest request) 94 public XmlRpcResponse XmlRpcResponseXmlRPCAddUserFriend(XmlRpcRequest request)
95 { 95 {
96 XmlRpcResponse response = new XmlRpcResponse(); 96 XmlRpcResponse response = new XmlRpcResponse();
97 Hashtable requestData = (Hashtable)request.Params[0]; 97 Hashtable requestData = (Hashtable)request.Params[0];
98 Hashtable responseData = new Hashtable(); 98 Hashtable responseData = new Hashtable();
99 string returnString = "FALSE"; 99 string returnString = "FALSE";
100 // Query Result Information 100 // Query Result Information
101 101
102 if (requestData.Contains("ownerID") && requestData.Contains("friendID") && 102 if (requestData.Contains("ownerID") && requestData.Contains("friendID") &&
103 requestData.Contains("friendPerms")) 103 requestData.Contains("friendPerms"))
104 { 104 {
105 // UserManagerBase.AddNewuserFriend 105 // UserManagerBase.AddNewuserFriend
106 m_userDataBaseService.AddNewUserFriend(new UUID((string)requestData["ownerID"]), 106 m_userDataBaseService.AddNewUserFriend(new UUID((string)requestData["ownerID"]),
107 new UUID((string)requestData["friendID"]), 107 new UUID((string)requestData["friendID"]),
108 (uint)Convert.ToInt32((string)requestData["friendPerms"])); 108 (uint)Convert.ToInt32((string)requestData["friendPerms"]));
109 returnString = "TRUE"; 109 returnString = "TRUE";
110 } 110 }
111 responseData["returnString"] = returnString; 111 responseData["returnString"] = returnString;
112 response.Value = responseData; 112 response.Value = responseData;
113 return response; 113 return response;
114 } 114 }
115 115
116 public XmlRpcResponse XmlRpcResponseXmlRPCRemoveUserFriend(XmlRpcRequest request) 116 public XmlRpcResponse XmlRpcResponseXmlRPCRemoveUserFriend(XmlRpcRequest request)
117 { 117 {
118 XmlRpcResponse response = new XmlRpcResponse(); 118 XmlRpcResponse response = new XmlRpcResponse();
119 Hashtable requestData = (Hashtable)request.Params[0]; 119 Hashtable requestData = (Hashtable)request.Params[0];
120 Hashtable responseData = new Hashtable(); 120 Hashtable responseData = new Hashtable();
121 string returnString = "FALSE"; 121 string returnString = "FALSE";
122 // Query Result Information 122 // Query Result Information
123 123
124 if (requestData.Contains("ownerID") && requestData.Contains("friendID")) 124 if (requestData.Contains("ownerID") && requestData.Contains("friendID"))
125 { 125 {
126 // UserManagerBase.AddNewuserFriend 126 // UserManagerBase.AddNewuserFriend
127 m_userDataBaseService.RemoveUserFriend(new UUID((string)requestData["ownerID"]), 127 m_userDataBaseService.RemoveUserFriend(new UUID((string)requestData["ownerID"]),
128 new UUID((string)requestData["friendID"])); 128 new UUID((string)requestData["friendID"]));
129 returnString = "TRUE"; 129 returnString = "TRUE";
130 } 130 }
131 responseData["returnString"] = returnString; 131 responseData["returnString"] = returnString;
132 response.Value = responseData; 132 response.Value = responseData;
133 return response; 133 return response;
134 } 134 }
135 135
136 public XmlRpcResponse XmlRpcResponseXmlRPCUpdateUserFriendPerms(XmlRpcRequest request) 136 public XmlRpcResponse XmlRpcResponseXmlRPCUpdateUserFriendPerms(XmlRpcRequest request)
137 { 137 {
138 XmlRpcResponse response = new XmlRpcResponse(); 138 XmlRpcResponse response = new XmlRpcResponse();
139 Hashtable requestData = (Hashtable)request.Params[0]; 139 Hashtable requestData = (Hashtable)request.Params[0];
140 Hashtable responseData = new Hashtable(); 140 Hashtable responseData = new Hashtable();
141 string returnString = "FALSE"; 141 string returnString = "FALSE";
142 142
143 if (requestData.Contains("ownerID") && requestData.Contains("friendID") && 143 if (requestData.Contains("ownerID") && requestData.Contains("friendID") &&
144 requestData.Contains("friendPerms")) 144 requestData.Contains("friendPerms"))
145 { 145 {
146 m_userDataBaseService.UpdateUserFriendPerms(new UUID((string)requestData["ownerID"]), 146 m_userDataBaseService.UpdateUserFriendPerms(new UUID((string)requestData["ownerID"]),
147 new UUID((string)requestData["friendID"]), 147 new UUID((string)requestData["friendID"]),
148 (uint)Convert.ToInt32((string)requestData["friendPerms"])); 148 (uint)Convert.ToInt32((string)requestData["friendPerms"]));
149 // UserManagerBase. 149 // UserManagerBase.
150 returnString = "TRUE"; 150 returnString = "TRUE";
151 } 151 }
152 responseData["returnString"] = returnString; 152 responseData["returnString"] = returnString;
153 response.Value = responseData; 153 response.Value = responseData;
154 return response; 154 return response;
155 } 155 }
156 156
157 public XmlRpcResponse XmlRpcResponseXmlRPCGetUserFriendList(XmlRpcRequest request) 157 public XmlRpcResponse XmlRpcResponseXmlRPCGetUserFriendList(XmlRpcRequest request)
158 { 158 {
159 // XmlRpcResponse response = new XmlRpcResponse(); 159 // XmlRpcResponse response = new XmlRpcResponse();
160 Hashtable requestData = (Hashtable)request.Params[0]; 160 Hashtable requestData = (Hashtable)request.Params[0];
161 // Hashtable responseData = new Hashtable(); 161 // Hashtable responseData = new Hashtable();
162 162
163 List<FriendListItem> returndata = new List<FriendListItem>(); 163 List<FriendListItem> returndata = new List<FriendListItem>();
164 164
165 if (requestData.Contains("ownerID")) 165 if (requestData.Contains("ownerID"))
166 { 166 {
167 returndata = m_userDataBaseService.GetUserFriendList(new UUID((string)requestData["ownerID"])); 167 returndata = m_userDataBaseService.GetUserFriendList(new UUID((string)requestData["ownerID"]));
168 } 168 }
169 169
170 return FriendListItemListtoXmlRPCResponse(returndata); 170 return FriendListItemListtoXmlRPCResponse(returndata);
171 } 171 }
172 } 172 }
173} 173}