* Locked some RemoteAdmin methods due to racing condition bad behavior.
* Methods locked: CreateRegion, DeleteRegion, CreateUser, CreateUserMethodEmail, UpdateUserAccountMethod, LoadOARMethod, LoadXMLMethod * An example of bad behavior was multiple region creation where same UUID and grid location was possible, by running multiple XMLRPC threads. From: Arthur Rodrigo S Valadares <arthursv@linux.vnet.ibm.com>0.6.1-post-fixes
parent
b2ab15ba34
commit
b337088997
|
@ -380,165 +380,166 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||||
XmlRpcResponse response = new XmlRpcResponse();
|
XmlRpcResponse response = new XmlRpcResponse();
|
||||||
Hashtable responseData = new Hashtable();
|
Hashtable responseData = new Hashtable();
|
||||||
|
|
||||||
int m_regionLimit = m_config.GetInt("region_limit", 0);
|
lock(this) {
|
||||||
|
int m_regionLimit = m_config.GetInt("region_limit", 0);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Hashtable requestData = (Hashtable) request.Params[0];
|
Hashtable requestData = (Hashtable) request.Params[0];
|
||||||
|
|
||||||
checkStringParameters(request, new string[] { "password",
|
checkStringParameters(request, new string[] { "password",
|
||||||
"region_name",
|
"region_name",
|
||||||
"region_master_first", "region_master_last",
|
"region_master_first", "region_master_last",
|
||||||
"region_master_password",
|
"region_master_password",
|
||||||
"listen_ip", "external_address"});
|
"listen_ip", "external_address"});
|
||||||
checkIntegerParams(request, new string[] {"region_x", "region_y", "listen_port"});
|
checkIntegerParams(request, new string[] {"region_x", "region_y", "listen_port"});
|
||||||
|
|
||||||
// check password
|
// check password
|
||||||
if (!String.IsNullOrEmpty(requiredPassword) &&
|
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)
|
// check whether we still have space left (iff we are using limits)
|
||||||
if (m_regionLimit != 0 && m_app.SceneManager.Scenes.Count >= m_regionLimit)
|
if (m_regionLimit != 0 && m_app.SceneManager.Scenes.Count >= m_regionLimit)
|
||||||
throw new Exception(String.Format("cannot instantiate new region, server capacity {0} already reached; delete regions first", m_regionLimit));
|
throw new Exception(String.Format("cannot instantiate new region, server capacity {0} already reached; delete regions first", m_regionLimit));
|
||||||
|
|
||||||
|
|
||||||
// extract or generate region ID now
|
// extract or generate region ID now
|
||||||
Scene scene = null;
|
Scene scene = null;
|
||||||
UUID regionID = UUID.Zero;
|
UUID regionID = UUID.Zero;
|
||||||
if (requestData.ContainsKey("region_id") &&
|
if (requestData.ContainsKey("region_id") &&
|
||||||
!String.IsNullOrEmpty((string)requestData["region_id"]))
|
!String.IsNullOrEmpty((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));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
regionID = UUID.Random();
|
|
||||||
m_log.DebugFormat("[RADMIN] CreateRegion: new region UUID {0}", regionID);
|
|
||||||
}
|
|
||||||
|
|
||||||
// create volatile or persistent region info
|
|
||||||
RegionInfo region = new RegionInfo();
|
|
||||||
|
|
||||||
region.RegionID = regionID;
|
|
||||||
region.RegionName = (string) requestData["region_name"];
|
|
||||||
region.RegionLocX = Convert.ToUInt32(requestData["region_x"]);
|
|
||||||
region.RegionLocY = Convert.ToUInt32(requestData["region_y"]);
|
|
||||||
|
|
||||||
// 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));
|
|
||||||
|
|
||||||
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));
|
|
||||||
|
|
||||||
region.InternalEndPoint =
|
|
||||||
new IPEndPoint(IPAddress.Parse((string) requestData["listen_ip"]), 0);
|
|
||||||
|
|
||||||
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));
|
|
||||||
|
|
||||||
|
|
||||||
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"];
|
|
||||||
|
|
||||||
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"]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// no client supplied UUID: look it up...
|
|
||||||
UserProfileData userProfile = m_app.CommunicationsManager.UserService.GetUserProfile(masterFirst, masterLast);
|
|
||||||
if (null == userProfile)
|
|
||||||
{
|
{
|
||||||
m_log.InfoFormat("master avatar does not exist, creating it");
|
regionID = (UUID)(string)requestData["region_id"];
|
||||||
// ...or create new user
|
if (m_app.SceneManager.TryGetScene(regionID, out scene))
|
||||||
userID = m_app.CommunicationsManager.UserAdminService.AddUser(
|
throw new Exception(String.Format("region UUID already in use by region {0}, UUID {1}, <{2},{3}>",
|
||||||
masterFirst, masterLast, masterPassword, "", region.RegionLocX, region.RegionLocY);
|
scene.RegionInfo.RegionName, scene.RegionInfo.RegionID,
|
||||||
|
scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY));
|
||||||
if (userID == UUID.Zero) throw new Exception(String.Format("failed to create new user {0} {1}",
|
|
||||||
masterFirst, masterLast));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
userID = userProfile.ID;
|
regionID = UUID.Random();
|
||||||
|
m_log.DebugFormat("[RADMIN] CreateRegion: new region UUID {0}", regionID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// create volatile or persistent region info
|
||||||
|
RegionInfo region = new RegionInfo();
|
||||||
|
|
||||||
|
region.RegionID = regionID;
|
||||||
|
region.RegionName = (string) requestData["region_name"];
|
||||||
|
region.RegionLocX = Convert.ToUInt32(requestData["region_x"]);
|
||||||
|
region.RegionLocY = Convert.ToUInt32(requestData["region_y"]);
|
||||||
|
|
||||||
|
// 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));
|
||||||
|
|
||||||
|
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));
|
||||||
|
|
||||||
|
region.InternalEndPoint =
|
||||||
|
new IPEndPoint(IPAddress.Parse((string) requestData["listen_ip"]), 0);
|
||||||
|
|
||||||
|
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));
|
||||||
|
|
||||||
|
|
||||||
|
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"];
|
||||||
|
|
||||||
|
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"]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// no client supplied UUID: look it up...
|
||||||
|
UserProfileData userProfile = m_app.CommunicationsManager.UserService.GetUserProfile(masterFirst, masterLast);
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
userID = userProfile.ID;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
region.MasterAvatarFirstName = masterFirst;
|
||||||
|
region.MasterAvatarLastName = masterLast;
|
||||||
|
region.MasterAvatarSandboxPassword = masterPassword;
|
||||||
|
region.MasterAvatarAssignedUUID = userID;
|
||||||
|
|
||||||
|
bool persist = Convert.ToBoolean((string)requestData["persist"]);
|
||||||
|
if (persist)
|
||||||
|
{
|
||||||
|
// default place for region XML files is in the
|
||||||
|
// Regions directory of the config dir (aka /bin)
|
||||||
|
string regionConfigPath = Path.Combine(Util.configDir(), "Regions");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// OpenSim.ini can specify a different regions dir
|
||||||
|
IConfig startupConfig = (IConfig)m_configSource.Configs["Startup"];
|
||||||
|
regionConfigPath = startupConfig.GetString("regionload_regionsdir", regionConfigPath).Trim();
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
// 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("/", "_")));
|
||||||
|
m_log.DebugFormat("[RADMIN] CreateRegion: persisting region {0} to {1}",
|
||||||
|
region.RegionID, regionXmlPath);
|
||||||
|
region.SaveRegionToFile("dynamic region", regionXmlPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_app.CreateRegion(region);
|
||||||
|
|
||||||
|
responseData["success"] = "true";
|
||||||
|
responseData["region_name"] = region.RegionName;
|
||||||
|
responseData["region_uuid"] = region.RegionID.ToString();
|
||||||
|
|
||||||
|
response.Value = responseData;
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
region.MasterAvatarFirstName = masterFirst;
|
|
||||||
region.MasterAvatarLastName = masterLast;
|
|
||||||
region.MasterAvatarSandboxPassword = masterPassword;
|
|
||||||
region.MasterAvatarAssignedUUID = userID;
|
|
||||||
|
|
||||||
bool persist = Convert.ToBoolean((string)requestData["persist"]);
|
|
||||||
if (persist)
|
|
||||||
{
|
{
|
||||||
// default place for region XML files is in the
|
m_log.ErrorFormat("[RADMIN] CreateRegion: failed {0}", e.Message);
|
||||||
// Regions directory of the config dir (aka /bin)
|
m_log.DebugFormat("[RADMIN] CreateRegion: failed {0}", e.ToString());
|
||||||
string regionConfigPath = Path.Combine(Util.configDir(), "Regions");
|
|
||||||
try
|
responseData["success"] = "false";
|
||||||
{
|
responseData["error"] = e.Message;
|
||||||
// OpenSim.ini can specify a different regions dir
|
|
||||||
IConfig startupConfig = (IConfig)m_configSource.Configs["Startup"];
|
response.Value = responseData;
|
||||||
regionConfigPath = startupConfig.GetString("regionload_regionsdir", regionConfigPath).Trim();
|
|
||||||
}
|
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
// 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("/", "_")));
|
|
||||||
m_log.DebugFormat("[RADMIN] CreateRegion: persisting region {0} to {1}",
|
|
||||||
region.RegionID, regionXmlPath);
|
|
||||||
region.SaveRegionToFile("dynamic region", regionXmlPath);
|
|
||||||
}
|
}
|
||||||
|
return response;
|
||||||
m_app.CreateRegion(region);
|
|
||||||
|
|
||||||
responseData["success"] = "true";
|
|
||||||
responseData["region_name"] = region.RegionName;
|
|
||||||
responseData["region_uuid"] = region.RegionID.ToString();
|
|
||||||
|
|
||||||
response.Value = responseData;
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.ErrorFormat("[RADMIN] CreateRegion: failed {0}", e.Message);
|
|
||||||
m_log.DebugFormat("[RADMIN] CreateRegion: failed {0}", e.ToString());
|
|
||||||
|
|
||||||
responseData["success"] = "false";
|
|
||||||
responseData["error"] = e.Message;
|
|
||||||
|
|
||||||
response.Value = responseData;
|
|
||||||
}
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -573,34 +574,37 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||||
XmlRpcResponse response = new XmlRpcResponse();
|
XmlRpcResponse response = new XmlRpcResponse();
|
||||||
Hashtable responseData = new Hashtable();
|
Hashtable responseData = new Hashtable();
|
||||||
|
|
||||||
try {
|
lock(this) {
|
||||||
Hashtable requestData = (Hashtable) request.Params[0];
|
try {
|
||||||
checkStringParameters(request, new string[] {"password", "region_name"});
|
Hashtable requestData = (Hashtable) request.Params[0];
|
||||||
|
checkStringParameters(request, new string[] {"password", "region_name"});
|
||||||
|
|
||||||
Scene scene = null;
|
Scene scene = null;
|
||||||
string regionName = (string)requestData["region_name"];
|
string regionName = (string)requestData["region_name"];
|
||||||
if (!m_app.SceneManager.TryGetScene(regionName, out scene))
|
if (!m_app.SceneManager.TryGetScene(regionName, out scene))
|
||||||
throw new Exception(String.Format("region \"{0}\" does not exist", regionName));
|
throw new Exception(String.Format("region \"{0}\" does not exist", regionName));
|
||||||
|
|
||||||
m_app.RemoveRegion(scene, true);
|
m_app.RemoveRegion(scene, true);
|
||||||
|
|
||||||
responseData["success"] = "true";
|
responseData["success"] = "true";
|
||||||
responseData["region_name"] = regionName;
|
responseData["region_name"] = regionName;
|
||||||
|
|
||||||
|
response.Value = responseData;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
m_log.ErrorFormat("[RADMIN] DeleteRegion: failed {0}", e.Message);
|
||||||
|
m_log.DebugFormat("[RADMIN] DeleteRegion: failed {0}", e.ToString());
|
||||||
|
|
||||||
|
responseData["success"] = "false";
|
||||||
|
responseData["error"] = e.Message;
|
||||||
|
|
||||||
|
response.Value = responseData;
|
||||||
|
}
|
||||||
|
|
||||||
|
return response;
|
||||||
|
|
||||||
response.Value = responseData;
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.ErrorFormat("[RADMIN] DeleteRegion: failed {0}", e.Message);
|
|
||||||
m_log.DebugFormat("[RADMIN] DeleteRegion: failed {0}", e.ToString());
|
|
||||||
|
|
||||||
responseData["success"] = "false";
|
|
||||||
responseData["error"] = e.Message;
|
|
||||||
|
|
||||||
response.Value = responseData;
|
|
||||||
}
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -645,58 +649,60 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||||
XmlRpcResponse response = new XmlRpcResponse();
|
XmlRpcResponse response = new XmlRpcResponse();
|
||||||
Hashtable responseData = new Hashtable();
|
Hashtable responseData = new Hashtable();
|
||||||
|
|
||||||
try
|
lock(this) {
|
||||||
{
|
try
|
||||||
Hashtable requestData = (Hashtable) request.Params[0];
|
{
|
||||||
|
Hashtable requestData = (Hashtable) request.Params[0];
|
||||||
|
|
||||||
// check completeness
|
// check completeness
|
||||||
checkStringParameters(request, new string[] { "password", "user_firstname",
|
checkStringParameters(request, new string[] { "password", "user_firstname",
|
||||||
"user_lastname", "user_password", });
|
"user_lastname", "user_password", });
|
||||||
checkIntegerParams(request, new string[] { "start_region_x", "start_region_y" });
|
checkIntegerParams(request, new string[] { "start_region_x", "start_region_y" });
|
||||||
|
|
||||||
// check password
|
// check password
|
||||||
if (!String.IsNullOrEmpty(requiredPassword) &&
|
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
|
// do the job
|
||||||
string firstname = (string) requestData["user_firstname"];
|
string firstname = (string) requestData["user_firstname"];
|
||||||
string lastname = (string) requestData["user_lastname"];
|
string lastname = (string) requestData["user_lastname"];
|
||||||
string passwd = (string) requestData["user_password"];
|
string passwd = (string) requestData["user_password"];
|
||||||
string email = ""; //Empty string for email
|
string email = ""; //Empty string for email
|
||||||
uint regX = Convert.ToUInt32((Int32)requestData["start_region_x"]);
|
uint regX = Convert.ToUInt32((Int32)requestData["start_region_x"]);
|
||||||
uint regY = Convert.ToUInt32((Int32)requestData["start_region_y"]);
|
uint regY = Convert.ToUInt32((Int32)requestData["start_region_y"]);
|
||||||
|
|
||||||
UserProfileData userProfile = m_app.CommunicationsManager.UserService.GetUserProfile(firstname, lastname);
|
UserProfileData userProfile = m_app.CommunicationsManager.UserService.GetUserProfile(firstname, lastname);
|
||||||
if (null != userProfile)
|
if (null != userProfile)
|
||||||
throw new Exception(String.Format("avatar {0} {1} already exists", firstname, lastname));
|
throw new Exception(String.Format("avatar {0} {1} already exists", firstname, lastname));
|
||||||
|
|
||||||
UUID userID
|
UUID userID
|
||||||
= m_app.CommunicationsManager.UserAdminService.AddUser(
|
= m_app.CommunicationsManager.UserAdminService.AddUser(
|
||||||
firstname, lastname, passwd, email, regX, regY);
|
firstname, lastname, passwd, email, regX, regY);
|
||||||
|
|
||||||
if (userID == UUID.Zero) throw new Exception(String.Format("failed to create new user {0} {1}",
|
if (userID == UUID.Zero) throw new Exception(String.Format("failed to create new user {0} {1}",
|
||||||
firstname, lastname));
|
firstname, lastname));
|
||||||
|
|
||||||
responseData["success"] = "true";
|
responseData["success"] = "true";
|
||||||
responseData["avatar_uuid"] = userID.ToString();
|
responseData["avatar_uuid"] = userID.ToString();
|
||||||
|
|
||||||
response.Value = responseData;
|
response.Value = responseData;
|
||||||
|
|
||||||
|
m_log.InfoFormat("[RADMIN]: CreateUser: User {0} {1} created, UUID {2}", firstname, lastname, userID);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
m_log.ErrorFormat("[RADMIN] CreateUser: failed: {0}", e.Message);
|
||||||
|
m_log.DebugFormat("[RADMIN] CreateUser: failed: {0}", e.ToString());
|
||||||
|
|
||||||
|
responseData["success"] = "false";
|
||||||
|
responseData["avatar_uuid"] = UUID.Zero.ToString();
|
||||||
|
responseData["error"] = e.Message;
|
||||||
|
|
||||||
|
response.Value = responseData;
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
|
||||||
m_log.InfoFormat("[RADMIN]: CreateUser: User {0} {1} created, UUID {2}", firstname, lastname, userID);
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.ErrorFormat("[RADMIN] CreateUser: failed: {0}", e.Message);
|
|
||||||
m_log.DebugFormat("[RADMIN] CreateUser: failed: {0}", e.ToString());
|
|
||||||
|
|
||||||
responseData["success"] = "false";
|
|
||||||
responseData["avatar_uuid"] = UUID.Zero.ToString();
|
|
||||||
responseData["error"] = e.Message;
|
|
||||||
|
|
||||||
response.Value = responseData;
|
|
||||||
}
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -743,58 +749,60 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||||
XmlRpcResponse response = new XmlRpcResponse();
|
XmlRpcResponse response = new XmlRpcResponse();
|
||||||
Hashtable responseData = new Hashtable();
|
Hashtable responseData = new Hashtable();
|
||||||
|
|
||||||
try
|
lock(this) {
|
||||||
{
|
try
|
||||||
Hashtable requestData = (Hashtable)request.Params[0];
|
{
|
||||||
|
Hashtable requestData = (Hashtable)request.Params[0];
|
||||||
|
|
||||||
// check completeness
|
// check completeness
|
||||||
checkStringParameters(request, new string[] { "password", "user_firstname",
|
checkStringParameters(request, new string[] { "password", "user_firstname",
|
||||||
"user_lastname", "user_password", "user_email" });
|
"user_lastname", "user_password", "user_email" });
|
||||||
checkIntegerParams(request, new string[] { "start_region_x", "start_region_y" });
|
checkIntegerParams(request, new string[] { "start_region_x", "start_region_y" });
|
||||||
|
|
||||||
// check password
|
// check password
|
||||||
if (!String.IsNullOrEmpty(requiredPassword) &&
|
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
|
// do the job
|
||||||
string firstname = (string)requestData["user_firstname"];
|
string firstname = (string)requestData["user_firstname"];
|
||||||
string lastname = (string)requestData["user_lastname"];
|
string lastname = (string)requestData["user_lastname"];
|
||||||
string passwd = (string)requestData["user_password"];
|
string passwd = (string)requestData["user_password"];
|
||||||
string email = (string)requestData["user_email"];
|
string email = (string)requestData["user_email"];
|
||||||
uint regX = Convert.ToUInt32((Int32)requestData["start_region_x"]);
|
uint regX = Convert.ToUInt32((Int32)requestData["start_region_x"]);
|
||||||
uint regY = Convert.ToUInt32((Int32)requestData["start_region_y"]);
|
uint regY = Convert.ToUInt32((Int32)requestData["start_region_y"]);
|
||||||
|
|
||||||
UserProfileData userProfile = m_app.CommunicationsManager.UserService.GetUserProfile(firstname, lastname);
|
UserProfileData userProfile = m_app.CommunicationsManager.UserService.GetUserProfile(firstname, lastname);
|
||||||
if (null != userProfile)
|
if (null != userProfile)
|
||||||
throw new Exception(String.Format("avatar {0} {1} already exists", firstname, lastname));
|
throw new Exception(String.Format("avatar {0} {1} already exists", firstname, lastname));
|
||||||
|
|
||||||
UUID userID
|
UUID userID
|
||||||
= m_app.CommunicationsManager.UserAdminService.AddUser(
|
= m_app.CommunicationsManager.UserAdminService.AddUser(
|
||||||
firstname, lastname, passwd, email, regX, regY);
|
firstname, lastname, passwd, email, regX, regY);
|
||||||
|
|
||||||
if (userID == UUID.Zero) throw new Exception(String.Format("failed to create new user {0} {1}",
|
if (userID == UUID.Zero) throw new Exception(String.Format("failed to create new user {0} {1}",
|
||||||
firstname, lastname));
|
firstname, lastname));
|
||||||
|
|
||||||
responseData["success"] = "true";
|
responseData["success"] = "true";
|
||||||
responseData["avatar_uuid"] = userID.ToString();
|
responseData["avatar_uuid"] = userID.ToString();
|
||||||
|
|
||||||
response.Value = responseData;
|
response.Value = responseData;
|
||||||
|
|
||||||
|
m_log.InfoFormat("[RADMIN]: CreateUser: User {0} {1} created, UUID {2}", firstname, lastname, userID);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
m_log.ErrorFormat("[RADMIN] CreateUser: failed: {0}", e.Message);
|
||||||
|
m_log.DebugFormat("[RADMIN] CreateUser: failed: {0}", e.ToString());
|
||||||
|
|
||||||
|
responseData["success"] = "false";
|
||||||
|
responseData["avatar_uuid"] = UUID.Zero.ToString();
|
||||||
|
responseData["error"] = e.Message;
|
||||||
|
|
||||||
|
response.Value = responseData;
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
|
||||||
m_log.InfoFormat("[RADMIN]: CreateUser: User {0} {1} created, UUID {2}", firstname, lastname, userID);
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.ErrorFormat("[RADMIN] CreateUser: failed: {0}", e.Message);
|
|
||||||
m_log.DebugFormat("[RADMIN] CreateUser: failed: {0}", e.ToString());
|
|
||||||
|
|
||||||
responseData["success"] = "false";
|
|
||||||
responseData["avatar_uuid"] = UUID.Zero.ToString();
|
|
||||||
responseData["error"] = e.Message;
|
|
||||||
|
|
||||||
response.Value = responseData;
|
|
||||||
}
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -909,87 +917,89 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||||
XmlRpcResponse response = new XmlRpcResponse();
|
XmlRpcResponse response = new XmlRpcResponse();
|
||||||
Hashtable responseData = new Hashtable();
|
Hashtable responseData = new Hashtable();
|
||||||
|
|
||||||
try
|
lock(this) {
|
||||||
{
|
try
|
||||||
Hashtable requestData = (Hashtable) request.Params[0];
|
|
||||||
|
|
||||||
// check completeness
|
|
||||||
checkStringParameters(request, new string[] { "password", "user_firstname",
|
|
||||||
"user_lastname" });
|
|
||||||
|
|
||||||
// check password
|
|
||||||
if (!String.IsNullOrEmpty(requiredPassword) &&
|
|
||||||
(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.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")) ulaY = 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")) ulaY = Convert.ToUInt32((Int32)requestData["start_lookat_z"]);
|
|
||||||
|
|
||||||
if (requestData.ContainsKey("start_standat_x")) usaY = 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")) usaY = Convert.ToUInt32((Int32)requestData["start_standat_z"]);
|
|
||||||
|
|
||||||
UserProfileData userProfile = m_app.CommunicationsManager.UserService.GetUserProfile(firstname, lastname);
|
|
||||||
|
|
||||||
if (null == userProfile)
|
|
||||||
throw new Exception(String.Format("avatar {0} {1} does not exist", firstname, lastname));
|
|
||||||
|
|
||||||
if (null != passwd)
|
|
||||||
{
|
{
|
||||||
string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(passwd) + ":" + String.Empty);
|
Hashtable requestData = (Hashtable) request.Params[0];
|
||||||
userProfile.PasswordHash = md5PasswdHash;
|
|
||||||
|
// check completeness
|
||||||
|
checkStringParameters(request, new string[] { "password", "user_firstname",
|
||||||
|
"user_lastname" });
|
||||||
|
|
||||||
|
// check password
|
||||||
|
if (!String.IsNullOrEmpty(requiredPassword) &&
|
||||||
|
(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.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")) ulaY = 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")) ulaY = Convert.ToUInt32((Int32)requestData["start_lookat_z"]);
|
||||||
|
|
||||||
|
if (requestData.ContainsKey("start_standat_x")) usaY = 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")) usaY = Convert.ToUInt32((Int32)requestData["start_standat_z"]);
|
||||||
|
|
||||||
|
UserProfileData userProfile = m_app.CommunicationsManager.UserService.GetUserProfile(firstname, lastname);
|
||||||
|
|
||||||
|
if (null == userProfile)
|
||||||
|
throw new Exception(String.Format("avatar {0} {1} does not exist", firstname, lastname));
|
||||||
|
|
||||||
|
if (null != passwd)
|
||||||
|
{
|
||||||
|
string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(passwd) + ":" + String.Empty);
|
||||||
|
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 (!m_app.CommunicationsManager.UserService.UpdateUserProfile(userProfile))
|
||||||
|
throw new Exception("did not manage to update user profile");
|
||||||
|
|
||||||
|
responseData["success"] = "true";
|
||||||
|
|
||||||
|
response.Value = responseData;
|
||||||
|
|
||||||
|
m_log.InfoFormat("[RADMIN]: UpdateUserAccount: account for user {0} {1} updated, UUID {2}", firstname, lastname,
|
||||||
|
userProfile.ID);
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
m_log.ErrorFormat("[RADMIN] UpdateUserAccount: failed: {0}", e.Message);
|
||||||
|
m_log.DebugFormat("[RADMIN] UpdateUserAccount: failed: {0}", e.ToString());
|
||||||
|
|
||||||
if (null != regX) userProfile.HomeRegionX = (uint)regX;
|
responseData["success"] = "false";
|
||||||
if (null != regY) userProfile.HomeRegionY = (uint)regY;
|
responseData["error"] = e.Message;
|
||||||
|
|
||||||
if (null != usaX) userProfile.HomeLocationX = (uint)usaX;
|
response.Value = responseData;
|
||||||
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");
|
|
||||||
|
|
||||||
responseData["success"] = "true";
|
|
||||||
|
|
||||||
response.Value = responseData;
|
|
||||||
|
|
||||||
m_log.InfoFormat("[RADMIN]: UpdateUserAccount: account for user {0} {1} updated, UUID {2}", firstname, lastname,
|
|
||||||
userProfile.ID);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.ErrorFormat("[RADMIN] UpdateUserAccount: failed: {0}", e.Message);
|
|
||||||
m_log.DebugFormat("[RADMIN] UpdateUserAccount: failed: {0}", e.ToString());
|
|
||||||
|
|
||||||
responseData["success"] = "false";
|
|
||||||
responseData["error"] = e.Message;
|
|
||||||
|
|
||||||
response.Value = responseData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
|
@ -1033,56 +1043,58 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||||
XmlRpcResponse response = new XmlRpcResponse();
|
XmlRpcResponse response = new XmlRpcResponse();
|
||||||
Hashtable responseData = new Hashtable();
|
Hashtable responseData = new Hashtable();
|
||||||
|
|
||||||
try
|
lock(this) {
|
||||||
{
|
try
|
||||||
Hashtable requestData = (Hashtable) request.Params[0];
|
|
||||||
|
|
||||||
// check completeness
|
|
||||||
foreach (string p in new string[] { "password", "filename" })
|
|
||||||
{
|
{
|
||||||
if (!requestData.Contains(p))
|
Hashtable requestData = (Hashtable) request.Params[0];
|
||||||
throw new Exception(String.Format("missing parameter {0}", p));
|
|
||||||
if (String.IsNullOrEmpty((string)requestData[p]))
|
// check completeness
|
||||||
throw new Exception(String.Format("parameter {0} is empty"));
|
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]))
|
||||||
|
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 filename = (string)requestData["filename"];
|
||||||
|
Scene scene = null;
|
||||||
|
if (requestData.Contains("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"];
|
||||||
|
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");
|
||||||
|
|
||||||
|
new ArchiveReadRequest(scene, filename);
|
||||||
|
responseData["loaded"] = "true";
|
||||||
|
|
||||||
|
response.Value = responseData;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
m_log.InfoFormat("[RADMIN] LoadOAR: {0}", e.Message);
|
||||||
|
m_log.DebugFormat("[RADMIN] LoadOAR: {0}", e.ToString());
|
||||||
|
|
||||||
|
responseData["loaded"] = "false";
|
||||||
|
responseData["error"] = e.Message;
|
||||||
|
|
||||||
|
response.Value = responseData;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check password
|
return response;
|
||||||
if (!String.IsNullOrEmpty(requiredPassword) &&
|
|
||||||
(string)requestData["password"] != requiredPassword) throw new Exception("wrong password");
|
|
||||||
|
|
||||||
string filename = (string)requestData["filename"];
|
|
||||||
Scene scene = null;
|
|
||||||
if (requestData.Contains("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"];
|
|
||||||
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");
|
|
||||||
|
|
||||||
new ArchiveReadRequest(scene, filename);
|
|
||||||
responseData["loaded"] = "true";
|
|
||||||
|
|
||||||
response.Value = responseData;
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.InfoFormat("[RADMIN] LoadOAR: {0}", e.Message);
|
|
||||||
m_log.DebugFormat("[RADMIN] LoadOAR: {0}", e.ToString());
|
|
||||||
|
|
||||||
responseData["loaded"] = "false";
|
|
||||||
responseData["error"] = e.Message;
|
|
||||||
|
|
||||||
response.Value = responseData;
|
|
||||||
}
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -1182,78 +1194,81 @@ namespace OpenSim.ApplicationPlugins.RemoteController
|
||||||
XmlRpcResponse response = new XmlRpcResponse();
|
XmlRpcResponse response = new XmlRpcResponse();
|
||||||
Hashtable responseData = new Hashtable();
|
Hashtable responseData = new Hashtable();
|
||||||
|
|
||||||
try
|
lock(this) {
|
||||||
{
|
|
||||||
Hashtable requestData = (Hashtable) request.Params[0];
|
|
||||||
|
|
||||||
// check completeness
|
try
|
||||||
foreach (string p in new string[] { "password", "filename" })
|
|
||||||
{
|
{
|
||||||
if (!requestData.Contains(p))
|
Hashtable requestData = (Hashtable) request.Params[0];
|
||||||
throw new Exception(String.Format("missing parameter {0}", p));
|
|
||||||
if (String.IsNullOrEmpty((string)requestData[p]))
|
// check completeness
|
||||||
throw new Exception(String.Format("parameter {0} is empty"));
|
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]))
|
||||||
|
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 filename = (string)requestData["filename"];
|
||||||
|
if (requestData.Contains("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"];
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
else throw new Exception("neither region_name nor region_uuid given");
|
||||||
|
|
||||||
|
responseData["switched"] = "true";
|
||||||
|
|
||||||
|
string xml_version = "1";
|
||||||
|
if (requestData.Contains("xml_version"))
|
||||||
|
{
|
||||||
|
xml_version = (string)requestData["xml_version"];
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (xml_version)
|
||||||
|
{
|
||||||
|
case "1":
|
||||||
|
m_app.SceneManager.LoadCurrentSceneFromXml(filename, true, new Vector3(0, 0, 0));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "2":
|
||||||
|
m_app.SceneManager.LoadCurrentSceneFromXml2(filename);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new Exception(String.Format("unknown Xml{0} format", xml_version));
|
||||||
|
}
|
||||||
|
|
||||||
|
responseData["loaded"] = "true";
|
||||||
|
response.Value = responseData;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
m_log.InfoFormat("[RADMIN] LoadXml: {0}", e.Message);
|
||||||
|
m_log.DebugFormat("[RADMIN] LoadXml: {0}", e.ToString());
|
||||||
|
|
||||||
|
responseData["loaded"] = "false";
|
||||||
|
responseData["switched"] = "false";
|
||||||
|
responseData["error"] = e.Message;
|
||||||
|
|
||||||
|
response.Value = responseData;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check password
|
return response;
|
||||||
if (!String.IsNullOrEmpty(requiredPassword) &&
|
|
||||||
(string)requestData["password"] != requiredPassword) throw new Exception("wrong password");
|
|
||||||
|
|
||||||
string filename = (string)requestData["filename"];
|
|
||||||
if (requestData.Contains("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"];
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
else throw new Exception("neither region_name nor region_uuid given");
|
|
||||||
|
|
||||||
responseData["switched"] = "true";
|
|
||||||
|
|
||||||
string xml_version = "1";
|
|
||||||
if (requestData.Contains("xml_version"))
|
|
||||||
{
|
|
||||||
xml_version = (string)requestData["xml_version"];
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (xml_version)
|
|
||||||
{
|
|
||||||
case "1":
|
|
||||||
m_app.SceneManager.LoadCurrentSceneFromXml(filename, true, new Vector3(0, 0, 0));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "2":
|
|
||||||
m_app.SceneManager.LoadCurrentSceneFromXml2(filename);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
throw new Exception(String.Format("unknown Xml{0} format", xml_version));
|
|
||||||
}
|
|
||||||
|
|
||||||
responseData["loaded"] = "true";
|
|
||||||
response.Value = responseData;
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
m_log.InfoFormat("[RADMIN] LoadXml: {0}", e.Message);
|
|
||||||
m_log.DebugFormat("[RADMIN] LoadXml: {0}", e.ToString());
|
|
||||||
|
|
||||||
responseData["loaded"] = "false";
|
|
||||||
responseData["switched"] = "false";
|
|
||||||
responseData["error"] = e.Message;
|
|
||||||
|
|
||||||
response.Value = responseData;
|
|
||||||
}
|
|
||||||
|
|
||||||
return response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue