From 63a5a0194554fa52d8e3dd135afb711b14888460 Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Tue, 10 Mar 2009 20:06:25 +0000 Subject: * Cleanup and CCC (Code Convention Conformance) --- .../LoadRegions/LoadRegionsPlugin.cs | 36 +- .../RemoteController/RemoteAdminPlugin.cs | 458 +++++++++++---------- 2 files changed, 272 insertions(+), 222 deletions(-) (limited to 'OpenSim/ApplicationPlugins') diff --git a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs index db89ea9..a470f04 100644 --- a/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs +++ b/OpenSim/ApplicationPlugins/LoadRegions/LoadRegionsPlugin.cs @@ -38,7 +38,6 @@ using OpenSim.Region.CoreModules.Avatar.InstantMessage; using OpenSim.Region.CoreModules.Scripting.DynamicTexture; using OpenSim.Region.CoreModules.Scripting.LoadImageURL; using OpenSim.Region.CoreModules.Scripting.XMLRPC; -using OpenSim.Framework.Servers; namespace OpenSim.ApplicationPlugins.LoadRegions { @@ -52,11 +51,18 @@ namespace OpenSim.ApplicationPlugins.LoadRegions #region IApplicationPlugin Members // TODO: required by IPlugin, but likely not at all right - string m_name = "LoadRegionsPlugin"; - string m_version = "0.0"; + private string m_name = "LoadRegionsPlugin"; + private string m_version = "0.0"; - public string Version { get { return m_version; } } - public string Name { get { return m_name; } } + public string Version + { + get { return m_version; } + } + + public string Name + { + get { return m_name; } + } protected OpenSimBase m_openSim; @@ -106,7 +112,8 @@ namespace OpenSim.ApplicationPlugins.LoadRegions for (int i = 0; i < regionsToLoad.Length; i++) { IScene scene; - m_log.Debug("[LOADREGIONS]: Creating Region: " + regionsToLoad[i].RegionName + " (ThreadID: " + Thread.CurrentThread.ManagedThreadId.ToString() + + m_log.Debug("[LOADREGIONS]: Creating Region: " + regionsToLoad[i].RegionName + " (ThreadID: " + + Thread.CurrentThread.ManagedThreadId.ToString() + ")"); m_openSim.CreateRegion(regionsToLoad[i], true, out scene); if (scene != null) @@ -151,22 +158,23 @@ namespace OpenSim.ApplicationPlugins.LoadRegions if (region.RegionID == checkedRegion.RegionID) { m_log.ErrorFormat( - "[LOADREGIONS]: Regions {0} and {1} have the same UUID {2}", - region.RegionName, checkedRegion.RegionName, region.RegionID); + "[LOADREGIONS]: Regions {0} and {1} have the same UUID {2}", + region.RegionName, checkedRegion.RegionName, region.RegionID); return false; } - else if (region.RegionLocX == checkedRegion.RegionLocX && region.RegionLocY == checkedRegion.RegionLocY) + else if (region.RegionLocX == checkedRegion.RegionLocX && + region.RegionLocY == checkedRegion.RegionLocY) { m_log.ErrorFormat( - "[LOADREGIONS]: Regions {0} and {1} have the same location {2} {3}", - region.RegionName, checkedRegion.RegionName, region.RegionLocX, region.RegionLocY); + "[LOADREGIONS]: Regions {0} and {1} have the same location {2} {3}", + region.RegionName, checkedRegion.RegionName, region.RegionLocX, region.RegionLocY); return false; } else if (region.InternalEndPoint.Port == checkedRegion.InternalEndPoint.Port) { m_log.ErrorFormat( - "[LOADREGIONS]: Regions {0} and {1} have the same internal IP port {2}", - region.RegionName, checkedRegion.RegionName, region.InternalEndPoint.Port); + "[LOADREGIONS]: Regions {0} and {1} have the same internal IP port {2}", + region.RegionName, checkedRegion.RegionName, region.InternalEndPoint.Port); return false; } } @@ -205,4 +213,4 @@ namespace OpenSim.ApplicationPlugins.LoadRegions } } } -} +} \ No newline at end of file diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index f3ee783..4bf6712 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs @@ -55,16 +55,23 @@ namespace OpenSim.ApplicationPlugins.RemoteController private string requiredPassword = String.Empty; // TODO: required by IPlugin, but likely not at all right - string m_name = "RemoteAdminPlugin"; - string m_version = "0.0"; + private string m_name = "RemoteAdminPlugin"; + private string m_version = "0.0"; - public string Version { get { return m_version; } } - public string Name { get { return m_name; } } + public string Version + { + get { return m_version; } + } + + public string Name + { + get { return m_name; } + } public void Initialise() { m_log.Info("[RADMIN]: " + Name + " cannot be default-initialized!"); - throw new PluginNotInitialisedException (Name); + throw new PluginNotInitialisedException(Name); } @@ -85,7 +92,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController requiredPassword = m_config.GetString("access_password", String.Empty); m_app = openSim; - m_httpd = openSim.HttpServer; + m_httpd = openSim.HttpServer; Dictionary availableMethods = new Dictionary(); availableMethods["admin_create_region"] = XmlRpcCreateRegionMethod; @@ -140,14 +147,15 @@ namespace OpenSim.ApplicationPlugins.RemoteController XmlRpcResponse response = new XmlRpcResponse(); Hashtable responseData = new Hashtable(); - try { + try + { Hashtable requestData = (Hashtable) request.Params[0]; m_log.Info("[RADMIN]: Request to restart Region."); - checkStringParameters(request, new string[] { "password", "regionID" }); + checkStringParameters(request, new string[] {"password", "regionID"}); if (requiredPassword != String.Empty && - (!requestData.Contains("password") || (string)requestData["password"] != requiredPassword)) + (!requestData.Contains("password") || (string) requestData["password"] != requiredPassword)) { throw new Exception("wrong password"); } @@ -167,7 +175,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController response.Value = responseData; rebootedScene.Restart(30); } - catch(Exception e) + catch (Exception e) { m_log.ErrorFormat("[RADMIN]: Restart region: failed: {0}", e.Message); m_log.DebugFormat("[RADMIN]: Restart region: failed: {0}", e.ToString()); @@ -186,11 +194,11 @@ namespace OpenSim.ApplicationPlugins.RemoteController XmlRpcResponse response = new XmlRpcResponse(); Hashtable responseData = new Hashtable(); - try + try { Hashtable requestData = (Hashtable) request.Params[0]; - checkStringParameters(request, new string[] { "password", "message" }); + checkStringParameters(request, new string[] {"password", "message"}); if (requiredPassword != String.Empty && (!requestData.Contains("password") || (string) requestData["password"] != requiredPassword)) @@ -202,16 +210,16 @@ namespace OpenSim.ApplicationPlugins.RemoteController responseData["accepted"] = "true"; responseData["success"] = "true"; response.Value = responseData; - + m_app.SceneManager.ForEachScene( delegate(Scene scene) - { - IDialogModule dialogModule = scene.RequestModuleInterface(); - if (dialogModule != null) - dialogModule.SendGeneralAlert(message); - }); + { + IDialogModule dialogModule = scene.RequestModuleInterface(); + if (dialogModule != null) + dialogModule.SendGeneralAlert(message); + }); } - catch(Exception e) + catch (Exception e) { m_log.ErrorFormat("[RADMIN]: Broadcasting: failed: {0}", e.Message); m_log.DebugFormat("[RADMIN]: Broadcasting: failed: {0}", e.ToString()); @@ -230,8 +238,9 @@ namespace OpenSim.ApplicationPlugins.RemoteController XmlRpcResponse response = new XmlRpcResponse(); Hashtable responseData = new Hashtable(); - try { - Hashtable requestData = (Hashtable)request.Params[0]; + try + { + Hashtable requestData = (Hashtable) request.Params[0]; m_log.DebugFormat("[RADMIN]: Load Terrain: XmlRpc {0}", request.ToString()); // foreach (string k in requestData.Keys) @@ -240,14 +249,14 @@ namespace OpenSim.ApplicationPlugins.RemoteController // k, (string)requestData[k], ((string)requestData[k]).Length); // } - checkStringParameters(request, new string[] { "password", "filename", "regionid"}); + checkStringParameters(request, new string[] {"password", "filename", "regionid"}); if (requiredPassword != String.Empty && - (!requestData.Contains("password") || (string)requestData["password"] != requiredPassword)) + (!requestData.Contains("password") || (string) requestData["password"] != requiredPassword)) throw new Exception("wrong password"); - string file = (string)requestData["filename"]; - UUID regionID = (UUID)(string) requestData["regionid"]; + string file = (string) requestData["filename"]; + UUID regionID = (UUID) (string) requestData["regionid"]; m_log.InfoFormat("[RADMIN]: Terrain Loading: {0}", file); responseData["accepted"] = "true"; @@ -283,7 +292,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController XmlRpcResponse response = new XmlRpcResponse(); Hashtable responseData = new Hashtable(); - try { + try + { Hashtable requestData = (Hashtable) request.Params[0]; if (requiredPassword != String.Empty && @@ -294,30 +304,30 @@ namespace OpenSim.ApplicationPlugins.RemoteController response.Value = responseData; int timeout = 2000; - string message; + string message; - if (requestData.ContainsKey("shutdown") - && ((string) requestData["shutdown"] == "delayed") + if (requestData.ContainsKey("shutdown") + && ((string) requestData["shutdown"] == "delayed") && requestData.ContainsKey("milliseconds")) { timeout = (Int32) requestData["milliseconds"]; - - message - = "Region is going down in " + ((int) (timeout/1000)).ToString() - + " second(s). Please save what you are doing and log out."; + + message + = "Region is going down in " + ((int) (timeout/1000)).ToString() + + " second(s). Please save what you are doing and log out."; } else { message = "Region is going down now."; } - + m_app.SceneManager.ForEachScene( delegate(Scene scene) - { - IDialogModule dialogModule = scene.RequestModuleInterface(); - if (dialogModule != null) - dialogModule.SendGeneralAlert(message); - }); + { + IDialogModule dialogModule = scene.RequestModuleInterface(); + if (dialogModule != null) + dialogModule.SendGeneralAlert(message); + }); // Perform shutdown Timer shutdownTimer = new Timer(timeout); // Wait before firing @@ -353,7 +363,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController { if (!requestData.Contains(p)) throw new Exception(String.Format("missing string parameter {0}", p)); - if (String.IsNullOrEmpty((string)requestData[p])) + if (String.IsNullOrEmpty((string) requestData[p])) throw new Exception(String.Format("parameter {0} is empty", p)); } } @@ -423,23 +433,27 @@ namespace OpenSim.ApplicationPlugins.RemoteController XmlRpcResponse response = new XmlRpcResponse(); Hashtable responseData = new Hashtable(); - lock (this) + lock (this) { int m_regionLimit = m_config.GetInt("region_limit", 0); - try { + try + { Hashtable requestData = (Hashtable) request.Params[0]; - checkStringParameters(request, new string[] { "password", - "region_name", - "region_master_first", "region_master_last", - "region_master_password", - "listen_ip", "external_address"}); + checkStringParameters(request, new string[] + { + "password", + "region_name", + "region_master_first", "region_master_last", + "region_master_password", + "listen_ip", "external_address" + }); checkIntegerParams(request, new string[] {"region_x", "region_y", "listen_port"}); // check password if (!String.IsNullOrEmpty(requiredPassword) && - (string)requestData["password"] != requiredPassword) throw new Exception("wrong password"); + (string) requestData["password"] != requiredPassword) throw new Exception("wrong password"); // check whether we still have space left (iff we are using limits) if (m_regionLimit != 0 && m_app.SceneManager.Scenes.Count >= m_regionLimit) @@ -450,13 +464,14 @@ namespace OpenSim.ApplicationPlugins.RemoteController Scene scene = null; UUID regionID = UUID.Zero; if (requestData.ContainsKey("region_id") && - !String.IsNullOrEmpty((string)requestData["region_id"])) + !String.IsNullOrEmpty((string) requestData["region_id"])) { - regionID = (UUID)(string)requestData["region_id"]; + regionID = (UUID) (string) requestData["region_id"]; if (m_app.SceneManager.TryGetScene(regionID, out scene)) - throw new Exception(String.Format("region UUID already in use by region {0}, UUID {1}, <{2},{3}>", - scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, - scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY)); + throw new Exception( + String.Format("region UUID already in use by region {0}, UUID {1}, <{2},{3}>", + scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, + scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY)); } else { @@ -475,15 +490,17 @@ namespace OpenSim.ApplicationPlugins.RemoteController // check for collisions: region name, region UUID, // region location if (m_app.SceneManager.TryGetScene(region.RegionName, out scene)) - throw new Exception(String.Format("region name already in use by region {0}, UUID {1}, <{2},{3}>", - scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, - scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY)); + throw new Exception( + String.Format("region name already in use by region {0}, UUID {1}, <{2},{3}>", + scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, + scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY)); if (m_app.SceneManager.TryGetScene(region.RegionLocX, region.RegionLocY, out scene)) - throw new Exception(String.Format("region location <{0},{1}> already in use by region {2}, UUID {3}, <{4},{5}>", - region.RegionLocX, region.RegionLocY, - scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, - scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY)); + throw new Exception( + String.Format("region location <{0},{1}> already in use by region {2}, UUID {3}, <{4},{5}>", + region.RegionLocX, region.RegionLocY, + scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, + scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY)); region.InternalEndPoint = new IPEndPoint(IPAddress.Parse((string) requestData["listen_ip"]), 0); @@ -491,39 +508,42 @@ namespace OpenSim.ApplicationPlugins.RemoteController region.InternalEndPoint.Port = Convert.ToInt32(requestData["listen_port"]); if (0 == region.InternalEndPoint.Port) throw new Exception("listen_port is 0"); if (m_app.SceneManager.TryGetScene(region.InternalEndPoint, out scene)) - throw new Exception(String.Format("region internal IP {0} and port {1} already in use by region {2}, UUID {3}, <{4},{5}>", - region.InternalEndPoint.Address, - region.InternalEndPoint.Port, - scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, - scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY)); + throw new Exception( + String.Format( + "region internal IP {0} and port {1} already in use by region {2}, UUID {3}, <{4},{5}>", + region.InternalEndPoint.Address, + region.InternalEndPoint.Port, + scene.RegionInfo.RegionName, scene.RegionInfo.RegionID, + scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY)); - region.ExternalHostName = (string)requestData["external_address"]; + region.ExternalHostName = (string) requestData["external_address"]; - string masterFirst = (string)requestData["region_master_first"]; - string masterLast = (string)requestData["region_master_last"]; - string masterPassword = (string)requestData["region_master_password"]; + string masterFirst = (string) requestData["region_master_first"]; + string masterLast = (string) requestData["region_master_last"]; + string masterPassword = (string) requestData["region_master_password"]; UUID userID = UUID.Zero; if (requestData.ContainsKey("region_master_uuid")) { // ok, client wants us to use an explicit UUID // regardless of what the avatar name provided - userID = new UUID((string)requestData["region_master_uuid"]); + userID = new UUID((string) requestData["region_master_uuid"]); } else { // no client supplied UUID: look it up... UserProfileData userProfile = m_app.CommunicationsManager.UserService.GetUserProfile(masterFirst, masterLast); - if (null == userProfile) + if (null == userProfile) { m_log.InfoFormat("master avatar does not exist, creating it"); // ...or create new user userID = m_app.CommunicationsManager.UserAdminService.AddUser( masterFirst, masterLast, masterPassword, "", region.RegionLocX, region.RegionLocY); - - if (userID == UUID.Zero) throw new Exception(String.Format("failed to create new user {0} {1}", - masterFirst, masterLast)); + + if (userID == UUID.Zero) + throw new Exception(String.Format("failed to create new user {0} {1}", + masterFirst, masterLast)); } else { @@ -536,7 +556,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController region.MasterAvatarSandboxPassword = masterPassword; region.MasterAvatarAssignedUUID = userID; - bool persist = Convert.ToBoolean((string)requestData["persist"]); + bool persist = Convert.ToBoolean((string) requestData["persist"]); if (persist) { // default place for region XML files is in the @@ -545,7 +565,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController try { // OpenSim.ini can specify a different regions dir - IConfig startupConfig = (IConfig)m_configSource.Configs["Startup"]; + IConfig startupConfig = (IConfig) m_configSource.Configs["Startup"]; regionConfigPath = startupConfig.GetString("regionload_regionsdir", regionConfigPath).Trim(); } catch (Exception) @@ -553,12 +573,15 @@ namespace OpenSim.ApplicationPlugins.RemoteController // No INI setting recorded. } string regionXmlPath = Path.Combine(regionConfigPath, - String.Format(m_config.GetString("region_file_template", "{0}x{1}-{2}.xml"), - region.RegionLocX.ToString(), - region.RegionLocY.ToString(), - regionID.ToString(), - region.InternalEndPoint.Port.ToString(), - region.RegionName.Replace(" ", "_").Replace(":", "_").Replace("/", "_"))); + String.Format( + m_config.GetString("region_file_template", + "{0}x{1}-{2}.xml"), + region.RegionLocX.ToString(), + region.RegionLocY.ToString(), + regionID.ToString(), + region.InternalEndPoint.Port.ToString(), + region.RegionName.Replace(" ", "_").Replace(":", "_"). + Replace("/", "_"))); m_log.DebugFormat("[RADMIN] CreateRegion: persisting region {0} to {1}", region.RegionID, regionXmlPath); region.SaveRegionToFile("dynamic region", regionXmlPath); @@ -566,7 +589,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController IScene newscene; m_app.CreateRegion(region, out newscene); - responseData["success"] = "true"; + responseData["success"] = "true"; responseData["region_name"] = region.RegionName; responseData["region_uuid"] = region.RegionID.ToString(); @@ -618,17 +641,18 @@ namespace OpenSim.ApplicationPlugins.RemoteController XmlRpcResponse response = new XmlRpcResponse(); Hashtable responseData = new Hashtable(); - lock (this) + lock (this) { - try { + try + { Hashtable requestData = (Hashtable) request.Params[0]; checkStringParameters(request, new string[] {"password", "region_name"}); Scene scene = null; - string regionName = (string)requestData["region_name"]; + string regionName = (string) requestData["region_name"]; if (!m_app.SceneManager.TryGetScene(regionName, out scene)) throw new Exception(String.Format("region \"{0}\" does not exist", regionName)); - + m_app.RemoveRegion(scene, true); responseData["success"] = "true"; @@ -648,7 +672,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController } return response; - } } @@ -694,40 +717,44 @@ namespace OpenSim.ApplicationPlugins.RemoteController XmlRpcResponse response = new XmlRpcResponse(); Hashtable responseData = new Hashtable(); - lock (this) + lock (this) { try { Hashtable requestData = (Hashtable) request.Params[0]; // check completeness - checkStringParameters(request, new string[] { "password", "user_firstname", - "user_lastname", "user_password", }); - checkIntegerParams(request, new string[] { "start_region_x", "start_region_y" }); + checkStringParameters(request, new string[] + { + "password", "user_firstname", + "user_lastname", "user_password", + }); + checkIntegerParams(request, new string[] {"start_region_x", "start_region_y"}); // check password if (!String.IsNullOrEmpty(requiredPassword) && - (string)requestData["password"] != requiredPassword) throw new Exception("wrong password"); + (string) requestData["password"] != requiredPassword) throw new Exception("wrong password"); // do the job string firstname = (string) requestData["user_firstname"]; - string lastname = (string) requestData["user_lastname"]; - string passwd = (string) requestData["user_password"]; - string email = ""; //Empty string for email - uint regX = Convert.ToUInt32((Int32)requestData["start_region_x"]); - uint regY = Convert.ToUInt32((Int32)requestData["start_region_y"]); + string lastname = (string) requestData["user_lastname"]; + string passwd = (string) requestData["user_password"]; + string email = ""; //Empty string for email + uint regX = Convert.ToUInt32((Int32) requestData["start_region_x"]); + uint regY = Convert.ToUInt32((Int32) requestData["start_region_y"]); UserProfileData userProfile = m_app.CommunicationsManager.UserService.GetUserProfile(firstname, lastname); if (null != userProfile) throw new Exception(String.Format("avatar {0} {1} already exists", firstname, lastname)); - UUID userID = m_app.CommunicationsManager.UserAdminService.AddUser(firstname, lastname, + UUID userID = m_app.CommunicationsManager.UserAdminService.AddUser(firstname, lastname, passwd, email, regX, regY); - if (userID == UUID.Zero) throw new Exception(String.Format("failed to create new user {0} {1}", - firstname, lastname)); + if (userID == UUID.Zero) + throw new Exception(String.Format("failed to create new user {0} {1}", + firstname, lastname)); - responseData["success"] = "true"; + responseData["success"] = "true"; responseData["avatar_uuid"] = userID.ToString(); response.Value = responseData; @@ -739,14 +766,13 @@ namespace OpenSim.ApplicationPlugins.RemoteController m_log.ErrorFormat("[RADMIN] CreateUser: failed: {0}", e.Message); m_log.DebugFormat("[RADMIN] CreateUser: failed: {0}", e.ToString()); - responseData["success"] = "false"; + responseData["success"] = "false"; responseData["avatar_uuid"] = UUID.Zero.ToString(); - responseData["error"] = e.Message; + responseData["error"] = e.Message; response.Value = responseData; } return response; - } } @@ -794,30 +820,34 @@ namespace OpenSim.ApplicationPlugins.RemoteController XmlRpcResponse response = new XmlRpcResponse(); Hashtable responseData = new Hashtable(); - lock (this) + lock (this) { try { - Hashtable requestData = (Hashtable)request.Params[0]; + Hashtable requestData = (Hashtable) request.Params[0]; // check completeness - checkStringParameters(request, new string[] { "password", "user_firstname", - "user_lastname", "user_password", "user_email" }); - checkIntegerParams(request, new string[] { "start_region_x", "start_region_y" }); + checkStringParameters(request, new string[] + { + "password", "user_firstname", + "user_lastname", "user_password", "user_email" + }); + checkIntegerParams(request, new string[] {"start_region_x", "start_region_y"}); // check password if (!String.IsNullOrEmpty(requiredPassword) && - (string)requestData["password"] != requiredPassword) throw new Exception("wrong password"); + (string) requestData["password"] != requiredPassword) throw new Exception("wrong password"); // do the job - string firstname = (string)requestData["user_firstname"]; - string lastname = (string)requestData["user_lastname"]; - string passwd = (string)requestData["user_password"]; - string email = (string)requestData["user_email"]; - uint regX = Convert.ToUInt32((Int32)requestData["start_region_x"]); - uint regY = Convert.ToUInt32((Int32)requestData["start_region_y"]); - - UserProfileData userProfile = m_app.CommunicationsManager.UserService.GetUserProfile(firstname, lastname); + string firstname = (string) requestData["user_firstname"]; + string lastname = (string) requestData["user_lastname"]; + string passwd = (string) requestData["user_password"]; + string email = (string) requestData["user_email"]; + uint regX = Convert.ToUInt32((Int32) requestData["start_region_x"]); + uint regY = Convert.ToUInt32((Int32) requestData["start_region_y"]); + + UserProfileData userProfile = + m_app.CommunicationsManager.UserService.GetUserProfile(firstname, lastname); if (null != userProfile) throw new Exception(String.Format("avatar {0} {1} already exists", firstname, lastname)); @@ -825,8 +855,9 @@ namespace OpenSim.ApplicationPlugins.RemoteController = m_app.CommunicationsManager.UserAdminService.AddUser( firstname, lastname, passwd, email, regX, regY); - if (userID == UUID.Zero) throw new Exception(String.Format("failed to create new user {0} {1}", - firstname, lastname)); + if (userID == UUID.Zero) + throw new Exception(String.Format("failed to create new user {0} {1}", + firstname, lastname)); responseData["success"] = "true"; responseData["avatar_uuid"] = userID.ToString(); @@ -847,7 +878,6 @@ namespace OpenSim.ApplicationPlugins.RemoteController response.Value = responseData; } return response; - } } @@ -892,11 +922,11 @@ namespace OpenSim.ApplicationPlugins.RemoteController Hashtable requestData = (Hashtable) request.Params[0]; // check completeness - checkStringParameters(request, new string[] { "password", "user_firstname", "user_lastname"}); - + checkStringParameters(request, new string[] {"password", "user_firstname", "user_lastname"}); + string firstname = (string) requestData["user_firstname"]; - string lastname = (string) requestData["user_lastname"]; - + string lastname = (string) requestData["user_lastname"]; + UserProfileData userProfile = m_app.CommunicationsManager.UserService.GetUserProfile(firstname, lastname); responseData["user_firstname"] = firstname; @@ -906,7 +936,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController responseData["success"] = false; else responseData["success"] = true; - + response.Value = responseData; } catch (Exception e) @@ -963,47 +993,58 @@ namespace OpenSim.ApplicationPlugins.RemoteController XmlRpcResponse response = new XmlRpcResponse(); Hashtable responseData = new Hashtable(); - lock (this) + lock (this) { try { Hashtable requestData = (Hashtable) request.Params[0]; // check completeness - checkStringParameters(request, new string[] { "password", "user_firstname", - "user_lastname" }); + checkStringParameters(request, new string[] + { + "password", "user_firstname", + "user_lastname" + }); // check password if (!String.IsNullOrEmpty(requiredPassword) && - (string)requestData["password"] != requiredPassword) throw new Exception("wrong password"); + (string) requestData["password"] != requiredPassword) throw new Exception("wrong password"); // do the job string firstname = (string) requestData["user_firstname"]; - string lastname = (string) requestData["user_lastname"]; + string lastname = (string) requestData["user_lastname"]; string passwd = String.Empty; - uint? regX = null; - uint? regY = null; - uint? ulaX = null; - uint? ulaY = null; - uint? ulaZ = null; - uint? usaX = null; - uint? usaY = null; - uint? usaZ = null; - - - if (requestData.ContainsKey("user_password")) passwd = (string) requestData["user_password"]; - if (requestData.ContainsKey("start_region_x")) regX = Convert.ToUInt32((Int32)requestData["start_region_x"]); - if (requestData.ContainsKey("start_region_y")) regY = Convert.ToUInt32((Int32)requestData["start_region_y"]); - - if (requestData.ContainsKey("start_lookat_x")) ulaX = Convert.ToUInt32((Int32)requestData["start_lookat_x"]); - if (requestData.ContainsKey("start_lookat_y")) ulaY = Convert.ToUInt32((Int32)requestData["start_lookat_y"]); - if (requestData.ContainsKey("start_lookat_z")) ulaZ = Convert.ToUInt32((Int32)requestData["start_lookat_z"]); - - if (requestData.ContainsKey("start_standat_x")) usaX = Convert.ToUInt32((Int32)requestData["start_standat_x"]); - if (requestData.ContainsKey("start_standat_y")) usaY = Convert.ToUInt32((Int32)requestData["start_standat_y"]); - if (requestData.ContainsKey("start_standat_z")) usaZ = Convert.ToUInt32((Int32)requestData["start_standat_z"]); + uint? regX = null; + uint? regY = null; + uint? ulaX = null; + uint? ulaY = null; + uint? ulaZ = null; + uint? usaX = null; + uint? usaY = null; + uint? usaZ = null; + + + if (requestData.ContainsKey("user_password")) passwd = (string) requestData["user_password"]; + if (requestData.ContainsKey("start_region_x")) + regX = Convert.ToUInt32((Int32) requestData["start_region_x"]); + if (requestData.ContainsKey("start_region_y")) + regY = Convert.ToUInt32((Int32) requestData["start_region_y"]); + + if (requestData.ContainsKey("start_lookat_x")) + ulaX = Convert.ToUInt32((Int32) requestData["start_lookat_x"]); + if (requestData.ContainsKey("start_lookat_y")) + ulaY = Convert.ToUInt32((Int32) requestData["start_lookat_y"]); + if (requestData.ContainsKey("start_lookat_z")) + ulaZ = Convert.ToUInt32((Int32) requestData["start_lookat_z"]); + + if (requestData.ContainsKey("start_standat_x")) + usaX = Convert.ToUInt32((Int32) requestData["start_standat_x"]); + if (requestData.ContainsKey("start_standat_y")) + usaY = Convert.ToUInt32((Int32) requestData["start_standat_y"]); + if (requestData.ContainsKey("start_standat_z")) + usaZ = Convert.ToUInt32((Int32) requestData["start_standat_z"]); UserProfileData userProfile = m_app.CommunicationsManager.UserService.GetUserProfile(firstname, lastname); @@ -1016,17 +1057,17 @@ namespace OpenSim.ApplicationPlugins.RemoteController userProfile.PasswordHash = md5PasswdHash; } - if (null != regX) userProfile.HomeRegionX = (uint)regX; - if (null != regY) userProfile.HomeRegionY = (uint)regY; - - if (null != usaX) userProfile.HomeLocationX = (uint)usaX; - if (null != usaY) userProfile.HomeLocationY = (uint)usaY; - if (null != usaZ) userProfile.HomeLocationZ = (uint)usaZ; - - if (null != ulaX) userProfile.HomeLookAtX = (uint)ulaX; - if (null != ulaY) userProfile.HomeLookAtY = (uint)ulaY; - if (null != ulaZ) userProfile.HomeLookAtZ = (uint)ulaZ; - + if (null != regX) userProfile.HomeRegionX = (uint) regX; + if (null != regY) userProfile.HomeRegionY = (uint) regY; + + if (null != usaX) userProfile.HomeLocationX = (uint) usaX; + if (null != usaY) userProfile.HomeLocationY = (uint) usaY; + if (null != usaZ) userProfile.HomeLocationZ = (uint) usaZ; + + if (null != ulaX) userProfile.HomeLookAtX = (uint) ulaX; + if (null != ulaY) userProfile.HomeLookAtY = (uint) ulaY; + if (null != ulaZ) userProfile.HomeLookAtZ = (uint) ulaZ; + if (!m_app.CommunicationsManager.UserService.UpdateUserProfile(userProfile)) throw new Exception("did not manage to update user profile"); @@ -1034,7 +1075,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController response.Value = responseData; - m_log.InfoFormat("[RADMIN]: UpdateUserAccount: account for user {0} {1} updated, UUID {2}", firstname, lastname, + m_log.InfoFormat("[RADMIN]: UpdateUserAccount: account for user {0} {1} updated, UUID {2}", + firstname, lastname, userProfile.ID); } catch (Exception e) @@ -1090,49 +1132,49 @@ namespace OpenSim.ApplicationPlugins.RemoteController XmlRpcResponse response = new XmlRpcResponse(); Hashtable responseData = new Hashtable(); - lock (this) - { + lock (this) + { try { Hashtable requestData = (Hashtable) request.Params[0]; // check completeness - foreach (string p in new string[] { "password", "filename" }) + foreach (string p in new string[] {"password", "filename"}) { if (!requestData.Contains(p)) throw new Exception(String.Format("missing parameter {0}", p)); - if (String.IsNullOrEmpty((string)requestData[p])) + if (String.IsNullOrEmpty((string) requestData[p])) throw new Exception(String.Format("parameter {0} is empty")); } // check password if (!String.IsNullOrEmpty(requiredPassword) && - (string)requestData["password"] != requiredPassword) throw new Exception("wrong password"); + (string) requestData["password"] != requiredPassword) throw new Exception("wrong password"); - string filename = (string)requestData["filename"]; + string filename = (string) requestData["filename"]; Scene scene = null; if (requestData.Contains("region_uuid")) { - UUID region_uuid = (UUID)(string)requestData["region_uuid"]; + UUID region_uuid = (UUID) (string) requestData["region_uuid"]; if (!m_app.SceneManager.TryGetScene(region_uuid, out scene)) throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString())); } else if (requestData.Contains("region_name")) { - string region_name = (string)requestData["region_name"]; + string region_name = (string) requestData["region_name"]; if (!m_app.SceneManager.TryGetScene(region_name, out scene)) throw new Exception(String.Format("failed to switch to region {0}", region_name)); } else throw new Exception("neither region_name nor region_uuid given"); IRegionArchiverModule archiver = scene.RequestModuleInterface(); - if (archiver != null) + if (archiver != null) archiver.DearchiveRegion(filename); - else + else throw new Exception("Archiver module not present for scene"); - + responseData["loaded"] = "true"; - + response.Value = responseData; } catch (Exception e) @@ -1193,29 +1235,29 @@ namespace OpenSim.ApplicationPlugins.RemoteController Hashtable requestData = (Hashtable) request.Params[0]; // check completeness - foreach (string p in new string[] { "password", "filename" }) + foreach (string p in new string[] {"password", "filename"}) { if (!requestData.Contains(p)) throw new Exception(String.Format("missing parameter {0}", p)); - if (String.IsNullOrEmpty((string)requestData[p])) + if (String.IsNullOrEmpty((string) requestData[p])) throw new Exception(String.Format("parameter {0} is empty")); } // check password if (!String.IsNullOrEmpty(requiredPassword) && - (string)requestData["password"] != requiredPassword) throw new Exception("wrong password"); + (string) requestData["password"] != requiredPassword) throw new Exception("wrong password"); - string filename = (string)requestData["filename"]; + string filename = (string) requestData["filename"]; Scene scene = null; if (requestData.Contains("region_uuid")) { - UUID region_uuid = (UUID)(string)requestData["region_uuid"]; + UUID region_uuid = (UUID) (string) requestData["region_uuid"]; if (!m_app.SceneManager.TryGetScene(region_uuid, out scene)) throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString())); } else if (requestData.Contains("region_name")) { - string region_name = (string)requestData["region_name"]; + string region_name = (string) requestData["region_name"]; if (!m_app.SceneManager.TryGetScene(region_name, out scene)) throw new Exception(String.Format("failed to switch to region {0}", region_name)); } @@ -1224,8 +1266,8 @@ namespace OpenSim.ApplicationPlugins.RemoteController IRegionArchiverModule archiver = scene.RequestModuleInterface(); if (archiver != null) archiver.ArchiveRegion(filename); - else - throw new Exception("Archiver module not present for scene"); + else + throw new Exception("Archiver module not present for scene"); responseData["saved"] = "true"; @@ -1250,37 +1292,37 @@ namespace OpenSim.ApplicationPlugins.RemoteController m_log.Info("[RADMIN]: Received Load XML Administrator Request"); XmlRpcResponse response = new XmlRpcResponse(); Hashtable responseData = new Hashtable(); - - lock (this) + + lock (this) { try { Hashtable requestData = (Hashtable) request.Params[0]; // check completeness - foreach (string p in new string[] { "password", "filename" }) + foreach (string p in new string[] {"password", "filename"}) { if (!requestData.Contains(p)) throw new Exception(String.Format("missing parameter {0}", p)); - if (String.IsNullOrEmpty((string)requestData[p])) + if (String.IsNullOrEmpty((string) requestData[p])) throw new Exception(String.Format("parameter {0} is empty")); } // check password if (!String.IsNullOrEmpty(requiredPassword) && - (string)requestData["password"] != requiredPassword) throw new Exception("wrong password"); + (string) requestData["password"] != requiredPassword) throw new Exception("wrong password"); - string filename = (string)requestData["filename"]; + string filename = (string) requestData["filename"]; if (requestData.Contains("region_uuid")) { - UUID region_uuid = (UUID)(string)requestData["region_uuid"]; + UUID region_uuid = (UUID) (string) requestData["region_uuid"]; if (!m_app.SceneManager.TrySetCurrentScene(region_uuid)) throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString())); m_log.InfoFormat("[RADMIN] Switched to region {0}", region_uuid.ToString()); } else if (requestData.Contains("region_name")) { - string region_name = (string)requestData["region_name"]; + string region_name = (string) requestData["region_name"]; if (!m_app.SceneManager.TrySetCurrentScene(region_name)) throw new Exception(String.Format("failed to switch to region {0}", region_name)); m_log.InfoFormat("[RADMIN] Switched to region {0}", region_name); @@ -1292,7 +1334,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController string xml_version = "1"; if (requestData.Contains("xml_version")) { - xml_version = (string)requestData["xml_version"]; + xml_version = (string) requestData["xml_version"]; } switch (xml_version) @@ -1317,7 +1359,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController m_log.InfoFormat("[RADMIN] LoadXml: {0}", e.Message); m_log.DebugFormat("[RADMIN] LoadXml: {0}", e.ToString()); - responseData["loaded"] = "false"; + responseData["loaded"] = "false"; responseData["switched"] = "false"; responseData["error"] = e.Message; @@ -1337,32 +1379,32 @@ namespace OpenSim.ApplicationPlugins.RemoteController try { - Hashtable requestData = (Hashtable)request.Params[0]; + Hashtable requestData = (Hashtable) request.Params[0]; // check completeness - foreach (string p in new string[] { "password", "filename" }) + foreach (string p in new string[] {"password", "filename"}) { if (!requestData.Contains(p)) throw new Exception(String.Format("missing parameter {0}", p)); - if (String.IsNullOrEmpty((string)requestData[p])) + if (String.IsNullOrEmpty((string) requestData[p])) throw new Exception(String.Format("parameter {0} is empty")); } // check password if (!String.IsNullOrEmpty(requiredPassword) && - (string)requestData["password"] != requiredPassword) throw new Exception("wrong password"); + (string) requestData["password"] != requiredPassword) throw new Exception("wrong password"); - string filename = (string)requestData["filename"]; + string filename = (string) requestData["filename"]; if (requestData.Contains("region_uuid")) { - UUID region_uuid = (UUID)(string)requestData["region_uuid"]; + UUID region_uuid = (UUID) (string) requestData["region_uuid"]; if (!m_app.SceneManager.TrySetCurrentScene(region_uuid)) throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString())); m_log.InfoFormat("[RADMIN] Switched to region {0}", region_uuid.ToString()); } else if (requestData.Contains("region_name")) { - string region_name = (string)requestData["region_name"]; + string region_name = (string) requestData["region_name"]; if (!m_app.SceneManager.TrySetCurrentScene(region_name)) throw new Exception(String.Format("failed to switch to region {0}", region_name)); m_log.InfoFormat("[RADMIN] Switched to region {0}", region_name); @@ -1374,7 +1416,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController string xml_version = "1"; if (requestData.Contains("xml_version")) { - xml_version = (string)requestData["xml_version"]; + xml_version = (string) requestData["xml_version"]; } switch (xml_version) @@ -1420,24 +1462,24 @@ namespace OpenSim.ApplicationPlugins.RemoteController { responseData["success"] = "true"; - Hashtable requestData = (Hashtable)request.Params[0]; + Hashtable requestData = (Hashtable) request.Params[0]; // check completeness if (!requestData.Contains("password")) throw new Exception(String.Format("missing required parameter")); if (!String.IsNullOrEmpty(requiredPassword) && - (string)requestData["password"] != requiredPassword) throw new Exception("wrong password"); + (string) requestData["password"] != requiredPassword) throw new Exception("wrong password"); if (requestData.Contains("region_uuid")) { - UUID region_uuid = (UUID)(string)requestData["region_uuid"]; + UUID region_uuid = (UUID) (string) requestData["region_uuid"]; if (!m_app.SceneManager.TrySetCurrentScene(region_uuid)) throw new Exception(String.Format("failed to switch to region {0}", region_uuid.ToString())); m_log.InfoFormat("[RADMIN] Switched to region {0}", region_uuid.ToString()); } else if (requestData.Contains("region_name")) { - string region_name = (string)requestData["region_name"]; + string region_name = (string) requestData["region_name"]; if (!m_app.SceneManager.TrySetCurrentScene(region_name)) throw new Exception(String.Format("failed to switch to region {0}", region_name)); m_log.InfoFormat("[RADMIN] Switched to region {0}", region_name); @@ -1469,4 +1511,4 @@ namespace OpenSim.ApplicationPlugins.RemoteController { } } -} +} \ No newline at end of file -- cgit v1.1