aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/LLLoginService/LLLoginResponse.cs
diff options
context:
space:
mode:
authorDiva Canto2009-12-31 17:18:55 -0800
committerDiva Canto2009-12-31 17:18:55 -0800
commit130c80efe004fa06808cc639ad8e2ee31c35744b (patch)
tree7ca8b57f70c36672ed06851f1f0efd0c36096c20 /OpenSim/Services/LLLoginService/LLLoginResponse.cs
parent* Added the Login server handlers that were lost in yesterday's commit grief (diff)
downloadopensim-SC_OLD-130c80efe004fa06808cc639ad8e2ee31c35744b.zip
opensim-SC_OLD-130c80efe004fa06808cc639ad8e2ee31c35744b.tar.gz
opensim-SC_OLD-130c80efe004fa06808cc639ad8e2ee31c35744b.tar.bz2
opensim-SC_OLD-130c80efe004fa06808cc639ad8e2ee31c35744b.tar.xz
A lot more beef on the login service. The LLLoginResponse is a MONSTER! Almost done...
Diffstat (limited to 'OpenSim/Services/LLLoginService/LLLoginResponse.cs')
-rw-r--r--OpenSim/Services/LLLoginService/LLLoginResponse.cs225
1 files changed, 225 insertions, 0 deletions
diff --git a/OpenSim/Services/LLLoginService/LLLoginResponse.cs b/OpenSim/Services/LLLoginService/LLLoginResponse.cs
index fbce63f..18a4f02 100644
--- a/OpenSim/Services/LLLoginService/LLLoginResponse.cs
+++ b/OpenSim/Services/LLLoginService/LLLoginResponse.cs
@@ -28,11 +28,19 @@
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Net;
31using System.Reflection; 32using System.Reflection;
33
32using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Capabilities;
36using OpenSim.Services.Interfaces;
37using GridRegion = OpenSim.Services.Interfaces.GridRegion;
38
33using log4net; 39using log4net;
34using OpenMetaverse; 40using OpenMetaverse;
35using OpenMetaverse.StructuredData; 41using OpenMetaverse.StructuredData;
42using OSDArray = OpenMetaverse.StructuredData.OSDArray;
43using OSDMap = OpenMetaverse.StructuredData.OSDMap;
36 44
37namespace OpenSim.Services.LLLoginService 45namespace OpenSim.Services.LLLoginService
38{ 46{
@@ -202,6 +210,132 @@ namespace OpenSim.Services.LLLoginService
202 SetDefaultValues(); 210 SetDefaultValues();
203 } 211 }
204 212
213 public LLLoginResponse(UserAccount account, AgentCircuitData aCircuit, PresenceInfo pinfo,
214 GridRegion destination, List<InventoryFolderBase> invSkel,
215 string where, string startlocation, Vector3 position, Vector3 lookAt, string message,
216 GridRegion home, IPEndPoint clientIP)
217 : this()
218 {
219 FillOutInventoryData(invSkel);
220
221 CircuitCode = (int)aCircuit.circuitcode;
222 Lastname = account.LastName;
223 Firstname = account.FirstName;
224 AgentID = account.PrincipalID;
225 SessionID = aCircuit.SessionID;
226 SecureSessionID = aCircuit.SecureSessionID;
227 Message = message;
228 // While we don't have friends...
229 //BuddList = ConvertFriendListItem(m_userManager.GetUserFriendList(agentID));
230 BuddList = new LLLoginResponse.BuddyList();
231 StartLocation = where;
232
233 FillOutHomeData(pinfo, home);
234 LookAt = String.Format("[r{0},r{1},r{2}]", lookAt.X, lookAt.Y, lookAt.Z);
235
236 FillOutRegionData(destination);
237
238 FillOutSeedCap(aCircuit, destination, clientIP);
239
240 }
241
242 private void FillOutInventoryData(List<InventoryFolderBase> invSkel)
243 {
244 InventoryData inventData = null;
245
246 try
247 {
248 inventData = GetInventorySkeleton(invSkel);
249 }
250 catch (Exception e)
251 {
252 m_log.WarnFormat(
253 "[LLLOGIN SERVICE]: Error processing inventory skeleton of agent {0} - {1}",
254 agentID, e);
255
256 // ignore and continue
257 }
258
259 if (inventData != null)
260 {
261 ArrayList AgentInventoryArray = inventData.InventoryArray;
262
263 Hashtable InventoryRootHash = new Hashtable();
264 InventoryRootHash["folder_id"] = inventData.RootFolderID.ToString();
265 InventoryRoot = new ArrayList();
266 InventoryRoot.Add(InventoryRootHash);
267 InventorySkeleton = AgentInventoryArray;
268 }
269
270 // Inventory Library Section
271 Hashtable InventoryLibRootHash = new Hashtable();
272 InventoryLibRootHash["folder_id"] = "00000112-000f-0000-0000-000100bba000";
273 InventoryLibRoot = new ArrayList();
274 InventoryLibRoot.Add(InventoryLibRootHash);
275
276 InventoryLibraryOwner = GetLibraryOwner();
277 InventoryLibrary = GetInventoryLibrary();
278 }
279
280 private void FillOutHomeData(PresenceInfo pinfo, GridRegion home)
281 {
282 int x = 1000 * (int)Constants.RegionSize, y = 1000 * (int)Constants.RegionSize;
283 if (home != null)
284 {
285 x = home.RegionLocX;
286 y = home.RegionLocY;
287 }
288
289 Home = string.Format(
290 "{{'region_handle':[r{0},r{1}], 'position':[r{2},r{3},r{4}], 'look_at':[r{5},r{6},r{7}]}}",
291 home.RegionLocX,
292 home.RegionLocY,
293 pinfo.HomePosition.X, pinfo.HomePosition.Y, pinfo.HomePosition.Z,
294 pinfo.HomeLookAt.X, pinfo.HomeLookAt.Y, pinfo.HomeLookAt.Z);
295
296 }
297
298 private void FillOutRegionData(GridRegion destination)
299 {
300 IPEndPoint endPoint = destination.ExternalEndPoint;
301 SimAddress = endPoint.Address.ToString();
302 SimPort = (uint)endPoint.Port;
303 RegionX = (uint)destination.RegionLocX;
304 RegionY = (uint)destination.RegionLocY;
305 }
306
307 private void FillOutSeedCap(AgentCircuitData aCircuit, GridRegion destination, IPEndPoint ipepClient)
308 {
309 string capsSeedPath = String.Empty;
310
311 // Don't use the following! It Fails for logging into any region not on the same port as the http server!
312 // Kept here so it doesn't happen again!
313 // response.SeedCapability = regionInfo.ServerURI + capsSeedPath;
314
315 #region IP Translation for NAT
316 if (ipepClient != null)
317 {
318 capsSeedPath
319 = "http://"
320 + NetworkUtil.GetHostFor(ipepClient.Address, destination.ExternalHostName)
321 + ":"
322 + destination.HttpPort
323 + CapsUtil.GetCapsSeedPath(aCircuit.CapsPath);
324 }
325 else
326 {
327 capsSeedPath
328 = "http://"
329 + destination.ExternalHostName
330 + ":"
331 + destination.HttpPort
332 + CapsUtil.GetCapsSeedPath(aCircuit.CapsPath);
333 }
334 #endregion
335
336 SeedCapability = capsSeedPath;
337 }
338
205 private void SetDefaultValues() 339 private void SetDefaultValues()
206 { 340 {
207 DST = TimeZone.CurrentTimeZone.IsDaylightSavingTime(DateTime.Now) ? "Y" : "N"; 341 DST = TimeZone.CurrentTimeZone.IsDaylightSavingTime(DateTime.Now) ? "Y" : "N";
@@ -465,6 +599,97 @@ namespace OpenSim.Services.LLLoginService
465 // this.classifiedCategoriesHash.Clear(); 599 // this.classifiedCategoriesHash.Clear();
466 } 600 }
467 601
602
603 private static LLLoginResponse.BuddyList ConvertFriendListItem(List<FriendListItem> LFL)
604 {
605 LLLoginResponse.BuddyList buddylistreturn = new LLLoginResponse.BuddyList();
606 foreach (FriendListItem fl in LFL)
607 {
608 LLLoginResponse.BuddyList.BuddyInfo buddyitem = new LLLoginResponse.BuddyList.BuddyInfo(fl.Friend);
609 buddyitem.BuddyID = fl.Friend;
610 buddyitem.BuddyRightsHave = (int)fl.FriendListOwnerPerms;
611 buddyitem.BuddyRightsGiven = (int)fl.FriendPerms;
612 buddylistreturn.AddNewBuddy(buddyitem);
613 }
614 return buddylistreturn;
615 }
616
617 private InventoryData GetInventorySkeleton(List<InventoryFolderBase> folders)
618 {
619 UUID rootID = UUID.Zero;
620 ArrayList AgentInventoryArray = new ArrayList();
621 Hashtable TempHash;
622 foreach (InventoryFolderBase InvFolder in folders)
623 {
624 if (InvFolder.ParentID == UUID.Zero)
625 {
626 rootID = InvFolder.ID;
627 }
628 TempHash = new Hashtable();
629 TempHash["name"] = InvFolder.Name;
630 TempHash["parent_id"] = InvFolder.ParentID.ToString();
631 TempHash["version"] = (Int32)InvFolder.Version;
632 TempHash["type_default"] = (Int32)InvFolder.Type;
633 TempHash["folder_id"] = InvFolder.ID.ToString();
634 AgentInventoryArray.Add(TempHash);
635 }
636
637 return new InventoryData(AgentInventoryArray, rootID);
638
639 }
640
641 /// <summary>
642 /// Converts the inventory library skeleton into the form required by the rpc request.
643 /// </summary>
644 /// <returns></returns>
645 protected virtual ArrayList GetInventoryLibrary()
646 {
647 // While we don't have library...
648 //Dictionary<UUID, InventoryFolderImpl> rootFolders
649 // = m_libraryRootFolder.RequestSelfAndDescendentFolders();
650 Dictionary<UUID, InventoryFolderImpl> rootFolders = new Dictionary<UUID,InventoryFolderImpl>();
651 ArrayList folderHashes = new ArrayList();
652
653 foreach (InventoryFolderBase folder in rootFolders.Values)
654 {
655 Hashtable TempHash = new Hashtable();
656 TempHash["name"] = folder.Name;
657 TempHash["parent_id"] = folder.ParentID.ToString();
658 TempHash["version"] = (Int32)folder.Version;
659 TempHash["type_default"] = (Int32)folder.Type;
660 TempHash["folder_id"] = folder.ID.ToString();
661 folderHashes.Add(TempHash);
662 }
663
664 return folderHashes;
665 }
666
667 /// <summary>
668 ///
669 /// </summary>
670 /// <returns></returns>
671 protected virtual ArrayList GetLibraryOwner()
672 {
673 //for now create random inventory library owner
674 Hashtable TempHash = new Hashtable();
675 TempHash["agent_id"] = "11111111-1111-0000-0000-000100bba000";
676 ArrayList inventoryLibOwner = new ArrayList();
677 inventoryLibOwner.Add(TempHash);
678 return inventoryLibOwner;
679 }
680
681 public class InventoryData
682 {
683 public ArrayList InventoryArray = null;
684 public UUID RootFolderID = UUID.Zero;
685
686 public InventoryData(ArrayList invList, UUID rootID)
687 {
688 InventoryArray = invList;
689 RootFolderID = rootID;
690 }
691 }
692
468 #region Properties 693 #region Properties
469 694
470 public string Login 695 public string Login