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