aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Server/Handlers/Login/LLLoginHandlers.cs14
-rw-r--r--OpenSim/Services/Interfaces/ILoginService.cs3
-rw-r--r--OpenSim/Services/LLLoginService/LLLoginResponse.cs225
-rw-r--r--OpenSim/Services/LLLoginService/LLLoginService.cs84
4 files changed, 302 insertions, 24 deletions
diff --git a/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs b/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs
index b973c11..aaa958b 100644
--- a/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs
+++ b/OpenSim/Server/Handlers/Login/LLLoginHandlers.cs
@@ -68,12 +68,22 @@ namespace OpenSim.Server.Handlers.Login
68 requestData.ContainsKey("last") && requestData["last"] != null && 68 requestData.ContainsKey("last") && requestData["last"] != null &&
69 requestData.ContainsKey("passwd") && requestData["passwd"] != null) 69 requestData.ContainsKey("passwd") && requestData["passwd"] != null)
70 { 70 {
71 string first = requestData["first"].ToString();
72 string last = requestData["last"].ToString();
73 string passwd = requestData["passwd"].ToString();
71 string startLocation = string.Empty; 74 string startLocation = string.Empty;
72 if (requestData.ContainsKey("start")) 75 if (requestData.ContainsKey("start"))
73 startLocation = requestData["start"].ToString(); 76 startLocation = requestData["start"].ToString();
74 77
78 string clientVersion = "Unknown";
79 if (requestData.Contains("version"))
80 clientVersion = requestData["version"].ToString();
81 // We should do something interesting with the client version...
82
83 m_log.InfoFormat("[LOGIN]: XMLRPC Login Requested for {0} {1}, starting in {2}, using {3}", first, last, startLocation, clientVersion);
84
75 LoginResponse reply = null; 85 LoginResponse reply = null;
76 reply = m_LocalService.Login(requestData["first"].ToString(), requestData["last"].ToString(), requestData["passwd"].ToString(), startLocation); 86 reply = m_LocalService.Login(first, last, passwd, startLocation, remoteClient);
77 87
78 XmlRpcResponse response = new XmlRpcResponse(); 88 XmlRpcResponse response = new XmlRpcResponse();
79 response.Value = reply.ToHashtable(); 89 response.Value = reply.ToHashtable();
@@ -102,7 +112,7 @@ namespace OpenSim.Server.Handlers.Login
102 m_log.Info("[LOGIN]: LLSD Login Requested for: '" + map["first"].AsString() + "' '" + map["last"].AsString() + "' / " + startLocation); 112 m_log.Info("[LOGIN]: LLSD Login Requested for: '" + map["first"].AsString() + "' '" + map["last"].AsString() + "' / " + startLocation);
103 113
104 LoginResponse reply = null; 114 LoginResponse reply = null;
105 reply = m_LocalService.Login(map["first"].AsString(), map["last"].AsString(), map["passwd"].AsString(), startLocation); 115 reply = m_LocalService.Login(map["first"].AsString(), map["last"].AsString(), map["passwd"].AsString(), startLocation, remoteClient);
106 return reply.ToOSDMap(); 116 return reply.ToOSDMap();
107 117
108 } 118 }
diff --git a/OpenSim/Services/Interfaces/ILoginService.cs b/OpenSim/Services/Interfaces/ILoginService.cs
index 0f82de5..24bf342 100644
--- a/OpenSim/Services/Interfaces/ILoginService.cs
+++ b/OpenSim/Services/Interfaces/ILoginService.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Net;
31 32
32using OpenMetaverse.StructuredData; 33using OpenMetaverse.StructuredData;
33 34
@@ -45,7 +46,7 @@ namespace OpenSim.Services.Interfaces
45 46
46 public interface ILoginService 47 public interface ILoginService
47 { 48 {
48 LoginResponse Login(string firstName, string lastName, string passwd, string startLocation); 49 LoginResponse Login(string firstName, string lastName, string passwd, string startLocation, IPEndPoint clientIP);
49 } 50 }
50 51
51 52
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
diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs
index 25a65b5..7d24637 100644
--- a/OpenSim/Services/LLLoginService/LLLoginService.cs
+++ b/OpenSim/Services/LLLoginService/LLLoginService.cs
@@ -1,5 +1,6 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Net;
3using System.Reflection; 4using System.Reflection;
4using System.Text.RegularExpressions; 5using System.Text.RegularExpressions;
5 6
@@ -8,6 +9,7 @@ using Nini.Config;
8using OpenMetaverse; 9using OpenMetaverse;
9 10
10using OpenSim.Framework; 11using OpenSim.Framework;
12using OpenSim.Framework.Capabilities;
11using OpenSim.Server.Base; 13using OpenSim.Server.Base;
12using OpenSim.Services.Interfaces; 14using OpenSim.Services.Interfaces;
13using GridRegion = OpenSim.Services.Interfaces.GridRegion; 15using GridRegion = OpenSim.Services.Interfaces.GridRegion;
@@ -27,6 +29,8 @@ namespace OpenSim.Services.LLLoginService
27 29
28 private string m_DefaultRegionName; 30 private string m_DefaultRegionName;
29 private string m_RemoteSimulationDll; 31 private string m_RemoteSimulationDll;
32 private string m_WelcomeMessage;
33 private bool m_RequireInventory;
30 34
31 public LLLoginService(IConfigSource config, ISimulationService simService) 35 public LLLoginService(IConfigSource config, ISimulationService simService)
32 { 36 {
@@ -42,6 +46,8 @@ namespace OpenSim.Services.LLLoginService
42 46
43 m_DefaultRegionName = serverConfig.GetString("DefaultRegion", String.Empty); 47 m_DefaultRegionName = serverConfig.GetString("DefaultRegion", String.Empty);
44 m_RemoteSimulationDll = serverConfig.GetString("RemoteSimulationService", String.Empty); 48 m_RemoteSimulationDll = serverConfig.GetString("RemoteSimulationService", String.Empty);
49 m_WelcomeMessage = serverConfig.GetString("WelcomeMessage", "Welcome to OpenSim!");
50 m_RequireInventory = serverConfig.GetBoolean("RequireInventory", true);
45 51
46 // These 3 are required; the other 2 aren't 52 // These 3 are required; the other 2 aren't
47 if (accountService == string.Empty || authService == string.Empty || 53 if (accountService == string.Empty || authService == string.Empty ||
@@ -64,50 +70,76 @@ namespace OpenSim.Services.LLLoginService
64 { 70 {
65 } 71 }
66 72
67 public LoginResponse Login(string firstName, string lastName, string passwd, string startLocation) 73 public LoginResponse Login(string firstName, string lastName, string passwd, string startLocation, IPEndPoint clientIP)
68 { 74 {
69 bool success = false; 75 bool success = false;
70 76
71 // Get the account and check that it exists 77 // Get the account and check that it exists
72 UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, firstName, lastName); 78 UserAccount account = m_UserAccountService.GetUserAccount(UUID.Zero, firstName, lastName);
73 if (account == null) 79 if (account == null)
80 {
81 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: user not found");
74 return LLFailedLoginResponse.UserProblem; 82 return LLFailedLoginResponse.UserProblem;
83 }
75 84
76 // Authenticate this user 85 // Authenticate this user
77 string token = m_AuthenticationService.Authenticate(account.PrincipalID, passwd, 30); 86 string token = m_AuthenticationService.Authenticate(account.PrincipalID, passwd, 30);
78 UUID secureSession = UUID.Zero; 87 UUID secureSession = UUID.Zero;
79 if ((token == string.Empty) || (token != string.Empty && !UUID.TryParse(token, out secureSession))) 88 if ((token == string.Empty) || (token != string.Empty && !UUID.TryParse(token, out secureSession)))
89 {
90 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: authentication failed");
80 return LLFailedLoginResponse.UserProblem; 91 return LLFailedLoginResponse.UserProblem;
92 }
81 93
82 // Get the user's inventory 94 // Get the user's inventory
83 List<InventoryFolderBase> inventorySkel = m_InventoryService.GetInventorySkeleton(account.PrincipalID); 95 List<InventoryFolderBase> inventorySkel = m_InventoryService.GetInventorySkeleton(account.PrincipalID);
84 if ((inventorySkel == null) || (inventorySkel != null && inventorySkel.Count == 0)) 96 if (m_RequireInventory && ((inventorySkel == null) || (inventorySkel != null && inventorySkel.Count == 0)))
97 {
98 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: unable to retrieve user inventory");
85 return LLFailedLoginResponse.InventoryProblem; 99 return LLFailedLoginResponse.InventoryProblem;
100 }
86 101
87 // Login the presence 102 // Login the presence
103 // We may want to check for user already logged in, to
104 // stay compatible with what people expect...
88 UUID session = UUID.Random(); 105 UUID session = UUID.Random();
106 PresenceInfo presence = null;
107 GridRegion home = null;
89 if (m_PresenceService != null) 108 if (m_PresenceService != null)
90 { 109 {
91 success = m_PresenceService.LoginAgent(account.PrincipalID.ToString(), session, secureSession); 110 success = m_PresenceService.LoginAgent(account.PrincipalID.ToString(), session, secureSession);
92 if (!success) 111 if (!success)
112 {
113 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: could not login presence");
93 return LLFailedLoginResponse.GridProblem; 114 return LLFailedLoginResponse.GridProblem;
115 }
116 // Get the updated presence info
117 presence = m_PresenceService.GetAgent(session);
118
119 // Get the home region
120 if ((presence.HomeRegionID != UUID.Zero) && m_GridService != null)
121 {
122 home = m_GridService.GetRegionByUUID(account.ScopeID, presence.HomeRegionID);
123 }
94 } 124 }
95 125
96 // Find the destination region/grid 126 // Find the destination region/grid
97 string where = string.Empty; 127 string where = string.Empty;
98 Vector3 position = Vector3.Zero; 128 Vector3 position = Vector3.Zero;
99 Vector3 lookAt = Vector3.Zero; 129 Vector3 lookAt = Vector3.Zero;
100 GridRegion destination = FindDestination(account, session, startLocation, out where, out position, out lookAt); 130 GridRegion destination = FindDestination(account, presence, session, startLocation, out where, out position, out lookAt);
101 if (destination == null) 131 if (destination == null)
102 { 132 {
103 m_PresenceService.LogoutAgent(session); 133 m_PresenceService.LogoutAgent(session);
134 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: destination not found");
104 return LLFailedLoginResponse.GridProblem; 135 return LLFailedLoginResponse.GridProblem;
105 } 136 }
106 137
107 // Instantiate/get the simulation interface and launch an agent at the destination 138 // Instantiate/get the simulation interface and launch an agent at the destination
108 ISimulationService simConnector = null; 139 ISimulationService simConnector = null;
109 success = false;
110 string reason = string.Empty; 140 string reason = string.Empty;
141 uint circuitCode = 0;
142 AgentCircuitData aCircuit = null;
111 Object[] args = new Object[] { destination }; 143 Object[] args = new Object[] { destination };
112 // HG standalones have both a localSimulatonDll and a remoteSimulationDll 144 // HG standalones have both a localSimulatonDll and a remoteSimulationDll
113 // non-HG standalones have just a localSimulationDll 145 // non-HG standalones have just a localSimulationDll
@@ -117,20 +149,27 @@ namespace OpenSim.Services.LLLoginService
117 else if (m_RemoteSimulationDll != string.Empty) 149 else if (m_RemoteSimulationDll != string.Empty)
118 simConnector = ServerUtils.LoadPlugin<ISimulationService>(m_RemoteSimulationDll, args); 150 simConnector = ServerUtils.LoadPlugin<ISimulationService>(m_RemoteSimulationDll, args);
119 if (simConnector != null) 151 if (simConnector != null)
120 success = LaunchAgent(simConnector, destination, account, session, out reason); 152 {
121 if (!success) 153 circuitCode = (uint)Util.RandomClass.Next(); ;
154 aCircuit = LaunchAgent(simConnector, destination, account, session, secureSession, circuitCode, position, out reason);
155 }
156 if (aCircuit == null)
122 { 157 {
123 m_PresenceService.LogoutAgent(session); 158 m_PresenceService.LogoutAgent(session);
159 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: {0}", reason);
124 return LLFailedLoginResponse.GridProblem; 160 return LLFailedLoginResponse.GridProblem;
125 } 161 }
126 162
163 // TODO: Get Friends list...
164
127 // Finally, fill out the response and return it 165 // Finally, fill out the response and return it
128 LLLoginResponse response = new LLLoginResponse(); 166 LLLoginResponse response = new LLLoginResponse(account, aCircuit, presence, destination, inventorySkel,
129 //.... 167 where, startLocation, position, lookAt, m_WelcomeMessage, home, clientIP);
168
130 return response; 169 return response;
131 } 170 }
132 171
133 private GridRegion FindDestination(UserAccount account, UUID sessionID, string startLocation, out string where, out Vector3 position, out Vector3 lookAt) 172 private GridRegion FindDestination(UserAccount account, PresenceInfo pinfo, UUID sessionID, string startLocation, out string where, out Vector3 position, out Vector3 lookAt)
134 { 173 {
135 where = "home"; 174 where = "home";
136 position = new Vector3(128, 128, 0); 175 position = new Vector3(128, 128, 0);
@@ -141,12 +180,11 @@ namespace OpenSim.Services.LLLoginService
141 if (m_PresenceService == null || m_GridService == null) 180 if (m_PresenceService == null || m_GridService == null)
142 return null; 181 return null;
143 182
144 GridRegion region = null;
145 PresenceInfo pinfo = m_PresenceService.GetAgent(sessionID);
146 // this should succeed; if it doesn't there's something wrong with this grid
147 if (pinfo == null) 183 if (pinfo == null)
148 return null; 184 return null;
149 185
186 GridRegion region = null;
187
150 if (pinfo.HomeRegionID.Equals(UUID.Zero)) 188 if (pinfo.HomeRegionID.Equals(UUID.Zero))
151 region = m_GridService.GetRegionByName(account.ScopeID, m_DefaultRegionName); 189 region = m_GridService.GetRegionByName(account.ScopeID, m_DefaultRegionName);
152 else 190 else
@@ -161,12 +199,11 @@ namespace OpenSim.Services.LLLoginService
161 if (m_PresenceService == null || m_GridService == null) 199 if (m_PresenceService == null || m_GridService == null)
162 return null; 200 return null;
163 201
164 GridRegion region = null;
165 PresenceInfo pinfo = m_PresenceService.GetAgent(sessionID);
166 // this should succeed; if it doesn't there's something wrong with this grid
167 if (pinfo == null) 202 if (pinfo == null)
168 return null; 203 return null;
169 204
205 GridRegion region = null;
206
170 if (pinfo.RegionID.Equals(UUID.Zero)) 207 if (pinfo.RegionID.Equals(UUID.Zero))
171 region = m_GridService.GetRegionByName(account.ScopeID, m_DefaultRegionName); 208 region = m_GridService.GetRegionByName(account.ScopeID, m_DefaultRegionName);
172 else 209 else
@@ -250,24 +287,29 @@ namespace OpenSim.Services.LLLoginService
250 287
251 } 288 }
252 289
253 private bool LaunchAgent(ISimulationService simConnector, GridRegion region, UserAccount account, UUID session, out string reason) 290 private AgentCircuitData LaunchAgent(ISimulationService simConnector, GridRegion region, UserAccount account,
291 UUID session, UUID secureSession, uint circuit, Vector3 position, out string reason)
254 { 292 {
255 reason = string.Empty; 293 reason = string.Empty;
256 AgentCircuitData aCircuit = new AgentCircuitData(); 294 AgentCircuitData aCircuit = new AgentCircuitData();
295
257 aCircuit.AgentID = account.PrincipalID; 296 aCircuit.AgentID = account.PrincipalID;
258 //aCircuit.Appearance = optional 297 //aCircuit.Appearance = optional
259 //aCircuit.BaseFolder = irrelevant 298 //aCircuit.BaseFolder = irrelevant
260 //aCircuit.CapsPath = required 299 aCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath();
261 aCircuit.child = false; 300 aCircuit.child = false;
262 //aCircuit.circuitcode = required 301 aCircuit.circuitcode = circuit;
263 aCircuit.firstname = account.FirstName; 302 aCircuit.firstname = account.FirstName;
264 //aCircuit.InventoryFolder = irrelevant 303 //aCircuit.InventoryFolder = irrelevant
265 aCircuit.lastname = account.LastName; 304 aCircuit.lastname = account.LastName;
266 //aCircuit.SecureSessionID = required 305 aCircuit.SecureSessionID = secureSession;
267 aCircuit.SessionID = session; 306 aCircuit.SessionID = session;
268 //aCircuit.startpos = required 307 aCircuit.startpos = position;
308
309 if (simConnector.CreateAgent(region.RegionHandle, aCircuit, 0, out reason))
310 return aCircuit;
269 311
270 return simConnector.CreateAgent(region.RegionHandle, aCircuit, 0, out reason); 312 return null;
271 313
272 } 314 }
273 } 315 }