aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Common/OpenSim.Servers/LocalUserProfileManager.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Common/OpenSim.Servers/LocalUserProfileManager.cs123
1 files changed, 123 insertions, 0 deletions
diff --git a/Common/OpenSim.Servers/LocalUserProfileManager.cs b/Common/OpenSim.Servers/LocalUserProfileManager.cs
new file mode 100644
index 0000000..a8b5f1f
--- /dev/null
+++ b/Common/OpenSim.Servers/LocalUserProfileManager.cs
@@ -0,0 +1,123 @@
1/*
2* Copyright (c) OpenSim project, http://sim.opensecondlife.org/
3*
4* Redistribution and use in source and binary forms, with or without
5* modification, are permitted provided that the following conditions are met:
6* * Redistributions of source code must retain the above copyright
7* notice, this list of conditions and the following disclaimer.
8* * Redistributions in binary form must reproduce the above copyright
9* notice, this list of conditions and the following disclaimer in the
10* documentation and/or other materials provided with the distribution.
11* * Neither the name of the <organization> nor the
12* names of its contributors may be used to endorse or promote products
13* derived from this software without specific prior written permission.
14*
15* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
16* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
19* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*
26*/
27
28using System;
29using System.Collections.Generic;
30using System.Collections;
31using System.Text;
32using OpenSim.Framework.User;
33using OpenSim.Framework.Grid;
34using OpenSim.Framework.Inventory;
35using OpenSim.Framework.Interfaces;
36using OpenSim.Framework.Types;
37using libsecondlife;
38
39namespace OpenSim.UserServer
40{
41 public class LocalUserProfileManager : UserProfileManager
42 {
43 private IGridServer m_gridServer;
44 private int m_port;
45 private string m_ipAddr;
46 private uint regionX;
47 private uint regionY;
48 private AddNewSessionHandler AddSession;
49
50 public LocalUserProfileManager(IGridServer gridServer, int simPort, string ipAddr , uint regX, uint regY)
51 {
52 m_gridServer = gridServer;
53 m_port = simPort;
54 m_ipAddr = ipAddr;
55 regionX = regX;
56 regionY = regY;
57 }
58
59 public void SetSessionHandler(AddNewSessionHandler sessionHandler)
60 {
61 this.AddSession = sessionHandler;
62 }
63
64 public override void InitUserProfiles()
65 {
66 // TODO: need to load from database
67 }
68
69 public override void CustomiseResponse(ref System.Collections.Hashtable response, UserProfile theUser)
70 {
71 Int32 circode = (Int32)response["circuit_code"];
72 theUser.AddSimCircuit((uint)circode, LLUUID.Random());
73 response["home"] = "{'region_handle':[r" + (997 * 256).ToString() + ",r" + (996 * 256).ToString() + "], 'position':[r" + theUser.homepos.X.ToString() + ",r" + theUser.homepos.Y.ToString() + ",r" + theUser.homepos.Z.ToString() + "], 'look_at':[r" + theUser.homelookat.X.ToString() + ",r" + theUser.homelookat.Y.ToString() + ",r" + theUser.homelookat.Z.ToString() + "]}";
74 response["sim_port"] = m_port;
75 response["sim_ip"] = m_ipAddr;
76 response["region_y"] = (Int32)regionY* 256;
77 response["region_x"] = (Int32)regionX* 256;
78
79 string first;
80 string last;
81 if (response.Contains("first_name"))
82 {
83 first = (string)response["first_name"];
84 }
85 else
86 {
87 first = "test";
88 }
89
90 if (response.Contains("last_name"))
91 {
92 last = (string)response["last_name"];
93 }
94 else
95 {
96 last = "User";
97 }
98
99 ArrayList InventoryList = (ArrayList)response["inventory-skeleton"];
100 Hashtable Inventory1 = (Hashtable)InventoryList[0];
101
102 Login _login = new Login();
103 //copy data to login object
104 _login.First = first;
105 _login.Last = last;
106 _login.Agent = new LLUUID((string)response["agent_id"]) ;
107 _login.Session = new LLUUID((string)response["session_id"]);
108 _login.SecureSession = new LLUUID((string)response["secure_session_id"]);
109 _login.CircuitCode =(uint) circode;
110 _login.BaseFolder = null;
111 _login.InventoryFolder = new LLUUID((string)Inventory1["folder_id"]);
112
113 //working on local computer if so lets add to the gridserver's list of sessions?
114 /*if (m_gridServer.GetName() == "Local")
115 {
116 Console.WriteLine("adding login data to gridserver");
117 ((LocalGridBase)this.m_gridServer).AddNewSession(_login);
118 }*/
119
120 this.AddSession(_login);
121 }
122 }
123}