diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Services/LLLoginService/LLLoginResponse.cs (renamed from OpenSim/Framework/Communications/Services/LoginResponse.cs) | 510 |
1 files changed, 329 insertions, 181 deletions
diff --git a/OpenSim/Framework/Communications/Services/LoginResponse.cs b/OpenSim/Services/LLLoginService/LLLoginResponse.cs index ec5f428..4db6a05 100644 --- a/OpenSim/Framework/Communications/Services/LoginResponse.cs +++ b/OpenSim/Services/LLLoginService/LLLoginResponse.cs | |||
@@ -28,25 +28,107 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Net; | ||
31 | using System.Reflection; | 32 | using System.Reflection; |
33 | |||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Framework.Capabilities; | ||
36 | using OpenSim.Services.Interfaces; | ||
37 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
38 | |||
32 | using log4net; | 39 | using log4net; |
33 | using Nwc.XmlRpc; | ||
34 | using OpenMetaverse; | 40 | using OpenMetaverse; |
35 | using OpenMetaverse.StructuredData; | 41 | using OpenMetaverse.StructuredData; |
42 | using OSDArray = OpenMetaverse.StructuredData.OSDArray; | ||
43 | using OSDMap = OpenMetaverse.StructuredData.OSDMap; | ||
36 | 44 | ||
37 | namespace OpenSim.Framework.Communications.Services | 45 | namespace OpenSim.Services.LLLoginService |
38 | { | 46 | { |
47 | public class LLFailedLoginResponse : OpenSim.Services.Interfaces.FailedLoginResponse | ||
48 | { | ||
49 | string m_key; | ||
50 | string m_value; | ||
51 | string m_login; | ||
52 | |||
53 | public static LLFailedLoginResponse UserProblem; | ||
54 | public static LLFailedLoginResponse AuthorizationProblem; | ||
55 | public static LLFailedLoginResponse GridProblem; | ||
56 | public static LLFailedLoginResponse InventoryProblem; | ||
57 | public static LLFailedLoginResponse DeadRegionProblem; | ||
58 | public static LLFailedLoginResponse LoginBlockedProblem; | ||
59 | public static LLFailedLoginResponse AlreadyLoggedInProblem; | ||
60 | public static LLFailedLoginResponse InternalError; | ||
61 | |||
62 | static LLFailedLoginResponse() | ||
63 | { | ||
64 | UserProblem = new LLFailedLoginResponse("key", | ||
65 | "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.", | ||
66 | "false"); | ||
67 | AuthorizationProblem = new LLFailedLoginResponse("key", | ||
68 | "Error connecting to grid. Unable to authorize your session into the region.", | ||
69 | "false"); | ||
70 | GridProblem = new LLFailedLoginResponse("key", | ||
71 | "Error connecting to the desired location. Try connecting to another region.", | ||
72 | "false"); | ||
73 | InventoryProblem = new LLFailedLoginResponse("key", | ||
74 | "The inventory service is not responding. Please notify your login region operator.", | ||
75 | "false"); | ||
76 | DeadRegionProblem = new LLFailedLoginResponse("key", | ||
77 | "The region you are attempting to log into is not responding. Please select another region and try again.", | ||
78 | "false"); | ||
79 | LoginBlockedProblem = new LLFailedLoginResponse("presence", | ||
80 | "Logins are currently restricted. Please try again later.", | ||
81 | "false"); | ||
82 | AlreadyLoggedInProblem = new LLFailedLoginResponse("presence", | ||
83 | "You appear to be already logged in. " + | ||
84 | "If this is not the case please wait for your session to timeout. " + | ||
85 | "If this takes longer than a few minutes please contact the grid owner. " + | ||
86 | "Please wait 5 minutes if you are going to connect to a region nearby to the region you were at previously.", | ||
87 | "false"); | ||
88 | InternalError = new LLFailedLoginResponse("Internal Error", "Error generating Login Response", "false"); | ||
89 | } | ||
90 | |||
91 | public LLFailedLoginResponse(string key, string value, string login) | ||
92 | { | ||
93 | m_key = key; | ||
94 | m_value = value; | ||
95 | m_login = login; | ||
96 | } | ||
97 | |||
98 | public override Hashtable ToHashtable() | ||
99 | { | ||
100 | Hashtable loginError = new Hashtable(); | ||
101 | loginError["reason"] = m_key; | ||
102 | loginError["message"] = m_value; | ||
103 | loginError["login"] = m_login; | ||
104 | return loginError; | ||
105 | } | ||
106 | |||
107 | public override OSD ToOSDMap() | ||
108 | { | ||
109 | OSDMap map = new OSDMap(); | ||
110 | |||
111 | map["reason"] = OSD.FromString(m_key); | ||
112 | map["message"] = OSD.FromString(m_value); | ||
113 | map["login"] = OSD.FromString(m_login); | ||
114 | |||
115 | return map; | ||
116 | } | ||
117 | } | ||
118 | |||
39 | /// <summary> | 119 | /// <summary> |
40 | /// A temp class to handle login response. | 120 | /// A class to handle LL login response. |
41 | /// Should make use of UserProfileManager where possible. | ||
42 | /// </summary> | 121 | /// </summary> |
43 | public class LoginResponse | 122 | public class LLLoginResponse : OpenSim.Services.Interfaces.LoginResponse |
44 | { | 123 | { |
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 124 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
125 | private static Hashtable globalTexturesHash; | ||
126 | // Global Textures | ||
127 | private static string sunTexture = "cce0f112-878f-4586-a2e2-a8f104bba271"; | ||
128 | private static string cloudTexture = "dc4b9f0b-d008-45c6-96a4-01dd947ac621"; | ||
129 | private static string moonTexture = "ec4b9f0b-d008-45c6-96a4-01dd947ac621"; | ||
46 | 130 | ||
47 | private Hashtable loginFlagsHash; | 131 | private Hashtable loginFlagsHash; |
48 | private Hashtable globalTexturesHash; | ||
49 | private Hashtable loginError; | ||
50 | private Hashtable uiConfigHash; | 132 | private Hashtable uiConfigHash; |
51 | 133 | ||
52 | private ArrayList loginFlags; | 134 | private ArrayList loginFlags; |
@@ -87,19 +169,10 @@ namespace OpenSim.Framework.Communications.Services | |||
87 | private string firstname; | 169 | private string firstname; |
88 | private string lastname; | 170 | private string lastname; |
89 | 171 | ||
90 | // Global Textures | ||
91 | private string sunTexture; | ||
92 | private string cloudTexture; | ||
93 | private string moonTexture; | ||
94 | |||
95 | // Error Flags | 172 | // Error Flags |
96 | private string errorReason; | 173 | private string errorReason; |
97 | private string errorMessage; | 174 | private string errorMessage; |
98 | 175 | ||
99 | // Response | ||
100 | private XmlRpcResponse xmlRpcResponse; | ||
101 | // private XmlRpcResponse defaultXmlRpcResponse; | ||
102 | |||
103 | private string welcomeMessage; | 176 | private string welcomeMessage; |
104 | private string startLocation; | 177 | private string startLocation; |
105 | private string allowFirstLife; | 178 | private string allowFirstLife; |
@@ -109,7 +182,17 @@ namespace OpenSim.Framework.Communications.Services | |||
109 | 182 | ||
110 | private BuddyList m_buddyList = null; | 183 | private BuddyList m_buddyList = null; |
111 | 184 | ||
112 | public LoginResponse() | 185 | static LLLoginResponse() |
186 | { | ||
187 | // This is being set, but it's not used | ||
188 | // not sure why. | ||
189 | globalTexturesHash = new Hashtable(); | ||
190 | globalTexturesHash["sun_texture_id"] = sunTexture; | ||
191 | globalTexturesHash["cloud_texture_id"] = cloudTexture; | ||
192 | globalTexturesHash["moon_texture_id"] = moonTexture; | ||
193 | } | ||
194 | |||
195 | public LLLoginResponse() | ||
113 | { | 196 | { |
114 | loginFlags = new ArrayList(); | 197 | loginFlags = new ArrayList(); |
115 | globalTextures = new ArrayList(); | 198 | globalTextures = new ArrayList(); |
@@ -117,7 +200,6 @@ namespace OpenSim.Framework.Communications.Services | |||
117 | uiConfig = new ArrayList(); | 200 | uiConfig = new ArrayList(); |
118 | classifiedCategories = new ArrayList(); | 201 | classifiedCategories = new ArrayList(); |
119 | 202 | ||
120 | loginError = new Hashtable(); | ||
121 | uiConfigHash = new Hashtable(); | 203 | uiConfigHash = new Hashtable(); |
122 | 204 | ||
123 | // defaultXmlRpcResponse = new XmlRpcResponse(); | 205 | // defaultXmlRpcResponse = new XmlRpcResponse(); |
@@ -129,12 +211,138 @@ namespace OpenSim.Framework.Communications.Services | |||
129 | inventoryLibraryOwner = new ArrayList(); | 211 | inventoryLibraryOwner = new ArrayList(); |
130 | activeGestures = new ArrayList(); | 212 | activeGestures = new ArrayList(); |
131 | 213 | ||
132 | xmlRpcResponse = new XmlRpcResponse(); | ||
133 | // defaultXmlRpcResponse = new XmlRpcResponse(); | ||
134 | |||
135 | SetDefaultValues(); | 214 | SetDefaultValues(); |
136 | } | 215 | } |
137 | 216 | ||
217 | public LLLoginResponse(UserAccount account, AgentCircuitData aCircuit, PresenceInfo pinfo, | ||
218 | GridRegion destination, List<InventoryFolderBase> invSkel, ILibraryService libService, | ||
219 | string where, string startlocation, Vector3 position, Vector3 lookAt, string message, | ||
220 | GridRegion home, IPEndPoint clientIP) | ||
221 | : this() | ||
222 | { | ||
223 | FillOutInventoryData(invSkel, libService); | ||
224 | |||
225 | CircuitCode = (int)aCircuit.circuitcode; | ||
226 | Lastname = account.LastName; | ||
227 | Firstname = account.FirstName; | ||
228 | AgentID = account.PrincipalID; | ||
229 | SessionID = aCircuit.SessionID; | ||
230 | SecureSessionID = aCircuit.SecureSessionID; | ||
231 | Message = message; | ||
232 | // While we don't have friends... | ||
233 | //BuddList = ConvertFriendListItem(m_userManager.GetUserFriendList(agentID)); | ||
234 | BuddList = new LLLoginResponse.BuddyList(); | ||
235 | StartLocation = where; | ||
236 | |||
237 | FillOutHomeData(pinfo, home); | ||
238 | LookAt = String.Format("[r{0},r{1},r{2}]", lookAt.X, lookAt.Y, lookAt.Z); | ||
239 | |||
240 | FillOutRegionData(destination); | ||
241 | |||
242 | FillOutSeedCap(aCircuit, destination, clientIP); | ||
243 | |||
244 | } | ||
245 | |||
246 | private void FillOutInventoryData(List<InventoryFolderBase> invSkel, ILibraryService libService) | ||
247 | { | ||
248 | InventoryData inventData = null; | ||
249 | |||
250 | try | ||
251 | { | ||
252 | inventData = GetInventorySkeleton(invSkel); | ||
253 | } | ||
254 | catch (Exception e) | ||
255 | { | ||
256 | m_log.WarnFormat( | ||
257 | "[LLLOGIN SERVICE]: Error processing inventory skeleton of agent {0} - {1}", | ||
258 | agentID, e); | ||
259 | |||
260 | // ignore and continue | ||
261 | } | ||
262 | |||
263 | if (inventData != null) | ||
264 | { | ||
265 | ArrayList AgentInventoryArray = inventData.InventoryArray; | ||
266 | |||
267 | Hashtable InventoryRootHash = new Hashtable(); | ||
268 | InventoryRootHash["folder_id"] = inventData.RootFolderID.ToString(); | ||
269 | InventoryRoot = new ArrayList(); | ||
270 | InventoryRoot.Add(InventoryRootHash); | ||
271 | InventorySkeleton = AgentInventoryArray; | ||
272 | } | ||
273 | |||
274 | // Inventory Library Section | ||
275 | if (libService != null && libService.LibraryRootFolder != null) | ||
276 | { | ||
277 | Hashtable InventoryLibRootHash = new Hashtable(); | ||
278 | InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000"; | ||
279 | InventoryLibRoot = new ArrayList(); | ||
280 | InventoryLibRoot.Add(InventoryLibRootHash); | ||
281 | |||
282 | InventoryLibraryOwner = GetLibraryOwner(libService.LibraryRootFolder); | ||
283 | InventoryLibrary = GetInventoryLibrary(libService); | ||
284 | } | ||
285 | } | ||
286 | |||
287 | private void FillOutHomeData(PresenceInfo pinfo, GridRegion home) | ||
288 | { | ||
289 | int x = 1000 * (int)Constants.RegionSize, y = 1000 * (int)Constants.RegionSize; | ||
290 | if (home != null) | ||
291 | { | ||
292 | x = home.RegionLocX; | ||
293 | y = home.RegionLocY; | ||
294 | } | ||
295 | |||
296 | Home = string.Format( | ||
297 | "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}", | ||
298 | x, | ||
299 | y, | ||
300 | pinfo.HomePosition.X, pinfo.HomePosition.Y, pinfo.HomePosition.Z, | ||
301 | pinfo.HomeLookAt.X, pinfo.HomeLookAt.Y, pinfo.HomeLookAt.Z); | ||
302 | |||
303 | } | ||
304 | |||
305 | private void FillOutRegionData(GridRegion destination) | ||
306 | { | ||
307 | IPEndPoint endPoint = destination.ExternalEndPoint; | ||
308 | SimAddress = endPoint.Address.ToString(); | ||
309 | SimPort = (uint)endPoint.Port; | ||
310 | RegionX = (uint)destination.RegionLocX; | ||
311 | RegionY = (uint)destination.RegionLocY; | ||
312 | } | ||
313 | |||
314 | private void FillOutSeedCap(AgentCircuitData aCircuit, GridRegion destination, IPEndPoint ipepClient) | ||
315 | { | ||
316 | string capsSeedPath = String.Empty; | ||
317 | |||
318 | // Don't use the following! It Fails for logging into any region not on the same port as the http server! | ||
319 | // Kept here so it doesn't happen again! | ||
320 | // response.SeedCapability = regionInfo.ServerURI + capsSeedPath; | ||
321 | |||
322 | #region IP Translation for NAT | ||
323 | if (ipepClient != null) | ||
324 | { | ||
325 | capsSeedPath | ||
326 | = "http://" | ||
327 | + NetworkUtil.GetHostFor(ipepClient.Address, destination.ExternalHostName) | ||
328 | + ":" | ||
329 | + destination.HttpPort | ||
330 | + CapsUtil.GetCapsSeedPath(aCircuit.CapsPath); | ||
331 | } | ||
332 | else | ||
333 | { | ||
334 | capsSeedPath | ||
335 | = "http://" | ||
336 | + destination.ExternalHostName | ||
337 | + ":" | ||
338 | + destination.HttpPort | ||
339 | + CapsUtil.GetCapsSeedPath(aCircuit.CapsPath); | ||
340 | } | ||
341 | #endregion | ||
342 | |||
343 | SeedCapability = capsSeedPath; | ||
344 | } | ||
345 | |||
138 | private void SetDefaultValues() | 346 | private void SetDefaultValues() |
139 | { | 347 | { |
140 | DST = TimeZone.CurrentTimeZone.IsDaylightSavingTime(DateTime.Now) ? "Y" : "N"; | 348 | DST = TimeZone.CurrentTimeZone.IsDaylightSavingTime(DateTime.Now) ? "Y" : "N"; |
@@ -149,10 +357,6 @@ namespace OpenSim.Framework.Communications.Services | |||
149 | startLocation = "last"; | 357 | startLocation = "last"; |
150 | allowFirstLife = "Y"; | 358 | allowFirstLife = "Y"; |
151 | 359 | ||
152 | SunTexture = "cce0f112-878f-4586-a2e2-a8f104bba271"; | ||
153 | CloudTexture = "dc4b9f0b-d008-45c6-96a4-01dd947ac621"; | ||
154 | MoonTexture = "ec4b9f0b-d008-45c6-96a4-01dd947ac621"; | ||
155 | |||
156 | ErrorMessage = "You have entered an invalid name/password combination. Check Caps/lock."; | 360 | ErrorMessage = "You have entered an invalid name/password combination. Check Caps/lock."; |
157 | ErrorReason = "key"; | 361 | ErrorReason = "key"; |
158 | welcomeMessage = "Welcome to OpenSim!"; | 362 | welcomeMessage = "Welcome to OpenSim!"; |
@@ -186,149 +390,8 @@ namespace OpenSim.Framework.Communications.Services | |||
186 | initialOutfit.Add(InitialOutfitHash); | 390 | initialOutfit.Add(InitialOutfitHash); |
187 | } | 391 | } |
188 | 392 | ||
189 | #region Login Failure Methods | ||
190 | 393 | ||
191 | public XmlRpcResponse GenerateFailureResponse(string reason, string message, string login) | 394 | public override Hashtable ToHashtable() |
192 | { | ||
193 | // Overwrite any default values; | ||
194 | xmlRpcResponse = new XmlRpcResponse(); | ||
195 | |||
196 | // Ensure Login Failed message/reason; | ||
197 | ErrorMessage = message; | ||
198 | ErrorReason = reason; | ||
199 | |||
200 | loginError["reason"] = ErrorReason; | ||
201 | loginError["message"] = ErrorMessage; | ||
202 | loginError["login"] = login; | ||
203 | xmlRpcResponse.Value = loginError; | ||
204 | return (xmlRpcResponse); | ||
205 | } | ||
206 | |||
207 | public OSD GenerateFailureResponseLLSD(string reason, string message, string login) | ||
208 | { | ||
209 | OSDMap map = new OSDMap(); | ||
210 | |||
211 | // Ensure Login Failed message/reason; | ||
212 | ErrorMessage = message; | ||
213 | ErrorReason = reason; | ||
214 | |||
215 | map["reason"] = OSD.FromString(ErrorReason); | ||
216 | map["message"] = OSD.FromString(ErrorMessage); | ||
217 | map["login"] = OSD.FromString(login); | ||
218 | |||
219 | return map; | ||
220 | } | ||
221 | |||
222 | public XmlRpcResponse CreateFailedResponse() | ||
223 | { | ||
224 | return (CreateLoginFailedResponse()); | ||
225 | } | ||
226 | |||
227 | public OSD CreateFailedResponseLLSD() | ||
228 | { | ||
229 | return CreateLoginFailedResponseLLSD(); | ||
230 | } | ||
231 | |||
232 | public XmlRpcResponse CreateLoginFailedResponse() | ||
233 | { | ||
234 | return | ||
235 | (GenerateFailureResponse("key", | ||
236 | "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.", | ||
237 | "false")); | ||
238 | } | ||
239 | |||
240 | public OSD CreateLoginFailedResponseLLSD() | ||
241 | { | ||
242 | return GenerateFailureResponseLLSD( | ||
243 | "key", | ||
244 | "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.", | ||
245 | "false"); | ||
246 | } | ||
247 | |||
248 | /// <summary> | ||
249 | /// Response to indicate that login failed because the agent's inventory was not available. | ||
250 | /// </summary> | ||
251 | /// <returns></returns> | ||
252 | public XmlRpcResponse CreateLoginInventoryFailedResponse() | ||
253 | { | ||
254 | return GenerateFailureResponse( | ||
255 | "key", | ||
256 | "The avatar inventory service is not responding. Please notify your login region operator.", | ||
257 | "false"); | ||
258 | } | ||
259 | |||
260 | public XmlRpcResponse CreateAlreadyLoggedInResponse() | ||
261 | { | ||
262 | return | ||
263 | (GenerateFailureResponse("presence", | ||
264 | "You appear to be already logged in. " + | ||
265 | "If this is not the case please wait for your session to timeout. " + | ||
266 | "If this takes longer than a few minutes please contact the grid owner. " + | ||
267 | "Please wait 5 minutes if you are going to connect to a region nearby to the region you were at previously.", | ||
268 | "false")); | ||
269 | } | ||
270 | |||
271 | public OSD CreateAlreadyLoggedInResponseLLSD() | ||
272 | { | ||
273 | return GenerateFailureResponseLLSD( | ||
274 | "presence", | ||
275 | "You appear to be already logged in. " + | ||
276 | "If this is not the case please wait for your session to timeout. " + | ||
277 | "If this takes longer than a few minutes please contact the grid owner", | ||
278 | "false"); | ||
279 | } | ||
280 | |||
281 | public XmlRpcResponse CreateLoginBlockedResponse() | ||
282 | { | ||
283 | return | ||
284 | (GenerateFailureResponse("presence", | ||
285 | "Logins are currently restricted. Please try again later", | ||
286 | "false")); | ||
287 | } | ||
288 | |||
289 | public OSD CreateLoginBlockedResponseLLSD() | ||
290 | { | ||
291 | return GenerateFailureResponseLLSD( | ||
292 | "presence", | ||
293 | "Logins are currently restricted. Please try again later", | ||
294 | "false"); | ||
295 | } | ||
296 | |||
297 | public XmlRpcResponse CreateDeadRegionResponse() | ||
298 | { | ||
299 | return | ||
300 | (GenerateFailureResponse("key", | ||
301 | "The region you are attempting to log into is not responding. Please select another region and try again.", | ||
302 | "false")); | ||
303 | } | ||
304 | |||
305 | public OSD CreateDeadRegionResponseLLSD() | ||
306 | { | ||
307 | return GenerateFailureResponseLLSD( | ||
308 | "key", | ||
309 | "The region you are attempting to log into is not responding. Please select another region and try again.", | ||
310 | "false"); | ||
311 | } | ||
312 | |||
313 | public XmlRpcResponse CreateGridErrorResponse() | ||
314 | { | ||
315 | return | ||
316 | (GenerateFailureResponse("key", | ||
317 | "Error connecting to grid. Could not percieve credentials from login XML.", | ||
318 | "false")); | ||
319 | } | ||
320 | |||
321 | public OSD CreateGridErrorResponseLLSD() | ||
322 | { | ||
323 | return GenerateFailureResponseLLSD( | ||
324 | "key", | ||
325 | "Error connecting to grid. Could not perceive credentials from login XML.", | ||
326 | "false"); | ||
327 | } | ||
328 | |||
329 | #endregion | ||
330 | |||
331 | public virtual XmlRpcResponse ToXmlRpcResponse() | ||
332 | { | 395 | { |
333 | try | 396 | try |
334 | { | 397 | { |
@@ -346,10 +409,6 @@ namespace OpenSim.Framework.Communications.Services | |||
346 | responseData["agent_access"] = agentAccess; | 409 | responseData["agent_access"] = agentAccess; |
347 | responseData["agent_access_max"] = agentAccessMax; | 410 | responseData["agent_access_max"] = agentAccessMax; |
348 | 411 | ||
349 | globalTexturesHash = new Hashtable(); | ||
350 | globalTexturesHash["sun_texture_id"] = SunTexture; | ||
351 | globalTexturesHash["cloud_texture_id"] = CloudTexture; | ||
352 | globalTexturesHash["moon_texture_id"] = MoonTexture; | ||
353 | globalTextures.Add(globalTexturesHash); | 412 | globalTextures.Add(globalTexturesHash); |
354 | // this.eventCategories.Add(this.eventCategoriesHash); | 413 | // this.eventCategories.Add(this.eventCategoriesHash); |
355 | 414 | ||
@@ -389,8 +448,8 @@ namespace OpenSim.Framework.Communications.Services | |||
389 | responseData["home"] = home; | 448 | responseData["home"] = home; |
390 | responseData["look_at"] = lookAt; | 449 | responseData["look_at"] = lookAt; |
391 | responseData["message"] = welcomeMessage; | 450 | responseData["message"] = welcomeMessage; |
392 | responseData["region_x"] = (Int32)(RegionX * Constants.RegionSize); | 451 | responseData["region_x"] = (Int32)(RegionX); |
393 | responseData["region_y"] = (Int32)(RegionY * Constants.RegionSize); | 452 | responseData["region_y"] = (Int32)(RegionY); |
394 | 453 | ||
395 | if (m_buddyList != null) | 454 | if (m_buddyList != null) |
396 | { | 455 | { |
@@ -398,19 +457,18 @@ namespace OpenSim.Framework.Communications.Services | |||
398 | } | 457 | } |
399 | 458 | ||
400 | responseData["login"] = "true"; | 459 | responseData["login"] = "true"; |
401 | xmlRpcResponse.Value = responseData; | ||
402 | 460 | ||
403 | return (xmlRpcResponse); | 461 | return responseData; |
404 | } | 462 | } |
405 | catch (Exception e) | 463 | catch (Exception e) |
406 | { | 464 | { |
407 | m_log.Warn("[CLIENT]: LoginResponse: Error creating XML-RPC Response: " + e.Message); | 465 | m_log.Warn("[CLIENT]: LoginResponse: Error creating Hashtable Response: " + e.Message); |
408 | 466 | ||
409 | return (GenerateFailureResponse("Internal Error", "Error generating Login Response", "false")); | 467 | return LLFailedLoginResponse.InternalError.ToHashtable(); |
410 | } | 468 | } |
411 | } | 469 | } |
412 | 470 | ||
413 | public OSD ToLLSDResponse() | 471 | public override OSD ToOSDMap() |
414 | { | 472 | { |
415 | try | 473 | try |
416 | { | 474 | { |
@@ -486,8 +544,8 @@ namespace OpenSim.Framework.Communications.Services | |||
486 | map["home"] = OSD.FromString(home); | 544 | map["home"] = OSD.FromString(home); |
487 | map["look_at"] = OSD.FromString(lookAt); | 545 | map["look_at"] = OSD.FromString(lookAt); |
488 | map["message"] = OSD.FromString(welcomeMessage); | 546 | map["message"] = OSD.FromString(welcomeMessage); |
489 | map["region_x"] = OSD.FromInteger(RegionX * Constants.RegionSize); | 547 | map["region_x"] = OSD.FromInteger(RegionX); |
490 | map["region_y"] = OSD.FromInteger(RegionY * Constants.RegionSize); | 548 | map["region_y"] = OSD.FromInteger(RegionY); |
491 | 549 | ||
492 | if (m_buddyList != null) | 550 | if (m_buddyList != null) |
493 | { | 551 | { |
@@ -502,7 +560,7 @@ namespace OpenSim.Framework.Communications.Services | |||
502 | { | 560 | { |
503 | m_log.Warn("[CLIENT]: LoginResponse: Error creating LLSD Response: " + e.Message); | 561 | m_log.Warn("[CLIENT]: LoginResponse: Error creating LLSD Response: " + e.Message); |
504 | 562 | ||
505 | return GenerateFailureResponseLLSD("Internal Error", "Error generating Login Response", "false"); | 563 | return LLFailedLoginResponse.InternalError.ToOSDMap(); |
506 | } | 564 | } |
507 | } | 565 | } |
508 | 566 | ||
@@ -548,6 +606,96 @@ namespace OpenSim.Framework.Communications.Services | |||
548 | // this.classifiedCategoriesHash.Clear(); | 606 | // this.classifiedCategoriesHash.Clear(); |
549 | } | 607 | } |
550 | 608 | ||
609 | |||
610 | private static LLLoginResponse.BuddyList ConvertFriendListItem(List<FriendListItem> LFL) | ||
611 | { | ||
612 | LLLoginResponse.BuddyList buddylistreturn = new LLLoginResponse.BuddyList(); | ||
613 | foreach (FriendListItem fl in LFL) | ||
614 | { | ||
615 | LLLoginResponse.BuddyList.BuddyInfo buddyitem = new LLLoginResponse.BuddyList.BuddyInfo(fl.Friend); | ||
616 | buddyitem.BuddyID = fl.Friend; | ||
617 | buddyitem.BuddyRightsHave = (int)fl.FriendListOwnerPerms; | ||
618 | buddyitem.BuddyRightsGiven = (int)fl.FriendPerms; | ||
619 | buddylistreturn.AddNewBuddy(buddyitem); | ||
620 | } | ||
621 | return buddylistreturn; | ||
622 | } | ||
623 | |||
624 | private InventoryData GetInventorySkeleton(List<InventoryFolderBase> folders) | ||
625 | { | ||
626 | UUID rootID = UUID.Zero; | ||
627 | ArrayList AgentInventoryArray = new ArrayList(); | ||
628 | Hashtable TempHash; | ||
629 | foreach (InventoryFolderBase InvFolder in folders) | ||
630 | { | ||
631 | if (InvFolder.ParentID == UUID.Zero) | ||
632 | { | ||
633 | rootID = InvFolder.ID; | ||
634 | } | ||
635 | TempHash = new Hashtable(); | ||
636 | TempHash["name"] = InvFolder.Name; | ||
637 | TempHash["parent_id"] = InvFolder.ParentID.ToString(); | ||
638 | TempHash["version"] = (Int32)InvFolder.Version; | ||
639 | TempHash["type_default"] = (Int32)InvFolder.Type; | ||
640 | TempHash["folder_id"] = InvFolder.ID.ToString(); | ||
641 | AgentInventoryArray.Add(TempHash); | ||
642 | } | ||
643 | |||
644 | return new InventoryData(AgentInventoryArray, rootID); | ||
645 | |||
646 | } | ||
647 | |||
648 | /// <summary> | ||
649 | /// Converts the inventory library skeleton into the form required by the rpc request. | ||
650 | /// </summary> | ||
651 | /// <returns></returns> | ||
652 | protected virtual ArrayList GetInventoryLibrary(ILibraryService library) | ||
653 | { | ||
654 | Dictionary<UUID, InventoryFolderImpl> rootFolders = library.GetAllFolders(); | ||
655 | m_log.DebugFormat("[LLOGIN]: Library has {0} folders", rootFolders.Count); | ||
656 | //Dictionary<UUID, InventoryFolderImpl> rootFolders = new Dictionary<UUID,InventoryFolderImpl>(); | ||
657 | ArrayList folderHashes = new ArrayList(); | ||
658 | |||
659 | foreach (InventoryFolderBase folder in rootFolders.Values) | ||
660 | { | ||
661 | Hashtable TempHash = new Hashtable(); | ||
662 | TempHash["name"] = folder.Name; | ||
663 | TempHash["parent_id"] = folder.ParentID.ToString(); | ||
664 | TempHash["version"] = (Int32)folder.Version; | ||
665 | TempHash["type_default"] = (Int32)folder.Type; | ||
666 | TempHash["folder_id"] = folder.ID.ToString(); | ||
667 | folderHashes.Add(TempHash); | ||
668 | } | ||
669 | |||
670 | return folderHashes; | ||
671 | } | ||
672 | |||
673 | /// <summary> | ||
674 | /// | ||
675 | /// </summary> | ||
676 | /// <returns></returns> | ||
677 | protected virtual ArrayList GetLibraryOwner(InventoryFolderImpl libFolder) | ||
678 | { | ||
679 | //for now create random inventory library owner | ||
680 | Hashtable TempHash = new Hashtable(); | ||
681 | TempHash["agent_id"] = "11111111-1111-0000-0000-000100bba000"; // libFolder.Owner | ||
682 | ArrayList inventoryLibOwner = new ArrayList(); | ||
683 | inventoryLibOwner.Add(TempHash); | ||
684 | return inventoryLibOwner; | ||
685 | } | ||
686 | |||
687 | public class InventoryData | ||
688 | { | ||
689 | public ArrayList InventoryArray = null; | ||
690 | public UUID RootFolderID = UUID.Zero; | ||
691 | |||
692 | public InventoryData(ArrayList invList, UUID rootID) | ||
693 | { | ||
694 | InventoryArray = invList; | ||
695 | RootFolderID = rootID; | ||
696 | } | ||
697 | } | ||
698 | |||
551 | #region Properties | 699 | #region Properties |
552 | 700 | ||
553 | public string Login | 701 | public string Login |