diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs | 64 |
1 files changed, 49 insertions, 15 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index 2eaca49..b33c2b1 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs | |||
@@ -75,6 +75,24 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
75 | private Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>(); | 75 | private Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>(); |
76 | private Scene m_aScene; | 76 | private Scene m_aScene; |
77 | 77 | ||
78 | private IUserAccountService m_UserAccountService; | ||
79 | protected IUserAccountService UserAccountService | ||
80 | { | ||
81 | get | ||
82 | { | ||
83 | if (m_UserAccountService == null) | ||
84 | // What a strange thing to do... | ||
85 | foreach (Scene s in m_scenes.Values) | ||
86 | { | ||
87 | m_UserAccountService = s.RequestModuleInterface<IUserAccountService>(); | ||
88 | break; | ||
89 | } | ||
90 | |||
91 | return m_UserAccountService; | ||
92 | } | ||
93 | } | ||
94 | |||
95 | |||
78 | public InventoryArchiverModule() {} | 96 | public InventoryArchiverModule() {} |
79 | 97 | ||
80 | public InventoryArchiverModule(bool disablePresenceChecks) | 98 | public InventoryArchiverModule(bool disablePresenceChecks) |
@@ -106,11 +124,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
106 | 124 | ||
107 | scene.AddCommand( | 125 | scene.AddCommand( |
108 | this, "save iar", | 126 | this, "save iar", |
109 | "save iar <first> <last> <inventory path> <password> [<IAR path>]", | 127 | "save iar <first> <last> <inventory path> <password> [--p|-profile=<url>] [<IAR path>]", |
110 | "Save user inventory archive (IAR).", | 128 | "Save user inventory archive (IAR).", |
111 | "<first> is the user's first name." + Environment.NewLine | 129 | "<first> is the user's first name." + Environment.NewLine |
112 | + "<last> is the user's last name." + Environment.NewLine | 130 | + "<last> is the user's last name." + Environment.NewLine |
113 | + "<inventory path> is the path inside the user's inventory for the folder/item to be saved." + Environment.NewLine | 131 | + "<inventory path> is the path inside the user's inventory for the folder/item to be saved." + Environment.NewLine |
132 | + "-p|--profile=<url> adds the url of the profile service to the saved user information." + Environment.NewLine | ||
114 | + "<IAR path> is the filesystem path at which to save the IAR." | 133 | + "<IAR path> is the filesystem path at which to save the IAR." |
115 | + string.Format(" If this is not given then the filename {0} in the current directory is used", DEFAULT_INV_BACKUP_FILENAME), | 134 | + string.Format(" If this is not given then the filename {0} in the current directory is used", DEFAULT_INV_BACKUP_FILENAME), |
116 | HandleSaveInvConsoleCommand); | 135 | HandleSaveInvConsoleCommand); |
@@ -157,7 +176,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
157 | { | 176 | { |
158 | try | 177 | try |
159 | { | 178 | { |
160 | new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, saveStream).Execute(); | 179 | new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, saveStream).Execute(options, UserAccountService); |
161 | } | 180 | } |
162 | catch (EntryPointNotFoundException e) | 181 | catch (EntryPointNotFoundException e) |
163 | { | 182 | { |
@@ -197,7 +216,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
197 | { | 216 | { |
198 | try | 217 | try |
199 | { | 218 | { |
200 | new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, savePath).Execute(); | 219 | new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, savePath).Execute(options, UserAccountService); |
201 | } | 220 | } |
202 | catch (EntryPointNotFoundException e) | 221 | catch (EntryPointNotFoundException e) |
203 | { | 222 | { |
@@ -235,14 +254,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
235 | if (m_scenes.Count > 0) | 254 | if (m_scenes.Count > 0) |
236 | { | 255 | { |
237 | UserAccount userInfo = GetUserInfo(firstName, lastName, pass); | 256 | UserAccount userInfo = GetUserInfo(firstName, lastName, pass); |
238 | 257 | ||
239 | if (userInfo != null) | 258 | if (userInfo != null) |
240 | { | 259 | { |
241 | if (CheckPresence(userInfo.PrincipalID)) | 260 | if (CheckPresence(userInfo.PrincipalID)) |
242 | { | 261 | { |
262 | |||
243 | InventoryArchiveReadRequest request; | 263 | InventoryArchiveReadRequest request; |
244 | bool merge = (options.ContainsKey("merge") ? (bool)options["merge"] : false); | 264 | bool merge = (options.ContainsKey("merge") ? (bool)options["merge"] : false); |
245 | 265 | ||
246 | try | 266 | try |
247 | { | 267 | { |
248 | request = new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadStream, merge); | 268 | request = new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadStream, merge); |
@@ -256,7 +276,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
256 | 276 | ||
257 | return false; | 277 | return false; |
258 | } | 278 | } |
259 | 279 | ||
260 | UpdateClientWithLoadedNodes(userInfo, request.Execute()); | 280 | UpdateClientWithLoadedNodes(userInfo, request.Execute()); |
261 | 281 | ||
262 | return true; | 282 | return true; |
@@ -268,6 +288,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
268 | userInfo.FirstName, userInfo.LastName, userInfo.PrincipalID); | 288 | userInfo.FirstName, userInfo.LastName, userInfo.PrincipalID); |
269 | } | 289 | } |
270 | } | 290 | } |
291 | else | ||
292 | m_log.ErrorFormat("[INVENTORY ARCHIVER]: User {0} {1} not found", | ||
293 | firstName, lastName); | ||
271 | } | 294 | } |
272 | 295 | ||
273 | return false; | 296 | return false; |
@@ -368,10 +391,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
368 | protected void HandleSaveInvConsoleCommand(string module, string[] cmdparams) | 391 | protected void HandleSaveInvConsoleCommand(string module, string[] cmdparams) |
369 | { | 392 | { |
370 | Guid id = Guid.NewGuid(); | 393 | Guid id = Guid.NewGuid(); |
371 | 394 | ||
395 | Dictionary<string, object> options = new Dictionary<string, object>(); | ||
396 | |||
397 | OptionSet ops = new OptionSet(); | ||
398 | //ops.Add("v|version=", delegate(string v) { options["version"] = v; }); | ||
399 | ops.Add("p|profile=", delegate(string v) { options["profile"] = v; }); | ||
400 | |||
401 | List<string> mainParams = ops.Parse(cmdparams); | ||
402 | |||
372 | try | 403 | try |
373 | { | 404 | { |
374 | if (cmdparams.Length < 6) | 405 | if (mainParams.Count < 6) |
375 | { | 406 | { |
376 | m_log.Error( | 407 | m_log.Error( |
377 | "[INVENTORY ARCHIVER]: usage is save iar <first name> <last name> <inventory path> <user password> [<save file path>]"); | 408 | "[INVENTORY ARCHIVER]: usage is save iar <first name> <last name> <inventory path> <user password> [<save file path>]"); |
@@ -379,18 +410,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
379 | } | 410 | } |
380 | 411 | ||
381 | m_log.Info("[INVENTORY ARCHIVER]: PLEASE NOTE THAT THIS FACILITY IS EXPERIMENTAL. BUG REPORTS WELCOME."); | 412 | m_log.Info("[INVENTORY ARCHIVER]: PLEASE NOTE THAT THIS FACILITY IS EXPERIMENTAL. BUG REPORTS WELCOME."); |
382 | 413 | if (options.ContainsKey("profile")) | |
383 | string firstName = cmdparams[2]; | 414 | m_log.WarnFormat("[INVENTORY ARCHIVER]: Please be aware that inventory archives with creator information are not compatible with OpenSim 0.7.0.2 and earlier. Do not use the -profile option if you want to produce a compatible IAR"); |
384 | string lastName = cmdparams[3]; | 415 | |
385 | string invPath = cmdparams[4]; | 416 | string firstName = mainParams[2]; |
386 | string pass = cmdparams[5]; | 417 | string lastName = mainParams[3]; |
387 | string savePath = (cmdparams.Length > 6 ? cmdparams[6] : DEFAULT_INV_BACKUP_FILENAME); | 418 | string invPath = mainParams[4]; |
419 | string pass = mainParams[5]; | ||
420 | string savePath = (mainParams.Count > 6 ? mainParams[6] : DEFAULT_INV_BACKUP_FILENAME); | ||
388 | 421 | ||
389 | m_log.InfoFormat( | 422 | m_log.InfoFormat( |
390 | "[INVENTORY ARCHIVER]: Saving archive {0} using inventory path {1} for {2} {3}", | 423 | "[INVENTORY ARCHIVER]: Saving archive {0} using inventory path {1} for {2} {3}", |
391 | savePath, invPath, firstName, lastName); | 424 | savePath, invPath, firstName, lastName); |
392 | 425 | ||
393 | ArchiveInventory(id, firstName, lastName, invPath, pass, savePath, new Dictionary<string, object>()); | 426 | ArchiveInventory(id, firstName, lastName, invPath, pass, savePath, options); |
394 | } | 427 | } |
395 | catch (InventoryArchiverException e) | 428 | catch (InventoryArchiverException e) |
396 | { | 429 | { |
@@ -518,5 +551,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
518 | 551 | ||
519 | return false; | 552 | return false; |
520 | } | 553 | } |
554 | |||
521 | } | 555 | } |
522 | } | 556 | } |