aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/LLLoginService/LLLoginResponse.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services/LLLoginService/LLLoginResponse.cs')
-rw-r--r--OpenSim/Services/LLLoginService/LLLoginResponse.cs972
1 files changed, 972 insertions, 0 deletions
diff --git a/OpenSim/Services/LLLoginService/LLLoginResponse.cs b/OpenSim/Services/LLLoginService/LLLoginResponse.cs
new file mode 100644
index 0000000..05f5b4c
--- /dev/null
+++ b/OpenSim/Services/LLLoginService/LLLoginResponse.cs
@@ -0,0 +1,972 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Net;
32using System.Reflection;
33
34using OpenSim.Framework;
35using OpenSim.Framework.Capabilities;
36using OpenSim.Services.Interfaces;
37using GridRegion = OpenSim.Services.Interfaces.GridRegion;
38using FriendInfo = OpenSim.Services.Interfaces.FriendInfo;
39
40using log4net;
41using OpenMetaverse;
42using OpenMetaverse.StructuredData;
43using OSDArray = OpenMetaverse.StructuredData.OSDArray;
44using OSDMap = OpenMetaverse.StructuredData.OSDMap;
45
46namespace OpenSim.Services.LLLoginService
47{
48 public class LLFailedLoginResponse : OpenSim.Services.Interfaces.FailedLoginResponse
49 {
50 string m_key;
51 string m_value;
52 string m_login;
53
54 public static LLFailedLoginResponse UserProblem;
55 public static LLFailedLoginResponse AuthorizationProblem;
56 public static LLFailedLoginResponse GridProblem;
57 public static LLFailedLoginResponse InventoryProblem;
58 public static LLFailedLoginResponse DeadRegionProblem;
59 public static LLFailedLoginResponse LoginBlockedProblem;
60 public static LLFailedLoginResponse AlreadyLoggedInProblem;
61 public static LLFailedLoginResponse InternalError;
62
63 static LLFailedLoginResponse()
64 {
65 UserProblem = new LLFailedLoginResponse("key",
66 "Could not authenticate your avatar. Please check your username and password, and check the grid if problems persist.",
67 "false");
68 AuthorizationProblem = new LLFailedLoginResponse("key",
69 "Error connecting to grid. Unable to authorize your session into the region.",
70 "false");
71 GridProblem = new LLFailedLoginResponse("key",
72 "Error connecting to the desired location. Try connecting to another region.",
73 "false");
74 InventoryProblem = new LLFailedLoginResponse("key",
75 "The inventory service is not responding. Please notify your login region operator.",
76 "false");
77 DeadRegionProblem = new LLFailedLoginResponse("key",
78 "The region you are attempting to log into is not responding. Please select another region and try again.",
79 "false");
80 LoginBlockedProblem = new LLFailedLoginResponse("presence",
81 "Logins are currently restricted. Please try again later.",
82 "false");
83 AlreadyLoggedInProblem = new LLFailedLoginResponse("presence",
84 "You appear to be already logged in. " +
85 "If this is not the case please wait for your session to timeout. " +
86 "If this takes longer than a few minutes please contact the grid owner. " +
87 "Please wait 5 minutes if you are going to connect to a region nearby to the region you were at previously.",
88 "false");
89 InternalError = new LLFailedLoginResponse("Internal Error", "Error generating Login Response", "false");
90 }
91
92 public LLFailedLoginResponse(string key, string value, string login)
93 {
94 m_key = key;
95 m_value = value;
96 m_login = login;
97 }
98
99 public override Hashtable ToHashtable()
100 {
101 Hashtable loginError = new Hashtable();
102 loginError["reason"] = m_key;
103 loginError["message"] = m_value;
104 loginError["login"] = m_login;
105 return loginError;
106 }
107
108 public override OSD ToOSDMap()
109 {
110 OSDMap map = new OSDMap();
111
112 map["reason"] = OSD.FromString(m_key);
113 map["message"] = OSD.FromString(m_value);
114 map["login"] = OSD.FromString(m_login);
115
116 return map;
117 }
118 }
119
120 /// <summary>
121 /// A class to handle LL login response.
122 /// </summary>
123 public class LLLoginResponse : OpenSim.Services.Interfaces.LoginResponse
124 {
125 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
126 private static Hashtable globalTexturesHash;
127 // Global Textures
128 private static string sunTexture = "cce0f112-878f-4586-a2e2-a8f104bba271";
129 private static string cloudTexture = "dc4b9f0b-d008-45c6-96a4-01dd947ac621";
130 private static string moonTexture = "ec4b9f0b-d008-45c6-96a4-01dd947ac621";
131
132 private Hashtable loginFlagsHash;
133 private Hashtable uiConfigHash;
134
135 private ArrayList loginFlags;
136 private ArrayList globalTextures;
137 private ArrayList eventCategories;
138 private ArrayList uiConfig;
139 private ArrayList classifiedCategories;
140 private ArrayList inventoryRoot;
141 private ArrayList initialOutfit;
142 private ArrayList agentInventory;
143 private ArrayList inventoryLibraryOwner;
144 private ArrayList inventoryLibRoot;
145 private ArrayList inventoryLibrary;
146 private ArrayList activeGestures;
147
148 private UserInfo userProfile;
149
150 private UUID agentID;
151 private UUID sessionID;
152 private UUID secureSessionID;
153
154 // Login Flags
155 private string dst;
156 private string stipendSinceLogin;
157 private string gendered;
158 private string everLoggedIn;
159 private string login;
160 private uint simPort;
161 private uint simHttpPort;
162 private string simAddress;
163 private string agentAccess;
164 private string agentAccessMax;
165 private Int32 circuitCode;
166 private uint regionX;
167 private uint regionY;
168
169 // Login
170 private string firstname;
171 private string lastname;
172
173 // Error Flags
174 private string errorReason;
175 private string errorMessage;
176
177 private string welcomeMessage;
178 private string startLocation;
179 private string allowFirstLife;
180 private string home;
181 private string seedCapability;
182 private string lookAt;
183
184 private BuddyList m_buddyList = null;
185
186 static LLLoginResponse()
187 {
188 // This is being set, but it's not used
189 // not sure why.
190 globalTexturesHash = new Hashtable();
191 globalTexturesHash["sun_texture_id"] = sunTexture;
192 globalTexturesHash["cloud_texture_id"] = cloudTexture;
193 globalTexturesHash["moon_texture_id"] = moonTexture;
194 }
195
196 public LLLoginResponse()
197 {
198 loginFlags = new ArrayList();
199 globalTextures = new ArrayList();
200 eventCategories = new ArrayList();
201 uiConfig = new ArrayList();
202 classifiedCategories = new ArrayList();
203
204 uiConfigHash = new Hashtable();
205
206 // defaultXmlRpcResponse = new XmlRpcResponse();
207 userProfile = new UserInfo();
208 inventoryRoot = new ArrayList();
209 initialOutfit = new ArrayList();
210 agentInventory = new ArrayList();
211 inventoryLibrary = new ArrayList();
212 inventoryLibraryOwner = new ArrayList();
213 activeGestures = new ArrayList();
214
215 SetDefaultValues();
216 }
217
218 public LLLoginResponse(UserAccount account, AgentCircuitData aCircuit, PresenceInfo pinfo,
219 GridRegion destination, List<InventoryFolderBase> invSkel, FriendInfo[] friendsList, ILibraryService libService,
220 string where, string startlocation, Vector3 position, Vector3 lookAt, string message,
221 GridRegion home, IPEndPoint clientIP)
222 : this()
223 {
224 FillOutInventoryData(invSkel, libService);
225
226 CircuitCode = (int)aCircuit.circuitcode;
227 Lastname = account.LastName;
228 Firstname = account.FirstName;
229 AgentID = account.PrincipalID;
230 SessionID = aCircuit.SessionID;
231 SecureSessionID = aCircuit.SecureSessionID;
232 Message = message;
233 BuddList = ConvertFriendListItem(friendsList);
234 StartLocation = where;
235
236 FillOutHomeData(pinfo, home);
237 LookAt = String.Format("[r{0},r{1},r{2}]", lookAt.X, lookAt.Y, lookAt.Z);
238
239 FillOutRegionData(destination);
240
241 FillOutSeedCap(aCircuit, destination, clientIP);
242
243 }
244
245 private void FillOutInventoryData(List<InventoryFolderBase> invSkel, ILibraryService libService)
246 {
247 InventoryData inventData = null;
248
249 try
250 {
251 inventData = GetInventorySkeleton(invSkel);
252 }
253 catch (Exception e)
254 {
255 m_log.WarnFormat(
256 "[LLLOGIN SERVICE]: Error processing inventory skeleton of agent {0} - {1}",
257 agentID, e);
258
259 // ignore and continue
260 }
261
262 if (inventData != null)
263 {
264 ArrayList AgentInventoryArray = inventData.InventoryArray;
265
266 Hashtable InventoryRootHash = new Hashtable();
267 InventoryRootHash["folder_id"] = inventData.RootFolderID.ToString();
268 InventoryRoot = new ArrayList();
269 InventoryRoot.Add(InventoryRootHash);
270 InventorySkeleton = AgentInventoryArray;
271 }
272
273 // Inventory Library Section
274 if (libService != null && libService.LibraryRootFolder != null)
275 {
276 Hashtable InventoryLibRootHash = new Hashtable();
277 InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000";
278 InventoryLibRoot = new ArrayList();
279 InventoryLibRoot.Add(InventoryLibRootHash);
280
281 InventoryLibraryOwner = GetLibraryOwner(libService.LibraryRootFolder);
282 InventoryLibrary = GetInventoryLibrary(libService);
283 }
284 }
285
286 private void FillOutHomeData(PresenceInfo pinfo, GridRegion home)
287 {
288 int x = 1000 * (int)Constants.RegionSize, y = 1000 * (int)Constants.RegionSize;
289 if (home != null)
290 {
291 x = home.RegionLocX;
292 y = home.RegionLocY;
293 }
294
295 Home = string.Format(
296 "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}",
297 x,
298 y,
299 pinfo.HomePosition.X, pinfo.HomePosition.Y, pinfo.HomePosition.Z,
300 pinfo.HomeLookAt.X, pinfo.HomeLookAt.Y, pinfo.HomeLookAt.Z);
301
302 }
303
304 private void FillOutRegionData(GridRegion destination)
305 {
306 IPEndPoint endPoint = destination.ExternalEndPoint;
307 SimAddress = endPoint.Address.ToString();
308 SimPort = (uint)endPoint.Port;
309 RegionX = (uint)destination.RegionLocX;
310 RegionY = (uint)destination.RegionLocY;
311 }
312
313 private void FillOutSeedCap(AgentCircuitData aCircuit, GridRegion destination, IPEndPoint ipepClient)
314 {
315 string capsSeedPath = String.Empty;
316
317 // Don't use the following! It Fails for logging into any region not on the same port as the http server!
318 // Kept here so it doesn't happen again!
319 // response.SeedCapability = regionInfo.ServerURI + capsSeedPath;
320
321 #region IP Translation for NAT
322 if (ipepClient != null)
323 {
324 capsSeedPath
325 = "http://"
326 + NetworkUtil.GetHostFor(ipepClient.Address, destination.ExternalHostName)
327 + ":"
328 + destination.HttpPort
329 + CapsUtil.GetCapsSeedPath(aCircuit.CapsPath);
330 }
331 else
332 {
333 capsSeedPath
334 = "http://"
335 + destination.ExternalHostName
336 + ":"
337 + destination.HttpPort
338 + CapsUtil.GetCapsSeedPath(aCircuit.CapsPath);
339 }
340 #endregion
341
342 SeedCapability = capsSeedPath;
343 }
344
345 private void SetDefaultValues()
346 {
347 DST = TimeZone.CurrentTimeZone.IsDaylightSavingTime(DateTime.Now) ? "Y" : "N";
348 StipendSinceLogin = "N";
349 Gendered = "Y";
350 EverLoggedIn = "Y";
351 login = "false";
352 firstname = "Test";
353 lastname = "User";
354 agentAccess = "M";
355 agentAccessMax = "A";
356 startLocation = "last";
357 allowFirstLife = "Y";
358
359 ErrorMessage = "You have entered an invalid name/password combination. Check Caps/lock.";
360 ErrorReason = "key";
361 welcomeMessage = "Welcome to OpenSim!";
362 seedCapability = String.Empty;
363 home = "{'region_handle':[r" + (1000*Constants.RegionSize).ToString() + ",r" + (1000*Constants.RegionSize).ToString() + "], 'position':[r" +
364 userProfile.homepos.X.ToString() + ",r" + userProfile.homepos.Y.ToString() + ",r" +
365 userProfile.homepos.Z.ToString() + "], 'look_at':[r" + userProfile.homelookat.X.ToString() + ",r" +
366 userProfile.homelookat.Y.ToString() + ",r" + userProfile.homelookat.Z.ToString() + "]}";
367 lookAt = "[r0.99949799999999999756,r0.03166859999999999814,r0]";
368 RegionX = (uint) 255232;
369 RegionY = (uint) 254976;
370
371 // Classifieds;
372 AddClassifiedCategory((Int32) 1, "Shopping");
373 AddClassifiedCategory((Int32) 2, "Land Rental");
374 AddClassifiedCategory((Int32) 3, "Property Rental");
375 AddClassifiedCategory((Int32) 4, "Special Attraction");
376 AddClassifiedCategory((Int32) 5, "New Products");
377 AddClassifiedCategory((Int32) 6, "Employment");
378 AddClassifiedCategory((Int32) 7, "Wanted");
379 AddClassifiedCategory((Int32) 8, "Service");
380 AddClassifiedCategory((Int32) 9, "Personal");
381
382 SessionID = UUID.Random();
383 SecureSessionID = UUID.Random();
384 AgentID = UUID.Random();
385
386 Hashtable InitialOutfitHash = new Hashtable();
387 InitialOutfitHash["folder_name"] = "Nightclub Female";
388 InitialOutfitHash["gender"] = "female";
389 initialOutfit.Add(InitialOutfitHash);
390 }
391
392
393 public override Hashtable ToHashtable()
394 {
395 try
396 {
397 Hashtable responseData = new Hashtable();
398
399 loginFlagsHash = new Hashtable();
400 loginFlagsHash["daylight_savings"] = DST;
401 loginFlagsHash["stipend_since_login"] = StipendSinceLogin;
402 loginFlagsHash["gendered"] = Gendered;
403 loginFlagsHash["ever_logged_in"] = EverLoggedIn;
404 loginFlags.Add(loginFlagsHash);
405
406 responseData["first_name"] = Firstname;
407 responseData["last_name"] = Lastname;
408 responseData["agent_access"] = agentAccess;
409 responseData["agent_access_max"] = agentAccessMax;
410
411 globalTextures.Add(globalTexturesHash);
412 // this.eventCategories.Add(this.eventCategoriesHash);
413
414 AddToUIConfig("allow_first_life", allowFirstLife);
415 uiConfig.Add(uiConfigHash);
416
417 responseData["sim_port"] = (Int32) SimPort;
418 responseData["sim_ip"] = SimAddress;
419 responseData["http_port"] = (Int32)SimHttpPort;
420
421 responseData["agent_id"] = AgentID.ToString();
422 responseData["session_id"] = SessionID.ToString();
423 responseData["secure_session_id"] = SecureSessionID.ToString();
424 responseData["circuit_code"] = CircuitCode;
425 responseData["seconds_since_epoch"] = (Int32) (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
426 responseData["login-flags"] = loginFlags;
427 responseData["global-textures"] = globalTextures;
428 responseData["seed_capability"] = seedCapability;
429
430 responseData["event_categories"] = eventCategories;
431 responseData["event_notifications"] = new ArrayList(); // todo
432 responseData["classified_categories"] = classifiedCategories;
433 responseData["ui-config"] = uiConfig;
434
435 if (agentInventory != null)
436 {
437 responseData["inventory-skeleton"] = agentInventory;
438 responseData["inventory-root"] = inventoryRoot;
439 }
440 responseData["inventory-skel-lib"] = inventoryLibrary;
441 responseData["inventory-lib-root"] = inventoryLibRoot;
442 responseData["gestures"] = activeGestures;
443 responseData["inventory-lib-owner"] = inventoryLibraryOwner;
444 responseData["initial-outfit"] = initialOutfit;
445 responseData["start_location"] = startLocation;
446 responseData["seed_capability"] = seedCapability;
447 responseData["home"] = home;
448 responseData["look_at"] = lookAt;
449 responseData["message"] = welcomeMessage;
450 responseData["region_x"] = (Int32)(RegionX);
451 responseData["region_y"] = (Int32)(RegionY);
452
453 if (m_buddyList != null)
454 {
455 responseData["buddy-list"] = m_buddyList.ToArray();
456 }
457
458 responseData["login"] = "true";
459
460 return responseData;
461 }
462 catch (Exception e)
463 {
464 m_log.Warn("[CLIENT]: LoginResponse: Error creating Hashtable Response: " + e.Message);
465
466 return LLFailedLoginResponse.InternalError.ToHashtable();
467 }
468 }
469
470 public override OSD ToOSDMap()
471 {
472 try
473 {
474 OSDMap map = new OSDMap();
475
476 map["first_name"] = OSD.FromString(Firstname);
477 map["last_name"] = OSD.FromString(Lastname);
478 map["agent_access"] = OSD.FromString(agentAccess);
479 map["agent_access_max"] = OSD.FromString(agentAccessMax);
480
481 map["sim_port"] = OSD.FromInteger(SimPort);
482 map["sim_ip"] = OSD.FromString(SimAddress);
483
484 map["agent_id"] = OSD.FromUUID(AgentID);
485 map["session_id"] = OSD.FromUUID(SessionID);
486 map["secure_session_id"] = OSD.FromUUID(SecureSessionID);
487 map["circuit_code"] = OSD.FromInteger(CircuitCode);
488 map["seconds_since_epoch"] = OSD.FromInteger((int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds);
489
490 #region Login Flags
491
492 OSDMap loginFlagsLLSD = new OSDMap();
493 loginFlagsLLSD["daylight_savings"] = OSD.FromString(DST);
494 loginFlagsLLSD["stipend_since_login"] = OSD.FromString(StipendSinceLogin);
495 loginFlagsLLSD["gendered"] = OSD.FromString(Gendered);
496 loginFlagsLLSD["ever_logged_in"] = OSD.FromString(EverLoggedIn);
497 map["login-flags"] = WrapOSDMap(loginFlagsLLSD);
498
499 #endregion Login Flags
500
501 #region Global Textures
502
503 OSDMap globalTexturesLLSD = new OSDMap();
504 globalTexturesLLSD["sun_texture_id"] = OSD.FromString(SunTexture);
505 globalTexturesLLSD["cloud_texture_id"] = OSD.FromString(CloudTexture);
506 globalTexturesLLSD["moon_texture_id"] = OSD.FromString(MoonTexture);
507
508 map["global-textures"] = WrapOSDMap(globalTexturesLLSD);
509
510 #endregion Global Textures
511
512 map["seed_capability"] = OSD.FromString(seedCapability);
513
514 map["event_categories"] = ArrayListToOSDArray(eventCategories);
515 //map["event_notifications"] = new OSDArray(); // todo
516 map["classified_categories"] = ArrayListToOSDArray(classifiedCategories);
517
518 #region UI Config
519
520 OSDMap uiConfigLLSD = new OSDMap();
521 uiConfigLLSD["allow_first_life"] = OSD.FromString(allowFirstLife);
522 map["ui-config"] = WrapOSDMap(uiConfigLLSD);
523
524 #endregion UI Config
525
526 #region Inventory
527
528 map["inventory-skeleton"] = ArrayListToOSDArray(agentInventory);
529
530 map["inventory-skel-lib"] = ArrayListToOSDArray(inventoryLibrary);
531 map["inventory-root"] = ArrayListToOSDArray(inventoryRoot); ;
532 map["inventory-lib-root"] = ArrayListToOSDArray(inventoryLibRoot);
533 map["inventory-lib-owner"] = ArrayListToOSDArray(inventoryLibraryOwner);
534
535 #endregion Inventory
536
537 map["gestures"] = ArrayListToOSDArray(activeGestures);
538
539 map["initial-outfit"] = ArrayListToOSDArray(initialOutfit);
540 map["start_location"] = OSD.FromString(startLocation);
541
542 map["seed_capability"] = OSD.FromString(seedCapability);
543 map["home"] = OSD.FromString(home);
544 map["look_at"] = OSD.FromString(lookAt);
545 map["message"] = OSD.FromString(welcomeMessage);
546 map["region_x"] = OSD.FromInteger(RegionX);
547 map["region_y"] = OSD.FromInteger(RegionY);
548
549 if (m_buddyList != null)
550 {
551 map["buddy-list"] = ArrayListToOSDArray(m_buddyList.ToArray());
552 }
553
554 map["login"] = OSD.FromString("true");
555
556 return map;
557 }
558 catch (Exception e)
559 {
560 m_log.Warn("[CLIENT]: LoginResponse: Error creating LLSD Response: " + e.Message);
561
562 return LLFailedLoginResponse.InternalError.ToOSDMap();
563 }
564 }
565
566 public OSDArray ArrayListToOSDArray(ArrayList arrlst)
567 {
568 OSDArray llsdBack = new OSDArray();
569 foreach (Hashtable ht in arrlst)
570 {
571 OSDMap mp = new OSDMap();
572 foreach (DictionaryEntry deHt in ht)
573 {
574 mp.Add((string)deHt.Key, OSDString.FromObject(deHt.Value));
575 }
576 llsdBack.Add(mp);
577 }
578 return llsdBack;
579 }
580
581 private static OSDArray WrapOSDMap(OSDMap wrapMe)
582 {
583 OSDArray array = new OSDArray();
584 array.Add(wrapMe);
585 return array;
586 }
587
588 public void SetEventCategories(string category, string value)
589 {
590 // this.eventCategoriesHash[category] = value;
591 //TODO
592 }
593
594 public void AddToUIConfig(string itemName, string item)
595 {
596 uiConfigHash[itemName] = item;
597 }
598
599 public void AddClassifiedCategory(Int32 ID, string categoryName)
600 {
601 Hashtable hash = new Hashtable();
602 hash["category_name"] = categoryName;
603 hash["category_id"] = ID;
604 classifiedCategories.Add(hash);
605 // this.classifiedCategoriesHash.Clear();
606 }
607
608
609 private static LLLoginResponse.BuddyList ConvertFriendListItem(FriendInfo[] friendsList)
610 {
611 LLLoginResponse.BuddyList buddylistreturn = new LLLoginResponse.BuddyList();
612 foreach (FriendInfo finfo in friendsList)
613 {
614 if (finfo.TheirFlags == -1)
615 continue;
616 LLLoginResponse.BuddyList.BuddyInfo buddyitem = new LLLoginResponse.BuddyList.BuddyInfo(finfo.Friend);
617 buddyitem.BuddyID = finfo.Friend;
618 buddyitem.BuddyRightsHave = (int)finfo.TheirFlags;
619 buddyitem.BuddyRightsGiven = (int)finfo.MyFlags;
620 buddylistreturn.AddNewBuddy(buddyitem);
621 }
622 return buddylistreturn;
623 }
624
625 private InventoryData GetInventorySkeleton(List<InventoryFolderBase> folders)
626 {
627 UUID rootID = UUID.Zero;
628 ArrayList AgentInventoryArray = new ArrayList();
629 Hashtable TempHash;
630 foreach (InventoryFolderBase InvFolder in folders)
631 {
632 if (InvFolder.ParentID == UUID.Zero)
633 {
634 rootID = InvFolder.ID;
635 }
636 TempHash = new Hashtable();
637 TempHash["name"] = InvFolder.Name;
638 TempHash["parent_id"] = InvFolder.ParentID.ToString();
639 TempHash["version"] = (Int32)InvFolder.Version;
640 TempHash["type_default"] = (Int32)InvFolder.Type;
641 TempHash["folder_id"] = InvFolder.ID.ToString();
642 AgentInventoryArray.Add(TempHash);
643 }
644
645 return new InventoryData(AgentInventoryArray, rootID);
646
647 }
648
649 /// <summary>
650 /// Converts the inventory library skeleton into the form required by the rpc request.
651 /// </summary>
652 /// <returns></returns>
653 protected virtual ArrayList GetInventoryLibrary(ILibraryService library)
654 {
655 Dictionary<UUID, InventoryFolderImpl> rootFolders = library.GetAllFolders();
656 m_log.DebugFormat("[LLOGIN]: Library has {0} folders", rootFolders.Count);
657 //Dictionary<UUID, InventoryFolderImpl> rootFolders = new Dictionary<UUID,InventoryFolderImpl>();
658 ArrayList folderHashes = new ArrayList();
659
660 foreach (InventoryFolderBase folder in rootFolders.Values)
661 {
662 Hashtable TempHash = new Hashtable();
663 TempHash["name"] = folder.Name;
664 TempHash["parent_id"] = folder.ParentID.ToString();
665 TempHash["version"] = (Int32)folder.Version;
666 TempHash["type_default"] = (Int32)folder.Type;
667 TempHash["folder_id"] = folder.ID.ToString();
668 folderHashes.Add(TempHash);
669 }
670
671 return folderHashes;
672 }
673
674 /// <summary>
675 ///
676 /// </summary>
677 /// <returns></returns>
678 protected virtual ArrayList GetLibraryOwner(InventoryFolderImpl libFolder)
679 {
680 //for now create random inventory library owner
681 Hashtable TempHash = new Hashtable();
682 TempHash["agent_id"] = "11111111-1111-0000-0000-000100bba000"; // libFolder.Owner
683 ArrayList inventoryLibOwner = new ArrayList();
684 inventoryLibOwner.Add(TempHash);
685 return inventoryLibOwner;
686 }
687
688 public class InventoryData
689 {
690 public ArrayList InventoryArray = null;
691 public UUID RootFolderID = UUID.Zero;
692
693 public InventoryData(ArrayList invList, UUID rootID)
694 {
695 InventoryArray = invList;
696 RootFolderID = rootID;
697 }
698 }
699
700 #region Properties
701
702 public string Login
703 {
704 get { return login; }
705 set { login = value; }
706 }
707
708 public string DST
709 {
710 get { return dst; }
711 set { dst = value; }
712 }
713
714 public string StipendSinceLogin
715 {
716 get { return stipendSinceLogin; }
717 set { stipendSinceLogin = value; }
718 }
719
720 public string Gendered
721 {
722 get { return gendered; }
723 set { gendered = value; }
724 }
725
726 public string EverLoggedIn
727 {
728 get { return everLoggedIn; }
729 set { everLoggedIn = value; }
730 }
731
732 public uint SimPort
733 {
734 get { return simPort; }
735 set { simPort = value; }
736 }
737
738 public uint SimHttpPort
739 {
740 get { return simHttpPort; }
741 set { simHttpPort = value; }
742 }
743
744 public string SimAddress
745 {
746 get { return simAddress; }
747 set { simAddress = value; }
748 }
749
750 public UUID AgentID
751 {
752 get { return agentID; }
753 set { agentID = value; }
754 }
755
756 public UUID SessionID
757 {
758 get { return sessionID; }
759 set { sessionID = value; }
760 }
761
762 public UUID SecureSessionID
763 {
764 get { return secureSessionID; }
765 set { secureSessionID = value; }
766 }
767
768 public Int32 CircuitCode
769 {
770 get { return circuitCode; }
771 set { circuitCode = value; }
772 }
773
774 public uint RegionX
775 {
776 get { return regionX; }
777 set { regionX = value; }
778 }
779
780 public uint RegionY
781 {
782 get { return regionY; }
783 set { regionY = value; }
784 }
785
786 public string SunTexture
787 {
788 get { return sunTexture; }
789 set { sunTexture = value; }
790 }
791
792 public string CloudTexture
793 {
794 get { return cloudTexture; }
795 set { cloudTexture = value; }
796 }
797
798 public string MoonTexture
799 {
800 get { return moonTexture; }
801 set { moonTexture = value; }
802 }
803
804 public string Firstname
805 {
806 get { return firstname; }
807 set { firstname = value; }
808 }
809
810 public string Lastname
811 {
812 get { return lastname; }
813 set { lastname = value; }
814 }
815
816 public string AgentAccess
817 {
818 get { return agentAccess; }
819 set { agentAccess = value; }
820 }
821
822 public string AgentAccessMax
823 {
824 get { return agentAccessMax; }
825 set { agentAccessMax = value; }
826 }
827
828 public string StartLocation
829 {
830 get { return startLocation; }
831 set { startLocation = value; }
832 }
833
834 public string LookAt
835 {
836 get { return lookAt; }
837 set { lookAt = value; }
838 }
839
840 public string SeedCapability
841 {
842 get { return seedCapability; }
843 set { seedCapability = value; }
844 }
845
846 public string ErrorReason
847 {
848 get { return errorReason; }
849 set { errorReason = value; }
850 }
851
852 public string ErrorMessage
853 {
854 get { return errorMessage; }
855 set { errorMessage = value; }
856 }
857
858 public ArrayList InventoryRoot
859 {
860 get { return inventoryRoot; }
861 set { inventoryRoot = value; }
862 }
863
864 public ArrayList InventorySkeleton
865 {
866 get { return agentInventory; }
867 set { agentInventory = value; }
868 }
869
870 public ArrayList InventoryLibrary
871 {
872 get { return inventoryLibrary; }
873 set { inventoryLibrary = value; }
874 }
875
876 public ArrayList InventoryLibraryOwner
877 {
878 get { return inventoryLibraryOwner; }
879 set { inventoryLibraryOwner = value; }
880 }
881
882 public ArrayList InventoryLibRoot
883 {
884 get { return inventoryLibRoot; }
885 set { inventoryLibRoot = value; }
886 }
887
888 public ArrayList ActiveGestures
889 {
890 get { return activeGestures; }
891 set { activeGestures = value; }
892 }
893
894 public string Home
895 {
896 get { return home; }
897 set { home = value; }
898 }
899
900 public string Message
901 {
902 get { return welcomeMessage; }
903 set { welcomeMessage = value; }
904 }
905
906 public BuddyList BuddList
907 {
908 get { return m_buddyList; }
909 set { m_buddyList = value; }
910 }
911
912 #endregion
913
914 public class UserInfo
915 {
916 public string firstname;
917 public string lastname;
918 public ulong homeregionhandle;
919 public Vector3 homepos;
920 public Vector3 homelookat;
921 }
922
923 public class BuddyList
924 {
925 public List<BuddyInfo> Buddies = new List<BuddyInfo>();
926
927 public void AddNewBuddy(BuddyInfo buddy)
928 {
929 if (!Buddies.Contains(buddy))
930 {
931 Buddies.Add(buddy);
932 }
933 }
934
935 public ArrayList ToArray()
936 {
937 ArrayList buddyArray = new ArrayList();
938 foreach (BuddyInfo buddy in Buddies)
939 {
940 buddyArray.Add(buddy.ToHashTable());
941 }
942 return buddyArray;
943 }
944
945 public class BuddyInfo
946 {
947 public int BuddyRightsHave = 1;
948 public int BuddyRightsGiven = 1;
949 public string BuddyID;
950
951 public BuddyInfo(string buddyID)
952 {
953 BuddyID = buddyID;
954 }
955
956 public BuddyInfo(UUID buddyID)
957 {
958 BuddyID = buddyID.ToString();
959 }
960
961 public Hashtable ToHashTable()
962 {
963 Hashtable hTable = new Hashtable();
964 hTable["buddy_rights_has"] = BuddyRightsHave;
965 hTable["buddy_rights_given"] = BuddyRightsGiven;
966 hTable["buddy_id"] = BuddyID;
967 return hTable;
968 }
969 }
970 }
971 }
972}