diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs | 223 |
1 files changed, 140 insertions, 83 deletions
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs index 59dd3bb..4c65ce3 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs | |||
@@ -54,14 +54,9 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
54 | 54 | ||
55 | protected Commander m_commander = new Commander("estate"); | 55 | protected Commander m_commander = new Commander("estate"); |
56 | 56 | ||
57 | // variable used in processing "estate set owner" | 57 | // used to prevent multiple processing of commands when called from root region |
58 | private static string[] m_ownerCmd = null; | 58 | private static string[] m_currentCmd = null; |
59 | 59 | private static EstateSettings m_estateSettings = null; | |
60 | // variable used in processing "estate set owner" | ||
61 | private static UserAccount m_ownerAccount; | ||
62 | |||
63 | // variable used in processing "estate set owner" | ||
64 | private static List<uint> m_ownerEstates; | ||
65 | 60 | ||
66 | public EstateManagementCommands(EstateManagementModule module) | 61 | public EstateManagementCommands(EstateManagementModule module) |
67 | { | 62 | { |
@@ -92,18 +87,22 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
92 | "Specify -1 in <x> or <y> to wildcard that coordinate.", | 87 | "Specify -1 in <x> or <y> to wildcard that coordinate.", |
93 | consoleSetWaterHeight); | 88 | consoleSetWaterHeight); |
94 | 89 | ||
95 | |||
96 | m_module.Scene.AddCommand( | 90 | m_module.Scene.AddCommand( |
97 | "Estates", m_module, "estate show", "estate show", "Shows all estates on the simulator.", ShowEstatesCommand); | 91 | "Estates", m_module, "estate show", "estate show", "Shows all estates on the simulator.", ShowEstatesCommand); |
98 | 92 | ||
99 | m_module.Scene.AddCommand( | 93 | m_module.Scene.AddCommand( |
100 | "Estates", m_module, "estate set owner", "estate set owner [ <UUID> | <Firstname> <Lastname> ]", | 94 | "Estates", m_module, "estate set owner", "estate set owner <estate-id>[ <UUID> | <Firstname> <Lastname> ]", |
101 | "Sets the owner of the current region's estate to the specified UUID or user. " + | 95 | "Sets the owner of the specified estate to the specified UUID or user. ", SetEstateOwnerCommand); |
102 | "If called from root region, all estates will be prompted for change.", SetEstateOwnerCommand); | 96 | |
97 | m_module.Scene.AddCommand( | ||
98 | "Estates", m_module, "estate set name", "estate set name <estate-id> <new name>", | ||
99 | "Sets the name of the specified estate to the specified value. " + | ||
100 | "New name must be unique.", SetEstateNameCommand); | ||
103 | } | 101 | } |
104 | 102 | ||
105 | public void Close() {} | 103 | public void Close() {} |
106 | 104 | ||
105 | #region CommandHandlers | ||
107 | protected void consoleSetTerrainTexture(string module, string[] args) | 106 | protected void consoleSetTerrainTexture(string module, string[] args) |
108 | { | 107 | { |
109 | string num = args[3]; | 108 | string num = args[3]; |
@@ -248,112 +247,170 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
248 | 247 | ||
249 | EstateSettings es = m_module.Scene.RegionInfo.EstateSettings; | 248 | EstateSettings es = m_module.Scene.RegionInfo.EstateSettings; |
250 | 249 | ||
251 | if(args != m_ownerCmd) | 250 | if (args == m_currentCmd) |
252 | { | 251 | { |
253 | // new command... clear out the old values | 252 | // HACK to propagate new estate info to Scene Regions |
254 | m_ownerCmd = args; | 253 | if (m_estateSettings != null && es.EstateID == m_estateSettings.EstateID) |
255 | m_ownerEstates = new List<uint>(); | 254 | es.EstateOwner = m_estateSettings.EstateOwner; |
256 | m_ownerAccount = null; | ||
257 | } | ||
258 | 255 | ||
259 | if (MainConsole.Instance.ConsoleScene == null) | 256 | return; |
260 | { | ||
261 | if(m_ownerEstates.Contains(es.EstateID)) | ||
262 | { | ||
263 | // already checked this one | ||
264 | return; | ||
265 | } | ||
266 | else if(m_ownerEstates.Count > 0 && m_ownerAccount == null) | ||
267 | { | ||
268 | // lookup will have been tried and not found. | ||
269 | return; | ||
270 | } | ||
271 | // flag this estate, so it is not tried multiple times | ||
272 | m_ownerEstates.Add(es.EstateID); | ||
273 | } | 257 | } |
274 | else if(MainConsole.Instance.ConsoleScene != m_module.Scene) | 258 | |
259 | // new command... clear out the old value | ||
260 | m_currentCmd = args; | ||
261 | |||
262 | if (args.Length == 3) | ||
275 | { | 263 | { |
276 | // trying to process a single region, and this isn't it | 264 | response = "No estate specified."; |
277 | return; | ||
278 | } | 265 | } |
279 | UserAccount account = null; | 266 | else |
280 | if(m_ownerAccount == null) | ||
281 | { | 267 | { |
282 | if(args.Length == 3) | 268 | int estateId; |
269 | if (!int.TryParse(args[3], out estateId)) | ||
283 | { | 270 | { |
284 | response = "No user specified."; | 271 | response = String.Format("\"{0}\" is not a valid ID for an Estate", args[3]); |
285 | } | 272 | } |
286 | else | 273 | else |
287 | { | 274 | { |
288 | // TODO: Is there a better choice here? | 275 | if (args.Length == 4) |
289 | UUID scopeID = UUID.Zero; | ||
290 | |||
291 | string s1 = args[3]; | ||
292 | if(args.Length == 4) | ||
293 | { | 276 | { |
294 | // attempt to get account by UUID | 277 | response = "No user specified."; |
295 | UUID u; | 278 | } |
296 | if(UUID.TryParse(s1, out u)) | 279 | else |
280 | { | ||
281 | UserAccount account = null; | ||
282 | |||
283 | // TODO: Is there a better choice here? | ||
284 | UUID scopeID = UUID.Zero; | ||
285 | |||
286 | string s1 = args[4]; | ||
287 | if (args.Length == 5) | ||
297 | { | 288 | { |
298 | account = m_module.Scene.UserAccountService.GetUserAccount(scopeID, u); | 289 | // attempt to get account by UUID |
299 | if(account == null) | 290 | UUID u; |
291 | if (UUID.TryParse(s1, out u)) | ||
292 | { | ||
293 | account = m_module.Scene.UserAccountService.GetUserAccount(scopeID, u); | ||
294 | if (account == null) | ||
295 | response = String.Format("Could not find user {0}", s1); | ||
296 | } | ||
297 | else | ||
300 | { | 298 | { |
301 | response = String.Format("Could not find user {0}", s1); | 299 | response = String.Format("Invalid UUID {0}", s1); |
302 | } | 300 | } |
303 | } | 301 | } |
304 | else | 302 | else |
305 | { | 303 | { |
306 | response = String.Format("Invalid UUID {0}", s1); | 304 | // attempt to get account by Firstname, Lastname |
307 | account = null; | 305 | string s2 = args[5]; |
306 | account = m_module.Scene.UserAccountService.GetUserAccount(scopeID, s1, s2); | ||
307 | if (account == null) | ||
308 | response = String.Format("Could not find user {0} {1}", s1, s2); | ||
308 | } | 309 | } |
309 | } | 310 | |
310 | else | 311 | // If it's valid, send it off for processing. |
311 | { | 312 | if (account != null) |
312 | // attempt to get account by Firstname, Lastname | 313 | response = m_module.SetEstateOwner(estateId, account); |
313 | string s2 = args[4]; | 314 | |
314 | account = m_module.Scene.UserAccountService.GetUserAccount(scopeID, s1, s2); | 315 | if (response == String.Empty) |
315 | if(account == null) | 316 | { |
317 | response = String.Format("Estate owner changed to {0} ({1} {2})", account.PrincipalID, account.FirstName, account.LastName); | ||
318 | |||
319 | // save data for propagation to other Scene Regions | ||
320 | m_estateSettings = new EstateSettings(); | ||
321 | m_estateSettings.EstateID = (uint)estateId; | ||
322 | m_estateSettings.EstateOwner = account.PrincipalID; | ||
323 | |||
324 | // update current Scene Region if appropriate | ||
325 | if (es.EstateID == estateId) | ||
326 | es.EstateOwner = account.PrincipalID; | ||
327 | } | ||
328 | else | ||
316 | { | 329 | { |
317 | response = String.Format("Could not find user {0} {1}", s1, s2); | 330 | m_estateSettings = null; |
318 | } | 331 | } |
319 | } | 332 | } |
320 | } | 333 | } |
321 | } | 334 | } |
322 | else | 335 | |
336 | // give the user some feedback | ||
337 | if (response != null) | ||
338 | MainConsole.Instance.Output(response); | ||
339 | } | ||
340 | |||
341 | protected void SetEstateNameCommand(string module, string[] args) | ||
342 | { | ||
343 | string response = null; | ||
344 | |||
345 | EstateSettings es = m_module.Scene.RegionInfo.EstateSettings; | ||
346 | |||
347 | if (args == m_currentCmd) | ||
323 | { | 348 | { |
324 | account = m_ownerAccount; | 349 | // HACK to propagate new estate info to Scene Regions |
350 | if (m_estateSettings != null && es.EstateID == m_estateSettings.EstateID) | ||
351 | es.EstateName = m_estateSettings.EstateName; | ||
352 | |||
353 | return; | ||
325 | } | 354 | } |
326 | if(account != null) | ||
327 | { | ||
328 | if (MainConsole.Instance.ConsoleScene == null) | ||
329 | m_ownerAccount = account; | ||
330 | 355 | ||
331 | string choice; | 356 | // new command... clear out the old value |
332 | do | 357 | m_currentCmd = args; |
333 | { | ||
334 | // Get user confirmation, in case there are multiple estates involved (from root) | ||
335 | choice = MainConsole.Instance.CmdPrompt( | ||
336 | string.Format("Change owner of Estate {0} ({1}) [y/n]? ",es.EstateID, es.EstateName), | ||
337 | "Y"); | ||
338 | 358 | ||
339 | if("y".Equals(choice, StringComparison.OrdinalIgnoreCase)) | 359 | if (args.Length == 3) |
360 | { | ||
361 | response = "No estate specified."; | ||
362 | } | ||
363 | else | ||
364 | { | ||
365 | int estateId; | ||
366 | if (!int.TryParse(args[3], out estateId)) | ||
367 | { | ||
368 | response = String.Format("\"{0}\" is not a valid ID for an Estate", args[3]); | ||
369 | } | ||
370 | else | ||
371 | { | ||
372 | if (args.Length == 4) | ||
340 | { | 373 | { |
341 | response = m_module.setEstateOwner((int)es.EstateID, account); | 374 | response = "No name specified."; |
342 | } | 375 | } |
343 | else if(!"n".Equals(choice, StringComparison.OrdinalIgnoreCase)) | 376 | else |
344 | { | 377 | { |
345 | MainConsole.Instance.Output("Invalid response. Please select y or n."); | 378 | // everything after the estate ID is "name" |
346 | choice = null; | 379 | StringBuilder sb = new StringBuilder(args[4]); |
380 | for (int i = 5; i < args.Length; i++) | ||
381 | sb.Append (" " + args[i]); | ||
382 | |||
383 | string estateName = sb.ToString(); | ||
384 | |||
385 | // send it off for processing. | ||
386 | response = m_module.SetEstateName(estateId, estateName); | ||
387 | |||
388 | if (response == String.Empty) | ||
389 | { | ||
390 | response = String.Format("Estate {0} renamed from \"{1}\" to \"{2}\"", estateId, es.EstateName, estateName); | ||
391 | |||
392 | // save data for propagation to other Scene Regions | ||
393 | m_estateSettings = new EstateSettings(); | ||
394 | m_estateSettings.EstateID = (uint)estateId; | ||
395 | m_estateSettings.EstateName = estateName; | ||
396 | |||
397 | // update current Scene Region if appropriate | ||
398 | if (es.EstateID == estateId) | ||
399 | es.EstateName = estateName; | ||
400 | } | ||
401 | else | ||
402 | { | ||
403 | m_estateSettings = null; | ||
404 | } | ||
347 | } | 405 | } |
348 | } | 406 | } |
349 | while(choice == null); | ||
350 | } | 407 | } |
351 | 408 | ||
352 | 409 | // give the user some feedback | |
353 | // Give the user some feedback | 410 | if (response != null) |
354 | if(response != null) | ||
355 | MainConsole.Instance.Output(response); | 411 | MainConsole.Instance.Output(response); |
356 | } | 412 | } |
357 | 413 | ||
414 | #endregion | ||
358 | } | 415 | } |
359 | } \ No newline at end of file | 416 | } \ No newline at end of file |