From a9dde515ba7d35b6069a3b2cd8b66bb72b007801 Mon Sep 17 00:00:00 2001
From: MW
Date: Fri, 22 Jun 2007 18:28:49 +0000
Subject: SandBox mode login now shares a base class with the grid mode user
server. To allow people to login without creating accounts first in sandbox
mode anytime a login request is received without a matching account already
being in the database, a new account will be made. (also in sandbox mode,
passwords aren't currently used).
---
.../CommunicationsLocal.cs | 11 ++-
.../LocalUserServices.cs | 96 +++++++++++++++++++---
2 files changed, 94 insertions(+), 13 deletions(-)
(limited to 'OpenSim/OpenSim.LocalCommunications')
diff --git a/OpenSim/OpenSim.LocalCommunications/CommunicationsLocal.cs b/OpenSim/OpenSim.LocalCommunications/CommunicationsLocal.cs
index 795f99d..008d47e 100644
--- a/OpenSim/OpenSim.LocalCommunications/CommunicationsLocal.cs
+++ b/OpenSim/OpenSim.LocalCommunications/CommunicationsLocal.cs
@@ -41,13 +41,20 @@ namespace OpenSim.LocalCommunications
public class CommunicationsLocal : CommunicationsManager
{
public LocalBackEndServices SandBoxServices = new LocalBackEndServices();
- protected LocalUserServices UserServices = new LocalUserServices();
+ public LocalUserServices UserServices;
- public CommunicationsLocal()
+ public CommunicationsLocal(uint defaultHomeX , uint defaultHomeY)
{
+ UserServices = new LocalUserServices(this , defaultHomeX, defaultHomeY);
+ UserServices.AddPlugin("OpenGrid.Framework.Data.DB4o.dll");
UserServer = UserServices;
GridServer = SandBoxServices;
InterRegion = SandBoxServices;
}
+
+ internal void InformRegionOfLogin(ulong regionHandle, Login login)
+ {
+ this.SandBoxServices.AddNewSession(regionHandle, login);
+ }
}
}
diff --git a/OpenSim/OpenSim.LocalCommunications/LocalUserServices.cs b/OpenSim/OpenSim.LocalCommunications/LocalUserServices.cs
index fdfdd16..7a7f2bf 100644
--- a/OpenSim/OpenSim.LocalCommunications/LocalUserServices.cs
+++ b/OpenSim/OpenSim.LocalCommunications/LocalUserServices.cs
@@ -4,9 +4,11 @@ using System.Collections.Generic;
using System.Text;
using OpenGrid.Framework.Communications;
-using OpenSim.Framework.User;
+//using OpenSim.Framework.User;
using OpenGrid.Framework.UserManagement;
using OpenGrid.Framework.Data;
+using OpenSim.Framework.Types;
+using OpenSim.Framework.Utilities;
using libsecondlife;
@@ -14,30 +16,102 @@ namespace OpenSim.LocalCommunications
{
public class LocalUserServices : UserManagerBase, IUserServices
{
-
- public LocalUserServices()
- {
+ private CommunicationsLocal m_Parent;
+ private uint defaultHomeX ;
+ private uint defaultHomeY;
+ public LocalUserServices(CommunicationsLocal parent, uint defHomeX, uint defHomeY)
+ {
+ m_Parent = parent;
+ defaultHomeX = defHomeX;
+ defaultHomeY = defHomeY;
}
- public UserProfileData GetUserProfile(string first_name, string last_name)
+ public UserProfileData GetUserProfile(string firstName, string lastName)
{
- return GetUserProfile(first_name + " " + last_name);
+ return GetUserProfile(firstName + " " + lastName);
}
public UserProfileData GetUserProfile(string name)
{
- return null;
+ return this.getUserProfile(name);
+ }
+ public UserProfileData GetUserProfile(LLUUID avatarID)
+ {
+ return this.getUserProfile(avatarID);
+ }
+
+ ///
+ ///
+ ///
+ ///
+ public override string GetMessage()
+ {
+ return "Welcome to OpenSim";
+ }
+
+ public override UserProfileData GetTheUser(string firstname, string lastname)
+ {
+ UserProfileData profile = getUserProfile(firstname, lastname);
+ if (profile != null)
+ {
+
+ return profile;
+ }
+
+ //no current user account so make one
+ Console.WriteLine("No User account found so creating a new one ");
+ this.AddUserProfile(firstname, lastname, "test", defaultHomeX, defaultHomeY);
+
+ profile = getUserProfile(firstname, lastname);
+
+ return profile;
}
- public UserProfileData GetUserProfile(LLUUID avatar_id)
+
+ public override bool AuthenticateUser(ref UserProfileData profile, string password)
{
- return null;
+ //for now we will accept any password in sandbox mode
+ Console.WriteLine("authorising user");
+ return true;
}
- public override void CustomiseResponse(ref Hashtable response, ref UserProfileData theUser)
+ public override void CustomiseResponse(ref LoginResponse response, ref UserProfileData theUser)
{
+ ulong currentRegion = theUser.currentAgent.currentHandle;
+ RegionInfo reg = m_Parent.GridServer.RequestNeighbourInfo(currentRegion);
+
+
+ if (reg != null)
+ {
+ response.Home = "{'region_handle':[r" + (reg.RegionLocX * 256).ToString() + ",r" + (reg.RegionLocY * 256).ToString() + "], " +
+ "'position':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " +
+ "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}";
+
+ response.SimAddress = reg.IPListenAddr;
+ response.SimPort = (Int32)reg.IPListenPort;
+ response.RegionX = reg.RegionLocX ;
+ response.RegionY = reg.RegionLocY ;
+
+ theUser.currentAgent.currentRegion = reg.SimUUID;
+ theUser.currentAgent.currentHandle = reg.RegionHandle;
+
+ Login _login = new Login();
+ //copy data to login object
+ _login.First = response.Firstname;
+ _login.Last = response.Lastname;
+ _login.Agent = response.AgentID;
+ _login.Session = response.SessionID;
+ _login.SecureSession = response.SecureSessionID;
+ _login.CircuitCode = (uint)response.CircuitCode;
+
+ m_Parent.InformRegionOfLogin(currentRegion, _login);
+ }
+ else
+ {
+ Console.WriteLine("not found region " + currentRegion);
+ }
}
-
+
}
}
--
cgit v1.1