diff options
author | Dev Random | 2014-04-02 00:32:29 -0400 |
---|---|---|
committer | Michael Cerquoni | 2014-04-03 12:45:43 -0400 |
commit | 4aa483777b244962b0bc8d4048cd8b9f021c40e6 (patch) | |
tree | 56f854addfdf169928458a38f0419fcfa293f713 | |
parent | Reduced log levels for REST 404 errors to DEBUG (diff) | |
download | opensim-SC_OLD-4aa483777b244962b0bc8d4048cd8b9f021c40e6.zip opensim-SC_OLD-4aa483777b244962b0bc8d4048cd8b9f021c40e6.tar.gz opensim-SC_OLD-4aa483777b244962b0bc8d4048cd8b9f021c40e6.tar.bz2 opensim-SC_OLD-4aa483777b244962b0bc8d4048cd8b9f021c40e6.tar.xz |
Move new Estate commands to OpenSim.cs
Signed-off-by: Michael Cerquoni <nebadon2025@gmail.com>
3 files changed, 156 insertions, 190 deletions
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index 5c3039d..544accf 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs | |||
@@ -45,6 +45,7 @@ using OpenSim.Framework.Servers; | |||
45 | using OpenSim.Framework.Monitoring; | 45 | using OpenSim.Framework.Monitoring; |
46 | using OpenSim.Region.Framework.Interfaces; | 46 | using OpenSim.Region.Framework.Interfaces; |
47 | using OpenSim.Region.Framework.Scenes; | 47 | using OpenSim.Region.Framework.Scenes; |
48 | using OpenSim.Services.Interfaces; | ||
48 | 49 | ||
49 | namespace OpenSim | 50 | namespace OpenSim |
50 | { | 51 | { |
@@ -399,6 +400,16 @@ namespace OpenSim | |||
399 | "delete-region <name>", | 400 | "delete-region <name>", |
400 | "Delete a region from disk", | 401 | "Delete a region from disk", |
401 | RunCommand); | 402 | RunCommand); |
403 | |||
404 | m_console.Commands.AddCommand("Estates", false, "estate set owner", | ||
405 | "estate set owner <estate-id>[ <UUID> | <Firstname> <Lastname> ]", | ||
406 | "Sets the owner of the specified estate to the specified UUID or user. ", | ||
407 | SetEstateOwnerCommand); | ||
408 | |||
409 | m_console.Commands.AddCommand("Estates", false, "estate set name", | ||
410 | "estate set name <estate-id> <new name>", | ||
411 | "Sets the name of the specified estate to the specified value. New name must be unique.", | ||
412 | SetEstateNameCommand); | ||
402 | } | 413 | } |
403 | 414 | ||
404 | protected override void ShutdownSpecific() | 415 | protected override void ShutdownSpecific() |
@@ -1165,6 +1176,130 @@ namespace OpenSim | |||
1165 | SceneManager.SaveCurrentSceneToArchive(cmdparams); | 1176 | SceneManager.SaveCurrentSceneToArchive(cmdparams); |
1166 | } | 1177 | } |
1167 | 1178 | ||
1179 | protected void SetEstateOwnerCommand(string module, string[] args) | ||
1180 | { | ||
1181 | string response = null; | ||
1182 | |||
1183 | Scene scene = SceneManager.CurrentOrFirstScene; | ||
1184 | IEstateModule estateModule = scene.RequestModuleInterface<IEstateModule>(); | ||
1185 | |||
1186 | if (args.Length == 3) | ||
1187 | { | ||
1188 | response = "No estate specified."; | ||
1189 | } | ||
1190 | else | ||
1191 | { | ||
1192 | int estateId; | ||
1193 | if (!int.TryParse(args[3], out estateId)) | ||
1194 | { | ||
1195 | response = String.Format("\"{0}\" is not a valid ID for an Estate", args[3]); | ||
1196 | } | ||
1197 | else | ||
1198 | { | ||
1199 | if (args.Length == 4) | ||
1200 | { | ||
1201 | response = "No user specified."; | ||
1202 | } | ||
1203 | else | ||
1204 | { | ||
1205 | UserAccount account = null; | ||
1206 | |||
1207 | // TODO: Is there a better choice here? | ||
1208 | UUID scopeID = UUID.Zero; | ||
1209 | |||
1210 | string s1 = args[4]; | ||
1211 | if (args.Length == 5) | ||
1212 | { | ||
1213 | // attempt to get account by UUID | ||
1214 | UUID u; | ||
1215 | if (UUID.TryParse(s1, out u)) | ||
1216 | { | ||
1217 | account = scene.UserAccountService.GetUserAccount(scopeID, u); | ||
1218 | if (account == null) | ||
1219 | response = String.Format("Could not find user {0}", s1); | ||
1220 | } | ||
1221 | else | ||
1222 | { | ||
1223 | response = String.Format("Invalid UUID {0}", s1); | ||
1224 | } | ||
1225 | } | ||
1226 | else | ||
1227 | { | ||
1228 | // attempt to get account by Firstname, Lastname | ||
1229 | string s2 = args[5]; | ||
1230 | account = scene.UserAccountService.GetUserAccount(scopeID, s1, s2); | ||
1231 | if (account == null) | ||
1232 | response = String.Format("Could not find user {0} {1}", s1, s2); | ||
1233 | } | ||
1234 | |||
1235 | // If it's valid, send it off for processing. | ||
1236 | if (account != null) | ||
1237 | response = estateModule.SetEstateOwner(estateId, account); | ||
1238 | |||
1239 | if (response == String.Empty) | ||
1240 | { | ||
1241 | response = String.Format("Estate owner changed to {0} ({1} {2})", account.PrincipalID, account.FirstName, account.LastName); | ||
1242 | } | ||
1243 | } | ||
1244 | } | ||
1245 | } | ||
1246 | |||
1247 | // give the user some feedback | ||
1248 | if (response != null) | ||
1249 | MainConsole.Instance.Output(response); | ||
1250 | } | ||
1251 | |||
1252 | protected void SetEstateNameCommand(string module, string[] args) | ||
1253 | { | ||
1254 | string response = null; | ||
1255 | |||
1256 | Scene scene = SceneManager.CurrentOrFirstScene; | ||
1257 | IEstateModule estateModule = scene.RequestModuleInterface<IEstateModule>(); | ||
1258 | |||
1259 | if (args.Length == 3) | ||
1260 | { | ||
1261 | response = "No estate specified."; | ||
1262 | } | ||
1263 | else | ||
1264 | { | ||
1265 | int estateId; | ||
1266 | if (!int.TryParse(args[3], out estateId)) | ||
1267 | { | ||
1268 | response = String.Format("\"{0}\" is not a valid ID for an Estate", args[3]); | ||
1269 | } | ||
1270 | else | ||
1271 | { | ||
1272 | if (args.Length == 4) | ||
1273 | { | ||
1274 | response = "No name specified."; | ||
1275 | } | ||
1276 | else | ||
1277 | { | ||
1278 | // everything after the estate ID is "name" | ||
1279 | StringBuilder sb = new StringBuilder(args[4]); | ||
1280 | for (int i = 5; i < args.Length; i++) | ||
1281 | sb.Append (" " + args[i]); | ||
1282 | |||
1283 | string estateName = sb.ToString(); | ||
1284 | |||
1285 | // send it off for processing. | ||
1286 | response = estateModule.SetEstateName(estateId, estateName); | ||
1287 | |||
1288 | if (response == String.Empty) | ||
1289 | { | ||
1290 | response = String.Format("Estate {0} renamed to \"{1}\"", estateId, estateName); | ||
1291 | } | ||
1292 | } | ||
1293 | } | ||
1294 | } | ||
1295 | |||
1296 | // give the user some feedback | ||
1297 | if (response != null) | ||
1298 | MainConsole.Instance.Output(response); | ||
1299 | } | ||
1300 | |||
1301 | #endregion | ||
1302 | |||
1168 | private static string CombineParams(string[] commandParams, int pos) | 1303 | private static string CombineParams(string[] commandParams, int pos) |
1169 | { | 1304 | { |
1170 | string result = String.Empty; | 1305 | string result = String.Empty; |
@@ -1175,7 +1310,5 @@ namespace OpenSim | |||
1175 | result = result.TrimEnd(' '); | 1310 | result = result.TrimEnd(' '); |
1176 | return result; | 1311 | return result; |
1177 | } | 1312 | } |
1178 | |||
1179 | #endregion | ||
1180 | } | 1313 | } |
1181 | } | 1314 | } |
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs index b1c4429..702b503 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs | |||
@@ -52,10 +52,6 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
52 | 52 | ||
53 | protected EstateManagementModule m_module; | 53 | protected EstateManagementModule m_module; |
54 | 54 | ||
55 | // used to prevent multiple processing of commands when called from root region | ||
56 | private static string[] m_currentCmd = null; | ||
57 | private static EstateSettings m_estateSettings = null; | ||
58 | |||
59 | public EstateManagementCommands(EstateManagementModule module) | 55 | public EstateManagementCommands(EstateManagementModule module) |
60 | { | 56 | { |
61 | m_module = module; | 57 | m_module = module; |
@@ -87,15 +83,6 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
87 | 83 | ||
88 | m_module.Scene.AddCommand( | 84 | m_module.Scene.AddCommand( |
89 | "Estates", m_module, "estate show", "estate show", "Shows all estates on the simulator.", ShowEstatesCommand); | 85 | "Estates", m_module, "estate show", "estate show", "Shows all estates on the simulator.", ShowEstatesCommand); |
90 | |||
91 | m_module.Scene.AddCommand( | ||
92 | "Estates", m_module, "estate set owner", "estate set owner <estate-id>[ <UUID> | <Firstname> <Lastname> ]", | ||
93 | "Sets the owner of the specified estate to the specified UUID or user. ", SetEstateOwnerCommand); | ||
94 | |||
95 | m_module.Scene.AddCommand( | ||
96 | "Estates", m_module, "estate set name", "estate set name <estate-id> <new name>", | ||
97 | "Sets the name of the specified estate to the specified value. " + | ||
98 | "New name must be unique.", SetEstateNameCommand); | ||
99 | } | 86 | } |
100 | 87 | ||
101 | public void Close() {} | 88 | public void Close() {} |
@@ -237,178 +224,7 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
237 | es.EstateName, es.EstateID, m_module.UserManager.GetUserName(es.EstateOwner)); | 224 | es.EstateName, es.EstateID, m_module.UserManager.GetUserName(es.EstateOwner)); |
238 | 225 | ||
239 | MainConsole.Instance.Output(report.ToString()); | 226 | MainConsole.Instance.Output(report.ToString()); |
240 | } | ||
241 | |||
242 | protected void SetEstateOwnerCommand(string module, string[] args) | ||
243 | { | ||
244 | string response = null; | ||
245 | |||
246 | EstateSettings es = m_module.Scene.RegionInfo.EstateSettings; | ||
247 | |||
248 | if (args == m_currentCmd) | ||
249 | { | ||
250 | // HACK to propagate new estate info to Scene Regions | ||
251 | if (m_estateSettings != null && es.EstateID == m_estateSettings.EstateID) | ||
252 | es.EstateOwner = m_estateSettings.EstateOwner; | ||
253 | |||
254 | return; | ||
255 | } | ||
256 | |||
257 | // new command... clear out the old value | ||
258 | m_currentCmd = args; | ||
259 | |||
260 | if (args.Length == 3) | ||
261 | { | ||
262 | response = "No estate specified."; | ||
263 | } | ||
264 | else | ||
265 | { | ||
266 | int estateId; | ||
267 | if (!int.TryParse(args[3], out estateId)) | ||
268 | { | ||
269 | response = String.Format("\"{0}\" is not a valid ID for an Estate", args[3]); | ||
270 | } | ||
271 | else | ||
272 | { | ||
273 | if (args.Length == 4) | ||
274 | { | ||
275 | response = "No user specified."; | ||
276 | } | ||
277 | else | ||
278 | { | ||
279 | UserAccount account = null; | ||
280 | |||
281 | // TODO: Is there a better choice here? | ||
282 | UUID scopeID = UUID.Zero; | ||
283 | |||
284 | string s1 = args[4]; | ||
285 | if (args.Length == 5) | ||
286 | { | ||
287 | // attempt to get account by UUID | ||
288 | UUID u; | ||
289 | if (UUID.TryParse(s1, out u)) | ||
290 | { | ||
291 | account = m_module.Scene.UserAccountService.GetUserAccount(scopeID, u); | ||
292 | if (account == null) | ||
293 | response = String.Format("Could not find user {0}", s1); | ||
294 | } | ||
295 | else | ||
296 | { | ||
297 | response = String.Format("Invalid UUID {0}", s1); | ||
298 | } | ||
299 | } | ||
300 | else | ||
301 | { | ||
302 | // attempt to get account by Firstname, Lastname | ||
303 | string s2 = args[5]; | ||
304 | account = m_module.Scene.UserAccountService.GetUserAccount(scopeID, s1, s2); | ||
305 | if (account == null) | ||
306 | response = String.Format("Could not find user {0} {1}", s1, s2); | ||
307 | } | ||
308 | |||
309 | // If it's valid, send it off for processing. | ||
310 | if (account != null) | ||
311 | response = m_module.SetEstateOwner(estateId, account); | ||
312 | |||
313 | if (response == String.Empty) | ||
314 | { | ||
315 | response = String.Format("Estate owner changed to {0} ({1} {2})", account.PrincipalID, account.FirstName, account.LastName); | ||
316 | |||
317 | // save data for propagation to other Scene Regions | ||
318 | m_estateSettings = new EstateSettings(); | ||
319 | m_estateSettings.EstateID = (uint)estateId; | ||
320 | m_estateSettings.EstateOwner = account.PrincipalID; | ||
321 | |||
322 | // update current Scene Region if appropriate | ||
323 | if (es.EstateID == estateId) | ||
324 | es.EstateOwner = account.PrincipalID; | ||
325 | } | ||
326 | else | ||
327 | { | ||
328 | m_estateSettings = null; | ||
329 | } | ||
330 | } | ||
331 | } | ||
332 | } | ||
333 | |||
334 | // give the user some feedback | ||
335 | if (response != null) | ||
336 | MainConsole.Instance.Output(response); | ||
337 | } | 227 | } |
338 | |||
339 | protected void SetEstateNameCommand(string module, string[] args) | ||
340 | { | ||
341 | string response = null; | ||
342 | |||
343 | EstateSettings es = m_module.Scene.RegionInfo.EstateSettings; | ||
344 | |||
345 | if (args == m_currentCmd) | ||
346 | { | ||
347 | // HACK to propagate new estate info to Scene Regions | ||
348 | if (m_estateSettings != null && es.EstateID == m_estateSettings.EstateID) | ||
349 | es.EstateName = m_estateSettings.EstateName; | ||
350 | |||
351 | return; | ||
352 | } | ||
353 | |||
354 | // new command... clear out the old value | ||
355 | m_currentCmd = args; | ||
356 | |||
357 | if (args.Length == 3) | ||
358 | { | ||
359 | response = "No estate specified."; | ||
360 | } | ||
361 | else | ||
362 | { | ||
363 | int estateId; | ||
364 | if (!int.TryParse(args[3], out estateId)) | ||
365 | { | ||
366 | response = String.Format("\"{0}\" is not a valid ID for an Estate", args[3]); | ||
367 | } | ||
368 | else | ||
369 | { | ||
370 | if (args.Length == 4) | ||
371 | { | ||
372 | response = "No name specified."; | ||
373 | } | ||
374 | else | ||
375 | { | ||
376 | // everything after the estate ID is "name" | ||
377 | StringBuilder sb = new StringBuilder(args[4]); | ||
378 | for (int i = 5; i < args.Length; i++) | ||
379 | sb.Append (" " + args[i]); | ||
380 | |||
381 | string estateName = sb.ToString(); | ||
382 | |||
383 | // send it off for processing. | ||
384 | response = m_module.SetEstateName(estateId, estateName); | ||
385 | |||
386 | if (response == String.Empty) | ||
387 | { | ||
388 | response = String.Format("Estate {0} renamed from \"{1}\" to \"{2}\"", estateId, es.EstateName, estateName); | ||
389 | |||
390 | // save data for propagation to other Scene Regions | ||
391 | m_estateSettings = new EstateSettings(); | ||
392 | m_estateSettings.EstateID = (uint)estateId; | ||
393 | m_estateSettings.EstateName = estateName; | ||
394 | |||
395 | // update current Scene Region if appropriate | ||
396 | if (es.EstateID == estateId) | ||
397 | es.EstateName = estateName; | ||
398 | } | ||
399 | else | ||
400 | { | ||
401 | m_estateSettings = null; | ||
402 | } | ||
403 | } | ||
404 | } | ||
405 | } | ||
406 | |||
407 | // give the user some feedback | ||
408 | if (response != null) | ||
409 | MainConsole.Instance.Output(response); | ||
410 | } | ||
411 | |||
412 | #endregion | 228 | #endregion |
413 | } | 229 | } |
414 | } \ No newline at end of file | 230 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index ae956e6..54a7302 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs | |||
@@ -251,8 +251,17 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
251 | m_log.InfoFormat("[ESTATE]: Estate Owner for {0} changed to {1} ({2} {3})", dbSettings.EstateName, | 251 | m_log.InfoFormat("[ESTATE]: Estate Owner for {0} changed to {1} ({2} {3})", dbSettings.EstateName, |
252 | account.PrincipalID, account.FirstName, account.LastName); | 252 | account.PrincipalID, account.FirstName, account.LastName); |
253 | 253 | ||
254 | TriggerEstateInfoChange(); | 254 | // propagate the change |
255 | sendRegionHandshakeToAll(); | 255 | List<UUID> regions = Scene.GetEstateRegions(estateID); |
256 | UUID regionId = (regions.Count() > 0) ? regions.ElementAt(0) : UUID.Zero; | ||
257 | if (regionId != UUID.Zero) | ||
258 | { | ||
259 | ChangeDelegate change = OnEstateInfoChange; | ||
260 | |||
261 | if (change != null) | ||
262 | change(regionId); | ||
263 | } | ||
264 | |||
256 | } | 265 | } |
257 | return response; | 266 | return response; |
258 | } | 267 | } |
@@ -289,8 +298,16 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
289 | // make sure there's a log entry to document the change | 298 | // make sure there's a log entry to document the change |
290 | m_log.InfoFormat("[ESTATE]: Estate {0} renamed from \"{1}\" to \"{2}\"", estateID, oldName, newName); | 299 | m_log.InfoFormat("[ESTATE]: Estate {0} renamed from \"{1}\" to \"{2}\"", estateID, oldName, newName); |
291 | 300 | ||
292 | TriggerEstateInfoChange(); | 301 | // propagate the change |
293 | sendRegionHandshakeToAll(); | 302 | List<UUID> regions = Scene.GetEstateRegions(estateID); |
303 | UUID regionId = (regions.Count() > 0) ? regions.ElementAt(0) : UUID.Zero; | ||
304 | if (regionId != UUID.Zero) | ||
305 | { | ||
306 | ChangeDelegate change = OnEstateInfoChange; | ||
307 | |||
308 | if (change != null) | ||
309 | change(regionId); | ||
310 | } | ||
294 | } | 311 | } |
295 | } | 312 | } |
296 | return response; | 313 | return response; |