aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-03-10 01:27:05 +0000
committerJustin Clark-Casey (justincc)2012-03-10 01:27:05 +0000
commitd6ebf2d6cacd6341fb65b4c124d358aa8c1c86f8 (patch)
tree4d9f3d1a7c576db0a51b3f4ac751ab53da9b1770 /OpenSim
parentFactor out common default animations code into SLUtil. LLClientView now make... (diff)
downloadopensim-SC-d6ebf2d6cacd6341fb65b4c124d358aa8c1c86f8.zip
opensim-SC-d6ebf2d6cacd6341fb65b4c124d358aa8c1c86f8.tar.gz
opensim-SC-d6ebf2d6cacd6341fb65b4c124d358aa8c1c86f8.tar.bz2
opensim-SC-d6ebf2d6cacd6341fb65b4c124d358aa8c1c86f8.tar.xz
Add ability to specify a default estate to be used when creating regions.
This is configured in the new [Estates] section of OpenSim.ini. If a default estate is configured then all new regions are automatically joined to it instead of asking the user. If the default estate does not already exist then it is created. Current default behaviour remains the same - the user is asked for estate details when necessary. Thanks to Frenando Oliveira for the patch which I adapated further.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Application/OpenSimBase.cs216
1 files changed, 152 insertions, 64 deletions
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index d3c1102..c6956fc 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.IO; 30using System.IO;
31using System.Linq;
31using System.Net; 32using System.Net;
32using System.Reflection; 33using System.Reflection;
33using System.Text; 34using System.Text;
@@ -67,6 +68,9 @@ namespace OpenSim
67 private const string PLUGIN_ASSET_CACHE = "/OpenSim/AssetCache"; 68 private const string PLUGIN_ASSET_CACHE = "/OpenSim/AssetCache";
68 private const string PLUGIN_ASSET_SERVER_CLIENT = "/OpenSim/AssetClient"; 69 private const string PLUGIN_ASSET_SERVER_CLIENT = "/OpenSim/AssetClient";
69 70
71 // OpenSim.ini Section name for ESTATES Settings
72 public const string ESTATE_SECTION_NAME = "Estates";
73
70 protected string proxyUrl; 74 protected string proxyUrl;
71 protected int proxyOffset = 0; 75 protected int proxyOffset = 0;
72 76
@@ -445,12 +449,42 @@ namespace OpenSim
445 { 449 {
446 RegionInfo regionInfo = scene.RegionInfo; 450 RegionInfo regionInfo = scene.RegionInfo;
447 451
452 string estateOwnerFirstName = null;
453 string estateOwnerLastName = null;
454 string estateOwnerEMail = null;
455 string estateOwnerPassword = null;
456 string rawEstateOwnerUuid = null;
457
458 if (m_config.Source.Configs[ESTATE_SECTION_NAME] != null)
459 {
460 string defaultEstateOwnerName
461 = m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerName", "").Trim();
462 string[] ownerNames = defaultEstateOwnerName.Split(' ');
463
464 if (ownerNames.Length >= 2)
465 {
466 estateOwnerFirstName = ownerNames[0];
467 estateOwnerLastName = ownerNames[1];
468 }
469
470 // Info to be used only on Standalone Mode
471 rawEstateOwnerUuid = m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerUUID", null);
472 estateOwnerEMail = m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerEMail", null);
473 estateOwnerPassword = m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerPassword", null);
474 }
475
448 MainConsole.Instance.OutputFormat("Estate {0} has no owner set.", regionInfo.EstateSettings.EstateName); 476 MainConsole.Instance.OutputFormat("Estate {0} has no owner set.", regionInfo.EstateSettings.EstateName);
449 List<char> excluded = new List<char>(new char[1]{' '}); 477 List<char> excluded = new List<char>(new char[1]{' '});
450 string first = MainConsole.Instance.CmdPrompt("Estate owner first name", "Test", excluded);
451 string last = MainConsole.Instance.CmdPrompt("Estate owner last name", "User", excluded);
452 478
453 UserAccount account = scene.UserAccountService.GetUserAccount(regionInfo.ScopeID, first, last); 479
480 if (estateOwnerFirstName == null || estateOwnerLastName == null)
481 {
482 estateOwnerFirstName = MainConsole.Instance.CmdPrompt("Estate owner first name", "Test", excluded);
483 estateOwnerLastName = MainConsole.Instance.CmdPrompt("Estate owner last name", "User", excluded);
484 }
485
486 UserAccount account
487 = scene.UserAccountService.GetUserAccount(regionInfo.ScopeID, estateOwnerFirstName, estateOwnerLastName);
454 488
455 if (account == null) 489 if (account == null)
456 { 490 {
@@ -469,23 +503,35 @@ namespace OpenSim
469 503
470 if (scene.UserAccountService is UserAccountService) 504 if (scene.UserAccountService is UserAccountService)
471 { 505 {
472 string password = MainConsole.Instance.PasswdPrompt("Password"); 506 if (estateOwnerPassword == null)
473 string email = MainConsole.Instance.CmdPrompt("Email", ""); 507 estateOwnerPassword = MainConsole.Instance.PasswdPrompt("Password");
508
509 if (estateOwnerEMail == null)
510 estateOwnerEMail = MainConsole.Instance.CmdPrompt("Email");
474 511
475 string rawPrincipalId = MainConsole.Instance.CmdPrompt("User ID", UUID.Random().ToString()); 512 if (rawEstateOwnerUuid == null)
513 rawEstateOwnerUuid = MainConsole.Instance.CmdPrompt("User ID", UUID.Random().ToString());
476 514
477 UUID principalId = UUID.Zero; 515 UUID estateOwnerUuid = UUID.Zero;
478 if (!UUID.TryParse(rawPrincipalId, out principalId)) 516 if (!UUID.TryParse(rawEstateOwnerUuid, out estateOwnerUuid))
479 { 517 {
480 m_log.ErrorFormat("[OPENSIM]: ID {0} is not a valid UUID", rawPrincipalId); 518 m_log.ErrorFormat("[OPENSIM]: ID {0} is not a valid UUID", rawEstateOwnerUuid);
481 return; 519 return;
482 } 520 }
483 521
522 // If we've been given a zero uuid then this signals that we should use a random user id
523 if (estateOwnerUuid == UUID.Zero)
524 estateOwnerUuid = UUID.Random();
525
484 account 526 account
485 = ((UserAccountService)scene.UserAccountService).CreateUser( 527 = ((UserAccountService)scene.UserAccountService).CreateUser(
486 regionInfo.ScopeID, principalId, first, last, password, email); 528 regionInfo.ScopeID,
529 estateOwnerUuid,
530 estateOwnerFirstName,
531 estateOwnerLastName,
532 estateOwnerPassword,
533 estateOwnerEMail);
487 } 534 }
488// }
489 } 535 }
490 536
491 if (account == null) 537 if (account == null)
@@ -885,15 +931,21 @@ namespace OpenSim
885 /// This method doesn't allow an estate to be created with the same name as existing estates. 931 /// This method doesn't allow an estate to be created with the same name as existing estates.
886 /// </remarks> 932 /// </remarks>
887 /// <param name="regInfo"></param> 933 /// <param name="regInfo"></param>
888 /// <param name="existingName">A list of estate names that already exist.</param> 934 /// <param name="estatesByName">A list of estate names that already exist.</param>
935 /// <param name="estateName">Estate name to create if already known</param>
889 /// <returns>true if the estate was created, false otherwise</returns> 936 /// <returns>true if the estate was created, false otherwise</returns>
890 public bool CreateEstate(RegionInfo regInfo, List<string> existingNames) 937 public bool CreateEstate(RegionInfo regInfo, Dictionary<string, EstateSettings> estatesByName, string estateName)
891 { 938 {
892 // Create a new estate 939 // Create a new estate
893 regInfo.EstateSettings = EstateDataService.LoadEstateSettings(regInfo.RegionID, true); 940 regInfo.EstateSettings = EstateDataService.LoadEstateSettings(regInfo.RegionID, true);
894 string newName = MainConsole.Instance.CmdPrompt("New estate name", regInfo.EstateSettings.EstateName);
895 941
896 if (existingNames.Contains(newName)) 942 string newName;
943 if (estateName != null && estateName != "")
944 newName = estateName;
945 else
946 newName = MainConsole.Instance.CmdPrompt("New estate name", regInfo.EstateSettings.EstateName);
947
948 if (estatesByName.ContainsKey(newName))
897 { 949 {
898 MainConsole.Instance.OutputFormat("An estate named {0} already exists. Please try again.", newName); 950 MainConsole.Instance.OutputFormat("An estate named {0} already exists. Please try again.", newName);
899 return false; 951 return false;
@@ -920,66 +972,102 @@ namespace OpenSim
920 if (EstateDataService != null) 972 if (EstateDataService != null)
921 regInfo.EstateSettings = EstateDataService.LoadEstateSettings(regInfo.RegionID, false); 973 regInfo.EstateSettings = EstateDataService.LoadEstateSettings(regInfo.RegionID, false);
922 974
923 if (regInfo.EstateSettings.EstateID == 0) // No record at all 975 if (regInfo.EstateSettings.EstateID != 0)
976 return;
977
978 m_log.WarnFormat("[ESTATE] Region {0} is not part of an estate.", regInfo.RegionName);
979
980 List<EstateSettings> estates = EstateDataService.LoadEstateSettingsAll();
981 Dictionary<string, EstateSettings> estatesByName = new Dictionary<string, EstateSettings>();
982
983 foreach (EstateSettings estate in estates)
984 estatesByName[estate.EstateName] = estate;
985
986 string defaultEstateName = null;
987
988 if (m_config.Source.Configs[ESTATE_SECTION_NAME] != null)
924 { 989 {
925 m_log.WarnFormat("[ESTATE] Region {0} is not part of an estate.", regInfo.RegionName); 990 defaultEstateName = m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateName", null);
926 991
927 List<EstateSettings> estates = EstateDataService.LoadEstateSettingsAll(); 992 if (defaultEstateName != null)
928 List<string> estateNames = new List<string>();
929 foreach (EstateSettings estate in estates)
930 estateNames.Add(estate.EstateName);
931
932 while (true)
933 { 993 {
934 if (estates.Count == 0) 994 EstateSettings defaultEstate;
935 { 995 bool defaultEstateJoined = false;
936 m_log.Info("[ESTATE] No existing estates found. You must create a new one."); 996
937 997 if (estatesByName.ContainsKey(defaultEstateName))
938 if (CreateEstate(regInfo, estateNames)) 998 {
939 break; 999 defaultEstate = estatesByName[defaultEstateName];
1000
1001 if (EstateDataService.LinkRegion(regInfo.RegionID, (int)defaultEstate.EstateID))
1002 defaultEstateJoined = true;
1003 }
1004 else
1005 {
1006 if (CreateEstate(regInfo, estatesByName, defaultEstateName))
1007 defaultEstateJoined = true;
1008 }
1009
1010 if (defaultEstateJoined)
1011 return;
1012 else
1013 m_log.ErrorFormat(
1014 "[OPENSIM BASE]: Joining default estate {0} failed", defaultEstateName);
1015 }
1016 }
1017
1018 // If we have no default estate or creation of the default estate failed then ask the user.
1019 while (true)
1020 {
1021 if (estates.Count == 0)
1022 {
1023 m_log.Info("[ESTATE]: No existing estates found. You must create a new one.");
1024
1025 if (CreateEstate(regInfo, estatesByName, null))
1026 break;
1027 else
1028 continue;
1029 }
1030 else
1031 {
1032 string response
1033 = MainConsole.Instance.CmdPrompt(
1034 string.Format(
1035 "Do you wish to join region {0} to an existing estate (yes/no)?", regInfo.RegionName),
1036 "yes",
1037 new List<string>() { "yes", "no" });
1038
1039 if (response == "no")
1040 {
1041 if (CreateEstate(regInfo, estatesByName, null))
1042 break;
940 else 1043 else
941 continue; 1044 continue;
942 } 1045 }
943 else 1046 else
944 { 1047 {
945 string response 1048 string[] estateNames = estatesByName.Keys.ToArray();
1049 response
946 = MainConsole.Instance.CmdPrompt( 1050 = MainConsole.Instance.CmdPrompt(
947 string.Format( 1051 string.Format(
948 "Do you wish to join region {0} to an existing estate (yes/no)?", regInfo.RegionName), 1052 "Name of estate to join. Existing estate names are ({0})",
949 "yes", 1053 string.Join(", ", estateNames)),
950 new List<string>() { "yes", "no" }); 1054 estateNames[0]);
951 1055
952 if (response == "no") 1056 List<int> estateIDs = EstateDataService.GetEstates(response);
1057 if (estateIDs.Count < 1)
953 { 1058 {
954 if (CreateEstate(regInfo, estateNames)) 1059 MainConsole.Instance.Output("The name you have entered matches no known estate. Please try again.");
955 break; 1060 continue;
956 else
957 continue;
958 }
959 else
960 {
961 response
962 = MainConsole.Instance.CmdPrompt(
963 string.Format(
964 "Name of estate to join. Existing estate names are ({0})", string.Join(", ", estateNames.ToArray())),
965 estateNames[0]);
966
967 List<int> estateIDs = EstateDataService.GetEstates(response);
968 if (estateIDs.Count < 1)
969 {
970 MainConsole.Instance.Output("The name you have entered matches no known estate. Please try again.");
971 continue;
972 }
973
974 int estateID = estateIDs[0];
975
976 regInfo.EstateSettings = EstateDataService.LoadEstateSettings(estateID);
977
978 if (EstateDataService.LinkRegion(regInfo.RegionID, estateID))
979 break;
980
981 MainConsole.Instance.Output("Joining the estate failed. Please try again.");
982 } 1061 }
1062
1063 int estateID = estateIDs[0];
1064
1065 regInfo.EstateSettings = EstateDataService.LoadEstateSettings(estateID);
1066
1067 if (EstateDataService.LinkRegion(regInfo.RegionID, estateID))
1068 break;
1069
1070 MainConsole.Instance.Output("Joining the estate failed. Please try again.");
983 } 1071 }
984 } 1072 }
985 } 1073 }