diff options
Diffstat (limited to 'OpenGridServices.GridServer/SimProfiles.cs')
-rw-r--r-- | OpenGridServices.GridServer/SimProfiles.cs | 65 |
1 files changed, 42 insertions, 23 deletions
diff --git a/OpenGridServices.GridServer/SimProfiles.cs b/OpenGridServices.GridServer/SimProfiles.cs index 9e93db0..5e02b4f 100644 --- a/OpenGridServices.GridServer/SimProfiles.cs +++ b/OpenGridServices.GridServer/SimProfiles.cs | |||
@@ -71,7 +71,10 @@ namespace OpenGridServices.GridServer | |||
71 | } | 71 | } |
72 | 72 | ||
73 | public SimProfileBase GetProfileByLLUUID(LLUUID ProfileLLUUID) { | 73 | public SimProfileBase GetProfileByLLUUID(LLUUID ProfileLLUUID) { |
74 | return SimProfiles[ProfileLLUUID]; | 74 | foreach (libsecondlife.LLUUID UUID in SimProfiles.Keys) { |
75 | if(SimProfiles[UUID].UUID==ProfileLLUUID) return SimProfiles[UUID]; | ||
76 | } | ||
77 | return null; | ||
75 | } | 78 | } |
76 | 79 | ||
77 | public bool AuthenticateSim(LLUUID RegionUUID, uint regionhandle, string simrecvkey) { | 80 | public bool AuthenticateSim(LLUUID RegionUUID, uint regionhandle, string simrecvkey) { |
@@ -172,13 +175,13 @@ namespace OpenGridServices.GridServer | |||
172 | responseData["estate_id"] = "1"; | 175 | responseData["estate_id"] = "1"; |
173 | responseData["neighbours"] = SimNeighboursData; | 176 | responseData["neighbours"] = SimNeighboursData; |
174 | 177 | ||
175 | responseData["asset_url"] = m_gridManager.DefaultAssetServer; | 178 | responseData["asset_url"] = m_gridManager.Cfg.DefaultAssetServer; |
176 | responseData["asset_sendkey"] = m_gridManager.AssetSendKey; | 179 | responseData["asset_sendkey"] = m_gridManager.Cfg.AssetSendKey; |
177 | responseData["asset_recvkey"] = m_gridManager.AssetRecvKey; | 180 | responseData["asset_recvkey"] = m_gridManager.Cfg.AssetRecvKey; |
178 | responseData["user_url"] = m_gridManager.DefaultUserServer; | 181 | responseData["user_url"] = m_gridManager.Cfg.DefaultUserServer; |
179 | responseData["user_sendkey"] = m_gridManager.UserSendKey; | 182 | responseData["user_sendkey"] = m_gridManager.Cfg.UserSendKey; |
180 | responseData["user_recvkey"] = m_gridManager.UserRecvKey; | 183 | responseData["user_recvkey"] = m_gridManager.Cfg.UserRecvKey; |
181 | responseData["authkey"] = m_gridManager.SimSendKey; | 184 | responseData["authkey"] = m_gridManager.Cfg.SimSendKey; |
182 | } | 185 | } |
183 | 186 | ||
184 | return response; | 187 | return response; |
@@ -188,30 +191,33 @@ namespace OpenGridServices.GridServer | |||
188 | { | 191 | { |
189 | Console.WriteLine("SimProfiles.cs:RestSetSimMethod() - processing request......"); | 192 | Console.WriteLine("SimProfiles.cs:RestSetSimMethod() - processing request......"); |
190 | SimProfileBase TheSim; | 193 | SimProfileBase TheSim; |
191 | LLUUID UUID = new LLUUID(param); | 194 | TheSim = GetProfileByLLUUID(new LLUUID(param)); |
192 | TheSim = GetProfileByLLUUID(UUID); | 195 | if ((TheSim) == null) { |
193 | if ((TheSim) == null) TheSim = new SimProfileBase(); | 196 | TheSim = new SimProfileBase(); |
194 | 197 | LLUUID UUID = new LLUUID(param); | |
198 | TheSim.UUID=UUID; | ||
199 | } | ||
200 | |||
195 | XmlDocument doc = new XmlDocument(); | 201 | XmlDocument doc = new XmlDocument(); |
196 | doc.LoadXml(request); | 202 | doc.LoadXml(request); |
197 | XmlNode authkeynode = doc.FirstChild; | 203 | XmlNode rootnode=doc.FirstChild; |
204 | XmlNode authkeynode = rootnode.ChildNodes[0]; | ||
198 | if (authkeynode.Name != "authkey") | 205 | if (authkeynode.Name != "authkey") |
199 | { | 206 | { |
200 | return "ERROR! bad XML - expected authkey tag"; | 207 | return "ERROR! bad XML - expected authkey tag"; |
201 | } | 208 | } |
202 | 209 | ||
203 | XmlNode simnode = doc.ChildNodes[1]; | 210 | XmlNode simnode = rootnode.ChildNodes[1]; |
204 | if (simnode.Name != "sim") | 211 | if (simnode.Name != "sim") |
205 | { | 212 | { |
206 | return "ERROR! bad XML - expected sim tag"; | 213 | return "ERROR! bad XML - expected sim tag"; |
207 | } | 214 | } |
208 | 215 | ||
209 | if (authkeynode.InnerText != m_gridManager.SimRecvKey) | 216 | if (authkeynode.InnerText != m_gridManager.Cfg.SimRecvKey) |
210 | { | 217 | { |
211 | return "ERROR! invalid key"; | 218 | return "ERROR! invalid key"; |
212 | } | 219 | } |
213 | 220 | for (int i = 0; i < simnode.ChildNodes.Count; i++) { | |
214 | for (int i = 0; i <= simnode.ChildNodes.Count; i++) { | ||
215 | switch (simnode.ChildNodes[i].Name) { | 221 | switch (simnode.ChildNodes[i].Name) { |
216 | case "regionname": | 222 | case "regionname": |
217 | TheSim.regionname = simnode.ChildNodes[i].InnerText; | 223 | TheSim.regionname = simnode.ChildNodes[i].InnerText; |
@@ -231,12 +237,23 @@ namespace OpenGridServices.GridServer | |||
231 | break; | 237 | break; |
232 | 238 | ||
233 | case "region_locy": | 239 | case "region_locy": |
234 | TheSim.RegionLocY = Convert.ToUInt32((string)simnode.ChildNodes[i].InnerText); | 240 | TheSim.RegionLocY = Convert.ToUInt32((string)simnode.ChildNodes[i].InnerText); |
235 | TheSim.regionhandle = Helpers.UIntsToLong((TheSim.RegionLocX * 256), (TheSim.RegionLocY * 256)); | 241 | TheSim.regionhandle = Helpers.UIntsToLong((TheSim.RegionLocX * 256), (TheSim.RegionLocY * 256)); |
236 | break; | 242 | break; |
237 | } | 243 | } |
238 | } | 244 | } |
239 | return "OK"; | 245 | |
246 | try { | ||
247 | SimProfiles.Add(TheSim.UUID, TheSim); | ||
248 | IObjectContainer db; | ||
249 | db = Db4oFactory.OpenFile("simprofiles.yap"); | ||
250 | db.Set(TheSim); | ||
251 | db.Close(); | ||
252 | return "OK"; | ||
253 | } catch(Exception e) { | ||
254 | return "ERROR! could not save to database!"; | ||
255 | } | ||
256 | |||
240 | } | 257 | } |
241 | 258 | ||
242 | public string RestGetRegionMethod(string request, string path, string param ) | 259 | public string RestGetRegionMethod(string request, string path, string param ) |
@@ -261,7 +278,8 @@ namespace OpenGridServices.GridServer | |||
261 | 278 | ||
262 | if (!(TheSim == null)) | 279 | if (!(TheSim == null)) |
263 | { | 280 | { |
264 | respstring = "<authkey>" + m_gridManager.SimSendKey + "</authkey>"; | 281 | respstring = "<Root>"; |
282 | respstring += "<authkey>" + m_gridManager.Cfg.SimSendKey + "</authkey>"; | ||
265 | respstring += "<sim>"; | 283 | respstring += "<sim>"; |
266 | respstring += "<uuid>" + TheSim.UUID.ToString() + "</uuid>"; | 284 | respstring += "<uuid>" + TheSim.UUID.ToString() + "</uuid>"; |
267 | respstring += "<regionname>" + TheSim.regionname + "</regionname>"; | 285 | respstring += "<regionname>" + TheSim.regionname + "</regionname>"; |
@@ -271,6 +289,7 @@ namespace OpenGridServices.GridServer | |||
271 | respstring += "<region_locy>" + TheSim.RegionLocY.ToString() + "</region_locy>"; | 289 | respstring += "<region_locy>" + TheSim.RegionLocY.ToString() + "</region_locy>"; |
272 | respstring += "<estate_id>1</estate_id>"; | 290 | respstring += "<estate_id>1</estate_id>"; |
273 | respstring += "</sim>"; | 291 | respstring += "</sim>"; |
292 | respstring += "</Root>"; | ||
274 | } | 293 | } |
275 | 294 | ||
276 | return respstring; | 295 | return respstring; |