diff options
author | Melanie | 2012-03-11 02:29:43 +0000 |
---|---|---|
committer | Melanie | 2012-03-11 02:29:43 +0000 |
commit | f292e19689f9b01a5706e765543064b6ad61caa9 (patch) | |
tree | 0752aaa6a4ddc23c2f3a9296f02143cea3b6e6e1 /OpenSim/Region/Application/OpenSimBase.cs | |
parent | Merge branch 'master' into careminster (diff) | |
parent | Merge branch 'master' of ssh://opensimulator.org/var/git/opensim (diff) | |
download | opensim-SC-f292e19689f9b01a5706e765543064b6ad61caa9.zip opensim-SC-f292e19689f9b01a5706e765543064b6ad61caa9.tar.gz opensim-SC-f292e19689f9b01a5706e765543064b6ad61caa9.tar.bz2 opensim-SC-f292e19689f9b01a5706e765543064b6ad61caa9.tar.xz |
Merge branch 'master' into careminster
Conflicts:
OpenSim/Region/Application/OpenSimBase.cs
Diffstat (limited to 'OpenSim/Region/Application/OpenSimBase.cs')
-rw-r--r-- | OpenSim/Region/Application/OpenSimBase.cs | 219 |
1 files changed, 152 insertions, 67 deletions
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 34f513d..b304403 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs | |||
@@ -28,6 +28,7 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.IO; | 30 | using System.IO; |
31 | using System.Linq; | ||
31 | using System.Net; | 32 | using System.Net; |
32 | using System.Reflection; | 33 | using System.Reflection; |
33 | using System.Text; | 34 | using 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 | ||
@@ -524,12 +528,42 @@ namespace OpenSim | |||
524 | { | 528 | { |
525 | RegionInfo regionInfo = scene.RegionInfo; | 529 | RegionInfo regionInfo = scene.RegionInfo; |
526 | 530 | ||
531 | string estateOwnerFirstName = null; | ||
532 | string estateOwnerLastName = null; | ||
533 | string estateOwnerEMail = null; | ||
534 | string estateOwnerPassword = null; | ||
535 | string rawEstateOwnerUuid = null; | ||
536 | |||
537 | if (m_config.Source.Configs[ESTATE_SECTION_NAME] != null) | ||
538 | { | ||
539 | string defaultEstateOwnerName | ||
540 | = m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerName", "").Trim(); | ||
541 | string[] ownerNames = defaultEstateOwnerName.Split(' '); | ||
542 | |||
543 | if (ownerNames.Length >= 2) | ||
544 | { | ||
545 | estateOwnerFirstName = ownerNames[0]; | ||
546 | estateOwnerLastName = ownerNames[1]; | ||
547 | } | ||
548 | |||
549 | // Info to be used only on Standalone Mode | ||
550 | rawEstateOwnerUuid = m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerUUID", null); | ||
551 | estateOwnerEMail = m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerEMail", null); | ||
552 | estateOwnerPassword = m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerPassword", null); | ||
553 | } | ||
554 | |||
527 | MainConsole.Instance.OutputFormat("Estate {0} has no owner set.", regionInfo.EstateSettings.EstateName); | 555 | MainConsole.Instance.OutputFormat("Estate {0} has no owner set.", regionInfo.EstateSettings.EstateName); |
528 | List<char> excluded = new List<char>(new char[1]{' '}); | 556 | List<char> excluded = new List<char>(new char[1]{' '}); |
529 | string first = MainConsole.Instance.CmdPrompt("Estate owner first name", "Test", excluded); | ||
530 | string last = MainConsole.Instance.CmdPrompt("Estate owner last name", "User", excluded); | ||
531 | 557 | ||
532 | UserAccount account = scene.UserAccountService.GetUserAccount(regionInfo.ScopeID, first, last); | 558 | |
559 | if (estateOwnerFirstName == null || estateOwnerLastName == null) | ||
560 | { | ||
561 | estateOwnerFirstName = MainConsole.Instance.CmdPrompt("Estate owner first name", "Test", excluded); | ||
562 | estateOwnerLastName = MainConsole.Instance.CmdPrompt("Estate owner last name", "User", excluded); | ||
563 | } | ||
564 | |||
565 | UserAccount account | ||
566 | = scene.UserAccountService.GetUserAccount(regionInfo.ScopeID, estateOwnerFirstName, estateOwnerLastName); | ||
533 | 567 | ||
534 | if (account == null) | 568 | if (account == null) |
535 | { | 569 | { |
@@ -548,23 +582,35 @@ namespace OpenSim | |||
548 | 582 | ||
549 | if (scene.UserAccountService is UserAccountService) | 583 | if (scene.UserAccountService is UserAccountService) |
550 | { | 584 | { |
551 | string password = MainConsole.Instance.PasswdPrompt("Password"); | 585 | if (estateOwnerPassword == null) |
552 | string email = MainConsole.Instance.CmdPrompt("Email", ""); | 586 | estateOwnerPassword = MainConsole.Instance.PasswdPrompt("Password"); |
587 | |||
588 | if (estateOwnerEMail == null) | ||
589 | estateOwnerEMail = MainConsole.Instance.CmdPrompt("Email"); | ||
553 | 590 | ||
554 | string rawPrincipalId = MainConsole.Instance.CmdPrompt("User ID", UUID.Random().ToString()); | 591 | if (rawEstateOwnerUuid == null) |
592 | rawEstateOwnerUuid = MainConsole.Instance.CmdPrompt("User ID", UUID.Random().ToString()); | ||
555 | 593 | ||
556 | UUID principalId = UUID.Zero; | 594 | UUID estateOwnerUuid = UUID.Zero; |
557 | if (!UUID.TryParse(rawPrincipalId, out principalId)) | 595 | if (!UUID.TryParse(rawEstateOwnerUuid, out estateOwnerUuid)) |
558 | { | 596 | { |
559 | m_log.ErrorFormat("[OPENSIM]: ID {0} is not a valid UUID", rawPrincipalId); | 597 | m_log.ErrorFormat("[OPENSIM]: ID {0} is not a valid UUID", rawEstateOwnerUuid); |
560 | return; | 598 | return; |
561 | } | 599 | } |
562 | 600 | ||
601 | // If we've been given a zero uuid then this signals that we should use a random user id | ||
602 | if (estateOwnerUuid == UUID.Zero) | ||
603 | estateOwnerUuid = UUID.Random(); | ||
604 | |||
563 | account | 605 | account |
564 | = ((UserAccountService)scene.UserAccountService).CreateUser( | 606 | = ((UserAccountService)scene.UserAccountService).CreateUser( |
565 | regionInfo.ScopeID, principalId, first, last, password, email); | 607 | regionInfo.ScopeID, |
608 | estateOwnerUuid, | ||
609 | estateOwnerFirstName, | ||
610 | estateOwnerLastName, | ||
611 | estateOwnerPassword, | ||
612 | estateOwnerEMail); | ||
566 | } | 613 | } |
567 | // } | ||
568 | } | 614 | } |
569 | 615 | ||
570 | if (account == null) | 616 | if (account == null) |
@@ -969,15 +1015,21 @@ namespace OpenSim | |||
969 | /// This method doesn't allow an estate to be created with the same name as existing estates. | 1015 | /// This method doesn't allow an estate to be created with the same name as existing estates. |
970 | /// </remarks> | 1016 | /// </remarks> |
971 | /// <param name="regInfo"></param> | 1017 | /// <param name="regInfo"></param> |
972 | /// <param name="existingName">A list of estate names that already exist.</param> | 1018 | /// <param name="estatesByName">A list of estate names that already exist.</param> |
1019 | /// <param name="estateName">Estate name to create if already known</param> | ||
973 | /// <returns>true if the estate was created, false otherwise</returns> | 1020 | /// <returns>true if the estate was created, false otherwise</returns> |
974 | public bool CreateEstate(RegionInfo regInfo, List<string> existingNames) | 1021 | public bool CreateEstate(RegionInfo regInfo, Dictionary<string, EstateSettings> estatesByName, string estateName) |
975 | { | 1022 | { |
976 | // Create a new estate | 1023 | // Create a new estate |
977 | regInfo.EstateSettings = EstateDataService.LoadEstateSettings(regInfo.RegionID, true); | 1024 | regInfo.EstateSettings = EstateDataService.LoadEstateSettings(regInfo.RegionID, true); |
978 | string newName = MainConsole.Instance.CmdPrompt("New estate name", regInfo.EstateSettings.EstateName); | ||
979 | 1025 | ||
980 | if (existingNames.Contains(newName)) | 1026 | string newName; |
1027 | if (estateName != null && estateName != "") | ||
1028 | newName = estateName; | ||
1029 | else | ||
1030 | newName = MainConsole.Instance.CmdPrompt("New estate name", regInfo.EstateSettings.EstateName); | ||
1031 | |||
1032 | if (estatesByName.ContainsKey(newName)) | ||
981 | { | 1033 | { |
982 | MainConsole.Instance.OutputFormat("An estate named {0} already exists. Please try again.", newName); | 1034 | MainConsole.Instance.OutputFormat("An estate named {0} already exists. Please try again.", newName); |
983 | return false; | 1035 | return false; |
@@ -1004,69 +1056,102 @@ namespace OpenSim | |||
1004 | if (EstateDataService != null) | 1056 | if (EstateDataService != null) |
1005 | regInfo.EstateSettings = EstateDataService.LoadEstateSettings(regInfo.RegionID, false); | 1057 | regInfo.EstateSettings = EstateDataService.LoadEstateSettings(regInfo.RegionID, false); |
1006 | 1058 | ||
1007 | if (regInfo.EstateSettings.EstateID == 0) // No record at all | 1059 | if (regInfo.EstateSettings.EstateID != 0) |
1060 | return; | ||
1061 | |||
1062 | m_log.WarnFormat("[ESTATE] Region {0} is not part of an estate.", regInfo.RegionName); | ||
1063 | |||
1064 | List<EstateSettings> estates = EstateDataService.LoadEstateSettingsAll(); | ||
1065 | Dictionary<string, EstateSettings> estatesByName = new Dictionary<string, EstateSettings>(); | ||
1066 | |||
1067 | foreach (EstateSettings estate in estates) | ||
1068 | estatesByName[estate.EstateName] = estate; | ||
1069 | |||
1070 | string defaultEstateName = null; | ||
1071 | |||
1072 | if (m_config.Source.Configs[ESTATE_SECTION_NAME] != null) | ||
1008 | { | 1073 | { |
1009 | m_log.WarnFormat("[ESTATE] Region {0} is not part of an estate.", regInfo.RegionName); | 1074 | defaultEstateName = m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateName", null); |
1010 | 1075 | ||
1011 | List<EstateSettings> estates = EstateDataService.LoadEstateSettingsAll(); | 1076 | if (defaultEstateName != null) |
1012 | List<string> estateNames = new List<string>(); | ||
1013 | foreach (EstateSettings estate in estates) | ||
1014 | estateNames.Add(estate.EstateName); | ||
1015 | |||
1016 | while (true) | ||
1017 | { | 1077 | { |
1018 | if (estates.Count == 0) | 1078 | EstateSettings defaultEstate; |
1019 | { | 1079 | bool defaultEstateJoined = false; |
1020 | m_log.Info("[ESTATE] No existing estates found. You must create a new one."); | 1080 | |
1021 | 1081 | if (estatesByName.ContainsKey(defaultEstateName)) | |
1022 | if (CreateEstate(regInfo, estateNames)) | 1082 | { |
1023 | break; | 1083 | defaultEstate = estatesByName[defaultEstateName]; |
1084 | |||
1085 | if (EstateDataService.LinkRegion(regInfo.RegionID, (int)defaultEstate.EstateID)) | ||
1086 | defaultEstateJoined = true; | ||
1087 | } | ||
1088 | else | ||
1089 | { | ||
1090 | if (CreateEstate(regInfo, estatesByName, defaultEstateName)) | ||
1091 | defaultEstateJoined = true; | ||
1092 | } | ||
1093 | |||
1094 | if (defaultEstateJoined) | ||
1095 | return; | ||
1096 | else | ||
1097 | m_log.ErrorFormat( | ||
1098 | "[OPENSIM BASE]: Joining default estate {0} failed", defaultEstateName); | ||
1099 | } | ||
1100 | } | ||
1101 | |||
1102 | // If we have no default estate or creation of the default estate failed then ask the user. | ||
1103 | while (true) | ||
1104 | { | ||
1105 | if (estates.Count == 0) | ||
1106 | { | ||
1107 | m_log.Info("[ESTATE]: No existing estates found. You must create a new one."); | ||
1108 | |||
1109 | if (CreateEstate(regInfo, estatesByName, null)) | ||
1110 | break; | ||
1111 | else | ||
1112 | continue; | ||
1113 | } | ||
1114 | else | ||
1115 | { | ||
1116 | string response | ||
1117 | = MainConsole.Instance.CmdPrompt( | ||
1118 | string.Format( | ||
1119 | "Do you wish to join region {0} to an existing estate (yes/no)?", regInfo.RegionName), | ||
1120 | "yes", | ||
1121 | new List<string>() { "yes", "no" }); | ||
1122 | |||
1123 | if (response == "no") | ||
1124 | { | ||
1125 | if (CreateEstate(regInfo, estatesByName, null)) | ||
1126 | break; | ||
1024 | else | 1127 | else |
1025 | continue; | 1128 | continue; |
1026 | } | 1129 | } |
1027 | else | 1130 | else |
1028 | { | 1131 | { |
1029 | string response | 1132 | string[] estateNames = estatesByName.Keys.ToArray(); |
1133 | response | ||
1030 | = MainConsole.Instance.CmdPrompt( | 1134 | = MainConsole.Instance.CmdPrompt( |
1031 | string.Format( | 1135 | string.Format( |
1032 | "Do you wish to join region {0} to an existing estate (yes/no)?", regInfo.RegionName), | 1136 | "Name of estate to join. Existing estate names are ({0})", |
1033 | "no", | 1137 | string.Join(", ", estateNames)), |
1034 | new List<string>() { "yes", "no" }); | 1138 | estateNames[0]); |
1035 | 1139 | ||
1036 | if (response == "no") | 1140 | List<int> estateIDs = EstateDataService.GetEstates(response); |
1141 | if (estateIDs.Count < 1) | ||
1037 | { | 1142 | { |
1038 | if (CreateEstate(regInfo, estateNames)) | 1143 | MainConsole.Instance.Output("The name you have entered matches no known estate. Please try again."); |
1039 | break; | 1144 | continue; |
1040 | else | ||
1041 | continue; | ||
1042 | } | ||
1043 | else | ||
1044 | { | ||
1045 | response | ||
1046 | = MainConsole.Instance.CmdPrompt( | ||
1047 | string.Format( | ||
1048 | "Name of estate to join. Existing estate names are ({0})", string.Join(", ", estateNames.ToArray())), | ||
1049 | "None"); | ||
1050 | |||
1051 | if (response == "None") | ||
1052 | continue; | ||
1053 | |||
1054 | List<int> estateIDs = EstateDataService.GetEstates(response); | ||
1055 | if (estateIDs.Count < 1) | ||
1056 | { | ||
1057 | MainConsole.Instance.Output("The name you have entered matches no known estate. Please try again."); | ||
1058 | continue; | ||
1059 | } | ||
1060 | |||
1061 | int estateID = estateIDs[0]; | ||
1062 | |||
1063 | regInfo.EstateSettings = EstateDataService.LoadEstateSettings(estateID); | ||
1064 | |||
1065 | if (EstateDataService.LinkRegion(regInfo.RegionID, estateID)) | ||
1066 | break; | ||
1067 | |||
1068 | MainConsole.Instance.Output("Joining the estate failed. Please try again."); | ||
1069 | } | 1145 | } |
1146 | |||
1147 | int estateID = estateIDs[0]; | ||
1148 | |||
1149 | regInfo.EstateSettings = EstateDataService.LoadEstateSettings(estateID); | ||
1150 | |||
1151 | if (EstateDataService.LinkRegion(regInfo.RegionID, estateID)) | ||
1152 | break; | ||
1153 | |||
1154 | MainConsole.Instance.Output("Joining the estate failed. Please try again."); | ||
1070 | } | 1155 | } |
1071 | } | 1156 | } |
1072 | } | 1157 | } |