aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ogs/userserver/src/UserProfiles.cs
diff options
context:
space:
mode:
authorgareth2007-03-22 10:11:15 +0000
committergareth2007-03-22 10:11:15 +0000
commit7daa3955bc3a1918e40962851f9e8d38597a245e (patch)
treebee3e1372a7eed0c1b220a8a49f7bee7d29a6b91 /ogs/userserver/src/UserProfiles.cs
parentLoad XML for neighbourinfo from grid (diff)
downloadopensim-SC-7daa3955bc3a1918e40962851f9e8d38597a245e.zip
opensim-SC-7daa3955bc3a1918e40962851f9e8d38597a245e.tar.gz
opensim-SC-7daa3955bc3a1918e40962851f9e8d38597a245e.tar.bz2
opensim-SC-7daa3955bc3a1918e40962851f9e8d38597a245e.tar.xz
brought zircon branch into trunk
Diffstat (limited to 'ogs/userserver/src/UserProfiles.cs')
-rw-r--r--ogs/userserver/src/UserProfiles.cs223
1 files changed, 0 insertions, 223 deletions
diff --git a/ogs/userserver/src/UserProfiles.cs b/ogs/userserver/src/UserProfiles.cs
deleted file mode 100644
index 4586ab3..0000000
--- a/ogs/userserver/src/UserProfiles.cs
+++ /dev/null
@@ -1,223 +0,0 @@
1/*
2Copyright (c) OpenGrid project, http://osgrid.org/
3
4
5* All rights reserved.
6*
7* Redistribution and use in source and binary forms, with or without
8* modification, are permitted provided that the following conditions are met:
9* * Redistributions of source code must retain the above copyright
10* notice, this list of conditions and the following disclaimer.
11* * Redistributions in binary form must reproduce the above copyright
12* notice, this list of conditions and the following disclaimer in the
13* documentation and/or other materials provided with the distribution.
14* * Neither the name of the <organization> nor the
15* names of its contributors may be used to endorse or promote products
16* derived from this software without specific prior written permission.
17*
18* THIS SOFTWARE IS PROVIDED BY <copyright holder> ``AS IS'' AND ANY
19* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21* DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
22* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28*/
29
30using System;
31using System.Text;
32using System.Collections;
33using System.Collections.Generic;
34using libsecondlife;
35using Nwc.XmlRpc;
36using ServerConsole;
37
38namespace OpenGridServices
39{
40 /// <summary>
41 /// </summary>
42 public class UserProfileManager {
43
44 public Dictionary<LLUUID, UserProfile> UserProfiles = new Dictionary<LLUUID, UserProfile>();
45
46 public UserProfileManager() {
47 }
48
49 public void InitUserProfiles() {
50 // TODO: need to load from database
51 }
52
53 public UserProfile GetProfileByName(string firstname, string lastname) {
54 foreach (libsecondlife.LLUUID UUID in UserProfiles.Keys) {
55 if((UserProfiles[UUID].firstname==firstname) && (UserProfiles[UUID].lastname==lastname)) return UserProfiles[UUID];
56 }
57 return null;
58 }
59
60 public UserProfile GetProfileByLLUUID(LLUUID ProfileLLUUID) {
61 return UserProfiles[ProfileLLUUID];
62 }
63
64 public bool AuthenticateUser(string firstname, string lastname, string passwd) {
65 UserProfile TheUser=GetProfileByName(firstname, lastname);
66 if(TheUser != null)
67 if(TheUser.MD5passwd==passwd) {
68 return true;
69 } else {
70 return false;
71 } else return false;
72
73 }
74
75 public void SetGod(LLUUID GodID) {
76 this.UserProfiles[GodID].IsGridGod=true;
77 }
78
79 public UserProfile CreateNewProfile(string firstname, string lastname, string MD5passwd) {
80 UserProfile newprofile = new UserProfile();
81 newprofile.homeregionhandle=Util.UIntsToLong((997*256), (996*256));
82 newprofile.firstname=firstname;
83 newprofile.lastname=lastname;
84 newprofile.MD5passwd=MD5passwd;
85 newprofile.UUID=LLUUID.Random();
86 this.UserProfiles.Add(newprofile.UUID,newprofile);
87 return newprofile;
88 }
89
90 }
91
92 public class UserProfile {
93
94 public string firstname;
95 public string lastname;
96 public ulong homeregionhandle;
97 public LLVector3 homepos;
98 public LLVector3 homelookat;
99
100 public bool IsGridGod=false;
101 public bool IsLocal=true; // will be used in future for visitors from foreign grids
102 public string AssetURL;
103 public string MD5passwd;
104
105 public LLUUID CurrentSessionID;
106 public LLUUID CurrentSecureSessionID;
107 public LLUUID UUID;
108 public Dictionary<LLUUID, uint> Circuits = new Dictionary<LLUUID, uint>(); // tracks circuit codes
109
110 public InventoryFolder InventoryRoot;
111 public Dictionary<LLUUID, InventoryFolder> InventoryFolders;
112 public Dictionary<LLUUID, InventoryItem> InventoryItems;
113
114 public UserProfile() {
115 Circuits = new Dictionary<LLUUID, uint>();
116 InventoryFolders = new Dictionary<LLUUID, InventoryFolder>();
117 InventoryItems = new Dictionary<LLUUID, InventoryItem>();
118 InventoryRoot=new InventoryFolder();
119 InventoryRoot.FolderID = LLUUID.Random();
120 InventoryRoot.ParentID=new LLUUID();
121 InventoryRoot.Version=1;
122 InventoryRoot.DefaultType=8;
123 InventoryRoot.FolderName="My Inventory";
124 InventoryFolders.Add(InventoryRoot.FolderID, InventoryRoot);
125 homeregionhandle=Util.UIntsToLong((997*256), (996*256));;
126 }
127
128 public void InitSessionData() {
129 CurrentSessionID=LLUUID.Random();
130 CurrentSecureSessionID=LLUUID.Random();
131 }
132
133 public void AddSimCircuit(uint circuit_code, LLUUID region_UUID) {
134 if(this.Circuits.ContainsKey(region_UUID)== false)
135 this.Circuits.Add(region_UUID, circuit_code);
136 }
137
138 public void SendDataToSim(SimProfile TheSim) {
139 Console.WriteLine(TheSim.caps_url);
140 Hashtable SimParams = new Hashtable();
141 SimParams["session_id"]=this.CurrentSessionID.ToString();
142 SimParams["secure_session_id"]=this.CurrentSecureSessionID.ToString();
143 SimParams["firstname"]=this.firstname;
144 SimParams["lastname"]=this.lastname;
145 SimParams["agent_id"]=this.UUID.ToString();
146 SimParams["circuit_code"]=(Int32)this.Circuits[TheSim.UUID];
147 ArrayList SendParams = new ArrayList();
148 SendParams.Add(SimParams);
149
150 XmlRpcRequest GridReq = new XmlRpcRequest("expect_user",SendParams);
151 XmlRpcResponse GridResp = GridReq.Send(TheSim.caps_url,3000);
152 }
153 }
154
155 public class InventoryFolder {
156 public LLUUID FolderID;
157 public LLUUID ParentID;
158 public string FolderName;
159 public ushort DefaultType;
160 public ushort Version;
161 }
162
163 public class InventoryItem { //TODO: Fixup this and add full permissions etc
164 public LLUUID FolderID;
165 public LLUUID OwnerID;
166 public LLUUID ItemID;
167 public LLUUID AssetID;
168 public LLUUID CreatorID = LLUUID.Zero;
169 public sbyte InvType;
170 public sbyte Type;
171 public string Name;
172 public string Description;
173 }
174
175 public class SimProfile {
176 public LLUUID UUID;
177 public ulong regionhandle;
178 public string regionname;
179 public string sim_ip;
180 public uint sim_port;
181 public string caps_url;
182 public uint RegionLocX;
183 public uint RegionLocY;
184 public string sendkey;
185 public string recvkey;
186
187
188 public SimProfile LoadFromGrid(ulong region_handle, string GridURL, string SendKey, string RecvKey) {
189 try {
190 Hashtable GridReqParams = new Hashtable();
191 GridReqParams["region_handle"]=region_handle.ToString();
192 GridReqParams["caller"]="userserver";
193 GridReqParams["authkey"]=SendKey;
194 ArrayList SendParams = new ArrayList();
195 SendParams.Add(GridReqParams);
196 XmlRpcRequest GridReq = new XmlRpcRequest("get_sim_info",SendParams);
197
198 XmlRpcResponse GridResp = GridReq.Send(GridURL,3000);
199
200 Hashtable RespData=(Hashtable)GridResp.Value;
201 this.UUID = new LLUUID((string)RespData["UUID"]);
202 this.regionhandle = (ulong)Convert.ToUInt64(RespData["regionhandle"]);
203 this.regionname=(string)RespData["regionname"];
204 this.sim_ip=(string)RespData["sim_ip"];
205 this.sim_port=(uint)Convert.ToUInt16(RespData["sim_port"]);
206 this.caps_url=(string)RespData["caps_url"];
207 this.RegionLocX=(uint)Convert.ToUInt32(RespData["RegionLocX"]);
208 this.RegionLocY=(uint)Convert.ToUInt32(RespData["RegionLocY"]);
209 this.sendkey=(string)RespData["sendkey"];
210 this.recvkey=(string)RespData["recvkey"];
211 } catch(Exception e) {
212 Console.WriteLine(e.ToString());
213 }
214 return this;
215 }
216
217 public SimProfile() {
218 }
219
220
221 }
222
223}