diff options
Diffstat (limited to 'OpenSim/Region/LocalCommunications/LocalUserServices.cs')
-rw-r--r-- | OpenSim/Region/LocalCommunications/LocalUserServices.cs | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/OpenSim/Region/LocalCommunications/LocalUserServices.cs b/OpenSim/Region/LocalCommunications/LocalUserServices.cs new file mode 100644 index 0000000..a7f7aa4 --- /dev/null +++ b/OpenSim/Region/LocalCommunications/LocalUserServices.cs | |||
@@ -0,0 +1,118 @@ | |||
1 | using System; | ||
2 | using System.Collections; | ||
3 | using System.Collections.Generic; | ||
4 | using System.Text; | ||
5 | |||
6 | using OpenGrid.Framework.Communications; | ||
7 | //using OpenSim.Framework.User; | ||
8 | using OpenGrid.Framework.UserManagement; | ||
9 | using OpenGrid.Framework.Data; | ||
10 | using OpenSim.Framework.Types; | ||
11 | using OpenSim.Framework.Utilities; | ||
12 | |||
13 | using libsecondlife; | ||
14 | |||
15 | namespace OpenSim.LocalCommunications | ||
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 | public UserProfileData GetUserProfile(LLUUID avatarID) | ||
40 | { | ||
41 | return this.getUserProfile(avatarID); | ||
42 | } | ||
43 | |||
44 | /// <summary> | ||
45 | /// | ||
46 | /// </summary> | ||
47 | /// <returns></returns> | ||
48 | public override string GetMessage() | ||
49 | { | ||
50 | return "Welcome to OpenSim"; | ||
51 | } | ||
52 | |||
53 | public override UserProfileData GetTheUser(string firstname, string lastname) | ||
54 | { | ||
55 | UserProfileData profile = getUserProfile(firstname, lastname); | ||
56 | if (profile != null) | ||
57 | { | ||
58 | |||
59 | return profile; | ||
60 | } | ||
61 | |||
62 | //no current user account so make one | ||
63 | Console.WriteLine("No User account found so creating a new one "); | ||
64 | this.AddUserProfile(firstname, lastname, "test", defaultHomeX, defaultHomeY); | ||
65 | |||
66 | profile = getUserProfile(firstname, lastname); | ||
67 | |||
68 | return profile; | ||
69 | } | ||
70 | |||
71 | public override bool AuthenticateUser(ref UserProfileData profile, string password) | ||
72 | { | ||
73 | //for now we will accept any password in sandbox mode | ||
74 | Console.WriteLine("authorising user"); | ||
75 | return true; | ||
76 | } | ||
77 | |||
78 | public override void CustomiseResponse(ref LoginResponse response, ref UserProfileData theUser) | ||
79 | { | ||
80 | ulong currentRegion = theUser.currentAgent.currentHandle; | ||
81 | RegionInfo reg = m_Parent.GridServer.RequestNeighbourInfo(currentRegion); | ||
82 | |||
83 | |||
84 | if (reg != null) | ||
85 | { | ||
86 | response.Home = "{'region_handle':[r" + (reg.RegionLocX * 256).ToString() + ",r" + (reg.RegionLocY * 256).ToString() + "], " + | ||
87 | "'position':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "], " + | ||
88 | "'look_at':[r" + theUser.homeLocation.X.ToString() + ",r" + theUser.homeLocation.Y.ToString() + ",r" + theUser.homeLocation.Z.ToString() + "]}"; | ||
89 | string capsPath = Util.GetRandomCapsPath(); | ||
90 | response.SimAddress = reg.CommsIPListenAddr; | ||
91 | response.SimPort = (Int32)reg.CommsIPListenPort; | ||
92 | response.RegionX = reg.RegionLocX ; | ||
93 | response.RegionY = reg.RegionLocY ; | ||
94 | response.SeedCapability = "http://" + reg.CommsIPListenAddr + ":" + "9000" + "/CAPS/" + capsPath + "0000/"; | ||
95 | theUser.currentAgent.currentRegion = reg.SimUUID; | ||
96 | theUser.currentAgent.currentHandle = reg.RegionHandle; | ||
97 | |||
98 | Login _login = new Login(); | ||
99 | //copy data to login object | ||
100 | _login.First = response.Firstname; | ||
101 | _login.Last = response.Lastname; | ||
102 | _login.Agent = response.AgentID; | ||
103 | _login.Session = response.SessionID; | ||
104 | _login.SecureSession = response.SecureSessionID; | ||
105 | _login.CircuitCode = (uint)response.CircuitCode; | ||
106 | _login.CapsPath = capsPath; | ||
107 | |||
108 | m_Parent.InformRegionOfLogin(currentRegion, _login); | ||
109 | } | ||
110 | else | ||
111 | { | ||
112 | Console.WriteLine("not found region " + currentRegion); | ||
113 | } | ||
114 | |||
115 | } | ||
116 | |||
117 | } | ||
118 | } | ||