aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
diff options
context:
space:
mode:
authorAdam Frisby2008-05-01 16:41:01 +0000
committerAdam Frisby2008-05-01 16:41:01 +0000
commitfc6c4dc399587f6f920d3f0759b1bd7a8b9b4ac8 (patch)
tree90a4799fa43e3761ffbe669d1d87837933d8db53 /OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
parent* Deletes my EventReader ScriptRewriter. It isn't required to rewrite the sc... (diff)
downloadopensim-SC_OLD-fc6c4dc399587f6f920d3f0759b1bd7a8b9b4ac8.zip
opensim-SC_OLD-fc6c4dc399587f6f920d3f0759b1bd7a8b9b4ac8.tar.gz
opensim-SC_OLD-fc6c4dc399587f6f920d3f0759b1bd7a8b9b4ac8.tar.bz2
opensim-SC_OLD-fc6c4dc399587f6f920d3f0759b1bd7a8b9b4ac8.tar.xz
* Cleaning code still.
Diffstat (limited to '')
-rw-r--r--OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs216
1 files changed, 116 insertions, 100 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
index e540e4d..b7067e7 100644
--- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
+++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
@@ -54,11 +54,13 @@ namespace OpenSim.ApplicationPlugins.RemoteController
54 private BaseHttpServer m_httpd; 54 private BaseHttpServer m_httpd;
55 private string requiredPassword = String.Empty; 55 private string requiredPassword = String.Empty;
56 56
57 #region IApplicationPlugin Members
58
57 public void Initialise(OpenSimMain openSim) 59 public void Initialise(OpenSimMain openSim)
58 { 60 {
59 try 61 try
60 { 62 {
61 if (openSim.ConfigSource.Configs["RemoteAdmin"] != null && 63 if (openSim.ConfigSource.Configs["RemoteAdmin"] != null &&
62 openSim.ConfigSource.Configs["RemoteAdmin"].GetBoolean("enabled", false)) 64 openSim.ConfigSource.Configs["RemoteAdmin"].GetBoolean("enabled", false))
63 { 65 {
64 m_log.Info("[RADMIN]: Remote Admin Plugin Enabled"); 66 m_log.Info("[RADMIN]: Remote Admin Plugin Enabled");
@@ -82,6 +84,12 @@ namespace OpenSim.ApplicationPlugins.RemoteController
82 } 84 }
83 } 85 }
84 86
87 public void Close()
88 {
89 }
90
91 #endregion
92
85 public XmlRpcResponse XmlRpcRestartMethod(XmlRpcRequest request) 93 public XmlRpcResponse XmlRpcRestartMethod(XmlRpcRequest request)
86 { 94 {
87 XmlRpcResponse response = new XmlRpcResponse(); 95 XmlRpcResponse response = new XmlRpcResponse();
@@ -90,13 +98,14 @@ namespace OpenSim.ApplicationPlugins.RemoteController
90 Hashtable responseData = new Hashtable(); 98 Hashtable responseData = new Hashtable();
91 99
92 m_log.Info("[RADMIN]: Request to restart Region."); 100 m_log.Info("[RADMIN]: Request to restart Region.");
93 try { 101 try
94 checkStringParameters(request, new string[] { "password", "regionID" }); 102 {
103 checkStringParameters(request, new[] {"password", "regionID"});
95 104
96 if (requiredPassword != String.Empty && 105 if (requiredPassword != String.Empty &&
97 (!requestData.Contains("password") || (string) requestData["password"] != requiredPassword)) 106 (!requestData.Contains("password") || (string) requestData["password"] != requiredPassword))
98 throw new Exception("wrong password"); 107 throw new Exception("wrong password");
99 108
100 LLUUID regionID = new LLUUID((string) requestData["regionID"]); 109 LLUUID regionID = new LLUUID((string) requestData["regionID"]);
101 110
102 responseData["accepted"] = "true"; 111 responseData["accepted"] = "true";
@@ -106,11 +115,11 @@ namespace OpenSim.ApplicationPlugins.RemoteController
106 115
107 if (!m_app.SceneManager.TryGetScene(regionID, out rebootedScene)) 116 if (!m_app.SceneManager.TryGetScene(regionID, out rebootedScene))
108 throw new Exception("region not found"); 117 throw new Exception("region not found");
109 118
110 responseData["rebooting"] = "true"; 119 responseData["rebooting"] = "true";
111 rebootedScene.Restart(30); 120 rebootedScene.Restart(30);
112 } 121 }
113 catch(Exception e) 122 catch (Exception e)
114 { 123 {
115 m_log.ErrorFormat("[RADMIN]: Restart region: failed: {0}", e.Message); 124 m_log.ErrorFormat("[RADMIN]: Restart region: failed: {0}", e.Message);
116 m_log.DebugFormat("[RADMIN]: Restart region: failed: {0}", e.ToString()); 125 m_log.DebugFormat("[RADMIN]: Restart region: failed: {0}", e.ToString());
@@ -130,13 +139,14 @@ namespace OpenSim.ApplicationPlugins.RemoteController
130 Hashtable requestData = (Hashtable) request.Params[0]; 139 Hashtable requestData = (Hashtable) request.Params[0];
131 Hashtable responseData = new Hashtable(); 140 Hashtable responseData = new Hashtable();
132 141
133 try { 142 try
134 checkStringParameters(request, new string[] { "password", "message" }); 143 {
144 checkStringParameters(request, new[] {"password", "message"});
135 145
136 if (requiredPassword != String.Empty && 146 if (requiredPassword != String.Empty &&
137 (!requestData.Contains("password") || (string) requestData["password"] != requiredPassword)) 147 (!requestData.Contains("password") || (string) requestData["password"] != requiredPassword))
138 throw new Exception("wrong password"); 148 throw new Exception("wrong password");
139 149
140 string message = (string) requestData["message"]; 150 string message = (string) requestData["message"];
141 m_log.InfoFormat("[RADMIN]: Broadcasting: {0}", message); 151 m_log.InfoFormat("[RADMIN]: Broadcasting: {0}", message);
142 152
@@ -145,7 +155,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
145 155
146 m_app.SceneManager.SendGeneralMessage(message); 156 m_app.SceneManager.SendGeneralMessage(message);
147 } 157 }
148 catch(Exception e) 158 catch (Exception e)
149 { 159 {
150 m_log.ErrorFormat("[RADMIN]: Broadcasting: failed: {0}", e.Message); 160 m_log.ErrorFormat("[RADMIN]: Broadcasting: failed: {0}", e.Message);
151 m_log.DebugFormat("[RADMIN]: Broadcasting: failed: {0}", e.ToString()); 161 m_log.DebugFormat("[RADMIN]: Broadcasting: failed: {0}", e.ToString());
@@ -162,24 +172,25 @@ namespace OpenSim.ApplicationPlugins.RemoteController
162 public XmlRpcResponse XmlRpcLoadHeightmapMethod(XmlRpcRequest request) 172 public XmlRpcResponse XmlRpcLoadHeightmapMethod(XmlRpcRequest request)
163 { 173 {
164 XmlRpcResponse response = new XmlRpcResponse(); 174 XmlRpcResponse response = new XmlRpcResponse();
165 Hashtable requestData = (Hashtable)request.Params[0]; 175 Hashtable requestData = (Hashtable) request.Params[0];
166 176
167 m_log.DebugFormat("[RADMIN]: Load Terrain: XmlRpc {0}", request.ToString()); 177 m_log.DebugFormat("[RADMIN]: Load Terrain: XmlRpc {0}", request.ToString());
168 foreach (string k in requestData.Keys) 178 foreach (string k in requestData.Keys)
169 { 179 {
170 m_log.DebugFormat("[RADMIN]: Load Terrain: XmlRpc {0}: >{1}< {2}", 180 m_log.DebugFormat("[RADMIN]: Load Terrain: XmlRpc {0}: >{1}< {2}",
171 k, (string)requestData[k], ((string)requestData[k]).Length); 181 k, requestData[k], ((string) requestData[k]).Length);
172 } 182 }
173 183
174 Hashtable responseData = new Hashtable(); 184 Hashtable responseData = new Hashtable();
175 try { 185 try
176 checkStringParameters(request, new string[] { "password", "filename", "regionid"}); 186 {
187 checkStringParameters(request, new[] {"password", "filename", "regionid"});
177 188
178 if (requiredPassword != String.Empty && 189 if (requiredPassword != String.Empty &&
179 (!requestData.Contains("password") || (string)requestData["password"] != requiredPassword)) 190 (!requestData.Contains("password") || (string) requestData["password"] != requiredPassword))
180 throw new Exception("wrong password"); 191 throw new Exception("wrong password");
181 192
182 string file = (string)requestData["filename"]; 193 string file = (string) requestData["filename"];
183 LLUUID regionID = (string) requestData["regionid"]; 194 LLUUID regionID = (string) requestData["regionid"];
184 m_log.InfoFormat("[RADMIN]: Terrain Loading: {0}", file); 195 m_log.InfoFormat("[RADMIN]: Terrain Loading: {0}", file);
185 196
@@ -198,7 +209,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
198 209
199 response.Value = responseData; 210 response.Value = responseData;
200 } 211 }
201 catch (Exception e) 212 catch (Exception e)
202 { 213 {
203 m_log.ErrorFormat("[RADMIN] Terrain Loading: failed: {0}", e.Message); 214 m_log.ErrorFormat("[RADMIN] Terrain Loading: failed: {0}", e.Message);
204 m_log.DebugFormat("[RADMIN] Terrain Loading: failed: {0}", e.ToString()); 215 m_log.DebugFormat("[RADMIN] Terrain Loading: failed: {0}", e.ToString());
@@ -217,7 +228,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController
217 Hashtable requestData = (Hashtable) request.Params[0]; 228 Hashtable requestData = (Hashtable) request.Params[0];
218 Hashtable responseData = new Hashtable(); 229 Hashtable responseData = new Hashtable();
219 230
220 try { 231 try
232 {
221 if (requiredPassword != String.Empty && 233 if (requiredPassword != String.Empty &&
222 (!requestData.Contains("password") || (string) requestData["password"] != requiredPassword)) 234 (!requestData.Contains("password") || (string) requestData["password"] != requiredPassword))
223 throw new Exception("wrong password"); 235 throw new Exception("wrong password");
@@ -227,14 +239,14 @@ namespace OpenSim.ApplicationPlugins.RemoteController
227 239
228 int timeout = 2000; 240 int timeout = 2000;
229 241
230 if (requestData.ContainsKey("shutdown") && 242 if (requestData.ContainsKey("shutdown") &&
231 ((string) requestData["shutdown"] == "delayed") && 243 ((string) requestData["shutdown"] == "delayed") &&
232 requestData.ContainsKey("milliseconds")) 244 requestData.ContainsKey("milliseconds"))
233 { 245 {
234 timeout = (Int32) requestData["milliseconds"]; 246 timeout = (Int32) requestData["milliseconds"];
235 m_app.SceneManager.SendGeneralMessage("Region is going down in " + ((int) (timeout/1000)).ToString() + 247 m_app.SceneManager.SendGeneralMessage("Region is going down in " + ((timeout / 1000)) +
236 " second(s). Please save what you are doing and log out."); 248 " second(s). Please save what you are doing and log out.");
237 } 249 }
238 else 250 else
239 { 251 {
240 m_app.SceneManager.SendGeneralMessage("Region is going down now."); 252 m_app.SceneManager.SendGeneralMessage("Region is going down now.");
@@ -243,12 +255,12 @@ namespace OpenSim.ApplicationPlugins.RemoteController
243 // Perform shutdown 255 // Perform shutdown
244 Timer shutdownTimer = new Timer(timeout); // Wait before firing 256 Timer shutdownTimer = new Timer(timeout); // Wait before firing
245 shutdownTimer.AutoReset = false; 257 shutdownTimer.AutoReset = false;
246 shutdownTimer.Elapsed += new ElapsedEventHandler(shutdownTimer_Elapsed); 258 shutdownTimer.Elapsed += shutdownTimer_Elapsed;
247 shutdownTimer.Start(); 259 shutdownTimer.Start();
248 260
249 responseData["success"] = "true"; 261 responseData["success"] = "true";
250 } 262 }
251 catch (Exception e) 263 catch (Exception e)
252 { 264 {
253 m_log.ErrorFormat("[RADMIN] Shutdown: failed: {0}", e.Message); 265 m_log.ErrorFormat("[RADMIN] Shutdown: failed: {0}", e.Message);
254 m_log.DebugFormat("[RADMIN] Shutdown: failed: {0}", e.ToString()); 266 m_log.DebugFormat("[RADMIN] Shutdown: failed: {0}", e.ToString());
@@ -272,9 +284,9 @@ namespace OpenSim.ApplicationPlugins.RemoteController
272 Hashtable requestData = (Hashtable) request.Params[0]; 284 Hashtable requestData = (Hashtable) request.Params[0];
273 foreach (string p in param) 285 foreach (string p in param)
274 { 286 {
275 if (!requestData.Contains(p)) 287 if (!requestData.Contains(p))
276 throw new Exception(String.Format("missing string parameter {0}", p)); 288 throw new Exception(String.Format("missing string parameter {0}", p));
277 if (String.IsNullOrEmpty((string)requestData[p])) 289 if (String.IsNullOrEmpty((string) requestData[p]))
278 throw new Exception(String.Format("parameter {0} is empty", p)); 290 throw new Exception(String.Format("parameter {0} is empty", p));
279 } 291 }
280 } 292 }
@@ -284,7 +296,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
284 Hashtable requestData = (Hashtable) request.Params[0]; 296 Hashtable requestData = (Hashtable) request.Params[0];
285 foreach (string p in param) 297 foreach (string p in param)
286 { 298 {
287 if (!requestData.Contains(p)) 299 if (!requestData.Contains(p))
288 throw new Exception(String.Format("missing integer parameter {0}", p)); 300 throw new Exception(String.Format("missing integer parameter {0}", p));
289 } 301 }
290 } 302 }
@@ -345,31 +357,35 @@ namespace OpenSim.ApplicationPlugins.RemoteController
345 Hashtable requestData = (Hashtable) request.Params[0]; 357 Hashtable requestData = (Hashtable) request.Params[0];
346 Hashtable responseData = new Hashtable(); 358 Hashtable responseData = new Hashtable();
347 359
348 try { 360 try
349 checkStringParameters(request, new string[] { "password", 361 {
350 "region_name", 362 checkStringParameters(request, new[]
351 "region_master_first", "region_master_last", 363 {
352 "region_master_password", 364 "password",
353 "listen_ip", "external_address"}); 365 "region_name",
354 checkIntegerParams(request, new string[] { "region_x", "region_y", "listen_port"}); 366 "region_master_first", "region_master_last",
367 "region_master_password",
368 "listen_ip", "external_address"
369 });
370 checkIntegerParams(request, new[] {"region_x", "region_y", "listen_port"});
355 371
356 // check password 372 // check password
357 if (!String.IsNullOrEmpty(requiredPassword) && 373 if (!String.IsNullOrEmpty(requiredPassword) &&
358 (string)requestData["password"] != requiredPassword) throw new Exception("wrong password"); 374 (string) requestData["password"] != requiredPassword) throw new Exception("wrong password");
359 375
360 // extract or generate region ID now 376 // extract or generate region ID now
361 Scene scene = null; 377 Scene scene = null;
362 LLUUID regionID = LLUUID.Zero; 378 LLUUID regionID = LLUUID.Zero;
363 if (requestData.ContainsKey("region_id") && 379 if (requestData.ContainsKey("region_id") &&
364 !String.IsNullOrEmpty((string)requestData["region_id"])) 380 !String.IsNullOrEmpty((string) requestData["region_id"]))
365 { 381 {
366 regionID = (string) requestData["region_id"]; 382 regionID = (string) requestData["region_id"];
367 if (m_app.SceneManager.TryGetScene(regionID, out scene)) 383 if (m_app.SceneManager.TryGetScene(regionID, out scene))
368 throw new Exception(String.Format("region UUID already in use by region {0}, UUID {1}, <{2},{3}>", 384 throw new Exception(String.Format("region UUID already in use by region {0}, UUID {1}, <{2},{3}>",
369 scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, 385 scene.RegionInfo.RegionName, scene.RegionInfo.RegionID,
370 scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY)); 386 scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY));
371 } 387 }
372 else 388 else
373 { 389 {
374 regionID = LLUUID.Random(); 390 regionID = LLUUID.Random();
375 m_log.DebugFormat("[RADMIN] CreateRegion: new region UUID {0}", regionID); 391 m_log.DebugFormat("[RADMIN] CreateRegion: new region UUID {0}", regionID);
@@ -385,7 +401,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
385 401
386 // check for collisions: region name, region UUID, 402 // check for collisions: region name, region UUID,
387 // region location 403 // region location
388 if (m_app.SceneManager.TryGetScene(region.RegionName, out scene)) 404 if (m_app.SceneManager.TryGetScene(region.RegionName, out scene))
389 throw new Exception(String.Format("region name already in use by region {0}, UUID {1}, <{2},{3}>", 405 throw new Exception(String.Format("region name already in use by region {0}, UUID {1}, <{2},{3}>",
390 scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, 406 scene.RegionInfo.RegionName, scene.RegionInfo.RegionID,
391 scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY)); 407 scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY));
@@ -395,46 +411,46 @@ namespace OpenSim.ApplicationPlugins.RemoteController
395 region.RegionLocX, region.RegionLocY, 411 region.RegionLocX, region.RegionLocY,
396 scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, 412 scene.RegionInfo.RegionName, scene.RegionInfo.RegionID,
397 scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY)); 413 scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY));
398 414
399 // Security risk [and apparently not used] 415 // Security risk [and apparently not used]
400 // if (requestData.ContainsKey("datastore")) 416 // if (requestData.ContainsKey("datastore"))
401 // region.DataStore = (string) requestData["datastore"]; 417 // region.DataStore = (string) requestData["datastore"];
402 418
403 region.InternalEndPoint = 419 region.InternalEndPoint =
404 new IPEndPoint(IPAddress.Parse((string) requestData["listen_ip"]), 0); 420 new IPEndPoint(IPAddress.Parse((string) requestData["listen_ip"]), 0);
405 421
406 region.InternalEndPoint.Port = (Int32) requestData["listen_port"]; 422 region.InternalEndPoint.Port = (Int32) requestData["listen_port"];
407 if (0 == region.InternalEndPoint.Port) throw new Exception("listen_port is 0"); 423 if (0 == region.InternalEndPoint.Port) throw new Exception("listen_port is 0");
408 if (m_app.SceneManager.TryGetScene(region.InternalEndPoint, out scene)) 424 if (m_app.SceneManager.TryGetScene(region.InternalEndPoint, out scene))
409 throw new Exception(String.Format("region internal IP {0} and port {1} already in use by region {2}, UUID {3}, <{4},{5}>", 425 throw new Exception(String.Format("region internal IP {0} and port {1} already in use by region {2}, UUID {3}, <{4},{5}>",
410 region.InternalEndPoint.Address, 426 region.InternalEndPoint.Address,
411 region.InternalEndPoint.Port, 427 region.InternalEndPoint.Port,
412 scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, 428 scene.RegionInfo.RegionName, scene.RegionInfo.RegionID,
413 scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY)); 429 scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY));
414 430
415 431
416 region.ExternalHostName = (string) requestData["external_address"]; 432 region.ExternalHostName = (string) requestData["external_address"];
417 433
418 region.MasterAvatarFirstName = (string) requestData["region_master_first"]; 434 region.MasterAvatarFirstName = (string) requestData["region_master_first"];
419 region.MasterAvatarLastName = (string) requestData["region_master_last"]; 435 region.MasterAvatarLastName = (string) requestData["region_master_last"];
420 region.MasterAvatarSandboxPassword = (string) requestData["region_master_password"]; 436 region.MasterAvatarSandboxPassword = (string) requestData["region_master_password"];
421 437
422 bool persist = Convert.ToBoolean((string)requestData["persist"]); 438 bool persist = Convert.ToBoolean((string) requestData["persist"]);
423 if (persist) 439 if (persist)
424 { 440 {
425 string regionConfigPath = Path.Combine(Path.Combine(Util.configDir(), "Regions"), 441 string regionConfigPath = Path.Combine(Path.Combine(Util.configDir(), "Regions"),
426 String.Format("{0}x{1}-{2}.xml", 442 String.Format("{0}x{1}-{2}.xml",
427 region.RegionLocX.ToString(), 443 region.RegionLocX,
428 region.RegionLocY.ToString(), 444 region.RegionLocY,
429 regionID.ToString())); 445 regionID));
430 m_log.DebugFormat("[RADMIN] CreateRegion: persisting region {0} to {1}", 446 m_log.DebugFormat("[RADMIN] CreateRegion: persisting region {0} to {1}",
431 region.RegionID, regionConfigPath); 447 region.RegionID, regionConfigPath);
432 region.SaveRegionToFile("dynamic region", regionConfigPath); 448 region.SaveRegionToFile("dynamic region", regionConfigPath);
433 } 449 }
434 450
435 m_app.CreateRegion(region); 451 m_app.CreateRegion(region);
436 452
437 responseData["success"] = "true"; 453 responseData["success"] = "true";
438 responseData["region_name"] = region.RegionName; 454 responseData["region_name"] = region.RegionName;
439 responseData["region_uuid"] = region.RegionID.ToString(); 455 responseData["region_uuid"] = region.RegionID.ToString();
440 456
@@ -497,48 +513,52 @@ namespace OpenSim.ApplicationPlugins.RemoteController
497 Hashtable requestData = (Hashtable) request.Params[0]; 513 Hashtable requestData = (Hashtable) request.Params[0];
498 Hashtable responseData = new Hashtable(); 514 Hashtable responseData = new Hashtable();
499 515
500 try 516 try
501 { 517 {
502 // check completeness 518 // check completeness
503 checkStringParameters(request, new string[] { "password", "user_firstname", 519 checkStringParameters(request, new[]
504 "user_lastname", "user_password" }); 520 {
505 checkIntegerParams(request, new string[] { "start_region_x", "start_region_y" }); 521 "password", "user_firstname",
522 "user_lastname", "user_password"
523 });
524 checkIntegerParams(request, new[] {"start_region_x", "start_region_y"});
506 525
507 // check password 526 // check password
508 if (!String.IsNullOrEmpty(requiredPassword) && 527 if (!String.IsNullOrEmpty(requiredPassword) &&
509 (string)requestData["password"] != requiredPassword) throw new Exception("wrong password"); 528 (string) requestData["password"] != requiredPassword) throw new Exception("wrong password");
510 529
511 // do the job 530 // do the job
512 string firstname = (string) requestData["user_firstname"]; 531 string firstname = (string) requestData["user_firstname"];
513 string lastname = (string) requestData["user_lastname"]; 532 string lastname = (string) requestData["user_lastname"];
514 string passwd = (string) requestData["user_password"]; 533 string passwd = (string) requestData["user_password"];
515 uint regX = Convert.ToUInt32((Int32)requestData["start_region_x"]); 534 uint regX = Convert.ToUInt32((Int32) requestData["start_region_x"]);
516 uint regY = Convert.ToUInt32((Int32)requestData["start_region_y"]); 535 uint regY = Convert.ToUInt32((Int32) requestData["start_region_y"]);
517 536
518 UserProfileData userProfile = m_app.CommunicationsManager.UserService.GetUserProfile(firstname, lastname); 537 UserProfileData userProfile = m_app.CommunicationsManager.UserService.GetUserProfile(firstname, lastname);
519 if (null != userProfile) 538 if (null != userProfile)
520 throw new Exception(String.Format("avatar {0} {1} already exists", firstname, lastname)); 539 throw new Exception(String.Format("avatar {0} {1} already exists", firstname, lastname));
521 540
522 LLUUID userID = m_app.CreateUser(firstname, lastname, passwd, regX, regY); 541 LLUUID userID = m_app.CreateUser(firstname, lastname, passwd, regX, regY);
523 542
524 if (userID == LLUUID.Zero) throw new Exception(String.Format("failed to create new user {0} {1}", 543 if (userID == LLUUID.Zero)
525 firstname, lastname)); 544 throw new Exception(String.Format("failed to create new user {0} {1}",
526 545 firstname, lastname));
527 responseData["success"] = "true"; 546
547 responseData["success"] = "true";
528 responseData["avatar_uuid"] = userID.ToString(); 548 responseData["avatar_uuid"] = userID.ToString();
529 549
530 response.Value = responseData; 550 response.Value = responseData;
531 551
532 m_log.InfoFormat("[RADMIN]: CreateUser: User {0} {1} created, UUID {2}", firstname, lastname, userID); 552 m_log.InfoFormat("[RADMIN]: CreateUser: User {0} {1} created, UUID {2}", firstname, lastname, userID);
533 } 553 }
534 catch (Exception e) 554 catch (Exception e)
535 { 555 {
536 m_log.ErrorFormat("[RADMIN] CreateUser: failed: {0}", e.Message); 556 m_log.ErrorFormat("[RADMIN] CreateUser: failed: {0}", e.Message);
537 m_log.DebugFormat("[RADMIN] CreateUser: failed: {0}", e.ToString()); 557 m_log.DebugFormat("[RADMIN] CreateUser: failed: {0}", e.ToString());
538 558
539 responseData["success"] = "false"; 559 responseData["success"] = "false";
540 responseData["avatar_uuid"] = LLUUID.Zero.ToString(); 560 responseData["avatar_uuid"] = LLUUID.Zero.ToString();
541 responseData["error"] = e.Message; 561 responseData["error"] = e.Message;
542 562
543 response.Value = responseData; 563 response.Value = responseData;
544 } 564 }
@@ -553,33 +573,33 @@ namespace OpenSim.ApplicationPlugins.RemoteController
553 Hashtable requestData = (Hashtable) request.Params[0]; 573 Hashtable requestData = (Hashtable) request.Params[0];
554 Hashtable responseData = new Hashtable(); 574 Hashtable responseData = new Hashtable();
555 575
556 try 576 try
557 { 577 {
558 // check completeness 578 // check completeness
559 foreach (string p in new string[] { "password", "filename" }) 579 foreach (string p in new[] {"password", "filename"})
560 { 580 {
561 if (!requestData.Contains(p)) 581 if (!requestData.Contains(p))
562 throw new Exception(String.Format("missing parameter {0}", p)); 582 throw new Exception(String.Format("missing parameter {0}", p));
563 if (String.IsNullOrEmpty((string)requestData[p])) 583 if (String.IsNullOrEmpty((string) requestData[p]))
564 throw new Exception(String.Format("parameter {0} is empty")); 584 throw new Exception(String.Format("parameter {0} is empty"));
565 } 585 }
566 586
567 // check password 587 // check password
568 if (!String.IsNullOrEmpty(requiredPassword) && 588 if (!String.IsNullOrEmpty(requiredPassword) &&
569 (string)requestData["password"] != requiredPassword) throw new Exception("wrong password"); 589 (string) requestData["password"] != requiredPassword) throw new Exception("wrong password");
570 590
571 string filename = (string)requestData["filename"]; 591 string filename = (string) requestData["filename"];
572 if (requestData.Contains("region_uuid")) 592 if (requestData.Contains("region_uuid"))
573 { 593 {
574 LLUUID region_uuid = (string)requestData["region_uuid"]; 594 LLUUID region_uuid = (string) requestData["region_uuid"];
575 if (!m_app.SceneManager.TrySetCurrentScene(region_uuid)) 595 if (!m_app.SceneManager.TrySetCurrentScene(region_uuid))
576 throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString())); 596 throw new Exception(String.Format("failed to switch to region {0}", region_uuid));
577 m_log.InfoFormat("[RADMIN] Switched to region {0}", region_uuid.ToString()); 597 m_log.InfoFormat("[RADMIN] Switched to region {0}", region_uuid.ToString());
578 } 598 }
579 else if (requestData.Contains("region_name")) 599 else if (requestData.Contains("region_name"))
580 { 600 {
581 string region_name = (string)requestData["region_name"]; 601 string region_name = (string) requestData["region_name"];
582 if (!m_app.SceneManager.TrySetCurrentScene(region_name)) 602 if (!m_app.SceneManager.TrySetCurrentScene(region_name))
583 throw new Exception(String.Format("failed to switch to region {0}", region_name)); 603 throw new Exception(String.Format("failed to switch to region {0}", region_name));
584 m_log.InfoFormat("[RADMIN] Switched to region {0}", region_name); 604 m_log.InfoFormat("[RADMIN] Switched to region {0}", region_name);
585 } 605 }
@@ -588,27 +608,23 @@ namespace OpenSim.ApplicationPlugins.RemoteController
588 responseData["switched"] = "true"; 608 responseData["switched"] = "true";
589 609
590 m_app.SceneManager.LoadCurrentSceneFromXml(filename, true, new LLVector3(0, 0, 0)); 610 m_app.SceneManager.LoadCurrentSceneFromXml(filename, true, new LLVector3(0, 0, 0));
591 responseData["loaded"] = "true"; 611 responseData["loaded"] = "true";
592 612
593 response.Value = responseData; 613 response.Value = responseData;
594 } 614 }
595 catch (Exception e) 615 catch (Exception e)
596 { 616 {
597 m_log.InfoFormat("[RADMIN] LoadXml: {0}", e.Message); 617 m_log.InfoFormat("[RADMIN] LoadXml: {0}", e.Message);
598 m_log.DebugFormat("[RADMIN] LoadXml: {0}", e.ToString()); 618 m_log.DebugFormat("[RADMIN] LoadXml: {0}", e.ToString());
599 619
600 responseData["loaded"] = "false"; 620 responseData["loaded"] = "false";
601 responseData["switched"] = "false"; 621 responseData["switched"] = "false";
602 responseData["error"] = e.Message; 622 responseData["error"] = e.Message;
603 623
604 response.Value = responseData; 624 response.Value = responseData;
605 } 625 }
606
607 return response;
608 }
609 626
610 public void Close() 627 return response;
611 {
612 } 628 }
613 } 629 }
614} \ No newline at end of file 630} \ No newline at end of file