29 using System.Collections;
 
   30 using System.Collections.Generic;
 
   31 using System.Globalization;
 
   35 using System.Reflection;
 
   37 using System.Threading;
 
   44 using OpenSim.Framework;
 
   45 using OpenSim.Framework.Console;
 
   46 using OpenSim.Framework.Servers;
 
   47 using OpenSim.Framework.Servers.HttpServer;
 
   48 using OpenSim.Region.CoreModules.World.Terrain;
 
   49 using OpenSim.Region.Framework.Interfaces;
 
   50 using OpenSim.Region.Framework.Scenes;
 
   51 using OpenSim.Services.Interfaces;
 
   57 namespace OpenSim.ApplicationPlugins.RemoteController
 
   59     [Extension(Path = 
"/OpenSim/Startup", Id = 
"LoadRegions", NodeName = 
"Plugin")]
 
   62         private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
 
   64         private static bool m_defaultAvatarsLoaded = 
false;
 
   70         private IConfig m_config;
 
   71         private IConfigSource m_configSource;
 
   72         private string m_requiredPassword = String.Empty;
 
   73         private HashSet<string> m_accessIP;
 
   75         private string m_name = 
"RemoteAdminPlugin";
 
   76         private string m_version = 
"0.0";
 
   77         private string m_openSimVersion;
 
   81             get { 
return m_version; }
 
   86             get { 
return m_name; }
 
   91             m_log.Error(
"[RADMIN]: " + Name + 
" cannot be default-initialized!");
 
   97             m_openSimVersion = openSim.GetVersionText();
 
   99             m_configSource = openSim.ConfigSource.Source;
 
  102                 if (m_configSource.Configs[
"RemoteAdmin"] == null ||
 
  103                     !m_configSource.Configs[
"RemoteAdmin"].GetBoolean(
"enabled", 
false))
 
  109                     m_config = m_configSource.Configs[
"RemoteAdmin"];
 
  110                     m_log.Debug(
"[RADMIN]: Remote Admin Plugin Enabled");
 
  111                     m_requiredPassword = m_config.GetString(
"access_password", String.Empty);
 
  112                     int port = m_config.GetInt(
"port", 0);
 
  114                     string accessIP = m_config.GetString(
"access_ip_addresses", String.Empty);
 
  115                     m_accessIP = 
new HashSet<string>();
 
  116                     if (accessIP != 
String.Empty)
 
  118                         string[] ips = accessIP.Split(
new char[] { 
',' });
 
  119                         foreach (
string ip 
in ips)
 
  121                             string current = ip.Trim();
 
  123                             if (current != 
String.Empty)
 
  124                                 m_accessIP.Add(current);
 
  128                     m_application = openSim;
 
  129                     string bind_ip_address = m_config.GetString(
"bind_ip_address", 
"0.0.0.0");
 
  130                     IPAddress ipaddr = IPAddress.Parse(bind_ip_address);
 
  131                     m_httpServer = MainServer.GetHttpServer((uint)port,ipaddr);
 
  133                     Dictionary<string, XmlRpcMethod> availableMethods = 
new Dictionary<string, XmlRpcMethod>();
 
  134                     availableMethods[
"admin_create_region"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcCreateRegionMethod);
 
  135                     availableMethods[
"admin_delete_region"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcDeleteRegionMethod);
 
  136                     availableMethods[
"admin_close_region"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcCloseRegionMethod);
 
  137                     availableMethods[
"admin_modify_region"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcModifyRegionMethod);
 
  138                     availableMethods[
"admin_region_query"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcRegionQueryMethod);
 
  139                     availableMethods[
"admin_shutdown"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcShutdownMethod);
 
  140                     availableMethods[
"admin_broadcast"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAlertMethod);
 
  141                     availableMethods[
"admin_dialog"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcDialogMethod);
 
  142                     availableMethods[
"admin_restart"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcRestartMethod);
 
  143                     availableMethods[
"admin_load_heightmap"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcLoadHeightmapMethod);
 
  144                     availableMethods[
"admin_save_heightmap"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcSaveHeightmapMethod);
 
  146                     availableMethods[
"admin_reset_land"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcResetLand);
 
  149                     availableMethods[
"admin_get_agents"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcGetAgentsMethod);
 
  150                     availableMethods[
"admin_teleport_agent"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcTeleportAgentMethod);
 
  153                     availableMethods[
"admin_create_user"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcCreateUserMethod);
 
  154                     availableMethods[
"admin_create_user_email"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcCreateUserMethod);
 
  155                     availableMethods[
"admin_exists_user"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcUserExistsMethod);
 
  156                     availableMethods[
"admin_update_user"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcUpdateUserAccountMethod);
 
  157                     availableMethods[
"admin_authenticate_user"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAuthenticateUserMethod);
 
  160                     availableMethods[
"admin_load_xml"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcLoadXMLMethod);
 
  161                     availableMethods[
"admin_save_xml"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcSaveXMLMethod);
 
  162                     availableMethods[
"admin_load_oar"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcLoadOARMethod);
 
  163                     availableMethods[
"admin_save_oar"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcSaveOARMethod);
 
  166                     availableMethods[
"admin_acl_clear"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAccessListClear);
 
  167                     availableMethods[
"admin_acl_add"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAccessListAdd);
 
  168                     availableMethods[
"admin_acl_remove"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAccessListRemove);
 
  169                     availableMethods[
"admin_acl_list"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcAccessListList);
 
  170                     availableMethods[
"admin_estate_reload"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcEstateReload);
 
  173                     availableMethods[
"admin_refresh_search"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcRefreshSearch);
 
  174                     availableMethods[
"admin_refresh_map"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcRefreshMap);
 
  175                     availableMethods[
"admin_get_opensim_version"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcGetOpenSimVersion);
 
  176                     availableMethods[
"admin_get_agent_count"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcGetAgentCount);
 
  179                     string enabledMethods = m_config.GetString(
"enabled_methods", 
"all");
 
  185                     if (!
String.IsNullOrEmpty(enabledMethods))
 
  186                         availableMethods[
"admin_console_command"] = (req, ep) => InvokeXmlRpcMethod(req, ep, XmlRpcConsoleCommandMethod);
 
  190                     if (enabledMethods.ToLower() == 
"all" || String.IsNullOrEmpty(enabledMethods))
 
  192                         foreach (
string method 
in availableMethods.Keys)
 
  194                             m_httpServer.AddXmlRPCHandler(method, availableMethods[method], 
false);
 
  199                         foreach (
string enabledMethod 
in enabledMethods.Split(
'|'))
 
  201                             m_httpServer.AddXmlRPCHandler(enabledMethod, availableMethods[enabledMethod], 
false);
 
  206             catch (NullReferenceException)
 
  214             if (!CreateDefaultAvatars())
 
  216                 m_log.Info(
"[RADMIN]: Default avatars not loaded");
 
  224         private XmlRpcResponse InvokeXmlRpcMethod(
 
  225             XmlRpcRequest request, IPEndPoint remoteClient, Action<XmlRpcRequest, XmlRpcResponse, IPEndPoint> method)
 
  227             XmlRpcResponse response = 
new XmlRpcResponse();
 
  228             Hashtable responseData = 
new Hashtable();
 
  229             response.Value = responseData;
 
  233                 Hashtable requestData = (Hashtable) request.Params[0];
 
  235                 CheckStringParameters(requestData, responseData, 
new string[] {
"password"});
 
  237                 FailIfRemoteAdminNotAllowed((
string)requestData[
"password"], responseData, remoteClient.Address.ToString());
 
  239                 method(request, response, remoteClient);
 
  244                     "[RADMIN]: Method {0} failed.  Exception {1}{2}", request.MethodName, e.Message, e.StackTrace);
 
  246                 responseData[
"success"] = 
false;
 
  247                 responseData[
"error"] = e.Message;
 
  253         private void FailIfRemoteAdminNotAllowed(
string password, Hashtable responseData, 
string check_ip_address)
 
  255             if (m_accessIP.Count > 0 && !m_accessIP.Contains(check_ip_address))
 
  257                 m_log.WarnFormat(
"[RADMIN]: Unauthorized access blocked from IP {0}", check_ip_address);
 
  258                 responseData[
"accepted"] = 
false;
 
  259                 throw new Exception(
"not authorized");
 
  262             if (m_requiredPassword != 
String.Empty && password != m_requiredPassword)
 
  264                 m_log.WarnFormat(
"[RADMIN]: Wrong password, blocked access from IP {0}", check_ip_address);
 
  265                 responseData[
"accepted"] = 
false;
 
  266                 throw new Exception(
"wrong password");
 
  270         private void XmlRpcRestartMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
 
  272             Hashtable responseData = (Hashtable)response.Value;
 
  273             Hashtable requestData = (Hashtable)request.Params[0];
 
  277                 Scene rebootedScene = null;
 
  278                 bool restartAll = 
false;
 
  280                 IConfig startupConfig = m_configSource.Configs[
"Startup"];
 
  281                 if (startupConfig != null)
 
  283                     if (startupConfig.GetBoolean(
"InworldRestartShutsDown", 
false))
 
  285                         rebootedScene = m_application.SceneManager.CurrentOrFirstScene;
 
  290                 if (rebootedScene == null)
 
  292                     CheckRegionParams(requestData, responseData);
 
  294                     GetSceneFromRegionParams(requestData, responseData, out rebootedScene);
 
  299                 responseData[
"success"] = 
false;
 
  300                 responseData[
"accepted"] = 
true;
 
  301                 responseData[
"rebooting"] = 
true;
 
  304                 List<int> times = 
new List<int>();
 
  306                 if (requestData.ContainsKey(
"alerts"))
 
  308                     string[] alertTimes = requestData[
"alerts"].ToString().Split( 
new char[] {
','});
 
  309                     if (alertTimes.Length == 1 && Convert.ToInt32(alertTimes[0]) == -1)
 
  311                         m_log.Info(
"[RADMIN]: Request to cancel restart.");
 
  313                         if (restartModule != null)
 
  315                             message = 
"Restart has been cancelled";
 
  317                             if (requestData.ContainsKey(
"message"))
 
  318                                 message = requestData[
"message"].ToString();
 
  320                             restartModule.AbortRestart(message);
 
  322                             responseData[
"success"] = 
true;
 
  323                             responseData[
"rebooting"] = 
false;
 
  328                     foreach (
string a 
in alertTimes)
 
  329                         times.Add(Convert.ToInt32(a));
 
  334                     if (requestData.ContainsKey(
"milliseconds"))
 
  335                         timeout = Int32.Parse(requestData[
"milliseconds"].ToString()) / 1000;
 
  341                         else if (timeout > 30)
 
  348                 m_log.Info(
"[RADMIN]: Request to restart Region.");
 
  350                 message = 
"Region is restarting in {0}. Please save what you are doing and log out.";
 
  352                 if (requestData.ContainsKey(
"message"))
 
  353                     message = requestData[
"message"].ToString();
 
  356                 if (requestData.ContainsKey(
"noticetype")
 
  357                     && ((string)requestData[
"noticetype"] == 
"dialog"))
 
  362                 List<Scene> restartList;
 
  365                     restartList = m_application.SceneManager.Scenes;
 
  367                     restartList = 
new List<Scene>() { rebootedScene };
 
  369                 foreach (
Scene s 
in m_application.SceneManager.Scenes)
 
  372                     if (restartModule != null)
 
  373                         restartModule.ScheduleRestart(UUID.Zero, message, times.ToArray(), notice);
 
  375                 responseData[
"success"] = 
true;
 
  380                 responseData[
"rebooting"] = 
false;
 
  385             m_log.Info(
"[RADMIN]: Restart Region request complete");
 
  388         private void XmlRpcAlertMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
 
  390             m_log.Info(
"[RADMIN]: Alert request started");
 
  392             Hashtable responseData = (Hashtable)response.Value;
 
  393             Hashtable requestData = (Hashtable)request.Params[0];
 
  395             string message = (string) requestData[
"message"];
 
  396             m_log.InfoFormat(
"[RADMIN]: Broadcasting: {0}", message);
 
  398             responseData[
"accepted"] = 
true;
 
  399             responseData[
"success"] = 
true;
 
  401             m_application.SceneManager.ForEachScene(
 
  402                 delegate(
Scene scene)
 
  405                         if (dialogModule != null)
 
  406                             dialogModule.SendGeneralAlert(message);
 
  409             m_log.Info(
"[RADMIN]: Alert request complete");
 
  412         public void XmlRpcDialogMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
 
  414             Hashtable responseData = (Hashtable)response.Value;
 
  416             m_log.Info(
"[RADMIN]: Dialog request started");
 
  418             Hashtable requestData = (Hashtable)request.Params[0];
 
  420             string message = (
string)requestData[
"message"];
 
  421             string fromuuid = (string)requestData[
"from"];
 
  422             m_log.InfoFormat(
"[RADMIN]: Broadcasting: {0}", message);
 
  424             responseData[
"accepted"] = 
true;
 
  425             responseData[
"success"] = 
true;
 
  427             m_application.SceneManager.ForEachScene(
 
  428                 delegate(
Scene scene)
 
  431                     if (dialogModule != null)
 
  432                         dialogModule.SendNotificationToUsersInRegion(UUID.Zero, fromuuid, message);
 
  435             m_log.Info(
"[RADMIN]: Dialog request complete");
 
  438         private void XmlRpcLoadHeightmapMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
 
  440             m_log.Info(
"[RADMIN]: Load height maps request started");
 
  442             Hashtable responseData = (Hashtable)response.Value;
 
  443             Hashtable requestData = (Hashtable)request.Params[0];
 
  452             CheckStringParameters(requestData, responseData, 
new string[] { 
"filename" });
 
  453             CheckRegionParams(requestData, responseData);
 
  456             GetSceneFromRegionParams(requestData, responseData, out scene);
 
  460                 string file = (string)requestData[
"filename"];
 
  462                 responseData[
"accepted"] = 
true;
 
  466                 responseData[
"success"] = 
true;
 
  470                 responseData[
"success"] = 
false;
 
  473             m_log.Info(
"[RADMIN]: Load height maps request complete");
 
  476         private void XmlRpcSaveHeightmapMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
 
  478             m_log.Info(
"[RADMIN]: Save height maps request started");
 
  480             Hashtable responseData = (Hashtable)response.Value;
 
  481             Hashtable requestData = (Hashtable)request.Params[0];
 
  485             CheckStringParameters(requestData, responseData, 
new string[] { 
"filename" });
 
  486             CheckRegionParams(requestData, responseData);
 
  489             GetSceneFromRegionParams(requestData, responseData, out scene);
 
  493                 string file = (string)requestData[
"filename"];
 
  494                 m_log.InfoFormat(
"[RADMIN]: Terrain Saving: {0}", file);
 
  496                 responseData[
"accepted"] = 
true;
 
  499                 if (null == terrainModule) 
throw new Exception(
"terrain module not available");
 
  501                 terrainModule.SaveToFile(file);
 
  503                 responseData[
"success"] = 
true;
 
  507                 responseData[
"success"] = 
false;
 
  510             m_log.Info(
"[RADMIN]: Save height maps request complete");
 
  513         private void XmlRpcShutdownMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
 
  515             m_log.Info(
"[RADMIN]: Received Shutdown Administrator Request");
 
  517             Hashtable responseData = (Hashtable)response.Value;
 
  518             Hashtable requestData = (Hashtable)request.Params[0];
 
  520             responseData[
"accepted"] = 
true;
 
  521             response.Value = responseData;
 
  526             if (requestData.ContainsKey(
"shutdown")
 
  527                 && ((string) requestData[
"shutdown"] == 
"delayed")
 
  528                 && requestData.ContainsKey(
"milliseconds"))
 
  530                 timeout = Int32.Parse(requestData[
"milliseconds"].ToString());
 
  533                     = 
"Region is going down in " + ((int) (timeout/1000)).ToString()
 
  534                       + 
" second(s). Please save what you are doing and log out.";
 
  538                 message = 
"Region is going down now.";
 
  541             if (requestData.ContainsKey(
"noticetype")
 
  542                 && ((string) requestData[
"noticetype"] == 
"dialog"))
 
  544                 m_application.SceneManager.ForEachScene(
 
  546                 delegate(
Scene scene)
 
  549                     if (dialogModule != null)
 
  550                             dialogModule.SendNotificationToUsersInRegion(UUID.Zero, 
"System", message);
 
  555                 if (!requestData.ContainsKey(
"noticetype")
 
  556                     || ((string)requestData[
"noticetype"] != 
"none"))
 
  558                     m_application.SceneManager.ForEachScene(
 
  559                     delegate(
Scene scene)
 
  562                         if (dialogModule != null)
 
  563                             dialogModule.SendGeneralAlert(message);
 
  569             System.Timers.Timer shutdownTimer = 
new System.Timers.Timer(timeout); 
 
  570             shutdownTimer.AutoReset = 
false;
 
  571             shutdownTimer.Elapsed += 
new ElapsedEventHandler(shutdownTimer_Elapsed);
 
  574                 shutdownTimer.Start();
 
  577             responseData[
"success"] = 
true;
 
  579             m_log.Info(
"[RADMIN]: Shutdown Administrator Request complete");
 
  582         private void shutdownTimer_Elapsed(
object sender, ElapsedEventArgs e)
 
  584             m_application.Shutdown();
 
  650         private void XmlRpcCreateRegionMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
 
  652             m_log.Info(
"[RADMIN]: CreateRegion: new request");
 
  654             Hashtable responseData = (Hashtable)response.Value;
 
  655             Hashtable requestData = (Hashtable)request.Params[0];
 
  659                 int  m_regionLimit = m_config.GetInt(
"region_limit", 0);
 
  660                 bool m_enableVoiceForNewRegions = m_config.GetBoolean(
"create_region_enable_voice", 
false);
 
  661                 bool m_publicAccess = m_config.GetBoolean(
"create_region_public", 
true);
 
  663                 CheckStringParameters(requestData, responseData, 
new string[]
 
  666                                                        "listen_ip", 
"external_address",
 
  669                 CheckIntegerParams(requestData, responseData, 
new string[] {
"region_x", 
"region_y", 
"listen_port"});
 
  672                 if (m_regionLimit != 0 && m_application.SceneManager.Scenes.Count >= m_regionLimit)
 
  673                     throw new Exception(
String.Format(
"cannot instantiate new region, server capacity {0} already reached; delete regions first",
 
  677                 UUID regionID = UUID.Zero;
 
  678                 if (requestData.ContainsKey(
"region_id") &&
 
  679                     !String.IsNullOrEmpty((string) requestData[
"region_id"]))
 
  681                     regionID = (
UUID) (
string) requestData[
"region_id"];
 
  682                     if (m_application.SceneManager.TryGetScene(regionID, out scene))
 
  684                             String.Format(
"region UUID already in use by region {0}, UUID {1}, <{2},{3}>",
 
  685                                           scene.RegionInfo.RegionName, scene.RegionInfo.RegionID,
 
  686                                           scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY));
 
  690                     regionID = UUID.Random();
 
  691                     m_log.DebugFormat(
"[RADMIN] CreateRegion: new region UUID {0}", regionID);
 
  697                 region.RegionID = regionID;
 
  698                 region.originRegionID = regionID;
 
  699                 region.RegionName = (string) requestData[
"region_name"];
 
  700                 region.RegionLocX = Convert.ToUInt32(requestData[
"region_x"]);
 
  701                 region.RegionLocY = Convert.ToUInt32(requestData[
"region_y"]);
 
  705                 if (m_application.SceneManager.TryGetScene(region.
RegionName, out scene))
 
  707                         String.Format(
"region name already in use by region {0}, UUID {1}, <{2},{3}>",
 
  708                                       scene.RegionInfo.RegionName, scene.RegionInfo.RegionID,
 
  709                                       scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY));
 
  713                         String.Format(
"region location <{0},{1}> already in use by region {2}, UUID {3}, <{4},{5}>",
 
  715                                       scene.RegionInfo.RegionName, scene.RegionInfo.RegionID,
 
  716                                       scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY));
 
  718                 region.InternalEndPoint =
 
  719                     new IPEndPoint(IPAddress.Parse((
string) requestData[
"listen_ip"]), 0);
 
  721                 region.InternalEndPoint.Port = Convert.ToInt32(requestData[
"listen_port"]);
 
  722                 if (0 == region.
InternalEndPoint.Port) 
throw new Exception(
"listen_port is 0");
 
  723                 if (m_application.SceneManager.TryGetScene(region.
InternalEndPoint, out scene))
 
  726                             "region internal IP {0} and port {1} already in use by region {2}, UUID {3}, <{4},{5}>",
 
  729                             scene.RegionInfo.RegionName, scene.RegionInfo.RegionID,
 
  730                             scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY));
 
  732                 region.ExternalHostName = (string) requestData[
"external_address"];
 
  734                 bool persist = Convert.ToBoolean(requestData[
"persist"]);
 
  739                     string regionConfigPath = Path.Combine(Util.configDir(), 
"Regions");
 
  743                         IConfig startupConfig = (IConfig) m_configSource.Configs[
"Startup"];
 
  744                         regionConfigPath = startupConfig.GetString(
"regionload_regionsdir", regionConfigPath).Trim();
 
  751                     string regionIniPath;
 
  753                     if (requestData.Contains(
"region_file"))
 
  756                         string requestedFilePath = Path.Combine(regionConfigPath, (string) requestData[
"region_file"]);
 
  757                         string requestedDirectory = Path.GetDirectoryName(Path.GetFullPath(requestedFilePath));
 
  758                         if (requestedDirectory.StartsWith(Path.GetFullPath(regionConfigPath)))
 
  759                             regionIniPath = requestedFilePath;
 
  761                             throw new Exception(
"Invalid location for region file.");
 
  765                         regionIniPath = Path.Combine(regionConfigPath,
 
  767                                                             m_config.GetString(
"region_file_template",
 
  770                                                             region.RegionLocY.ToString(),
 
  772                                                             region.InternalEndPoint.Port.ToString(),
 
  773                                                             region.
RegionName.Replace(
" ", 
"_").Replace(
":", 
"_").
 
  777                     m_log.DebugFormat(
"[RADMIN] CreateRegion: persisting region {0} to {1}",
 
  778                                       region.RegionID, regionIniPath);
 
  779                     region.SaveRegionToFile(
"dynamic region", regionIniPath);
 
  783                     region.Persistent = 
false;
 
  789                 List<int> estateIDs = m_application.EstateDataService.GetEstates((string) requestData[
"estate_name"]);
 
  790                 if (estateIDs.Count < 1)
 
  792                     UUID userID = UUID.Zero;
 
  793                     if (requestData.ContainsKey(
"estate_owner_uuid"))
 
  797                         userID = 
new UUID((
string) requestData[
"estate_owner_uuid"]);
 
  800                         Scene currentOrFirst = m_application.SceneManager.CurrentOrFirstScene;
 
  802                         UserAccount user = accountService.GetUserAccount(currentOrFirst.RegionInfo.ScopeID, userID);
 
  805                             throw new Exception(
"Specified user was not found.");
 
  807                     else if (requestData.ContainsKey(
"estate_owner_first") & requestData.ContainsKey(
"estate_owner_last"))
 
  810                         string ownerFirst = (string) requestData[
"estate_owner_first"];
 
  811                         string ownerLast = (string) requestData[
"estate_owner_last"];
 
  813                         Scene currentOrFirst = m_application.SceneManager.CurrentOrFirstScene;
 
  815                         UserAccount user = accountService.GetUserAccount(currentOrFirst.RegionInfo.ScopeID,
 
  816                                                                            ownerFirst, ownerLast);
 
  820                             throw new Exception(
"Specified user was not found.");
 
  822                         userID = user.PrincipalID;
 
  826                         throw new Exception(
"Estate owner details not provided.");
 
  830                     region.EstateSettings = m_application.EstateDataService.CreateNewEstate();
 
  832                     region.EstateSettings.EstateName = (string) requestData[
"estate_name"];
 
  833                     region.EstateSettings.EstateOwner = userID;
 
  835                     m_application.EstateDataService.StoreEstateSettings(region.EstateSettings);
 
  838                         throw new Exception(
"Failed to join estate.");
 
  842                     int estateID = estateIDs[0];
 
  844                     region.EstateSettings = m_application.EstateDataService.LoadEstateSettings(region.RegionID, 
false);
 
  849                         region.EstateSettings = m_application.EstateDataService.LoadEstateSettings(estateID);
 
  851                         if (!m_application.EstateDataService.LinkRegion(region.
RegionID, estateID))
 
  852                             throw new Exception(
"Failed to join estate.");
 
  859                 m_application.CreateRegion(region, out newScene);
 
  864                 newScene.RegionInfo.EstateSettings.PublicAccess = GetBoolean(requestData, 
"public", m_publicAccess);
 
  865                 m_application.EstateDataService.StoreEstateSettings(newScene.RegionInfo.EstateSettings);
 
  870                 if (GetBoolean(requestData, 
"enable_voice", m_enableVoiceForNewRegions))
 
  872                     List<ILandObject> parcels = ((
Scene)newScene).LandChannel.AllParcels();
 
  876                         parcel.LandData.Flags |= (uint) ParcelFlags.AllowVoiceChat;
 
  877                         parcel.
LandData.
Flags |= (uint) ParcelFlags.UseEstateVoiceChan;
 
  878                         ((
Scene)newScene).LandChannel.UpdateLandObject(parcel.LandData.LocalID, parcel.LandData);
 
  883                 if (requestData.Contains(
"heightmap_file"))
 
  885                     LoadHeightmap((
string)requestData[
"heightmap_file"], region.RegionID);
 
  888                 responseData[
"success"] = 
true;
 
  889                 responseData[
"region_name"] = region.RegionName;
 
  890                 responseData[
"region_id"] = region.RegionID.ToString();
 
  892                 m_log.Info(
"[RADMIN]: CreateRegion: request complete");
 
  922         private void XmlRpcDeleteRegionMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
 
  924             m_log.Info(
"[RADMIN]: DeleteRegion: new request");
 
  926             Hashtable responseData = (Hashtable)response.Value;
 
  927             Hashtable requestData = (Hashtable)request.Params[0];
 
  931                 CheckStringParameters(requestData, responseData, 
new string[] {
"region_name"});
 
  932                 CheckRegionParams(requestData, responseData);
 
  935                 GetSceneFromRegionParams(requestData, responseData, out scene);
 
  937                 m_application.RemoveRegion(scene, 
true);
 
  939                 responseData[
"success"] = 
true;
 
  940                 responseData[
"region_name"] = scene.RegionInfo.RegionName;
 
  941                 responseData[
"region_id"] = scene.RegionInfo.RegionID;
 
  943                 m_log.Info(
"[RADMIN]: DeleteRegion: request complete");
 
  975         private void XmlRpcCloseRegionMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
 
  977             m_log.Info(
"[RADMIN]: CloseRegion: new request");
 
  979             Hashtable responseData = (Hashtable)response.Value;
 
  980             Hashtable requestData = (Hashtable)request.Params[0];
 
  984                 CheckRegionParams(requestData, responseData);
 
  987                 GetSceneFromRegionParams(requestData, responseData, out scene);
 
  989                 m_application.CloseRegion(scene);
 
  991                 responseData[
"success"] = 
true;
 
  992                 responseData[
"region_name"] = scene.RegionInfo.RegionName;
 
  993                 responseData[
"region_id"] = scene.RegionInfo.RegionID;
 
  995                 response.Value = responseData;
 
  997                 m_log.Info(
"[RADMIN]: CloseRegion: request complete");
 
 1033         private void XmlRpcModifyRegionMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
 
 1035             m_log.Info(
"[RADMIN]: ModifyRegion: new request");
 
 1037             Hashtable responseData = (Hashtable)response.Value;
 
 1038             Hashtable requestData = (Hashtable)request.Params[0];
 
 1040             lock (m_requestLock)
 
 1042                 CheckRegionParams(requestData, responseData);
 
 1045                 GetSceneFromRegionParams(requestData, responseData, out scene);
 
 1048                 scene.RegionInfo.EstateSettings.PublicAccess =
 
 1051                     m_application.EstateDataService.StoreEstateSettings(scene.RegionInfo.EstateSettings);
 
 1053                 if (requestData.ContainsKey(
"enable_voice"))
 
 1055                     bool enableVoice = GetBoolean(requestData, 
"enable_voice", 
true);
 
 1056                     List<ILandObject> parcels = ((
Scene)scene).LandChannel.AllParcels();
 
 1062                             parcel.LandData.Flags |= (uint)ParcelFlags.AllowVoiceChat;
 
 1063                             parcel.
LandData.
Flags |= (uint)ParcelFlags.UseEstateVoiceChan;
 
 1067                             parcel.LandData.Flags &= ~(uint)ParcelFlags.AllowVoiceChat;
 
 1068                             parcel.
LandData.
Flags &= ~(uint)ParcelFlags.UseEstateVoiceChan;
 
 1070                         scene.LandChannel.UpdateLandObject(parcel.LandData.LocalID, parcel.LandData);
 
 1074                 responseData[
"success"] = 
true;
 
 1075                 responseData[
"region_name"] = scene.RegionInfo.RegionName;
 
 1076                 responseData[
"region_id"] = scene.RegionInfo.RegionID;
 
 1078                 m_log.Info(
"[RADMIN]: ModifyRegion: request complete");
 
 1120         private void XmlRpcCreateUserMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
 
 1122             m_log.Info(
"[RADMIN]: CreateUser: new request");
 
 1124             Hashtable responseData = (Hashtable)response.Value;
 
 1125             Hashtable requestData = (Hashtable)request.Params[0];
 
 1127             lock (m_requestLock)
 
 1132                     CheckStringParameters(requestData, responseData, 
new string[]
 
 1135                                                            "user_lastname", 
"user_password",
 
 1137                     CheckIntegerParams(requestData, responseData, 
new string[] {
"start_region_x", 
"start_region_y"});
 
 1140                     string firstName = (string) requestData[
"user_firstname"];
 
 1141                     string lastName = (string) requestData[
"user_lastname"];
 
 1142                     string password = (string) requestData[
"user_password"];
 
 1144                     uint regionXLocation = Convert.ToUInt32(requestData[
"start_region_x"]);
 
 1145                     uint regionYLocation = Convert.ToUInt32(requestData[
"start_region_y"]);
 
 1148                     if (requestData.Contains(
"user_email"))
 
 1149                         email = (
string)requestData[
"user_email"];
 
 1151                     Scene scene = m_application.SceneManager.CurrentOrFirstScene;
 
 1152                     UUID scopeID = scene.RegionInfo.ScopeID;
 
 1154                     UserAccount account = CreateUser(scopeID, firstName, lastName, password, email);
 
 1156                     if (null == account)
 
 1157                         throw new Exception(
String.Format(
"failed to create new user {0} {1}",
 
 1158                                                           firstName, lastName));
 
 1162                     GridRegion home = scene.GridService.GetRegionByPosition(scopeID, 
 
 1163                                         (int)Util.RegionToWorldLoc(regionXLocation), (int)Util.RegionToWorldLoc(regionYLocation));
 
 1166                         m_log.WarnFormat(
"[RADMIN]: Unable to set home region for newly created user account {0} {1}", firstName, lastName);
 
 1170                         scene.GridUserService.SetHome(account.PrincipalID.ToString(), home.RegionID, 
new Vector3(128, 128, 0), 
new Vector3(0, 1, 0));
 
 1171                         m_log.DebugFormat(
"[RADMIN]: Set home region {0} for updated user account {1} {2}", home.RegionID, firstName, lastName);
 
 1176                     UpdateUserAppearance(responseData, requestData, account.
PrincipalID);
 
 1178                     responseData[
"success"] = 
true;
 
 1179                     responseData[
"avatar_uuid"] = account.PrincipalID.ToString();
 
 1181                     m_log.InfoFormat(
"[RADMIN]: CreateUser: User {0} {1} created, UUID {2}", firstName, lastName, account.PrincipalID);
 
 1185                     responseData[
"avatar_uuid"] = UUID.Zero.ToString();
 
 1190                 m_log.Info(
"[RADMIN]: CreateUser: request complete");
 
 1226         private void XmlRpcUserExistsMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
 
 1228             m_log.Info(
"[RADMIN]: UserExists: new request");
 
 1230             Hashtable responseData = (Hashtable)response.Value;
 
 1231             Hashtable requestData = (Hashtable)request.Params[0];
 
 1234             CheckStringParameters(requestData, responseData, 
new string[] {
"user_firstname", 
"user_lastname"});
 
 1236             string firstName = (string) requestData[
"user_firstname"];
 
 1237             string lastName = (string) requestData[
"user_lastname"];
 
 1239             responseData[
"user_firstname"] = firstName;
 
 1240             responseData[
"user_lastname"] = lastName;
 
 1242             UUID scopeID = m_application.SceneManager.CurrentOrFirstScene.RegionInfo.ScopeID;
 
 1244             UserAccount account = m_application.SceneManager.CurrentOrFirstScene.UserAccountService.GetUserAccount(scopeID, firstName, lastName);
 
 1246             if (null == account)
 
 1248                 responseData[
"success"] = 
false;
 
 1249                 responseData[
"lastlogin"] = 0;
 
 1253                 GridUserInfo userInfo = m_application.SceneManager.CurrentOrFirstScene.GridUserService.GetGridUserInfo(account.PrincipalID.ToString());
 
 1254                 if (userInfo != null)
 
 1255                     responseData[
"lastlogin"] = Util.ToUnixTime(userInfo.Login);
 
 1257                     responseData[
"lastlogin"] = 0;
 
 1259                 responseData[
"success"] = 
true;
 
 1262             m_log.Info(
"[RADMIN]: UserExists: request complete");
 
 1307         private void XmlRpcUpdateUserAccountMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
 
 1309             m_log.Info(
"[RADMIN]: UpdateUserAccount: new request");
 
 1310             m_log.Warn(
"[RADMIN]: This method needs update for 0.7");
 
 1312             Hashtable responseData = (Hashtable)response.Value;
 
 1313             Hashtable requestData = (Hashtable)request.Params[0];
 
 1315             lock (m_requestLock)
 
 1320                     CheckStringParameters(requestData, responseData, 
new string[] {
 
 1325                     string firstName = (string) requestData[
"user_firstname"];
 
 1326                     string lastName = (string) requestData[
"user_lastname"];
 
 1328                     string password = String.Empty;
 
 1329                     uint? regionXLocation = null;
 
 1330                     uint? regionYLocation = null;
 
 1340                     if (requestData.ContainsKey(
"user_password")) password = (
string) requestData[
"user_password"];
 
 1341                     if (requestData.ContainsKey(
"start_region_x"))
 
 1342                         regionXLocation = Convert.ToUInt32(requestData[
"start_region_x"]);
 
 1343                     if (requestData.ContainsKey(
"start_region_y"))
 
 1344                         regionYLocation = Convert.ToUInt32(requestData[
"start_region_y"]);
 
 1364                     Scene scene = m_application.SceneManager.CurrentOrFirstScene;
 
 1365                     UUID scopeID = scene.RegionInfo.ScopeID;
 
 1366                     UserAccount account = scene.UserAccountService.GetUserAccount(scopeID, firstName, lastName);
 
 1368                     if (null == account)
 
 1369                         throw new Exception(
String.Format(
"avatar {0} {1} does not exist", firstName, lastName));
 
 1371                     if (!
String.IsNullOrEmpty(password))
 
 1373                         m_log.DebugFormat(
"[RADMIN]: UpdateUserAccount: updating password for avatar {0} {1}", firstName, lastName);
 
 1374                         ChangeUserPassword(firstName, lastName, password);
 
 1390                     if ((null != regionXLocation) && (null != regionYLocation))
 
 1392                         GridRegion home = scene.GridService.GetRegionByPosition(scopeID, 
 
 1393                                         (int)Util.RegionToWorldLoc((uint)regionXLocation), (int)Util.RegionToWorldLoc((uint)regionYLocation));
 
 1395                             m_log.WarnFormat(
"[RADMIN]: Unable to set home region for updated user account {0} {1}", firstName, lastName);
 
 1397                             scene.GridUserService.SetHome(account.PrincipalID.ToString(), home.
RegionID, 
new Vector3(128, 128, 0), 
new Vector3(0, 1, 0));
 
 1398                             m_log.DebugFormat(
"[RADMIN]: Set home region {0} for updated user account {1} {2}", home.RegionID, firstName, lastName);
 
 1404                     UpdateUserAppearance(responseData, requestData, account.
PrincipalID);
 
 1406                     responseData[
"success"] = 
true;
 
 1407                     responseData[
"avatar_uuid"] = account.PrincipalID.ToString();
 
 1409                     m_log.InfoFormat(
"[RADMIN]: UpdateUserAccount: account for user {0} {1} updated, UUID {2}",
 
 1410                                      firstName, lastName,
 
 1411                                      account.PrincipalID);
 
 1415                     responseData[
"avatar_uuid"] = UUID.Zero.ToString();
 
 1420                 m_log.Info(
"[RADMIN]: UpdateUserAccount: request complete");
 
 1456         private void XmlRpcAuthenticateUserMethod(XmlRpcRequest request, XmlRpcResponse response,
 
 1457                                                    IPEndPoint remoteClient)
 
 1459             m_log.Info(
"[RADMIN]: AuthenticateUser: new request");
 
 1461             var responseData = (Hashtable)response.Value;
 
 1462             var requestData = (Hashtable)request.Params[0];
 
 1464             lock (m_requestLock)
 
 1468                     CheckStringParameters(requestData, responseData, 
new[]
 
 1476                     var firstName = (string)requestData[
"user_firstname"];
 
 1477                     var lastName = (string)requestData[
"user_lastname"];
 
 1478                     var password = (string)requestData[
"user_password"];
 
 1480                     var scene = m_application.SceneManager.CurrentOrFirstScene;
 
 1482                     if (scene.Equals(null))
 
 1484                         m_log.Debug(
"scene does not exist");
 
 1485                         throw new Exception(
"Scene does not exist.");
 
 1488                     var scopeID = scene.RegionInfo.ScopeID;
 
 1489                     var account = scene.UserAccountService.GetUserAccount(scopeID, firstName, lastName);
 
 1491                     if (account.Equals(null) || account.PrincipalID.Equals(UUID.Zero))
 
 1493                         m_log.DebugFormat(
"avatar {0} {1} does not exist", firstName, lastName);
 
 1494                         throw new Exception(
String.Format(
"avatar {0} {1} does not exist", firstName, lastName));
 
 1497                     if (
String.IsNullOrEmpty(password))
 
 1499                         m_log.DebugFormat(
"[RADMIN]: AuthenticateUser: no password provided for {0} {1}", firstName,
 
 1501                         throw new Exception(
String.Format(
"no password provided for {0} {1}", firstName,
 
 1506                     if (
int.TryParse((
string)requestData[
"token_lifetime"], NumberStyles.Integer, CultureInfo.InvariantCulture, out lifetime) == 
false)
 
 1508                         m_log.DebugFormat(
"[RADMIN]: AuthenticateUser: no token lifetime provided for {0} {1}", firstName,
 
 1510                         throw new Exception(
String.Format(
"no token lifetime provided for {0} {1}", firstName,
 
 1517                         m_log.DebugFormat(
"[RADMIN]: AuthenticateUser: token lifetime longer than 30s for {0} {1}", firstName,
 
 1519                         throw new Exception(
String.Format(
"token lifetime longer than 30s for {0} {1}", firstName,
 
 1524                     if (authModule == null)
 
 1526                         m_log.Debug(
"[RADMIN]: AuthenticateUser: no authentication module loded");
 
 1527                         throw new Exception(
"no authentication module loaded");
 
 1530                     var token = authModule.Authenticate(account.PrincipalID, password, lifetime);
 
 1531                     if (
String.IsNullOrEmpty(token))
 
 1533                         m_log.DebugFormat(
"[RADMIN]: AuthenticateUser: authentication failed for {0} {1}", firstName,
 
 1535                         throw new Exception(
String.Format(
"authentication failed for {0} {1}", firstName,
 
 1539                     m_log.DebugFormat(
"[RADMIN]: AuthenticateUser: account for user {0} {1} identified with token {2}",
 
 1540                         firstName, lastName, token);
 
 1542                     responseData[
"token"] = token;
 
 1543                     responseData[
"success"] = 
true;
 
 1548                     responseData[
"success"] = 
false;
 
 1549                     responseData[
"error"] = e.Message;
 
 1553                 m_log.Info(
"[RADMIN]: AuthenticateUser: request complete");
 
 1593         private void XmlRpcLoadOARMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
 
 1595             m_log.Info(
"[RADMIN]: Received Load OAR Administrator Request");
 
 1597             Hashtable responseData = (Hashtable)response.Value;
 
 1598             Hashtable requestData = (Hashtable)request.Params[0];
 
 1600             lock (m_requestLock)
 
 1604                     CheckStringParameters(requestData, responseData, 
new string[] {
"filename"});
 
 1605                     CheckRegionParams(requestData, responseData);
 
 1608                     GetSceneFromRegionParams(requestData, responseData, out scene);
 
 1610                     string filename = (string) requestData[
"filename"];
 
 1612                     bool mergeOar = 
false;
 
 1613                     bool skipAssets = 
false;
 
 1615                     if ((
string)requestData[
"merge"] == 
"true")
 
 1619                     if ((
string)requestData[
"skip-assets"] == 
"true")
 
 1625                     Dictionary<string, object> archiveOptions = 
new Dictionary<string, object>();
 
 1626                     if (mergeOar) archiveOptions.Add(
"merge", null);
 
 1627                     if (skipAssets) archiveOptions.Add(
"skipAssets", null);
 
 1628                     if (archiver != null)
 
 1629                         archiver.DearchiveRegion(filename, Guid.Empty, archiveOptions);
 
 1631                         throw new Exception(
"Archiver module not present for scene");
 
 1633                     responseData[
"loaded"] = 
true;
 
 1637                     responseData[
"loaded"] = 
false;
 
 1642                 m_log.Info(
"[RADMIN]: Load OAR Administrator Request complete");
 
 1686         private void XmlRpcSaveOARMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
 
 1688             m_log.Info(
"[RADMIN]: Received Save OAR Request");
 
 1690             Hashtable responseData = (Hashtable)response.Value;
 
 1691             Hashtable requestData = (Hashtable)request.Params[0];
 
 1695                 CheckStringParameters(requestData, responseData, 
new string[] {
"filename"});
 
 1696                 CheckRegionParams(requestData, responseData);
 
 1699                 GetSceneFromRegionParams(requestData, responseData, out scene);
 
 1701                 string filename = (string)requestData[
"filename"];
 
 1703                 Dictionary<string, object> 
options = 
new Dictionary<string, object>();
 
 1710                 if (requestData.Contains(
"home"))
 
 1712                     options[
"home"] = (string)requestData[
"home"];
 
 1715                 if ((
string)requestData[
"noassets"] == 
"true")
 
 1717                     options[
"noassets"] = (string)requestData[
"noassets"] ;
 
 1720                 if (requestData.Contains(
"perm"))
 
 1722                     options[
"checkPermissions"] = (string)requestData[
"perm"];
 
 1725                 if ((
string)requestData[
"all"] == 
"true")
 
 1727                     options[
"all"] = (string)requestData[
"all"];
 
 1732                 if (archiver != null)
 
 1734                     Guid requestId = Guid.NewGuid();
 
 1735                     scene.EventManager.OnOarFileSaved += RemoteAdminOarSaveCompleted;
 
 1738                         "[RADMIN]: Submitting save OAR request for {0} to file {1}, request ID {2}", 
 
 1739                         scene.Name, filename, requestId);
 
 1741                     archiver.ArchiveRegion(filename, requestId, 
options);
 
 1743                     lock (m_saveOarLock)
 
 1744                         Monitor.Wait(m_saveOarLock,5000);
 
 1746                     scene.
EventManager.OnOarFileSaved -= RemoteAdminOarSaveCompleted;
 
 1750                     throw new Exception(
"Archiver module not present for scene");
 
 1753                 responseData[
"saved"] = 
true;
 
 1757                 responseData[
"saved"] = 
false;
 
 1762             m_log.Info(
"[RADMIN]: Save OAR Request complete");
 
 1765         private void RemoteAdminOarSaveCompleted(Guid uuid, 
string name)
 
 1768                 m_log.ErrorFormat(
"[RADMIN]: Saving of OAR file with request ID {0} failed with message {1}", uuid, name);
 
 1770                 m_log.DebugFormat(
"[RADMIN]: Saved OAR file for request {0}", uuid);
 
 1772             lock (m_saveOarLock)
 
 1773                 Monitor.Pulse(m_saveOarLock);
 
 1776         private 
void XmlRpcLoadXMLMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
 
 1778             m_log.Info(
"[RADMIN]: Received Load XML Administrator Request");
 
 1780             Hashtable responseData = (Hashtable)response.Value;
 
 1781             Hashtable requestData = (Hashtable)request.Params[0];
 
 1783             lock (m_requestLock)
 
 1787                     CheckStringParameters(requestData, responseData, 
new string[] {
"filename"});
 
 1788                     CheckRegionParams(requestData, responseData);
 
 1791                     GetSceneFromRegionParams(requestData, responseData, out scene);
 
 1793                     string filename = (string) requestData[
"filename"];
 
 1795                     responseData[
"switched"] = 
true;
 
 1797                     string xml_version = 
"1";
 
 1798                     if (requestData.Contains(
"xml_version"))
 
 1800                         xml_version = (string) requestData[
"xml_version"];
 
 1803                     switch (xml_version)
 
 1806                             m_application.SceneManager.LoadCurrentSceneFromXml(filename, 
true, 
new Vector3(0, 0, 0));
 
 1810                             m_application.SceneManager.LoadCurrentSceneFromXml2(filename);
 
 1814                             throw new Exception(
String.Format(
"unknown Xml{0} format", xml_version));
 
 1817                     responseData[
"loaded"] = 
true;
 
 1821                     responseData[
"loaded"] = 
false;
 
 1822                     responseData[
"switched"] = 
false;
 
 1827                 m_log.Info(
"[RADMIN]: Load XML Administrator Request complete");
 
 1831         private void XmlRpcSaveXMLMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
 
 1833             m_log.Info(
"[RADMIN]: Received Save XML Administrator Request");
 
 1835             Hashtable responseData = (Hashtable)response.Value;
 
 1836             Hashtable requestData = (Hashtable)request.Params[0];
 
 1840                 CheckStringParameters(requestData, responseData, 
new string[] {
"filename"});
 
 1841                 CheckRegionParams(requestData, responseData);
 
 1844                 GetSceneFromRegionParams(requestData, responseData, out scene);
 
 1846                 string filename = (string) requestData[
"filename"];
 
 1848                 responseData[
"switched"] = 
true;
 
 1850                 string xml_version = 
"1";
 
 1851                 if (requestData.Contains(
"xml_version"))
 
 1853                     xml_version = (string) requestData[
"xml_version"];
 
 1856                 switch (xml_version)
 
 1859                         m_application.SceneManager.SaveCurrentSceneToXml(filename);
 
 1863                         m_application.SceneManager.SaveCurrentSceneToXml2(filename);
 
 1867                         throw new Exception(
String.Format(
"unknown Xml{0} format", xml_version));
 
 1870                 responseData[
"saved"] = 
true;
 
 1874                 responseData[
"saved"] = 
false;
 
 1875                 responseData[
"switched"] = 
false;
 
 1880             m_log.Info(
"[RADMIN]: Save XML Administrator Request complete");
 
 1883         private void XmlRpcRegionQueryMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
 
 1885             Hashtable responseData = (Hashtable)response.Value;
 
 1886             Hashtable requestData = (Hashtable)request.Params[0];
 
 1889             string text = String.Empty;
 
 1891             responseData[
"success"] = 
true;
 
 1893             CheckRegionParams(requestData, responseData);
 
 1898                 GetSceneFromRegionParams(requestData, responseData, out scene);
 
 1899                 health = scene.GetHealth(out flags, out text);
 
 1903                 responseData[
"error"] = null;
 
 1906             responseData[
"success"] = 
true;
 
 1907             responseData[
"health"] = health;
 
 1908             responseData[
"flags"] = flags;
 
 1909             responseData[
"message"] = text;
 
 1912         private void XmlRpcConsoleCommandMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
 
 1914             m_log.Info(
"[RADMIN]: Received Command XML Administrator Request");
 
 1916             Hashtable responseData = (Hashtable)response.Value;
 
 1917             Hashtable requestData = (Hashtable)request.Params[0];
 
 1919             CheckStringParameters(requestData, responseData, 
new string[] {
"command"});
 
 1921             MainConsole.Instance.RunCommand(requestData[
"command"].ToString());
 
 1923             m_log.Info(
"[RADMIN]: Command XML Administrator Request complete");
 
 1926         private void XmlRpcAccessListClear(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
 
 1928             m_log.Info(
"[RADMIN]: Received Access List Clear Request");
 
 1930             Hashtable responseData = (Hashtable)response.Value;
 
 1931             Hashtable requestData = (Hashtable)request.Params[0];
 
 1933             responseData[
"success"] = 
true;
 
 1935             CheckRegionParams(requestData, responseData);
 
 1938             GetSceneFromRegionParams(requestData, responseData, out scene);
 
 1940             scene.RegionInfo.EstateSettings.EstateAccess = 
new UUID[]{};
 
 1943                 m_application.EstateDataService.StoreEstateSettings(scene.RegionInfo.EstateSettings);
 
 1945             m_log.Info(
"[RADMIN]: Access List Clear Request complete");
 
 1948         private void XmlRpcAccessListAdd(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
 
 1950             m_log.Info(
"[RADMIN]: Received Access List Add Request");
 
 1952             Hashtable responseData = (Hashtable)response.Value;
 
 1953             Hashtable requestData = (Hashtable)request.Params[0];
 
 1955             CheckRegionParams(requestData, responseData);
 
 1958             GetSceneFromRegionParams(requestData, responseData, out scene);
 
 1962             if (requestData.Contains(
"users"))
 
 1964                 UUID scopeID = scene.RegionInfo.ScopeID;
 
 1966                 Hashtable users = (Hashtable) requestData[
"users"];
 
 1967                 List<UUID> uuids = 
new List<UUID>();
 
 1968                 foreach (
string name 
in users.Values)
 
 1970                     string[] parts = name.Split();
 
 1971                     UserAccount account = userService.GetUserAccount(scopeID, parts[0], parts[1]);
 
 1972                     if (account != null)
 
 1974                         uuids.Add(account.PrincipalID);
 
 1975                         m_log.DebugFormat(
"[RADMIN]: adding \"{0}\" to ACL for \"{1}\"", name, scene.RegionInfo.RegionName);
 
 1978                 List<UUID> accessControlList = 
new List<UUID>(scene.RegionInfo.EstateSettings.EstateAccess);
 
 1979                 foreach (UUID uuid 
in uuids)
 
 1981                    if (!accessControlList.Contains(uuid))
 
 1983                         accessControlList.Add(uuid);
 
 1987                 scene.RegionInfo.EstateSettings.EstateAccess = accessControlList.ToArray();
 
 1989                     m_application.EstateDataService.StoreEstateSettings(scene.RegionInfo.EstateSettings);
 
 1992             responseData[
"added"] = addedUsers;
 
 1994             m_log.Info(
"[RADMIN]: Access List Add Request complete");
 
 1997         private void XmlRpcAccessListRemove(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
 
 1999             m_log.Info(
"[RADMIN]: Received Access List Remove Request");
 
 2001             Hashtable responseData = (Hashtable)response.Value;
 
 2002             Hashtable requestData = (Hashtable)request.Params[0];
 
 2004             CheckRegionParams(requestData, responseData);
 
 2007             GetSceneFromRegionParams(requestData, responseData, out scene);
 
 2009             int removedUsers = 0;
 
 2011             if (requestData.Contains(
"users"))
 
 2013                 UUID scopeID = scene.RegionInfo.ScopeID;
 
 2016                 Hashtable users = (Hashtable) requestData[
"users"];
 
 2017                 List<UUID> uuids = 
new List<UUID>();
 
 2018                 foreach (
string name 
in users.Values)
 
 2020                     string[] parts = name.Split();
 
 2021                     UserAccount account = userService.GetUserAccount(scopeID, parts[0], parts[1]);
 
 2022                     if (account != null)
 
 2024                         uuids.Add(account.PrincipalID);
 
 2027                 List<UUID> accessControlList = 
new List<UUID>(scene.RegionInfo.EstateSettings.EstateAccess);
 
 2028                 foreach (UUID uuid 
in uuids)
 
 2030                    if (accessControlList.Contains(uuid))
 
 2032                         accessControlList.Remove(uuid);
 
 2036                 scene.RegionInfo.EstateSettings.EstateAccess = accessControlList.ToArray();
 
 2038                     m_application.EstateDataService.StoreEstateSettings(scene.RegionInfo.EstateSettings);
 
 2041             responseData[
"removed"] = removedUsers;
 
 2042             responseData[
"success"] = 
true;
 
 2044             m_log.Info(
"[RADMIN]: Access List Remove Request complete");
 
 2047         private void XmlRpcAccessListList(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
 
 2049             m_log.Info(
"[RADMIN]: Received Access List List Request");
 
 2051             Hashtable responseData = (Hashtable)response.Value;
 
 2052             Hashtable requestData = (Hashtable)request.Params[0];
 
 2054             CheckRegionParams(requestData, responseData);
 
 2057             GetSceneFromRegionParams(requestData, responseData, out scene);
 
 2059             UUID[] accessControlList = scene.RegionInfo.EstateSettings.EstateAccess;
 
 2060             Hashtable users = 
new Hashtable();
 
 2062             foreach (UUID user 
in accessControlList)
 
 2064                 UUID scopeID = scene.RegionInfo.ScopeID;
 
 2065                 UserAccount account = scene.UserAccountService.GetUserAccount(scopeID, user);
 
 2066                 if (account != null)
 
 2072             responseData[
"users"] = users;
 
 2073             responseData[
"success"] = 
true;
 
 2075             m_log.Info(
"[RADMIN]: Access List List Request complete");
 
 2078         private void XmlRpcEstateReload(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
 
 2080             m_log.Info(
"[RADMIN]: Received Estate Reload Request");
 
 2082             Hashtable responseData = (Hashtable)response.Value;
 
 2085             m_application.SceneManager.ForEachScene(s => 
 
 2089             responseData[
"success"] = 
true;
 
 2091             m_log.Info(
"[RADMIN]: Estate Reload Request complete");
 
 2094         private void XmlRpcGetAgentsMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
 
 2096             Hashtable responseData = (Hashtable)response.Value;
 
 2097             Hashtable requestData = (Hashtable)request.Params[0];
 
 2099             bool includeChildren = 
false;
 
 2101             if (requestData.Contains(
"include_children"))
 
 2102                 bool.TryParse((
string)requestData[
"include_children"], out includeChildren);
 
 2105             GetSceneFromRegionParams(requestData, responseData, out scene);
 
 2107             ArrayList xmlRpcRegions = 
new ArrayList();
 
 2108             responseData[
"regions"] = xmlRpcRegions;
 
 2110             Hashtable xmlRpcRegion = 
new Hashtable();
 
 2111             xmlRpcRegions.Add(xmlRpcRegion);
 
 2113             xmlRpcRegion[
"name"] = scene.Name;
 
 2114             xmlRpcRegion[
"id"] = scene.RegionInfo.RegionID.ToString();
 
 2116             List<ScenePresence> agents = scene.GetScenePresences();
 
 2117             ArrayList xmlrpcAgents = 
new ArrayList();
 
 2124                 Hashtable xmlRpcAgent = 
new Hashtable();
 
 2125                 xmlRpcAgent.Add(
"name", agent.Name);
 
 2126                 xmlRpcAgent.Add(
"id", agent.UUID.ToString());
 
 2127                 xmlRpcAgent.Add(
"type", agent.PresenceType.ToString());
 
 2128                 xmlRpcAgent.Add(
"current_parcel_id", agent.currentParcelUUID.ToString());
 
 2130                 Vector3 pos = agent.AbsolutePosition;
 
 2131                 xmlRpcAgent.Add(
"pos_x", pos.X.ToString());
 
 2132                 xmlRpcAgent.Add(
"pos_y", pos.Y.ToString());
 
 2133                 xmlRpcAgent.Add(
"pos_z", pos.Z.ToString());
 
 2135                 Vector3 lookAt = agent.Lookat;
 
 2136                 xmlRpcAgent.Add(
"lookat_x", lookAt.X.ToString());
 
 2137                 xmlRpcAgent.Add(
"lookat_y", lookAt.Y.ToString());
 
 2138                 xmlRpcAgent.Add(
"lookat_z", lookAt.Z.ToString());
 
 2140                 Vector3 vel = agent.Velocity;
 
 2141                 xmlRpcAgent.Add(
"vel_x", vel.X.ToString());
 
 2142                 xmlRpcAgent.Add(
"vel_y", vel.Y.ToString());
 
 2143                 xmlRpcAgent.Add(
"vel_z", vel.Z.ToString());
 
 2145                 xmlRpcAgent.Add(
"is_flying", agent.Flying.ToString());
 
 2146                 xmlRpcAgent.Add(
"is_sat_on_ground", agent.SitGround.ToString());
 
 2147                 xmlRpcAgent.Add(
"is_sat_on_object", agent.IsSatOnObject.ToString());
 
 2149                 xmlrpcAgents.Add(xmlRpcAgent);
 
 2153                 "[REMOTE ADMIN]: XmlRpcGetAgents found {0} agents in {1}", xmlrpcAgents.Count, scene.Name);
 
 2155             xmlRpcRegion[
"agents"] = xmlrpcAgents;
 
 2156             responseData[
"success"] = 
true;
 
 2159         private void XmlRpcTeleportAgentMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
 
 2161             Hashtable responseData = (Hashtable)response.Value;
 
 2162             Hashtable requestData = (Hashtable)request.Params[0];
 
 2165             string regionName = null;
 
 2166             Vector3 pos, lookAt;
 
 2169             if (requestData.Contains(
"agent_first_name") && requestData.Contains(
"agent_last_name"))
 
 2171                 string firstName = requestData[
"agent_first_name"].ToString();
 
 2172                 string lastName = requestData[
"agent_last_name"].ToString();
 
 2173                 m_application.SceneManager.TryGetRootScenePresenceByName(firstName, lastName, out sp);
 
 2176                     throw new Exception(
 
 2178                             "No agent found with agent_first_name {0} and agent_last_name {1}", firstName, lastName));
 
 2180             else if (requestData.Contains(
"agent_id"))
 
 2182                 string rawAgentId = (string)requestData[
"agent_id"];
 
 2184                 if (!
UUID.TryParse(rawAgentId, out agentId))
 
 2185                     throw new Exception(
string.Format(
"agent_id {0} does not have the correct id format", rawAgentId));
 
 2187                 m_application.SceneManager.TryGetRootScenePresence(agentId, out sp);
 
 2190                     throw new Exception(
string.Format(
"No agent with agent_id {0} found in this simulator", agentId));
 
 2194                 throw new Exception(
"No agent_id or agent_first_name and agent_last_name parameters specified");
 
 2197             if (requestData.Contains(
"region_name"))
 
 2198                 regionName = (
string)requestData[
"region_name"];
 
 2203             lookAt.X = ParseFloat(requestData, 
"lookat_x", sp.
Lookat.X);
 
 2204             lookAt.Y = ParseFloat(requestData, 
"lookat_y", sp.
Lookat.Y);
 
 2205             lookAt.Z = ParseFloat(requestData, 
"lookat_z", sp.
Lookat.Z);
 
 2207             sp.Scene.RequestTeleportLocation(
 
 2211             responseData[
"success"] = 
true;
 
 2214         private void XmlRpcResetLand(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
 
 2216             Hashtable requestData = (Hashtable)request.Params[0];
 
 2217             Hashtable responseData = (Hashtable)response.Value;
 
 2218             string musicURL = string.Empty;
 
 2219             UUID groupID = UUID.Zero;
 
 2221             bool set_group = 
false, set_music = 
false, set_flags = 
false;
 
 2223             if (requestData.Contains(
"group") && requestData[
"group"] != null)
 
 2224                 set_group = 
UUID.TryParse(requestData[
"group"].ToString(), out groupID);
 
 2225             if (requestData.Contains(
"music") && requestData[
"music"] != null)
 
 2228                 musicURL = requestData[
"music"].ToString();
 
 2232             if (requestData.Contains(
"flags") && requestData[
"flags"] != null)
 
 2233                 set_flags = UInt32.TryParse(requestData[
"flags"].ToString(), out flags);
 
 2235             m_log.InfoFormat(
"[RADMIN]: Received Reset Land Request group={0} musicURL={1} flags={2}",
 
 2236                 (set_group ? groupID.ToString() : 
"unchanged"),
 
 2237                 (set_music ? musicURL : 
"unchanged"),
 
 2238                 (set_flags ? flags.ToString() : 
"unchanged"));
 
 2240             m_application.SceneManager.ForEachScene(delegate (
Scene s)
 
 2242                 List<ILandObject> parcels = s.LandChannel.AllParcels();
 
 2246                         p.LandData.MusicURL = musicURL;
 
 2248                         p.LandData.GroupID = groupID;
 
 2250                         p.LandData.Flags = flags;
 
 2251                     s.LandChannel.UpdateLandObject(p.LandData.LocalID, p.LandData);
 
 2255             responseData[
"success"] = 
true;
 
 2256             m_log.Info(
"[RADMIN]: Reset Land Request complete");
 
 2259         private void XmlRpcRefreshSearch(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
 
 2261             m_log.Info(
"[RADMIN]: Received Refresh Search Request");
 
 2263             Hashtable responseData = (Hashtable)response.Value;
 
 2264             Hashtable requestData = (Hashtable)request.Params[0];
 
 2266             CheckRegionParams(requestData, responseData);
 
 2269             GetSceneFromRegionParams(requestData, responseData, out scene);
 
 2272             if (searchModule != null)
 
 2274                 searchModule.Refresh();
 
 2275                 responseData[
"success"] = 
true;
 
 2279                 responseData[
"success"] = 
false;
 
 2282             m_log.Info(
"[RADMIN]: Refresh Search Request complete");
 
 2285         private void XmlRpcRefreshMap(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
 
 2287             m_log.Info(
"[RADMIN]: Received Refresh Map Request");
 
 2289             Hashtable responseData = (Hashtable)response.Value;
 
 2290             Hashtable requestData = (Hashtable)request.Params[0];
 
 2292             CheckRegionParams(requestData, responseData);
 
 2295             GetSceneFromRegionParams(requestData, responseData, out scene);
 
 2298             if (mapTileModule != null)
 
 2300                 Util.FireAndForget((x) =>
 
 2302                     mapTileModule.UploadMapTile(scene);
 
 2304                 responseData[
"success"] = 
true;
 
 2308                 responseData[
"success"] = 
false;
 
 2311             m_log.Info(
"[RADMIN]: Refresh Map Request complete");
 
 2314         private void XmlRpcGetOpenSimVersion(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
 
 2316             m_log.Info(
"[RADMIN]: Received Get OpenSim Version Request");
 
 2318             Hashtable responseData = (Hashtable)response.Value;
 
 2320             responseData[
"version"] = m_openSimVersion;
 
 2321             responseData[
"success"] = 
true;
 
 2323             m_log.Info(
"[RADMIN]: Get OpenSim Version Request complete");
 
 2326         private void XmlRpcGetAgentCount(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
 
 2328             m_log.Info(
"[RADMIN]: Received Get Agent Count Request");
 
 2330             Hashtable responseData = (Hashtable)response.Value;
 
 2331             Hashtable requestData = (Hashtable)request.Params[0];
 
 2333             CheckRegionParams(requestData, responseData);
 
 2336             GetSceneFromRegionParams(requestData, responseData, out scene);
 
 2340                 responseData[
"success"] = 
false;
 
 2344                 responseData[
"count"] = scene.GetRootAgentCount();
 
 2345                 responseData[
"success"] = 
true;
 
 2348             m_log.Info(
"[RADMIN]: Get Agent Count Request complete");
 
 2362         private static float ParseFloat(Hashtable requestData, 
string paramName, 
float defaultVal)
 
 2364             if (requestData.Contains(paramName))
 
 2366                 string rawVal = (string)requestData[paramName];
 
 2369                 if (!
float.TryParse(rawVal, out val))
 
 2370                     throw new Exception(
string.Format(
"{0} {1} is not a valid float", paramName, rawVal));
 
 2380         private static void CheckStringParameters(Hashtable requestData, Hashtable responseData, 
string[] param)
 
 2382             foreach (
string parameter 
in param)
 
 2384                 if (!requestData.Contains(parameter))
 
 2386                     responseData[
"accepted"] = 
false;
 
 2387                     throw new Exception(
String.Format(
"missing string parameter {0}", parameter));
 
 2389                 if (
String.IsNullOrEmpty((
string) requestData[parameter]))
 
 2391                     responseData[
"accepted"] = 
false;
 
 2392                     throw new Exception(
String.Format(
"parameter {0} is empty", parameter));
 
 2397         private static void CheckIntegerParams(Hashtable requestData, Hashtable responseData, 
string[] param)
 
 2399             foreach (
string parameter 
in param)
 
 2401                 if (!requestData.Contains(parameter))
 
 2403                     responseData[
"accepted"] = 
false;
 
 2404                     throw new Exception(
String.Format(
"missing integer parameter {0}", parameter));
 
 2409         private void CheckRegionParams(Hashtable requestData, Hashtable responseData)
 
 2412             if ((requestData.ContainsKey(
"region_id") && !String.IsNullOrEmpty((string)requestData[
"region_id"])) ||
 
 2413                 (requestData.ContainsKey(
"region_name") && !String.IsNullOrEmpty((string)requestData[
"region_name"])))
 
 2419                 responseData[
"accepted"] = 
false;
 
 2420                 throw new Exception(
"no region_name or region_id given");
 
 2424         private void GetSceneFromRegionParams(Hashtable requestData, Hashtable responseData, out 
Scene scene)
 
 2428             if (requestData.ContainsKey(
"region_id") &&
 
 2429                 !String.IsNullOrEmpty((string)requestData[
"region_id"]))
 
 2431                 UUID regionID = (
UUID)(
string)requestData[
"region_id"];
 
 2432                 if (!m_application.SceneManager.TryGetScene(regionID, out scene))
 
 2434                     responseData[
"error"] = String.Format(
"Region ID {0} not found", regionID);
 
 2435                     throw new Exception(
String.Format(
"Region ID {0} not found", regionID));
 
 2438             else if (requestData.ContainsKey(
"region_name") &&
 
 2439                 !String.IsNullOrEmpty((string)requestData[
"region_name"]))
 
 2441                 string regionName = (string)requestData[
"region_name"];
 
 2442                 if (!m_application.SceneManager.TryGetScene(regionName, out scene))
 
 2444                     responseData[
"error"] = String.Format(
"Region {0} not found", regionName);
 
 2445                     throw new Exception(
String.Format(
"Region {0} not found", regionName));
 
 2450                 responseData[
"error"] = 
"no region_name or region_id given";
 
 2451                 throw new Exception(
"no region_name or region_id given");
 
 2456         private bool GetBoolean(Hashtable requestData, 
string tag, 
bool defaultValue)
 
 2459             if (requestData.Contains(tag))
 
 2461                 switch (((
string)requestData[tag]).ToLower())
 
 2472                         return defaultValue;
 
 2476                 return defaultValue;
 
 2479         private int GetIntegerAttribute(XmlNode node, 
string attribute, 
int defaultValue)
 
 2481             try { 
return Convert.ToInt32(node.Attributes[attribute].Value); } 
catch{}
 
 2482             return defaultValue;
 
 2485         private uint GetUnsignedAttribute(XmlNode node, 
string attribute, uint defaultValue)
 
 2487             try { 
return Convert.ToUInt32(node.Attributes[attribute].Value); } 
catch{}
 
 2488             return defaultValue;
 
 2491         private string GetStringAttribute(XmlNode node, 
string attribute, 
string defaultValue)
 
 2493             try { 
return node.Attributes[attribute].Value; } 
catch{}
 
 2494             return defaultValue;
 
 2509         private UserAccount CreateUser(UUID scopeID, 
string firstName, 
string lastName, 
string password, 
string email)
 
 2511             Scene scene = m_application.SceneManager.CurrentOrFirstScene;
 
 2518             UserAccount account = userAccountService.GetUserAccount(scopeID, firstName, lastName);
 
 2519             if (null == account)
 
 2521                 account = 
new UserAccount(scopeID, 
UUID.Random(), firstName, lastName, email);
 
 2524                     account.ServiceURLs = 
new Dictionary<string, object>();
 
 2525                     account.ServiceURLs[
"HomeURI"] = string.Empty;
 
 2526                     account.ServiceURLs[
"InventoryServerURI"] = string.Empty;
 
 2527                     account.ServiceURLs[
"AssetServerURI"] = string.Empty;
 
 2533                     if (authenticationService != null)
 
 2535                         success = authenticationService.SetPassword(account.PrincipalID, password);
 
 2537                             m_log.WarnFormat(
"[RADMIN]: Unable to set password for account {0} {1}.",
 
 2538                                 firstName, lastName);
 
 2542                     if (gridService != null)
 
 2544                         List<GridRegion> defaultRegions = gridService.GetDefaultRegions(UUID.Zero);
 
 2545                         if (defaultRegions != null && defaultRegions.Count >= 1)
 
 2546                             home = defaultRegions[0];
 
 2548                         if (gridUserService != null && home != null)
 
 2549                             gridUserService.SetHome(account.PrincipalID.ToString(), home.
RegionID, 
new Vector3(128, 128, 0), 
new Vector3(0, 1, 0));
 
 2551                             m_log.WarnFormat(
"[RADMIN]: Unable to set home for account {0} {1}.",
 
 2552                                firstName, lastName);
 
 2555                         m_log.WarnFormat(
"[RADMIN]: Unable to retrieve home region for account {0} {1}.",
 
 2556                            firstName, lastName);
 
 2558                     if (inventoryService != null)
 
 2560                         success = inventoryService.CreateUserInventory(account.PrincipalID);
 
 2562                             m_log.WarnFormat(
"[RADMIN]: Unable to create inventory for account {0} {1}.",
 
 2563                                 firstName, lastName);
 
 2566                     m_log.InfoFormat(
"[RADMIN]: Account {0} {1} created successfully", firstName, lastName);
 
 2569                     m_log.ErrorFormat(
"[RADMIN]: Account creation failed for account {0} {1}", firstName, lastName);
 
 2574                 m_log.ErrorFormat(
"[RADMIN]: A user with the name {0} {1} already exists!", firstName, lastName);
 
 2585         private bool ChangeUserPassword(
string firstName, 
string lastName, 
string password)
 
 2587             Scene scene = m_application.SceneManager.CurrentOrFirstScene;
 
 2591             UserAccount account = userAccountService.GetUserAccount(UUID.Zero, firstName, lastName);
 
 2592             if (null != account)
 
 2594                 bool success = 
false;
 
 2595                 if (authenticationService != null)
 
 2596                     success = authenticationService.SetPassword(account.PrincipalID, password);
 
 2600                     m_log.WarnFormat(
"[RADMIN]: Unable to set password for account {0} {1}.",
 
 2601                        firstName, lastName);
 
 2608                 m_log.ErrorFormat(
"[RADMIN]: No such user");
 
 2613         private bool LoadHeightmap(
string file, UUID regionID)
 
 2615             m_log.InfoFormat(
"[RADMIN]: Terrain Loading: {0}", file);
 
 2617             Scene region = null;
 
 2619             if (!m_application.SceneManager.TryGetScene(regionID, out region))
 
 2621                 m_log.InfoFormat(
"[RADMIN]: unable to get a scene with that name: {0}", regionID.ToString());
 
 2626             if (null == terrainModule) 
throw new Exception(
"terrain module not available");
 
 2627             if (Uri.IsWellFormedUriString(file, UriKind.Absolute))
 
 2629                 m_log.Info(
"[RADMIN]: Terrain path is URL");
 
 2631                 if (Uri.TryCreate(file, UriKind.RelativeOrAbsolute, out result))
 
 2634                     string fileType = file.Substring(file.LastIndexOf(
'/') + 1);
 
 2635                     terrainModule.LoadFromStream(fileType, result);
 
 2640                 terrainModule.LoadFromFile(file);
 
 2643             m_log.Info(
"[RADMIN]: Load height maps request complete");
 
 2656         private void UpdateUserAppearance(Hashtable responseData, Hashtable requestData, UUID userid)
 
 2658             m_log.DebugFormat(
"[RADMIN]: updateUserAppearance");
 
 2660             string defaultMale   = m_config.GetString(
"default_male", 
"Default Male");
 
 2661             string defaultFemale = m_config.GetString(
"default_female", 
"Default Female");
 
 2662             string defaultNeutral   = m_config.GetString(
"default_female", 
"Default Default");
 
 2663             string model   = String.Empty;
 
 2667             if (requestData.Contains(
"gender"))
 
 2669                 switch ((
string)requestData[
"gender"])
 
 2673                         model = defaultMale;
 
 2677                         model = defaultFemale;
 
 2682                         model = defaultNeutral;
 
 2689             if (requestData.Contains(
"model") && (String.IsNullOrEmpty((string)requestData[
"gender"])))
 
 2691                 model = (string)requestData[
"model"];
 
 2696             if (
String.IsNullOrEmpty(model))
 
 2698                 m_log.DebugFormat(
"[RADMIN]: Appearance update not requested");
 
 2702             m_log.DebugFormat(
"[RADMIN]: Setting appearance for avatar {0}, using model <{1}>", userid, model);
 
 2704             string[] modelSpecifiers = model.Split();
 
 2705             if (modelSpecifiers.Length != 2)
 
 2707                 m_log.WarnFormat(
"[RADMIN]: User appearance not set for {0}. Invalid model name : <{1}>", userid, model);
 
 2712             Scene scene = m_application.SceneManager.CurrentOrFirstScene;
 
 2713             UUID scopeID = scene.RegionInfo.ScopeID;
 
 2714             UserAccount modelProfile = scene.UserAccountService.GetUserAccount(scopeID, modelSpecifiers[0], modelSpecifiers[1]);
 
 2716             if (modelProfile == null)
 
 2718                 m_log.WarnFormat(
"[RADMIN]: Requested model ({0}) not found. Appearance unchanged", model);
 
 2726             EstablishAppearance(userid, modelProfile.
PrincipalID);
 
 2728             m_log.DebugFormat(
"[RADMIN]: Finished setting appearance for avatar {0}, using model {1}",
 
 2737         private void EstablishAppearance(UUID destination, UUID source)
 
 2739             m_log.DebugFormat(
"[RADMIN]: Initializing inventory for {0} from {1}", destination, source);
 
 2740             Scene scene = m_application.SceneManager.CurrentOrFirstScene;
 
 2743             AvatarAppearance avatarAppearance = scene.AvatarService.GetAppearance(source);
 
 2744             if (avatarAppearance == null)
 
 2748             bool copyFolders = m_config.GetBoolean(
"copy_folders", 
false);
 
 2755                     CopyWearablesAndAttachments(destination, source, avatarAppearance);
 
 2757                     scene.AvatarService.SetAppearance(destination, avatarAppearance);
 
 2761                     m_log.WarnFormat(
"[RADMIN]: Error transferring appearance for {0} : {1}",
 
 2762                                       destination, e.Message);
 
 2771                 Dictionary<UUID,UUID> inventoryMap = 
new Dictionary<UUID,UUID>();
 
 2772                 CopyInventoryFolders(destination, source, FolderType.Clothing, inventoryMap, avatarAppearance);
 
 2773                 CopyInventoryFolders(destination, source, FolderType.BodyPart, inventoryMap, avatarAppearance);
 
 2777                 for (
int i=0; i<wearables.Length; i++)
 
 2779                     if (inventoryMap.ContainsKey(wearables[i][0].ItemID))
 
 2782                         wearable.Wear(inventoryMap[wearables[i][0].ItemID],
 
 2783                                 wearables[i][0].AssetID);
 
 2784                         avatarAppearance.SetWearable(i, wearable);
 
 2788                 scene.AvatarService.SetAppearance(destination, avatarAppearance);
 
 2792                m_log.WarnFormat(
"[RADMIN]: Error transferring appearance for {0} : {1}",
 
 2793                                   destination, e.Message);
 
 2804         private void CopyWearablesAndAttachments(UUID destination, UUID source, 
AvatarAppearance avatarAppearance)
 
 2806             IInventoryService inventoryService = m_application.SceneManager.CurrentOrFirstScene.InventoryService;
 
 2809             InventoryFolderBase destinationFolder = inventoryService.GetFolderForType(destination, FolderType.Clothing);
 
 2811             if (destinationFolder == null)
 
 2812                 throw new Exception(
"Cannot locate folder(s)");
 
 2815             if (destinationFolder.
Type != (
short)FolderType.Clothing)
 
 2819                 destinationFolder.ID       = UUID.Random();
 
 2820                 destinationFolder.Name     = 
"Clothing";
 
 2821                 destinationFolder.Owner    = destination;
 
 2822                 destinationFolder.Type = (short)FolderType.Clothing;
 
 2824                 destinationFolder.Version  = 1;
 
 2825                 inventoryService.AddFolder(destinationFolder);     
 
 2826                 m_log.ErrorFormat(
"[RADMIN]: Created folder for destination {0}", source);
 
 2833             for (
int i = 0; i<wearables.Length; i++)
 
 2835                 wearable = wearables[i];
 
 2836                 if (wearable[0].ItemID != 
UUID.Zero)
 
 2840                     item = inventoryService.GetItem(item);
 
 2845                         destinationItem.Name = item.Name;
 
 2846                         destinationItem.Owner = destination;
 
 2847                         destinationItem.Description = item.Description;
 
 2848                         destinationItem.InvType = item.InvType;
 
 2849                         destinationItem.CreatorId = item.CreatorId;
 
 2850                         destinationItem.CreatorData = item.CreatorData;
 
 2851                         destinationItem.NextPermissions = item.NextPermissions;
 
 2852                         destinationItem.CurrentPermissions = item.CurrentPermissions;
 
 2853                         destinationItem.BasePermissions = item.BasePermissions;
 
 2854                         destinationItem.EveryOnePermissions = item.EveryOnePermissions;
 
 2855                         destinationItem.GroupPermissions = item.GroupPermissions;
 
 2856                         destinationItem.AssetType = item.AssetType;
 
 2857                         destinationItem.AssetID = item.AssetID;
 
 2858                         destinationItem.GroupID = item.GroupID;
 
 2859                         destinationItem.GroupOwned = item.GroupOwned;
 
 2860                         destinationItem.SalePrice = item.SalePrice;
 
 2861                         destinationItem.SaleType = item.SaleType;
 
 2862                         destinationItem.Flags = item.Flags;
 
 2863                         destinationItem.CreationDate = item.CreationDate;
 
 2864                         destinationItem.Folder = destinationFolder.ID;
 
 2865                         ApplyNextOwnerPermissions(destinationItem);
 
 2867                         m_application.SceneManager.CurrentOrFirstScene.AddInventoryItem(destinationItem);
 
 2868                         m_log.DebugFormat(
"[RADMIN]: Added item {0} to folder {1}", destinationItem.ID, destinationFolder.ID);
 
 2872                         newWearable.Wear(destinationItem.ID, wearable[0].AssetID);
 
 2873                         avatarAppearance.SetWearable(i, newWearable);
 
 2877                         m_log.WarnFormat(
"[RADMIN]: Error transferring {0} to folder {1}", wearable[0].ItemID, destinationFolder.ID);
 
 2883             List<AvatarAttachment> attachments = avatarAppearance.GetAttachments();
 
 2887                 int attachpoint = attachment.AttachPoint;
 
 2888                 UUID itemID = attachment.ItemID;
 
 2890                 if (itemID != 
UUID.Zero)
 
 2894                     item = inventoryService.GetItem(item);
 
 2899                         destinationItem.Name = item.Name;
 
 2900                         destinationItem.Owner = destination;
 
 2901                         destinationItem.Description = item.Description;
 
 2902                         destinationItem.InvType = item.InvType;
 
 2903                         destinationItem.CreatorId = item.CreatorId;
 
 2904                         destinationItem.CreatorData = item.CreatorData;
 
 2905                         destinationItem.NextPermissions = item.NextPermissions;
 
 2906                         destinationItem.CurrentPermissions = item.CurrentPermissions;
 
 2907                         destinationItem.BasePermissions = item.BasePermissions;
 
 2908                         destinationItem.EveryOnePermissions = item.EveryOnePermissions;
 
 2909                         destinationItem.GroupPermissions = item.GroupPermissions;
 
 2910                         destinationItem.AssetType = item.AssetType;
 
 2911                         destinationItem.AssetID = item.AssetID;
 
 2912                         destinationItem.GroupID = item.GroupID;
 
 2913                         destinationItem.GroupOwned = item.GroupOwned;
 
 2914                         destinationItem.SalePrice = item.SalePrice;
 
 2915                         destinationItem.SaleType = item.SaleType;
 
 2916                         destinationItem.Flags = item.Flags;
 
 2917                         destinationItem.CreationDate = item.CreationDate;
 
 2918                         destinationItem.Folder = destinationFolder.ID;
 
 2919                         ApplyNextOwnerPermissions(destinationItem);
 
 2921                         m_application.SceneManager.CurrentOrFirstScene.AddInventoryItem(destinationItem);
 
 2922                         m_log.DebugFormat(
"[RADMIN]: Added item {0} to folder {1}", destinationItem.ID, destinationFolder.ID);
 
 2925                         avatarAppearance.SetAttachment(attachpoint, destinationItem.ID, destinationItem.AssetID);
 
 2926                         m_log.DebugFormat(
"[RADMIN]: Attached {0}", destinationItem.ID);
 
 2930                         m_log.WarnFormat(
"[RADMIN]: Error transferring {0} to folder {1}", itemID, destinationFolder.ID);
 
 2940         private void CopyInventoryFolders(UUID destination, UUID source, FolderType assetType, Dictionary<UUID, UUID> inventoryMap,
 
 2943             IInventoryService inventoryService = m_application.SceneManager.CurrentOrFirstScene.InventoryService;
 
 2946             InventoryFolderBase destinationFolder = inventoryService.GetFolderForType(destination, assetType);
 
 2948             if (sourceFolder == null || destinationFolder == null)
 
 2949                 throw new Exception(
"Cannot locate folder(s)");
 
 2952             if (sourceFolder.
Type != (
short)assetType)
 
 2955                 sourceFolder.ID       = UUID.Random();
 
 2956                 if (assetType == FolderType.Clothing) 
 
 2958                     sourceFolder.Name     = 
"Clothing";
 
 2962                     sourceFolder.Name     = 
"Body Parts";
 
 2964                 sourceFolder.Owner    = source;
 
 2965                 sourceFolder.Type     = (short)assetType;
 
 2966                 sourceFolder.ParentID = inventoryService.GetRootFolder(source).ID;
 
 2967                 sourceFolder.Version  = 1;
 
 2968                 inventoryService.AddFolder(sourceFolder);     
 
 2969                 m_log.ErrorFormat(
"[RADMIN] Created folder for source {0}", source);
 
 2973             if (destinationFolder.Type != (
short)assetType)
 
 2976                 destinationFolder.ID       = UUID.Random();
 
 2977                 if (assetType == FolderType.Clothing)
 
 2979                     destinationFolder.Name  = 
"Clothing";
 
 2983                     destinationFolder.Name  = 
"Body Parts";
 
 2985                 destinationFolder.Owner    = destination;
 
 2986                 destinationFolder.Type     = (short)assetType;
 
 2987                 destinationFolder.ParentID = inventoryService.GetRootFolder(destination).ID;
 
 2988                 destinationFolder.Version  = 1;
 
 2989                 inventoryService.AddFolder(destinationFolder);     
 
 2990                 m_log.ErrorFormat(
"[RADMIN]: Created folder for destination {0}", source);
 
 2994             List<InventoryFolderBase> folders = inventoryService.GetFolderContent(source, sourceFolder.ID).Folders;
 
 2999                 extraFolder.ID = UUID.Random();
 
 3000                 extraFolder.Name = folder.Name;
 
 3001                 extraFolder.Owner = destination;
 
 3002                 extraFolder.Type = folder.Type;
 
 3003                 extraFolder.Version = folder.Version;
 
 3004                 extraFolder.ParentID = destinationFolder.ID;
 
 3005                 inventoryService.AddFolder(extraFolder);
 
 3007                 m_log.DebugFormat(
"[RADMIN]: Added folder {0} to folder {1}", extraFolder.ID, sourceFolder.ID);
 
 3009                 List<InventoryItemBase> items = inventoryService.GetFolderContent(source, folder.ID).Items;
 
 3014                     destinationItem.Name = item.Name;
 
 3015                     destinationItem.Owner = destination;
 
 3016                     destinationItem.Description = item.Description;
 
 3017                     destinationItem.InvType = item.InvType;
 
 3018                     destinationItem.CreatorId = item.CreatorId;
 
 3019                     destinationItem.CreatorData = item.CreatorData;
 
 3020                     destinationItem.NextPermissions = item.NextPermissions;
 
 3021                     destinationItem.CurrentPermissions = item.CurrentPermissions;
 
 3022                     destinationItem.BasePermissions = item.BasePermissions;
 
 3023                     destinationItem.EveryOnePermissions = item.EveryOnePermissions;
 
 3024                     destinationItem.GroupPermissions = item.GroupPermissions;
 
 3025                     destinationItem.AssetType = item.AssetType;
 
 3026                     destinationItem.AssetID = item.AssetID;
 
 3027                     destinationItem.GroupID = item.GroupID;
 
 3028                     destinationItem.GroupOwned = item.GroupOwned;
 
 3029                     destinationItem.SalePrice = item.SalePrice;
 
 3030                     destinationItem.SaleType = item.SaleType;
 
 3031                     destinationItem.Flags = item.Flags;
 
 3032                     destinationItem.CreationDate = item.CreationDate;
 
 3033                     destinationItem.Folder = extraFolder.ID;
 
 3034                     ApplyNextOwnerPermissions(destinationItem);
 
 3036                     m_application.SceneManager.CurrentOrFirstScene.AddInventoryItem(destinationItem);
 
 3037                     inventoryMap.Add(item.ID, destinationItem.ID);
 
 3038                     m_log.DebugFormat(
"[RADMIN]: Added item {0} to folder {1}", destinationItem.ID, extraFolder.ID);
 
 3041                     int attachpoint = avatarAppearance.GetAttachpoint(item.ID);
 
 3042                     if (attachpoint != 0)
 
 3044                         avatarAppearance.SetAttachment(attachpoint, destinationItem.ID, destinationItem.AssetID);
 
 3045                         m_log.DebugFormat(
"[RADMIN]: Attached {0}", destinationItem.ID);
 
 3058                 uint perms = item.CurrentPermissions;
 
 3059                 PermissionsUtil.ApplyFoldedPermissions(item.CurrentPermissions, ref perms);
 
 3060                 item.CurrentPermissions = perms;
 
 3063             item.CurrentPermissions &= item.NextPermissions;
 
 3064             item.BasePermissions &= item.NextPermissions;
 
 3065             item.EveryOnePermissions &= item.NextPermissions;
 
 3080         private bool CreateDefaultAvatars()
 
 3083             if (m_defaultAvatarsLoaded)
 
 3088             m_log.DebugFormat(
"[RADMIN]: Creating default avatar entries");
 
 3090             m_defaultAvatarsLoaded = 
true;
 
 3096                 string defaultAppearanceFileName = null;
 
 3099                 if (m_config != null)
 
 3101                     defaultAppearanceFileName = m_config.GetString(
"default_appearance", 
"default_appearance.xml");
 
 3104                 if (
File.Exists(defaultAppearanceFileName))
 
 3106                     XmlDocument doc = 
new XmlDocument();
 
 3107                     string name     = 
"*unknown*";
 
 3108                     string email    = 
"anon@anon";
 
 3109                     uint   regionXLocation     = 1000;
 
 3110                     uint   regionYLocation     = 1000;
 
 3111                     string password   = UUID.Random().ToString(); 
 
 3112                     UUID ID = UUID.Zero;
 
 3114                     XmlNodeList avatars;
 
 3116                     XmlNode perms = null;
 
 3117                     bool include = 
false;
 
 3118                     bool select  = 
false;
 
 3120                     Scene scene = m_application.SceneManager.CurrentOrFirstScene;
 
 3124                     doc.LoadXml(File.ReadAllText(defaultAppearanceFileName));
 
 3127                     assets = doc.GetElementsByTagName(
"RequiredAsset");
 
 3128                     foreach (XmlNode assetNode 
in assets)
 
 3130                         AssetBase asset = 
new AssetBase(
UUID.Random(), GetStringAttribute(assetNode, 
"name", 
""), SByte.Parse(GetStringAttribute(assetNode, 
"type", 
"")), 
UUID.Zero.ToString());
 
 3131                         asset.Description = GetStringAttribute(assetNode,
"desc",
"");
 
 3132                         asset.Local       = Boolean.Parse(GetStringAttribute(assetNode,
"local",
""));
 
 3133                         asset.Temporary   = Boolean.Parse(GetStringAttribute(assetNode,
"temporary",
""));
 
 3134                         asset.Data        = Convert.FromBase64String(assetNode.InnerText);
 
 3135                         assetService.Store(asset);
 
 3138                     avatars = doc.GetElementsByTagName(
"Avatar");
 
 3142                     foreach (XmlElement avatar 
in avatars)
 
 3144                         m_log.DebugFormat(
"[RADMIN]: Loading appearance for {0}, gender = {1}",
 
 3145                             GetStringAttribute(avatar,
"name",
"?"), GetStringAttribute(avatar,
"gender",
"?"));
 
 3152                             name   = GetStringAttribute(avatar,
"name",name);
 
 3153                             email  = GetStringAttribute(avatar,
"email",email);
 
 3154                             regionXLocation   = GetUnsignedAttribute(avatar,
"regx",regionXLocation);
 
 3155                             regionYLocation   = GetUnsignedAttribute(avatar,
"regy",regionYLocation);
 
 3156                             password = GetStringAttribute(avatar,
"password",password);
 
 3158                             string[] names = name.Split();
 
 3159                             UUID scopeID = scene.RegionInfo.ScopeID;
 
 3160                             UserAccount account = scene.UserAccountService.GetUserAccount(scopeID, names[0], names[1]);
 
 3161                             if (null == account)
 
 3163                                 account = CreateUser(scopeID, names[0], names[1], password, email);
 
 3164                                 if (null == account)
 
 3166                                     m_log.ErrorFormat(
"[RADMIN]: Avatar {0} {1} was not created", names[0], names[1]);
 
 3173                             GridRegion home = scene.GridService.GetRegionByPosition(scopeID, 
 
 3174                                         (int)Util.RegionToWorldLoc(regionXLocation), (int)Util.RegionToWorldLoc(regionYLocation));
 
 3176                                 m_log.WarnFormat(
"[RADMIN]: Unable to set home region for newly created user account {0} {1}", names[0], names[1]);
 
 3178                                 scene.GridUserService.SetHome(account.PrincipalID.ToString(), home.
RegionID, 
new Vector3(128, 128, 0), 
new Vector3(0, 1, 0));
 
 3179                                 m_log.DebugFormat(
"[RADMIN]: Set home region {0} for updated user account {1} {2}", home.RegionID, names[0], names[1]);
 
 3182                             ID = account.PrincipalID;
 
 3184                             m_log.DebugFormat(
"[RADMIN]: User {0}[{1}] created or retrieved", name, ID);
 
 3189                             m_log.DebugFormat(
"[RADMIN]: Error creating user {0} : {1}", name, e.Message);
 
 3201                             avatarAppearance = scene.AvatarService.GetAppearance(ID);
 
 3202                             if (avatarAppearance == null)
 
 3206                             for (
int i=0; i<wearables.Length; i++)
 
 3216                                 InventoryFolderBase clothingFolder = inventoryService.GetFolderForType(ID, FolderType.Clothing);
 
 3219                                 if (clothingFolder == null || clothingFolder.
Type != (
short)FolderType.Clothing)
 
 3222                                     clothingFolder.ID       = UUID.Random();
 
 3223                                     clothingFolder.Name     = 
"Clothing";
 
 3224                                     clothingFolder.Owner    = ID;
 
 3225                                     clothingFolder.Type     = (short)FolderType.Clothing;
 
 3227                                     clothingFolder.Version  = 1;
 
 3228                                     inventoryService.AddFolder(clothingFolder);     
 
 3229                                     m_log.ErrorFormat(
"[RADMIN]: Created clothing folder for {0}/{1}", name, ID);
 
 3235                                 XmlNodeList outfits = avatar.GetElementsByTagName(
"Ensemble");
 
 3240                                 foreach (XmlElement outfit 
in outfits)
 
 3242                                     m_log.DebugFormat(
"[RADMIN]: Loading outfit {0} for {1}",
 
 3243                                         GetStringAttribute(outfit,
"name",
"?"), GetStringAttribute(avatar,
"name",
"?"));
 
 3245                                     outfitName   = GetStringAttribute(outfit,
"name",
"");
 
 3246                                     select  = (GetStringAttribute(outfit,
"default",
"no") == 
"yes");
 
 3251                                     List<InventoryFolderBase> folders = inventoryService.GetFolderContent(ID, clothingFolder.ID).Folders;
 
 3256                                     if (folder.
Name == outfitName)
 
 3258                                             extraFolder = folder;
 
 3264                                     if (extraFolder == null)
 
 3266                                         m_log.DebugFormat(
"[RADMIN]: Creating outfit folder {0} for {1}", outfitName, name);
 
 3268                                         extraFolder.ID       = UUID.Random();
 
 3269                                         extraFolder.Name     = outfitName;
 
 3270                                         extraFolder.Owner    = ID;
 
 3271                                         extraFolder.Type     = (short)FolderType.Clothing;
 
 3272                                         extraFolder.Version  = 1;
 
 3273                                         extraFolder.ParentID = clothingFolder.
ID;
 
 3274                                         inventoryService.
AddFolder(extraFolder);
 
 3275                                         m_log.DebugFormat(
"[RADMIN]: Adding outfile folder {0} to folder {1}", extraFolder.ID, clothingFolder.ID);
 
 3279                                     XmlNodeList items = outfit.GetElementsByTagName(
"Item");
 
 3281                                     foreach (XmlElement item 
in items)
 
 3283                                         assetid = UUID.Zero;
 
 3284                                         XmlNodeList children = item.ChildNodes;
 
 3285                                         foreach (XmlNode child 
in children)
 
 3289                                                 case "Permissions" :
 
 3290                                                     m_log.DebugFormat(
"[RADMIN]: Permissions specified");
 
 3294                                                     assetid = 
new UUID(child.InnerText);
 
 3302                                         inventoryItem = null;
 
 3303                                         List<InventoryItemBase> inventoryItems = inventoryService.GetFolderContent(ID, extraFolder.ID).Items;
 
 3307                                             if (listItem.
AssetID == assetid)
 
 3309                                                 inventoryItem = listItem;
 
 3315                                         if (inventoryItem == null)
 
 3318                                             inventoryItem.Name = GetStringAttribute(item,
"name",
"");
 
 3319                                             inventoryItem.Description = GetStringAttribute(item,
"desc",
"");
 
 3320                                             inventoryItem.InvType = GetIntegerAttribute(item,
"invtype",-1);
 
 3321                                             inventoryItem.CreatorId = GetStringAttribute(item,
"creatorid",
"");
 
 3322                                             inventoryItem.CreatorData = GetStringAttribute(item, 
"creatordata", 
"");
 
 3323                                             inventoryItem.NextPermissions = GetUnsignedAttribute(perms, 
"next", 0x7fffffff);
 
 3324                                             inventoryItem.CurrentPermissions = GetUnsignedAttribute(perms,
"current",0x7fffffff);
 
 3325                                             inventoryItem.BasePermissions = GetUnsignedAttribute(perms,
"base",0x7fffffff);
 
 3326                                             inventoryItem.EveryOnePermissions = GetUnsignedAttribute(perms,
"everyone",0x7fffffff);
 
 3327                                             inventoryItem.GroupPermissions = GetUnsignedAttribute(perms,
"group",0x7fffffff);
 
 3328                                             inventoryItem.AssetType = GetIntegerAttribute(item,
"assettype",-1);
 
 3329                                             inventoryItem.AssetID = assetid; 
 
 3330                                             inventoryItem.GroupID = (
UUID)GetStringAttribute(item,
"groupid",
"");
 
 3331                                             inventoryItem.GroupOwned = (GetStringAttribute(item,
"groupowned",
"false") == 
"true");
 
 3332                                             inventoryItem.SalePrice = GetIntegerAttribute(item,
"saleprice",0);
 
 3333                                             inventoryItem.SaleType = (byte)GetIntegerAttribute(item,
"saletype",0);
 
 3334                                             inventoryItem.Flags = GetUnsignedAttribute(item,
"flags",0);
 
 3335                                             inventoryItem.CreationDate = GetIntegerAttribute(item,
"creationdate",Util.UnixTimeSinceEpoch());
 
 3336                                             inventoryItem.Folder = extraFolder.ID; 
 
 3338                                             m_application.SceneManager.CurrentOrFirstScene.AddInventoryItem(inventoryItem);
 
 3339                                             m_log.DebugFormat(
"[RADMIN]: Added item {0} to folder {1}", inventoryItem.ID, extraFolder.ID);
 
 3343                                         int attachpoint = GetIntegerAttribute(item,
"attachpoint",0);
 
 3344                                         if (attachpoint != 0)
 
 3346                                             avatarAppearance.SetAttachment(attachpoint, inventoryItem.ID, inventoryItem.AssetID);
 
 3347                                             m_log.DebugFormat(
"[RADMIN]: Attached {0}", inventoryItem.ID);
 
 3353                                         if (select && (GetStringAttribute(item, 
"wear", 
"false") == 
"true"))
 
 3355                                                 avatarAppearance.Wearables[inventoryItem.Flags].Wear(inventoryItem.ID, inventoryItem.AssetID);
 
 3360                                             m_log.WarnFormat(
"[RADMIN]: Error wearing item {0} : {1}", inventoryItem.ID, e.Message);
 
 3363                                     m_log.DebugFormat(
"[RADMIN]: Outfit {0} load completed", outfitName);
 
 3365                                 m_log.DebugFormat(
"[RADMIN]: Inventory update complete for {0}", name);
 
 3366                                 scene.AvatarService.SetAppearance(ID, avatarAppearance);
 
 3370                                 m_log.WarnFormat(
"[RADMIN]: Inventory processing incomplete for user {0} : {1}",
 
 3375                     m_log.DebugFormat(
"[RADMIN]: Default avatar loading complete");
 
 3379                     m_log.DebugFormat(
"[RADMIN]: No default avatar information available");
 
 3385                 m_log.WarnFormat(
"[RADMIN]: Exception whilst loading default avatars ; {0}", e.Message);
 
EstateSettings EstateSettings
 
void XmlRpcDialogMethod(XmlRpcRequest request, XmlRpcResponse response, IPEndPoint remoteClient)
 
OpenSim.Framework.RegionInfo RegionInfo
 
OpenSimulator Application Plugin framework interface 
 
InventoryFolderBase GetRootFolder(UUID userID)
Retrieve the root inventory folder for the given user. 
 
Contains the Avatar's Appearance and methods to manipulate the appearance. 
 
void Initialise(OpenSimBase openSim)
Initialize the Plugin 
 
Interface to region archive functionality 
 
OpenSim.Framework.PermissionMask PermissionMask
 
bool AddFolder(InventoryFolderBase folder)
Add a new folder to the user's inventory 
 
Records user information specific to a grid but which is not part of a user's account. 
 
IPEndPoint InternalEndPoint
 
Interface to OpenSimulator's built in HTTP server. Use this to register handlers (http, llsd, xmlrpc, etc.) for given URLs. 
 
void Initialise()
Default-initialises the plugin 
 
bool StoreUserAccount(UserAccount data)
Store the data given, wich replaces the stored data, therefore must be complete. 
 
Asset class. All Assets are reference by this class or a class derived from this class ...
 
OpenSim.Services.Interfaces.PresenceInfo PresenceInfo
 
override Vector3 AbsolutePosition
Position of this avatar relative to the region the avatar is in 
 
Inventory Item - contains all the properties associated with an individual inventory piece...
 
Exception thrown if Initialise has been called, but failed. 
 
Interactive OpenSim region server 
 
A class for triggering remote scene events. 
 
UUID ID
A UUID containing the ID for the inventory node itself 
 
virtual string Name
The name of the node (64 characters or less) 
 
Common OpenSimulator simulator code 
 
Dictionary< string, object > ServiceURLs
 
uint Flags
Parcel settings. Access flags, Fly, NoPush, Voice, Scripts allowed, etc. ParcelFlags ...
 
virtual RegionInfo RegionInfo
 
OpenSim.Services.Interfaces.GridRegion GridRegion
 
uint RegionLocY
The y co-ordinate of this region in map tiles (e.g. 1000). Coordinate is scaled as world coordinates ...
 
uint RegionLocX
The x co-ordinate of this region in map tiles (e.g. 1000). Coordinate is scaled as world coordinates ...
 
void PostInitialise()
Called when the application loading is completed