aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
diff options
context:
space:
mode:
authorJustin Clarke Casey2009-02-17 15:39:18 +0000
committerJustin Clarke Casey2009-02-17 15:39:18 +0000
commit229b69e044ca81233f248ff623b22516136bb3c6 (patch)
tree6c8d1d8f145b5bb2ec7745fe1209b1d3221496c3 /OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
parent* Ignored a bunch of genned files (diff)
downloadopensim-SC_OLD-229b69e044ca81233f248ff623b22516136bb3c6.zip
opensim-SC_OLD-229b69e044ca81233f248ff623b22516136bb3c6.tar.gz
opensim-SC_OLD-229b69e044ca81233f248ff623b22516136bb3c6.tar.bz2
opensim-SC_OLD-229b69e044ca81233f248ff623b22516136bb3c6.tar.xz
* Establish InventoryArchiveSaved event for unit tests
* This is done on the inventory archiver module directly rather than Scene.EventManager - the module seems the more appropriate location
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs34
1 files changed, 24 insertions, 10 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
index 786cbeb..1997562 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
@@ -25,6 +25,7 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System;
28using System.Collections.Generic; 29using System.Collections.Generic;
29using System.IO; 30using System.IO;
30using System.Reflection; 31using System.Reflection;
@@ -38,7 +39,7 @@ using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes; 39using OpenSim.Region.Framework.Scenes;
39 40
40namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver 41namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
41{ 42{
42 /// <summary> 43 /// <summary>
43 /// This module loads and saves OpenSimulator inventory archives 44 /// This module loads and saves OpenSimulator inventory archives
44 /// </summary> 45 /// </summary>
@@ -50,10 +51,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
50 51
51 public bool IsSharedModule { get { return true; } } 52 public bool IsSharedModule { get { return true; } }
52 53
54 public event InventoryArchiveSaved OnInventoryArchiveSaved;
55
53 /// <summary> 56 /// <summary>
54 /// The file to load and save inventory if no filename has been specified 57 /// The file to load and save inventory if no filename has been specified
55 /// </summary> 58 /// </summary>
56 protected const string DEFAULT_INV_BACKUP_FILENAME = "user-inventory_iar.tar.gz"; 59 protected const string DEFAULT_INV_BACKUP_FILENAME = "user-inventory_iar.tar.gz";
57 60
58 /// <value> 61 /// <value>
59 /// All scenes that this module knows about 62 /// All scenes that this module knows about
@@ -63,14 +66,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
63 /// <value> 66 /// <value>
64 /// The comms manager we will use for all comms requests 67 /// The comms manager we will use for all comms requests
65 /// </value> 68 /// </value>
66 private CommunicationsManager m_commsManager; 69 protected internal CommunicationsManager CommsManager;
67 70
68 public void Initialise(Scene scene, IConfigSource source) 71 public void Initialise(Scene scene, IConfigSource source)
69 { 72 {
70 if (m_scenes.Count == 0) 73 if (m_scenes.Count == 0)
71 { 74 {
72 scene.RegisterModuleInterface<IInventoryArchiverModule>(this); 75 scene.RegisterModuleInterface<IInventoryArchiverModule>(this);
73 m_commsManager = scene.CommsManager; 76 CommsManager = scene.CommsManager;
74 77
75 scene.AddCommand( 78 scene.AddCommand(
76 this, "load iar", 79 this, "load iar",
@@ -89,6 +92,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
89 public void PostInitialise() {} 92 public void PostInitialise() {}
90 93
91 public void Close() {} 94 public void Close() {}
95
96 /// <summary>
97 /// Trigger the inventory archive saved event.
98 /// </summary>
99 protected internal void TriggerInventoryArchiveSaved(
100 bool succeeded, CachedUserInfo userInfo, string invPath, Stream saveStream, Exception reportedException)
101 {
102 InventoryArchiveSaved handlerInventoryArchiveSaved = OnInventoryArchiveSaved;
103 if (handlerInventoryArchiveSaved != null)
104 handlerInventoryArchiveSaved(succeeded, userInfo, invPath, saveStream, reportedException);
105 }
92 106
93 public void DearchiveInventory(string firstName, string lastName, string invPath, Stream loadStream) 107 public void DearchiveInventory(string firstName, string lastName, string invPath, Stream loadStream)
94 { 108 {
@@ -99,7 +113,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
99 if (userInfo != null) 113 if (userInfo != null)
100 { 114 {
101 InventoryArchiveReadRequest request = 115 InventoryArchiveReadRequest request =
102 new InventoryArchiveReadRequest(userInfo, invPath, loadStream, m_commsManager); 116 new InventoryArchiveReadRequest(userInfo, invPath, loadStream, CommsManager);
103 UpdateClientWithLoadedNodes(userInfo, request.Execute()); 117 UpdateClientWithLoadedNodes(userInfo, request.Execute());
104 } 118 }
105 } 119 }
@@ -112,7 +126,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
112 CachedUserInfo userInfo = GetUserInfo(firstName, lastName); 126 CachedUserInfo userInfo = GetUserInfo(firstName, lastName);
113 127
114 if (userInfo != null) 128 if (userInfo != null)
115 new InventoryArchiveWriteRequest(userInfo, invPath, saveStream, m_commsManager).Execute(); 129 new InventoryArchiveWriteRequest(this, userInfo, invPath, saveStream).Execute();
116 } 130 }
117 } 131 }
118 132
@@ -125,7 +139,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
125 if (userInfo != null) 139 if (userInfo != null)
126 { 140 {
127 InventoryArchiveReadRequest request = 141 InventoryArchiveReadRequest request =
128 new InventoryArchiveReadRequest(userInfo, invPath, loadPath, m_commsManager); 142 new InventoryArchiveReadRequest(userInfo, invPath, loadPath, CommsManager);
129 UpdateClientWithLoadedNodes(userInfo, request.Execute()); 143 UpdateClientWithLoadedNodes(userInfo, request.Execute());
130 } 144 }
131 } 145 }
@@ -138,7 +152,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
138 CachedUserInfo userInfo = GetUserInfo(firstName, lastName); 152 CachedUserInfo userInfo = GetUserInfo(firstName, lastName);
139 153
140 if (userInfo != null) 154 if (userInfo != null)
141 new InventoryArchiveWriteRequest(userInfo, invPath, savePath, m_commsManager).Execute(); 155 new InventoryArchiveWriteRequest(this, userInfo, invPath, savePath).Execute();
142 } 156 }
143 } 157 }
144 158
@@ -208,7 +222,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
208 /// <returns></returns> 222 /// <returns></returns>
209 protected CachedUserInfo GetUserInfo(string firstName, string lastName) 223 protected CachedUserInfo GetUserInfo(string firstName, string lastName)
210 { 224 {
211 UserProfileData userProfile = m_commsManager.UserService.GetUserProfile(firstName, lastName); 225 UserProfileData userProfile = CommsManager.UserService.GetUserProfile(firstName, lastName);
212 226
213 if (null == userProfile) 227 if (null == userProfile)
214 { 228 {
@@ -216,7 +230,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
216 return null; 230 return null;
217 } 231 }
218 232
219 CachedUserInfo userInfo = m_commsManager.UserProfileCacheService.GetUserDetails(userProfile.ID); 233 CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(userProfile.ID);
220 if (null == userInfo) 234 if (null == userInfo)
221 { 235 {
222 m_log.ErrorFormat( 236 m_log.ErrorFormat(