diff options
Diffstat (limited to 'OpenSim/Region/CoreModules/World')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Estate/EstateManagementCommands.cs | 184 | ||||
-rw-r--r-- | OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs | 25 |
2 files changed, 21 insertions, 188 deletions
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; |