aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Communications/Local/LocalUserServices.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Communications/Local/LocalUserServices.cs')
-rw-r--r--OpenSim/Region/Communications/Local/LocalUserServices.cs142
1 files changed, 142 insertions, 0 deletions
diff --git a/OpenSim/Region/Communications/Local/LocalUserServices.cs b/OpenSim/Region/Communications/Local/LocalUserServices.cs
new file mode 100644
index 0000000..592b36c
--- /dev/null
+++ b/OpenSim/Region/Communications/Local/LocalUserServices.cs
@@ -0,0 +1,142 @@
1using System;
2using libsecondlife;
3using OpenSim.Framework.Communications;
4using OpenSim.Framework.Data;
5using OpenSim.Framework.Types;
6using OpenSim.Framework.UserManagement;
7using OpenSim.Framework.Utilities;
8
9namespace OpenSim.Region.Communications.Local
10{
11 public class LocalUserServices : UserManagerBase, IUserServices
12 {
13 private CommunicationsLocal m_Parent;
14
15 private NetworkServersInfo serversInfo;
16 private uint defaultHomeX ;
17 private uint defaultHomeY;
18 public LocalUserServices(CommunicationsLocal parent, NetworkServersInfo serversData)
19 {
20 m_Parent = parent;
21 this.serversInfo = serversData;
22 defaultHomeX = this.serversInfo.DefaultHomeLocX;
23 defaultHomeY = this.serversInfo.DefaultHomeLocY;
24 }
25
26 public UserProfileData GetUserProfile(string firstName, string lastName)
27 {
28 return GetUserProfile(firstName + " " + lastName);
29 }
30
31 public UserProfileData GetUserProfile(string name)
32 {
33 return this.getUserProfile(name);
34 }
35
36 public UserProfileData GetUserProfile(LLUUID avatarID)
37 {
38 return this.getUserProfile(avatarID);
39 }
40
41 /// <summary>
42 ///
43 /// </summary>
44 /// <returns></returns>
45 public override string GetMessage()
46 {
47 return "Welcome to OpenSim";
48 }
49
50 public override UserProfileData GetTheUser(string firstname, string lastname)
51 {
52 UserProfileData profile = getUserProfile(firstname, lastname);
53 if (profile != null)
54 {
55
56 return profile;
57 }
58
59 //no current user account so make one
60 Console.WriteLine("No User account found so creating a new one ");
61 this.AddUserProfile(firstname, lastname, "test", defaultHomeX, defaultHomeY);
62
63 profile = getUserProfile(firstname, lastname);
64
65 return profile;
66 }
67
68 public override bool AuthenticateUser(UserProfileData profile, string password)
69 {
70 //for now we will accept any password in sandbox mode
71 Console.WriteLine("authorising user");
72 return true;
73 }
74
75 public override void CustomiseResponse(LoginResponse response, UserProfileData theUser)
76 {
77 ulong currentRegion = theUser.currentAgent.currentHandle;
78 RegionInfo reg = m_Parent.GridServer.RequestNeighbourInfo(currentRegion);
79
80 if (reg != null)
81 {
82 response.Home = "{'region_handle':[r" + (reg.RegionLocX * 256).ToString() + ",r" + (reg.RegionLocY * 256).ToString() + "], " +
83 "'position':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " +
84 "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}";
85 string capsPath = Util.GetRandomCapsPath();
86 response.SimAddress = reg.ExternalEndPoint.Address.ToString();
87 response.SimPort = (Int32)reg.ExternalEndPoint.Port;
88 response.RegionX = reg.RegionLocX ;
89 response.RegionY = reg.RegionLocY ;
90
91 //following port needs changing as we don't want a http listener for every region (or do we?)
92 response.SeedCapability = "http://" + reg.ExternalHostName + ":" + this.serversInfo.HttpListenerPort.ToString() + "/CAPS/" + capsPath + "0000/";
93 theUser.currentAgent.currentRegion = reg.SimUUID;
94 theUser.currentAgent.currentHandle = reg.RegionHandle;
95
96 Login _login = new Login();
97 //copy data to login object
98 _login.First = response.Firstname;
99 _login.Last = response.Lastname;
100 _login.Agent = response.AgentID;
101 _login.Session = response.SessionID;
102 _login.SecureSession = response.SecureSessionID;
103 _login.CircuitCode = (uint)response.CircuitCode;
104 _login.CapsPath = capsPath;
105
106 m_Parent.InformRegionOfLogin(currentRegion, _login);
107 }
108 else
109 {
110 Console.WriteLine("not found region " + currentRegion);
111 }
112
113 }
114
115 public UserProfileData SetupMasterUser(string firstName, string lastName)
116 {
117 return SetupMasterUser(firstName, lastName, "");
118 }
119
120 public UserProfileData SetupMasterUser(string firstName, string lastName, string password)
121 {
122 UserProfileData profile = getUserProfile(firstName, lastName);
123 if (profile != null)
124 {
125
126 return profile;
127 }
128
129 Console.WriteLine("Unknown Master User. Sandbox Mode: Creating Account");
130 this.AddUserProfile(firstName, lastName, password, defaultHomeX, defaultHomeY);
131
132 profile = getUserProfile(firstName, lastName);
133
134 if (profile == null)
135 {
136 Console.WriteLine("Unknown Master User after creation attempt. No clue what to do here.");
137 }
138
139 return profile;
140 }
141 }
142}