aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services')
-rw-r--r--OpenSim/Services/Connectors/GridUser/GridUserServiceConnector.cs196
-rw-r--r--OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs54
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs88
-rw-r--r--OpenSim/Services/HypergridService/UserAgentService.cs21
-rw-r--r--OpenSim/Services/Interfaces/IGridUserService.cs42
-rw-r--r--OpenSim/Services/Interfaces/IPresenceService.cs24
-rw-r--r--OpenSim/Services/LLLoginService/LLLoginResponse.cs4
-rw-r--r--OpenSim/Services/LLLoginService/LLLoginService.cs63
-rw-r--r--OpenSim/Services/PresenceService/PresenceService.cs79
-rw-r--r--OpenSim/Services/UserAccountService/GridUserService.cs95
-rw-r--r--OpenSim/Services/UserAccountService/UserAccountService.cs10
11 files changed, 465 insertions, 211 deletions
diff --git a/OpenSim/Services/Connectors/GridUser/GridUserServiceConnector.cs b/OpenSim/Services/Connectors/GridUser/GridUserServiceConnector.cs
index 0e85067..b4500a5 100644
--- a/OpenSim/Services/Connectors/GridUser/GridUserServiceConnector.cs
+++ b/OpenSim/Services/Connectors/GridUser/GridUserServiceConnector.cs
@@ -25,14 +25,206 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using log4net;
28using System; 29using System;
30using System.Collections.Generic;
31using System.IO;
32using System.Reflection;
33using Nini.Config;
34using OpenSim.Framework;
35using OpenSim.Framework.Communications;
36using OpenSim.Framework.Servers.HttpServer;
37using OpenSim.Services.Interfaces;
38using GridRegion = OpenSim.Services.Interfaces.GridRegion;
39using OpenSim.Server.Base;
40using OpenMetaverse;
29 41
30namespace OpenSim.Services.Connectors 42namespace OpenSim.Services.Connectors
31{ 43{
32 public class GridUserServiceConnector 44 public class GridUserServicesConnector : IGridUserService
33 { 45 {
34 public GridUserServiceConnector() 46 private static readonly ILog m_log =
47 LogManager.GetLogger(
48 MethodBase.GetCurrentMethod().DeclaringType);
49
50 private string m_ServerURI = String.Empty;
51
52 public GridUserServicesConnector()
53 {
54 }
55
56 public GridUserServicesConnector(string serverURI)
57 {
58 m_ServerURI = serverURI.TrimEnd('/');
59 }
60
61 public GridUserServicesConnector(IConfigSource source)
62 {
63 Initialise(source);
64 }
65
66 public virtual void Initialise(IConfigSource source)
67 {
68 IConfig gridConfig = source.Configs["GridUserService"];
69 if (gridConfig == null)
70 {
71 m_log.Error("[GRID USER CONNECTOR]: GridUserService missing from OpenSim.ini");
72 throw new Exception("GridUser connector init error");
73 }
74
75 string serviceURI = gridConfig.GetString("GridUserServerURI",
76 String.Empty);
77
78 if (serviceURI == String.Empty)
79 {
80 m_log.Error("[GRID USER CONNECTOR]: No Server URI named in section GridUserService");
81 throw new Exception("GridUser connector init error");
82 }
83 m_ServerURI = serviceURI;
84 }
85
86
87 #region IPresenceService
88
89
90 public GridUserInfo LoggedIn(string userID)
91 {
92 Dictionary<string, object> sendData = new Dictionary<string, object>();
93 //sendData["SCOPEID"] = scopeID.ToString();
94 sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
95 sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
96 sendData["METHOD"] = "loggedin";
97
98 sendData["UserID"] = userID;
99
100 return Get(sendData);
101
102 }
103
104 public bool LoggedOut(string userID, UUID region, Vector3 position, Vector3 lookat)
105 {
106 Dictionary<string, object> sendData = new Dictionary<string, object>();
107 //sendData["SCOPEID"] = scopeID.ToString();
108 sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
109 sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
110 sendData["METHOD"] = "loggedout";
111
112 return Set(sendData, userID, region, position, lookat);
113 }
114
115 public bool SetHome(string userID, UUID regionID, Vector3 position, Vector3 lookAt)
116 {
117 Dictionary<string, object> sendData = new Dictionary<string, object>();
118 //sendData["SCOPEID"] = scopeID.ToString();
119 sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
120 sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
121 sendData["METHOD"] = "sethome";
122
123 return Set(sendData, userID, regionID, position, lookAt);
124 }
125
126 public bool SetLastPosition(string userID, UUID regionID, Vector3 position, Vector3 lookAt)
127 {
128 Dictionary<string, object> sendData = new Dictionary<string, object>();
129 //sendData["SCOPEID"] = scopeID.ToString();
130 sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
131 sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
132 sendData["METHOD"] = "setposition";
133
134 return Set(sendData, userID, regionID, position, lookAt);
135 }
136
137 public GridUserInfo GetGridUserInfo(string userID)
138 {
139 Dictionary<string, object> sendData = new Dictionary<string, object>();
140 //sendData["SCOPEID"] = scopeID.ToString();
141 sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
142 sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
143 sendData["METHOD"] = "getgriduserinfo";
144
145 sendData["UserID"] = userID;
146
147 return Get(sendData);
148 }
149
150 #endregion
151
152 protected bool Set(Dictionary<string, object> sendData, string userID, UUID regionID, Vector3 position, Vector3 lookAt)
153 {
154 sendData["UserID"] = userID;
155 sendData["RegionID"] = regionID.ToString();
156 sendData["Position"] = position.ToString();
157 sendData["LookAt"] = lookAt.ToString();
158
159 string reqString = ServerUtils.BuildQueryString(sendData);
160 // m_log.DebugFormat("[GRID USER CONNECTOR]: queryString = {0}", reqString);
161 try
162 {
163 string reply = SynchronousRestFormsRequester.MakeRequest("POST",
164 m_ServerURI + "/griduser",
165 reqString);
166 if (reply != string.Empty)
167 {
168 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
169
170 if (replyData.ContainsKey("result"))
171 {
172 if (replyData["result"].ToString().ToLower() == "success")
173 return true;
174 else
175 return false;
176 }
177 else
178 m_log.DebugFormat("[GRID USER CONNECTOR]: SetPosition reply data does not contain result field");
179
180 }
181 else
182 m_log.DebugFormat("[GRID USER CONNECTOR]: SetPosition received empty reply");
183 }
184 catch (Exception e)
185 {
186 m_log.DebugFormat("[GRID USER CONNECTOR]: Exception when contacting grid user server: {0}", e.Message);
187 }
188
189 return false;
190 }
191
192 protected GridUserInfo Get(Dictionary<string, object> sendData)
35 { 193 {
194 string reqString = ServerUtils.BuildQueryString(sendData);
195 // m_log.DebugFormat("[GRID USER CONNECTOR]: queryString = {0}", reqString);
196 try
197 {
198 string reply = SynchronousRestFormsRequester.MakeRequest("POST",
199 m_ServerURI + "/griduser",
200 reqString);
201 if (reply != string.Empty)
202 {
203 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
204 GridUserInfo guinfo = null;
205
206 if ((replyData != null) && replyData.ContainsKey("result") && (replyData["result"] != null))
207 {
208 if (replyData["result"] is Dictionary<string, object>)
209 {
210 guinfo = new GridUserInfo((Dictionary<string, object>)replyData["result"]);
211 }
212 }
213
214 return guinfo;
215
216 }
217 else
218 m_log.DebugFormat("[GRID USER CONNECTOR]: Loggedin received empty reply");
219 }
220 catch (Exception e)
221 {
222 m_log.DebugFormat("[GRID USER CONNECTOR]: Exception when contacting grid user server: {0}", e.Message);
223 }
224
225 return null;
226
36 } 227 }
228
37 } 229 }
38} 230}
diff --git a/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs b/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs
index 23621b7..41ebeaf 100644
--- a/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs
+++ b/OpenSim/Services/Connectors/Presence/PresenceServiceConnector.cs
@@ -132,7 +132,7 @@ namespace OpenSim.Services.Connectors
132 132
133 } 133 }
134 134
135 public bool LogoutAgent(UUID sessionID, Vector3 position, Vector3 lookat) 135 public bool LogoutAgent(UUID sessionID)
136 { 136 {
137 Dictionary<string, object> sendData = new Dictionary<string, object>(); 137 Dictionary<string, object> sendData = new Dictionary<string, object>();
138 //sendData["SCOPEID"] = scopeID.ToString(); 138 //sendData["SCOPEID"] = scopeID.ToString();
@@ -141,8 +141,6 @@ namespace OpenSim.Services.Connectors
141 sendData["METHOD"] = "logout"; 141 sendData["METHOD"] = "logout";
142 142
143 sendData["SessionID"] = sessionID.ToString(); 143 sendData["SessionID"] = sessionID.ToString();
144 sendData["Position"] = position.ToString();
145 sendData["LookAt"] = lookat.ToString();
146 144
147 string reqString = ServerUtils.BuildQueryString(sendData); 145 string reqString = ServerUtils.BuildQueryString(sendData);
148 // m_log.DebugFormat("[PRESENCE CONNECTOR]: queryString = {0}", reqString); 146 // m_log.DebugFormat("[PRESENCE CONNECTOR]: queryString = {0}", reqString);
@@ -220,7 +218,7 @@ namespace OpenSim.Services.Connectors
220 return false; 218 return false;
221 } 219 }
222 220
223 public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt) 221 public bool ReportAgent(UUID sessionID, UUID regionID)
224 { 222 {
225 Dictionary<string, object> sendData = new Dictionary<string, object>(); 223 Dictionary<string, object> sendData = new Dictionary<string, object>();
226 //sendData["SCOPEID"] = scopeID.ToString(); 224 //sendData["SCOPEID"] = scopeID.ToString();
@@ -230,8 +228,6 @@ namespace OpenSim.Services.Connectors
230 228
231 sendData["SessionID"] = sessionID.ToString(); 229 sendData["SessionID"] = sessionID.ToString();
232 sendData["RegionID"] = regionID.ToString(); 230 sendData["RegionID"] = regionID.ToString();
233 sendData["position"] = position.ToString();
234 sendData["lookAt"] = lookAt.ToString();
235 231
236 string reqString = ServerUtils.BuildQueryString(sendData); 232 string reqString = ServerUtils.BuildQueryString(sendData);
237 // m_log.DebugFormat("[PRESENCE CONNECTOR]: queryString = {0}", reqString); 233 // m_log.DebugFormat("[PRESENCE CONNECTOR]: queryString = {0}", reqString);
@@ -371,52 +367,6 @@ namespace OpenSim.Services.Connectors
371 } 367 }
372 368
373 369
374 public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt)
375 {
376 Dictionary<string, object> sendData = new Dictionary<string, object>();
377 //sendData["SCOPEID"] = scopeID.ToString();
378 sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
379 sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
380 sendData["METHOD"] = "sethome";
381
382 sendData["UserID"] = userID;
383 sendData["RegionID"] = regionID.ToString();
384 sendData["position"] = position.ToString();
385 sendData["lookAt"] = lookAt.ToString();
386
387 string reqString = ServerUtils.BuildQueryString(sendData);
388 // m_log.DebugFormat("[PRESENCE CONNECTOR]: queryString = {0}", reqString);
389 try
390 {
391 string reply = SynchronousRestFormsRequester.MakeRequest("POST",
392 m_ServerURI + "/presence",
393 reqString);
394 if (reply != string.Empty)
395 {
396 Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
397
398 if (replyData.ContainsKey("result"))
399 {
400 if (replyData["result"].ToString().ToLower() == "success")
401 return true;
402 else
403 return false;
404 }
405 else
406 m_log.DebugFormat("[PRESENCE CONNECTOR]: SetHomeLocation reply data does not contain result field");
407
408 }
409 else
410 m_log.DebugFormat("[PRESENCE CONNECTOR]: SetHomeLocation received empty reply");
411 }
412 catch (Exception e)
413 {
414 m_log.DebugFormat("[PRESENCE CONNECTOR]: Exception when contacting presence server: {0}", e.Message);
415 }
416
417 return false;
418 }
419
420 #endregion 370 #endregion
421 371
422 } 372 }
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs
index c324272..e48b7de 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs
@@ -51,7 +51,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
51 /// message routing) to the SimianGrid backend 51 /// message routing) to the SimianGrid backend
52 /// </summary> 52 /// </summary>
53 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] 53 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
54 public class SimianPresenceServiceConnector : IPresenceService, ISharedRegionModule 54 public class SimianPresenceServiceConnector : IPresenceService, IGridUserService, ISharedRegionModule
55 { 55 {
56 private static readonly ILog m_log = 56 private static readonly ILog m_log =
57 LogManager.GetLogger( 57 LogManager.GetLogger(
@@ -73,6 +73,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
73 if (!String.IsNullOrEmpty(m_serverUrl)) 73 if (!String.IsNullOrEmpty(m_serverUrl))
74 { 74 {
75 scene.RegisterModuleInterface<IPresenceService>(this); 75 scene.RegisterModuleInterface<IPresenceService>(this);
76 scene.RegisterModuleInterface<IGridUserService>(this);
76 77
77 scene.EventManager.OnMakeRootAgent += MakeRootAgentHandler; 78 scene.EventManager.OnMakeRootAgent += MakeRootAgentHandler;
78 scene.EventManager.OnNewClient += NewClientHandler; 79 scene.EventManager.OnNewClient += NewClientHandler;
@@ -86,6 +87,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
86 if (!String.IsNullOrEmpty(m_serverUrl)) 87 if (!String.IsNullOrEmpty(m_serverUrl))
87 { 88 {
88 scene.UnregisterModuleInterface<IPresenceService>(this); 89 scene.UnregisterModuleInterface<IPresenceService>(this);
90 scene.UnregisterModuleInterface<IGridUserService>(this);
89 91
90 scene.EventManager.OnMakeRootAgent -= MakeRootAgentHandler; 92 scene.EventManager.OnMakeRootAgent -= MakeRootAgentHandler;
91 scene.EventManager.OnNewClient -= NewClientHandler; 93 scene.EventManager.OnNewClient -= NewClientHandler;
@@ -151,7 +153,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
151 return success; 153 return success;
152 } 154 }
153 155
154 public bool LogoutAgent(UUID sessionID, Vector3 position, Vector3 lookAt) 156 public bool LogoutAgent(UUID sessionID)
155 { 157 {
156 m_log.InfoFormat("[SIMIAN PRESENCE CONNECTOR]: Logout requested for agent with sessionID " + sessionID); 158 m_log.InfoFormat("[SIMIAN PRESENCE CONNECTOR]: Logout requested for agent with sessionID " + sessionID);
157 159
@@ -189,7 +191,12 @@ namespace OpenSim.Services.Connectors.SimianGrid
189 return success; 191 return success;
190 } 192 }
191 193
192 public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt) 194 public bool ReportAgent(UUID sessionID, UUID regionID)
195 {
196 return ReportAgent(sessionID, regionID, Vector3.Zero, Vector3.Zero);
197 }
198
199 protected bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt)
193 { 200 {
194 //m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Updating session data for agent with sessionID " + sessionID); 201 //m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Updating session data for agent with sessionID " + sessionID);
195 202
@@ -261,7 +268,23 @@ namespace OpenSim.Services.Connectors.SimianGrid
261 return presences.ToArray(); 268 return presences.ToArray();
262 } 269 }
263 270
264 public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt) 271 #endregion IPresenceService
272
273 #region IGridUserService
274
275 public GridUserInfo LoggedIn(string userID)
276 {
277 // never implemented at the sim
278 return null;
279 }
280
281 public bool LoggedOut(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt)
282 {
283 // Not needed for simian grid, event handler is doing it
284 return true;
285 }
286
287 public bool SetHome(string userID, UUID regionID, Vector3 position, Vector3 lookAt)
265 { 288 {
266 m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Setting home location for user " + userID); 289 m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Setting home location for user " + userID);
267 290
@@ -281,7 +304,35 @@ namespace OpenSim.Services.Connectors.SimianGrid
281 return success; 304 return success;
282 } 305 }
283 306
284 #endregion IPresenceService 307 public bool SetLastPosition(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt)
308 {
309 // Not needed for simian grid, presence detection is doing it
310 return true;
311 }
312
313 public GridUserInfo GetGridUserInfo(string user)
314 {
315 m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting session data for agent " + user);
316
317 UUID userID = new UUID(user);
318 m_log.DebugFormat("[SIMIAN PRESENCE CONNECTOR]: Requesting user data for " + userID);
319
320 NameValueCollection requestArgs = new NameValueCollection
321 {
322 { "RequestMethod", "GetUser" },
323 { "UserID", userID.ToString() }
324 };
325
326 OSDMap userResponse = WebUtil.PostToService(m_serverUrl, requestArgs);
327 if (userResponse["Success"].AsBoolean())
328 return ResponseToGridUserInfo(userResponse);
329 else
330 m_log.Warn("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for " + userID + ": " + userResponse["Message"].AsString());
331
332 return null;
333 }
334
335 #endregion
285 336
286 #region Presence Detection 337 #region Presence Detection
287 338
@@ -325,7 +376,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
325 SetLastLocation(client.SessionId); 376 SetLastLocation(client.SessionId);
326 } 377 }
327 378
328 LogoutAgent(client.SessionId, Vector3.Zero, Vector3.UnitX); 379 LogoutAgent(client.SessionId);
329 } 380 }
330 } 381 }
331 382
@@ -478,6 +529,31 @@ namespace OpenSim.Services.Connectors.SimianGrid
478 return info; 529 return info;
479 } 530 }
480 531
532 private GridUserInfo ResponseToGridUserInfo(OSDMap userResponse)
533 {
534 if (userResponse != null && userResponse["User"] is OSDMap)
535 {
536
537 GridUserInfo info = new GridUserInfo();
538
539 info.Online = true;
540 info.UserID = userResponse["UserID"].AsUUID().ToString();
541 info.LastRegionID = userResponse["SceneID"].AsUUID();
542 info.LastPosition = userResponse["ScenePosition"].AsVector3();
543 info.LastLookAt = userResponse["SceneLookAt"].AsVector3();
544
545 OSDMap user = (OSDMap)userResponse["User"];
546
547 info.Login = user["LastLoginDate"].AsDate();
548 info.Logout = user["LastLogoutDate"].AsDate();
549 DeserializeLocation(user["HomeLocation"].AsString(), out info.HomeRegionID, out info.HomePosition, out info.HomeLookAt);
550
551 return info;
552 }
553
554 return null;
555 }
556
481 private string SerializeLocation(UUID regionID, Vector3 position, Vector3 lookAt) 557 private string SerializeLocation(UUID regionID, Vector3 position, Vector3 lookAt)
482 { 558 {
483 return "{" + String.Format("\"SceneID\":\"{0}\",\"Position\":\"{1}\",\"LookAt\":\"{2}\"", regionID, position, lookAt) + "}"; 559 return "{" + String.Format("\"SceneID\":\"{0}\",\"Position\":\"{1}\",\"LookAt\":\"{2}\"", regionID, position, lookAt) + "}";
diff --git a/OpenSim/Services/HypergridService/UserAgentService.cs b/OpenSim/Services/HypergridService/UserAgentService.cs
index 26f211b..3af7ef9 100644
--- a/OpenSim/Services/HypergridService/UserAgentService.cs
+++ b/OpenSim/Services/HypergridService/UserAgentService.cs
@@ -59,7 +59,7 @@ namespace OpenSim.Services.HypergridService
59 59
60 static bool m_Initialized = false; 60 static bool m_Initialized = false;
61 61
62 protected static IPresenceService m_PresenceService; 62 protected static IGridUserService m_GridUserService;
63 protected static IGridService m_GridService; 63 protected static IGridService m_GridService;
64 protected static GatekeeperServiceConnector m_GatekeeperConnector; 64 protected static GatekeeperServiceConnector m_GatekeeperConnector;
65 65
@@ -74,14 +74,14 @@ namespace OpenSim.Services.HypergridService
74 throw new Exception(String.Format("No section UserAgentService in config file")); 74 throw new Exception(String.Format("No section UserAgentService in config file"));
75 75
76 string gridService = serverConfig.GetString("GridService", String.Empty); 76 string gridService = serverConfig.GetString("GridService", String.Empty);
77 string presenceService = serverConfig.GetString("PresenceService", String.Empty); 77 string gridUserService = serverConfig.GetString("GridUserService", String.Empty);
78 78
79 if (gridService == string.Empty || presenceService == string.Empty) 79 if (gridService == string.Empty || gridUserService == string.Empty)
80 throw new Exception(String.Format("Incomplete specifications, UserAgent Service cannot function.")); 80 throw new Exception(String.Format("Incomplete specifications, UserAgent Service cannot function."));
81 81
82 Object[] args = new Object[] { config }; 82 Object[] args = new Object[] { config };
83 m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args); 83 m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args);
84 m_PresenceService = ServerUtils.LoadPlugin<IPresenceService>(presenceService, args); 84 m_GridUserService = ServerUtils.LoadPlugin<IGridUserService>(gridUserService, args);
85 m_GatekeeperConnector = new GatekeeperServiceConnector(); 85 m_GatekeeperConnector = new GatekeeperServiceConnector();
86 86
87 m_Initialized = true; 87 m_Initialized = true;
@@ -95,15 +95,14 @@ namespace OpenSim.Services.HypergridService
95 m_log.DebugFormat("[USER AGENT SERVICE]: Request to get home region of user {0}", userID); 95 m_log.DebugFormat("[USER AGENT SERVICE]: Request to get home region of user {0}", userID);
96 96
97 GridRegion home = null; 97 GridRegion home = null;
98 PresenceInfo[] presences = m_PresenceService.GetAgents(new string[] { userID.ToString() }); 98 GridUserInfo uinfo = m_GridUserService.GetGridUserInfo(userID.ToString());
99 if (presences != null && presences.Length > 0) 99 if (uinfo != null)
100 { 100 {
101 UUID homeID = presences[0].HomeRegionID; 101 if (uinfo.HomeRegionID != UUID.Zero)
102 if (homeID != UUID.Zero)
103 { 102 {
104 home = m_GridService.GetRegionByUUID(UUID.Zero, homeID); 103 home = m_GridService.GetRegionByUUID(UUID.Zero, uinfo.HomeRegionID);
105 position = presences[0].HomePosition; 104 position = uinfo.HomePosition;
106 lookAt = presences[0].HomeLookAt; 105 lookAt = uinfo.HomeLookAt;
107 } 106 }
108 if (home == null) 107 if (home == null)
109 { 108 {
diff --git a/OpenSim/Services/Interfaces/IGridUserService.cs b/OpenSim/Services/Interfaces/IGridUserService.cs
index a7c2c6f..e629dff 100644
--- a/OpenSim/Services/Interfaces/IGridUserService.cs
+++ b/OpenSim/Services/Interfaces/IGridUserService.cs
@@ -37,39 +37,79 @@ namespace OpenSim.Services.Interfaces
37 public class GridUserInfo 37 public class GridUserInfo
38 { 38 {
39 public string UserID; 39 public string UserID;
40
40 public UUID HomeRegionID; 41 public UUID HomeRegionID;
41 public Vector3 HomePosition; 42 public Vector3 HomePosition;
42 public Vector3 HomeLookAt; 43 public Vector3 HomeLookAt;
43 44
45 public UUID LastRegionID;
46 public Vector3 LastPosition;
47 public Vector3 LastLookAt;
48
49 public bool Online;
50 public DateTime Login;
51 public DateTime Logout;
52
44 public GridUserInfo() {} 53 public GridUserInfo() {}
45 54
46 public GridUserInfo(Dictionary<string, object> kvp) 55 public GridUserInfo(Dictionary<string, object> kvp)
47 { 56 {
48 if (kvp.ContainsKey("UserID")) 57 if (kvp.ContainsKey("UserID"))
49 UserID = kvp["UserID"].ToString(); 58 UserID = kvp["UserID"].ToString();
59
50 if (kvp.ContainsKey("HomeRegionID")) 60 if (kvp.ContainsKey("HomeRegionID"))
51 UUID.TryParse(kvp["HomeRegionID"].ToString(), out HomeRegionID); 61 UUID.TryParse(kvp["HomeRegionID"].ToString(), out HomeRegionID);
52 if (kvp.ContainsKey("HomePosition")) 62 if (kvp.ContainsKey("HomePosition"))
53 Vector3.TryParse(kvp["HomePosition"].ToString(), out HomePosition); 63 Vector3.TryParse(kvp["HomePosition"].ToString(), out HomePosition);
54 if (kvp.ContainsKey("HomeLookAt")) 64 if (kvp.ContainsKey("HomeLookAt"))
55 Vector3.TryParse(kvp["HomeLookAt"].ToString(), out HomeLookAt); 65 Vector3.TryParse(kvp["HomeLookAt"].ToString(), out HomeLookAt);
66
67 if (kvp.ContainsKey("LastRegionID"))
68 UUID.TryParse(kvp["LastRegionID"].ToString(), out HomeRegionID);
69 if (kvp.ContainsKey("LastPosition"))
70 Vector3.TryParse(kvp["LastPosition"].ToString(), out LastPosition);
71 if (kvp.ContainsKey("LastLookAt"))
72 Vector3.TryParse(kvp["LastLookAt"].ToString(), out LastLookAt);
73
74 if (kvp.ContainsKey("Login"))
75 DateTime.TryParse(kvp["Login"].ToString(), out Login);
76 if (kvp.ContainsKey("Logout"))
77 DateTime.TryParse(kvp["Logout"].ToString(), out Logout);
78 if (kvp.ContainsKey("Online"))
79 Boolean.TryParse(kvp["Online"].ToString(), out Online);
80
56 } 81 }
57 82
58 public Dictionary<string, object> ToKeyValuePairs() 83 public Dictionary<string, object> ToKeyValuePairs()
59 { 84 {
60 Dictionary<string, object> result = new Dictionary<string, object>(); 85 Dictionary<string, object> result = new Dictionary<string, object>();
61 result["UserID"] = UserID; 86 result["UserID"] = UserID;
87
62 result["HomeRegionID"] = HomeRegionID.ToString(); 88 result["HomeRegionID"] = HomeRegionID.ToString();
63 result["HomePosition"] = HomePosition.ToString(); 89 result["HomePosition"] = HomePosition.ToString();
64 result["HomeLookAt"] = HomeLookAt.ToString(); 90 result["HomeLookAt"] = HomeLookAt.ToString();
65 91
92 result["LastRegionID"] = LastRegionID.ToString();
93 result["LastPosition"] = LastPosition.ToString();
94 result["LastLookAt"] = LastLookAt.ToString();
95
96 result["Online"] = Online.ToString();
97 result["Login"] = Login.ToString();
98 result["Logout"] = Logout.ToString();
99
100
66 return result; 101 return result;
67 } 102 }
68 } 103 }
69 104
70 public interface IGridUserService 105 public interface IGridUserService
71 { 106 {
107 GridUserInfo LoggedIn(string userID);
108 bool LoggedOut(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt);
109
110 bool SetHome(string userID, UUID homeID, Vector3 homePosition, Vector3 homeLookAt);
111 bool SetLastPosition(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt);
112
72 GridUserInfo GetGridUserInfo(string userID); 113 GridUserInfo GetGridUserInfo(string userID);
73 bool StoreGridUserInfo(GridUserInfo info);
74 } 114 }
75} \ No newline at end of file 115} \ No newline at end of file
diff --git a/OpenSim/Services/Interfaces/IPresenceService.cs b/OpenSim/Services/Interfaces/IPresenceService.cs
index b4c1859..9687d22 100644
--- a/OpenSim/Services/Interfaces/IPresenceService.cs
+++ b/OpenSim/Services/Interfaces/IPresenceService.cs
@@ -55,23 +55,10 @@ namespace OpenSim.Services.Interfaces
55 UserID = kvp["UserID"].ToString(); 55 UserID = kvp["UserID"].ToString();
56 if (kvp.ContainsKey("RegionID")) 56 if (kvp.ContainsKey("RegionID"))
57 UUID.TryParse(kvp["RegionID"].ToString(), out RegionID); 57 UUID.TryParse(kvp["RegionID"].ToString(), out RegionID);
58 if (kvp.ContainsKey("login"))
59 DateTime.TryParse(kvp["login"].ToString(), out Login);
60 if (kvp.ContainsKey("logout"))
61 DateTime.TryParse(kvp["logout"].ToString(), out Logout);
62 if (kvp.ContainsKey("lookAt")) 58 if (kvp.ContainsKey("lookAt"))
63 Vector3.TryParse(kvp["lookAt"].ToString(), out LookAt); 59 Vector3.TryParse(kvp["lookAt"].ToString(), out LookAt);
64 if (kvp.ContainsKey("online"))
65 Boolean.TryParse(kvp["online"].ToString(), out Online);
66 if (kvp.ContainsKey("position")) 60 if (kvp.ContainsKey("position"))
67 Vector3.TryParse(kvp["position"].ToString(), out Position); 61 Vector3.TryParse(kvp["position"].ToString(), out Position);
68 if (kvp.ContainsKey("HomeRegionID"))
69 UUID.TryParse(kvp["HomeRegionID"].ToString(), out HomeRegionID);
70 if (kvp.ContainsKey("HomePosition"))
71 Vector3.TryParse(kvp["HomePosition"].ToString(), out HomePosition);
72 if (kvp.ContainsKey("HomeLookAt"))
73 Vector3.TryParse(kvp["HomeLookAt"].ToString(), out HomeLookAt);
74
75 } 62 }
76 63
77 public Dictionary<string, object> ToKeyValuePairs() 64 public Dictionary<string, object> ToKeyValuePairs()
@@ -79,14 +66,8 @@ namespace OpenSim.Services.Interfaces
79 Dictionary<string, object> result = new Dictionary<string, object>(); 66 Dictionary<string, object> result = new Dictionary<string, object>();
80 result["UserID"] = UserID; 67 result["UserID"] = UserID;
81 result["RegionID"] = RegionID.ToString(); 68 result["RegionID"] = RegionID.ToString();
82 result["online"] = Online.ToString();
83 result["login"] = Login.ToString();
84 result["logout"] = Logout.ToString();
85 result["position"] = Position.ToString(); 69 result["position"] = Position.ToString();
86 result["lookAt"] = LookAt.ToString(); 70 result["lookAt"] = LookAt.ToString();
87 result["HomeRegionID"] = HomeRegionID.ToString();
88 result["HomePosition"] = HomePosition.ToString();
89 result["HomeLookAt"] = HomeLookAt.ToString();
90 71
91 return result; 72 return result;
92 } 73 }
@@ -115,11 +96,10 @@ namespace OpenSim.Services.Interfaces
115 public interface IPresenceService 96 public interface IPresenceService
116 { 97 {
117 bool LoginAgent(string userID, UUID sessionID, UUID secureSessionID); 98 bool LoginAgent(string userID, UUID sessionID, UUID secureSessionID);
118 bool LogoutAgent(UUID sessionID, Vector3 position, Vector3 lookAt); 99 bool LogoutAgent(UUID sessionID);
119 bool LogoutRegionAgents(UUID regionID); 100 bool LogoutRegionAgents(UUID regionID);
120 101
121 bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt); 102 bool ReportAgent(UUID sessionID, UUID regionID);
122 bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt);
123 103
124 PresenceInfo GetAgent(UUID sessionID); 104 PresenceInfo GetAgent(UUID sessionID);
125 PresenceInfo[] GetAgents(string[] userIDs); 105 PresenceInfo[] GetAgents(string[] userIDs);
diff --git a/OpenSim/Services/LLLoginService/LLLoginResponse.cs b/OpenSim/Services/LLLoginService/LLLoginResponse.cs
index ee30fa3..d1dcfe7 100644
--- a/OpenSim/Services/LLLoginService/LLLoginResponse.cs
+++ b/OpenSim/Services/LLLoginService/LLLoginResponse.cs
@@ -215,7 +215,7 @@ namespace OpenSim.Services.LLLoginService
215 SetDefaultValues(); 215 SetDefaultValues();
216 } 216 }
217 217
218 public LLLoginResponse(UserAccount account, AgentCircuitData aCircuit, PresenceInfo pinfo, 218 public LLLoginResponse(UserAccount account, AgentCircuitData aCircuit, GridUserInfo pinfo,
219 GridRegion destination, List<InventoryFolderBase> invSkel, FriendInfo[] friendsList, ILibraryService libService, 219 GridRegion destination, List<InventoryFolderBase> invSkel, FriendInfo[] friendsList, ILibraryService libService,
220 string where, string startlocation, Vector3 position, Vector3 lookAt, string message, 220 string where, string startlocation, Vector3 position, Vector3 lookAt, string message,
221 GridRegion home, IPEndPoint clientIP) 221 GridRegion home, IPEndPoint clientIP)
@@ -283,7 +283,7 @@ namespace OpenSim.Services.LLLoginService
283 } 283 }
284 } 284 }
285 285
286 private void FillOutHomeData(PresenceInfo pinfo, GridRegion home) 286 private void FillOutHomeData(GridUserInfo pinfo, GridRegion home)
287 { 287 {
288 int x = 1000 * (int)Constants.RegionSize, y = 1000 * (int)Constants.RegionSize; 288 int x = 1000 * (int)Constants.RegionSize, y = 1000 * (int)Constants.RegionSize;
289 if (home != null) 289 if (home != null)
diff --git a/OpenSim/Services/LLLoginService/LLLoginService.cs b/OpenSim/Services/LLLoginService/LLLoginService.cs
index be90d38..f97222e 100644
--- a/OpenSim/Services/LLLoginService/LLLoginService.cs
+++ b/OpenSim/Services/LLLoginService/LLLoginService.cs
@@ -53,6 +53,7 @@ namespace OpenSim.Services.LLLoginService
53 private static bool Initialized = false; 53 private static bool Initialized = false;
54 54
55 protected IUserAccountService m_UserAccountService; 55 protected IUserAccountService m_UserAccountService;
56 protected IGridUserService m_GridUserService;
56 protected IAuthenticationService m_AuthenticationService; 57 protected IAuthenticationService m_AuthenticationService;
57 protected IInventoryService m_InventoryService; 58 protected IInventoryService m_InventoryService;
58 protected IGridService m_GridService; 59 protected IGridService m_GridService;
@@ -82,6 +83,7 @@ namespace OpenSim.Services.LLLoginService
82 throw new Exception(String.Format("No section LoginService in config file")); 83 throw new Exception(String.Format("No section LoginService in config file"));
83 84
84 string accountService = m_LoginServerConfig.GetString("UserAccountService", String.Empty); 85 string accountService = m_LoginServerConfig.GetString("UserAccountService", String.Empty);
86 string gridUserService = m_LoginServerConfig.GetString("GridUserService", String.Empty);
85 string agentService = m_LoginServerConfig.GetString("UserAgentService", String.Empty); 87 string agentService = m_LoginServerConfig.GetString("UserAgentService", String.Empty);
86 string authService = m_LoginServerConfig.GetString("AuthenticationService", String.Empty); 88 string authService = m_LoginServerConfig.GetString("AuthenticationService", String.Empty);
87 string invService = m_LoginServerConfig.GetString("InventoryService", String.Empty); 89 string invService = m_LoginServerConfig.GetString("InventoryService", String.Empty);
@@ -105,8 +107,10 @@ namespace OpenSim.Services.LLLoginService
105 107
106 Object[] args = new Object[] { config }; 108 Object[] args = new Object[] { config };
107 m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(accountService, args); 109 m_UserAccountService = ServerUtils.LoadPlugin<IUserAccountService>(accountService, args);
110 m_GridUserService = ServerUtils.LoadPlugin<IGridUserService>(gridUserService, args);
108 m_AuthenticationService = ServerUtils.LoadPlugin<IAuthenticationService>(authService, args); 111 m_AuthenticationService = ServerUtils.LoadPlugin<IAuthenticationService>(authService, args);
109 m_InventoryService = ServerUtils.LoadPlugin<IInventoryService>(invService, args); 112 m_InventoryService = ServerUtils.LoadPlugin<IInventoryService>(invService, args);
113
110 if (gridService != string.Empty) 114 if (gridService != string.Empty)
111 m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args); 115 m_GridService = ServerUtils.LoadPlugin<IGridService>(gridService, args);
112 if (presenceService != string.Empty) 116 if (presenceService != string.Empty)
@@ -271,8 +275,6 @@ namespace OpenSim.Services.LLLoginService
271 // 275 //
272 // Login the presence 276 // Login the presence
273 // 277 //
274 PresenceInfo presence = null;
275 GridRegion home = null;
276 if (m_PresenceService != null) 278 if (m_PresenceService != null)
277 { 279 {
278 success = m_PresenceService.LoginAgent(account.PrincipalID.ToString(), session, secureSession); 280 success = m_PresenceService.LoginAgent(account.PrincipalID.ToString(), session, secureSession);
@@ -281,28 +283,35 @@ namespace OpenSim.Services.LLLoginService
281 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: could not login presence"); 283 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: could not login presence");
282 return LLFailedLoginResponse.GridProblem; 284 return LLFailedLoginResponse.GridProblem;
283 } 285 }
284
285 // Get the updated presence info
286 presence = m_PresenceService.GetAgent(session);
287
288 // Get the home region
289 if ((presence.HomeRegionID != UUID.Zero) && m_GridService != null)
290 {
291 home = m_GridService.GetRegionByUUID(scopeID, presence.HomeRegionID);
292 }
293 } 286 }
294 287
295 // 288 //
289 // Change Online status and get the home region
290 //
291 GridRegion home = null;
292 GridUserInfo guinfo = m_GridUserService.LoggedIn(account.PrincipalID.ToString());
293 if (guinfo != null && (guinfo.HomeRegionID != UUID.Zero) && m_GridService != null)
294 {
295 home = m_GridService.GetRegionByUUID(scopeID, guinfo.HomeRegionID);
296 }
297 if (guinfo == null)
298 {
299 // something went wrong, make something up, so that we don't have to test this anywhere else
300 guinfo = new GridUserInfo();
301 guinfo.LastPosition = guinfo.HomePosition = new Vector3(128, 128, 30);
302 }
303
304 //
296 // Find the destination region/grid 305 // Find the destination region/grid
297 // 306 //
298 string where = string.Empty; 307 string where = string.Empty;
299 Vector3 position = Vector3.Zero; 308 Vector3 position = Vector3.Zero;
300 Vector3 lookAt = Vector3.Zero; 309 Vector3 lookAt = Vector3.Zero;
301 GridRegion gatekeeper = null; 310 GridRegion gatekeeper = null;
302 GridRegion destination = FindDestination(account, scopeID, presence, session, startLocation, out gatekeeper, out where, out position, out lookAt); 311 GridRegion destination = FindDestination(account, scopeID, guinfo, session, startLocation, home, out gatekeeper, out where, out position, out lookAt);
303 if (destination == null) 312 if (destination == null)
304 { 313 {
305 m_PresenceService.LogoutAgent(session, presence.Position, presence.LookAt); 314 m_PresenceService.LogoutAgent(session);
306 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: destination not found"); 315 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: destination not found");
307 return LLFailedLoginResponse.GridProblem; 316 return LLFailedLoginResponse.GridProblem;
308 } 317 }
@@ -324,7 +333,7 @@ namespace OpenSim.Services.LLLoginService
324 333
325 if (aCircuit == null) 334 if (aCircuit == null)
326 { 335 {
327 m_PresenceService.LogoutAgent(session, presence.Position, presence.LookAt); 336 m_PresenceService.LogoutAgent(session);
328 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: {0}", reason); 337 m_log.InfoFormat("[LLOGIN SERVICE]: Login failed, reason: {0}", reason);
329 return LLFailedLoginResponse.AuthorizationProblem; 338 return LLFailedLoginResponse.AuthorizationProblem;
330 339
@@ -340,7 +349,7 @@ namespace OpenSim.Services.LLLoginService
340 // 349 //
341 // Finally, fill out the response and return it 350 // Finally, fill out the response and return it
342 // 351 //
343 LLLoginResponse response = new LLLoginResponse(account, aCircuit, presence, destination, inventorySkel, friendsList, m_LibraryService, 352 LLLoginResponse response = new LLLoginResponse(account, aCircuit, guinfo, destination, inventorySkel, friendsList, m_LibraryService,
344 where, startLocation, position, lookAt, m_WelcomeMessage, home, clientIP); 353 where, startLocation, position, lookAt, m_WelcomeMessage, home, clientIP);
345 354
346 m_log.DebugFormat("[LLOGIN SERVICE]: All clear. Sending login response to client."); 355 m_log.DebugFormat("[LLOGIN SERVICE]: All clear. Sending login response to client.");
@@ -350,12 +359,12 @@ namespace OpenSim.Services.LLLoginService
350 { 359 {
351 m_log.WarnFormat("[LLOGIN SERVICE]: Exception processing login for {0} {1}: {2} {3}", firstName, lastName, e.ToString(), e.StackTrace); 360 m_log.WarnFormat("[LLOGIN SERVICE]: Exception processing login for {0} {1}: {2} {3}", firstName, lastName, e.ToString(), e.StackTrace);
352 if (m_PresenceService != null) 361 if (m_PresenceService != null)
353 m_PresenceService.LogoutAgent(session, new Vector3(128, 128, 0), new Vector3(0, 1, 0)); 362 m_PresenceService.LogoutAgent(session);
354 return LLFailedLoginResponse.InternalError; 363 return LLFailedLoginResponse.InternalError;
355 } 364 }
356 } 365 }
357 366
358 protected GridRegion FindDestination(UserAccount account, UUID scopeID, PresenceInfo pinfo, UUID sessionID, string startLocation, out GridRegion gatekeeper, out string where, out Vector3 position, out Vector3 lookAt) 367 protected GridRegion FindDestination(UserAccount account, UUID scopeID, GridUserInfo pinfo, UUID sessionID, string startLocation, GridRegion home, out GridRegion gatekeeper, out string where, out Vector3 position, out Vector3 lookAt)
359 { 368 {
360 m_log.DebugFormat("[LLOGIN SERVICE]: FindDestination for start location {0}", startLocation); 369 m_log.DebugFormat("[LLOGIN SERVICE]: FindDestination for start location {0}", startLocation);
361 370
@@ -377,7 +386,7 @@ namespace OpenSim.Services.LLLoginService
377 386
378 bool tryDefaults = false; 387 bool tryDefaults = false;
379 388
380 if (pinfo.HomeRegionID.Equals(UUID.Zero)) 389 if (home == null)
381 { 390 {
382 m_log.WarnFormat( 391 m_log.WarnFormat(
383 "[LLOGIN SERVICE]: User {0} {1} tried to login to a 'home' start location but they have none set", 392 "[LLOGIN SERVICE]: User {0} {1} tried to login to a 'home' start location but they have none set",
@@ -387,16 +396,10 @@ namespace OpenSim.Services.LLLoginService
387 } 396 }
388 else 397 else
389 { 398 {
390 region = m_GridService.GetRegionByUUID(scopeID, pinfo.HomeRegionID); 399 region = home;
391 400
392 if (null == region) 401 position = pinfo.HomePosition;
393 { 402 lookAt = pinfo.HomeLookAt;
394 m_log.WarnFormat(
395 "[LLOGIN SERVICE]: User {0} {1} has a recorded home region of {2} but this cannot be found by the grid service",
396 account.FirstName, account.LastName, pinfo.HomeRegionID);
397
398 tryDefaults = true;
399 }
400 } 403 }
401 404
402 if (tryDefaults) 405 if (tryDefaults)
@@ -432,7 +435,7 @@ namespace OpenSim.Services.LLLoginService
432 435
433 GridRegion region = null; 436 GridRegion region = null;
434 437
435 if (pinfo.RegionID.Equals(UUID.Zero) || (region = m_GridService.GetRegionByUUID(scopeID, pinfo.RegionID)) == null) 438 if (pinfo.LastRegionID.Equals(UUID.Zero) || (region = m_GridService.GetRegionByUUID(scopeID, pinfo.LastRegionID)) == null)
436 { 439 {
437 List<GridRegion> defaults = m_GridService.GetDefaultRegions(scopeID); 440 List<GridRegion> defaults = m_GridService.GetDefaultRegions(scopeID);
438 if (defaults != null && defaults.Count > 0) 441 if (defaults != null && defaults.Count > 0)
@@ -454,8 +457,8 @@ namespace OpenSim.Services.LLLoginService
454 } 457 }
455 else 458 else
456 { 459 {
457 position = pinfo.Position; 460 position = pinfo.LastPosition;
458 lookAt = pinfo.LookAt; 461 lookAt = pinfo.LastLookAt;
459 } 462 }
460 463
461 return region; 464 return region;
diff --git a/OpenSim/Services/PresenceService/PresenceService.cs b/OpenSim/Services/PresenceService/PresenceService.cs
index ea8d673..7e7e98e 100644
--- a/OpenSim/Services/PresenceService/PresenceService.cs
+++ b/OpenSim/Services/PresenceService/PresenceService.cs
@@ -54,8 +54,6 @@ namespace OpenSim.Services.PresenceService
54 public bool LoginAgent(string userID, UUID sessionID, 54 public bool LoginAgent(string userID, UUID sessionID,
55 UUID secureSessionID) 55 UUID secureSessionID)
56 { 56 {
57 m_Database.Prune(userID);
58
59 PresenceData[] d = m_Database.Get("UserID", userID); 57 PresenceData[] d = m_Database.Get("UserID", userID);
60 58
61 PresenceData data = new PresenceData(); 59 PresenceData data = new PresenceData();
@@ -65,24 +63,6 @@ namespace OpenSim.Services.PresenceService
65 data.SessionID = sessionID; 63 data.SessionID = sessionID;
66 data.Data = new Dictionary<string, string>(); 64 data.Data = new Dictionary<string, string>();
67 data.Data["SecureSessionID"] = secureSessionID.ToString(); 65 data.Data["SecureSessionID"] = secureSessionID.ToString();
68 data.Data["Online"] = "true";
69 data.Data["Login"] = Util.UnixTimeSinceEpoch().ToString();
70 if (d != null && d.Length > 0)
71 {
72 data.Data["HomeRegionID"] = d[0].Data["HomeRegionID"];
73 data.Data["HomePosition"] = d[0].Data["HomePosition"];
74 data.Data["HomeLookAt"] = d[0].Data["HomeLookAt"];
75 data.Data["Position"] = d[0].Data["Position"];
76 data.Data["LookAt"] = d[0].Data["LookAt"];
77
78 data.RegionID = d[0].RegionID;
79 }
80 else
81 {
82 data.Data["HomeRegionID"] = UUID.Zero.ToString();
83 data.Data["HomePosition"] = new Vector3(128, 128, 0).ToString();
84 data.Data["HomeLookAt"] = new Vector3(0, 1, 0).ToString();
85 }
86 66
87 m_Database.Store(data); 67 m_Database.Store(data);
88 68
@@ -91,28 +71,10 @@ namespace OpenSim.Services.PresenceService
91 return true; 71 return true;
92 } 72 }
93 73
94 public bool LogoutAgent(UUID sessionID, Vector3 position, Vector3 lookat) 74 public bool LogoutAgent(UUID sessionID)
95 { 75 {
96 PresenceData data = m_Database.Get(sessionID); 76 m_log.DebugFormat("[PRESENCE SERVICE]: Session {0} logout", sessionID);
97 if (data == null) 77 return m_Database.Delete("SessionID", sessionID.ToString());
98 return false;
99
100 PresenceData[] d = m_Database.Get("UserID", data.UserID);
101
102 m_log.DebugFormat("[PRESENCE SERVICE]: LogoutAgent {0} with {1} sessions currently present", data.UserID, d.Length);
103 if (d.Length > 1)
104 {
105 m_Database.Delete("UserID", data.UserID);
106 }
107
108 data.Data["Online"] = "false";
109 data.Data["Logout"] = Util.UnixTimeSinceEpoch().ToString();
110 data.Data["Position"] = position.ToString();
111 data.Data["LookAt"] = lookat.ToString();
112
113 m_Database.Store(data);
114
115 return true;
116 } 78 }
117 79
118 public bool LogoutRegionAgents(UUID regionID) 80 public bool LogoutRegionAgents(UUID regionID)
@@ -123,7 +85,7 @@ namespace OpenSim.Services.PresenceService
123 } 85 }
124 86
125 87
126 public bool ReportAgent(UUID sessionID, UUID regionID, Vector3 position, Vector3 lookAt) 88 public bool ReportAgent(UUID sessionID, UUID regionID)
127 { 89 {
128 m_log.DebugFormat("[PRESENCE SERVICE]: ReportAgent with session {0} in region {1}", sessionID, regionID); 90 m_log.DebugFormat("[PRESENCE SERVICE]: ReportAgent with session {0} in region {1}", sessionID, regionID);
129 try 91 try
@@ -134,14 +96,7 @@ namespace OpenSim.Services.PresenceService
134 if (pdata.Data == null) 96 if (pdata.Data == null)
135 return false; 97 return false;
136 98
137 if (!pdata.Data.ContainsKey("Online") || (pdata.Data.ContainsKey("Online") && pdata.Data["Online"] == "false")) 99 return m_Database.ReportAgent(sessionID, regionID);
138 {
139 m_log.WarnFormat("[PRESENCE SERVICE]: Someone tried to report presence of an agent who's not online");
140 return false;
141 }
142
143 return m_Database.ReportAgent(sessionID, regionID,
144 position.ToString(), lookAt.ToString());
145 } 100 }
146 catch (Exception e) 101 catch (Exception e)
147 { 102 {
@@ -160,22 +115,10 @@ namespace OpenSim.Services.PresenceService
160 115
161 ret.UserID = data.UserID; 116 ret.UserID = data.UserID;
162 ret.RegionID = data.RegionID; 117 ret.RegionID = data.RegionID;
163 if (data.Data.ContainsKey("Online"))
164 ret.Online = bool.Parse(data.Data["Online"]);
165 if (data.Data.ContainsKey("Login"))
166 ret.Login = Util.ToDateTime(Convert.ToInt32(data.Data["Login"]));
167 if (data.Data.ContainsKey("Logout"))
168 ret.Logout = Util.ToDateTime(Convert.ToInt32(data.Data["Logout"]));
169 if (data.Data.ContainsKey("Position")) 118 if (data.Data.ContainsKey("Position"))
170 ret.Position = Vector3.Parse(data.Data["Position"]); 119 ret.Position = Vector3.Parse(data.Data["Position"]);
171 if (data.Data.ContainsKey("LookAt")) 120 if (data.Data.ContainsKey("LookAt"))
172 ret.LookAt = Vector3.Parse(data.Data["LookAt"]); 121 ret.LookAt = Vector3.Parse(data.Data["LookAt"]);
173 if (data.Data.ContainsKey("HomeRegionID"))
174 ret.HomeRegionID = new UUID(data.Data["HomeRegionID"]);
175 if (data.Data.ContainsKey("HomePosition"))
176 ret.HomePosition = Vector3.Parse(data.Data["HomePosition"]);
177 if (data.Data.ContainsKey("HomeLookAt"))
178 ret.HomeLookAt = Vector3.Parse(data.Data["HomeLookAt"]);
179 122
180 return ret; 123 return ret;
181 } 124 }
@@ -195,16 +138,8 @@ namespace OpenSim.Services.PresenceService
195 138
196 ret.UserID = d.UserID; 139 ret.UserID = d.UserID;
197 ret.RegionID = d.RegionID; 140 ret.RegionID = d.RegionID;
198 ret.Online = bool.Parse(d.Data["Online"]);
199 ret.Login = Util.ToDateTime(Convert.ToInt32(
200 d.Data["Login"]));
201 ret.Logout = Util.ToDateTime(Convert.ToInt32(
202 d.Data["Logout"]));
203 ret.Position = Vector3.Parse(d.Data["Position"]); 141 ret.Position = Vector3.Parse(d.Data["Position"]);
204 ret.LookAt = Vector3.Parse(d.Data["LookAt"]); 142 ret.LookAt = Vector3.Parse(d.Data["LookAt"]);
205 ret.HomeRegionID = new UUID(d.Data["HomeRegionID"]);
206 ret.HomePosition = Vector3.Parse(d.Data["HomePosition"]);
207 ret.HomeLookAt = Vector3.Parse(d.Data["HomeLookAt"]);
208 143
209 info.Add(ret); 144 info.Add(ret);
210 } 145 }
@@ -214,9 +149,5 @@ namespace OpenSim.Services.PresenceService
214 return info.ToArray(); 149 return info.ToArray();
215 } 150 }
216 151
217 public bool SetHomeLocation(string userID, UUID regionID, Vector3 position, Vector3 lookAt)
218 {
219 return m_Database.SetHomeLocation(userID, regionID, position, lookAt);
220 }
221 } 152 }
222} 153}
diff --git a/OpenSim/Services/UserAccountService/GridUserService.cs b/OpenSim/Services/UserAccountService/GridUserService.cs
index c6e33bb..697ba63 100644
--- a/OpenSim/Services/UserAccountService/GridUserService.cs
+++ b/OpenSim/Services/UserAccountService/GridUserService.cs
@@ -31,6 +31,7 @@ using System.Reflection;
31using Nini.Config; 31using Nini.Config;
32using OpenSim.Data; 32using OpenSim.Data;
33using OpenSim.Services.Interfaces; 33using OpenSim.Services.Interfaces;
34using OpenSim.Framework;
34using OpenSim.Framework.Console; 35using OpenSim.Framework.Console;
35using GridRegion = OpenSim.Services.Interfaces.GridRegion; 36using GridRegion = OpenSim.Services.Interfaces.GridRegion;
36 37
@@ -50,27 +51,109 @@ namespace OpenSim.Services.UserAccountService
50 51
51 public GridUserInfo GetGridUserInfo(string userID) 52 public GridUserInfo GetGridUserInfo(string userID)
52 { 53 {
53 GridUserData d = m_Database.GetGridUserData(userID); 54 GridUserData d = m_Database.Get(userID);
54 55
56 if (d == null)
57 return null;
58
55 GridUserInfo info = new GridUserInfo(); 59 GridUserInfo info = new GridUserInfo();
56 info.UserID = d.UserID; 60 info.UserID = d.UserID;
57 info.HomeRegionID = new UUID(d.Data["HomeRegionID"]); 61 info.HomeRegionID = new UUID(d.Data["HomeRegionID"]);
58 info.HomePosition = Vector3.Parse(d.Data["HomePosition"]); 62 info.HomePosition = Vector3.Parse(d.Data["HomePosition"]);
59 info.HomeLookAt = Vector3.Parse(d.Data["HomeLookAt"]); 63 info.HomeLookAt = Vector3.Parse(d.Data["HomeLookAt"]);
60 64
65 info.LastRegionID = new UUID(d.Data["LastRegionID"]);
66 info.LastPosition = Vector3.Parse(d.Data["LastPosition"]);
67 info.LastLookAt = Vector3.Parse(d.Data["LastLookAt"]);
68
69 info.Online = bool.Parse(d.Data["Online"]);
70 info.Login = Util.ToDateTime(Convert.ToInt32(d.Data["Login"]));
71 info.Logout = Util.ToDateTime(Convert.ToInt32(d.Data["Logout"]));
72
61 return info; 73 return info;
62 } 74 }
63 75
64 public bool StoreGridUserInfo(GridUserInfo info) 76 public GridUserInfo LoggedIn(string userID)
77 {
78 m_log.DebugFormat("[GRID USER SERVICE]: User {0} is online", userID);
79 GridUserData d = m_Database.Get(userID);
80
81 if (d == null)
82 {
83 d = new GridUserData();
84 d.UserID = userID;
85 }
86
87 d.Data["Online"] = true.ToString();
88 d.Data["Login"] = Util.UnixTimeSinceEpoch().ToString();
89
90 m_Database.Store(d);
91
92 return GetGridUserInfo(userID);
93 }
94
95 public bool LoggedOut(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt)
96 {
97 m_log.DebugFormat("[GRID USER SERVICE]: User {0} is offline", userID);
98 GridUserData d = m_Database.Get(userID);
99
100 if (d == null)
101 {
102 d = new GridUserData();
103 d.UserID = userID;
104 }
105
106 d.Data["Online"] = false.ToString();
107 d.Data["Logout"] = Util.UnixTimeSinceEpoch().ToString();
108 d.Data["LastRegionID"] = regionID.ToString();
109 d.Data["LastPosition"] = lastPosition.ToString();
110 d.Data["LastLookAt"] = lastLookAt.ToString();
111
112 return m_Database.Store(d);
113 }
114
115 protected bool StoreGridUserInfo(GridUserInfo info)
65 { 116 {
66 GridUserData d = new GridUserData(); 117 GridUserData d = new GridUserData();
67 118
68 d.Data["UserID"] = info.UserID;
69 d.Data["HomeRegionID"] = info.HomeRegionID.ToString(); 119 d.Data["HomeRegionID"] = info.HomeRegionID.ToString();
70 d.Data["HomePosition"] = info.HomePosition.ToString(); 120 d.Data["HomePosition"] = info.HomePosition.ToString();
71 d.Data["HomeLookAt"] = info.HomeLookAt.ToString(); 121 d.Data["HomeLookAt"] = info.HomeLookAt.ToString();
72 122
73 return m_Database.StoreGridUserData(d); 123 return m_Database.Store(d);
124 }
125
126 public bool SetHome(string userID, UUID homeID, Vector3 homePosition, Vector3 homeLookAt)
127 {
128 GridUserData d = m_Database.Get(userID);
129 if (d == null)
130 {
131 d = new GridUserData();
132 d.UserID = userID;
133 }
134
135 d.Data["HomeRegionID"] = homeID.ToString();
136 d.Data["HomePosition"] = homePosition.ToString();
137 d.Data["HomeLookAt"] = homeLookAt.ToString();
138
139 return m_Database.Store(d);
140 }
141
142 public bool SetLastPosition(string userID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt)
143 {
144 //m_log.DebugFormat("[Grid User Service]: SetLastPosition for {0}", userID);
145 GridUserData d = m_Database.Get(userID);
146 if (d == null)
147 {
148 d = new GridUserData();
149 d.UserID = userID;
150 }
151
152 d.Data["LastRegionID"] = regionID.ToString();
153 d.Data["LastPosition"] = lastPosition.ToString();
154 d.Data["LastLookAt"] = lastLookAt.ToString();
155
156 return m_Database.Store(d);
74 } 157 }
75 } 158 }
76} \ No newline at end of file 159} \ No newline at end of file
diff --git a/OpenSim/Services/UserAccountService/UserAccountService.cs b/OpenSim/Services/UserAccountService/UserAccountService.cs
index 35e2826..6923293 100644
--- a/OpenSim/Services/UserAccountService/UserAccountService.cs
+++ b/OpenSim/Services/UserAccountService/UserAccountService.cs
@@ -46,7 +46,7 @@ namespace OpenSim.Services.UserAccountService
46 46
47 protected IGridService m_GridService; 47 protected IGridService m_GridService;
48 protected IAuthenticationService m_AuthenticationService; 48 protected IAuthenticationService m_AuthenticationService;
49 protected IPresenceService m_PresenceService; 49 protected IGridUserService m_GridUserService;
50 protected IInventoryService m_InventoryService; 50 protected IInventoryService m_InventoryService;
51 51
52 public UserAccountService(IConfigSource config) 52 public UserAccountService(IConfigSource config)
@@ -69,9 +69,9 @@ namespace OpenSim.Services.UserAccountService
69 if (authServiceDll != string.Empty) 69 if (authServiceDll != string.Empty)
70 m_AuthenticationService = LoadPlugin<IAuthenticationService>(authServiceDll, new Object[] { config }); 70 m_AuthenticationService = LoadPlugin<IAuthenticationService>(authServiceDll, new Object[] { config });
71 71
72 string presenceServiceDll = userConfig.GetString("PresenceService", string.Empty); 72 string presenceServiceDll = userConfig.GetString("GridUserService", string.Empty);
73 if (presenceServiceDll != string.Empty) 73 if (presenceServiceDll != string.Empty)
74 m_PresenceService = LoadPlugin<IPresenceService>(presenceServiceDll, new Object[] { config }); 74 m_GridUserService = LoadPlugin<IGridUserService>(presenceServiceDll, new Object[] { config });
75 75
76 string invServiceDll = userConfig.GetString("InventoryService", string.Empty); 76 string invServiceDll = userConfig.GetString("InventoryService", string.Empty);
77 if (invServiceDll != string.Empty) 77 if (invServiceDll != string.Empty)
@@ -333,8 +333,8 @@ namespace OpenSim.Services.UserAccountService
333 if (defaultRegions != null && defaultRegions.Count >= 1) 333 if (defaultRegions != null && defaultRegions.Count >= 1)
334 home = defaultRegions[0]; 334 home = defaultRegions[0];
335 335
336 if (m_PresenceService != null && home != null) 336 if (m_GridUserService != null && home != null)
337 m_PresenceService.SetHomeLocation(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0)); 337 m_GridUserService.SetHome(account.PrincipalID.ToString(), home.RegionID, new Vector3(128, 128, 0), new Vector3(0, 1, 0));
338 else 338 else
339 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set home for account {0} {1}.", 339 m_log.WarnFormat("[USER ACCOUNT SERVICE]: Unable to set home for account {0} {1}.",
340 firstName, lastName); 340 firstName, lastName);