aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2009-09-07 19:57:44 +0100
committerJustin Clark-Casey (justincc)2009-09-07 19:57:44 +0100
commitfa1d79533e22266f8ee7f1aa4d93a3f7fba0e230 (patch)
tree07980bd5c2eac7e0a31107f7dbe8a73d4cc5e8a9 /OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
parentmake oar module logging a little less noisy (diff)
downloadopensim-SC_OLD-fa1d79533e22266f8ee7f1aa4d93a3f7fba0e230.zip
opensim-SC_OLD-fa1d79533e22266f8ee7f1aa4d93a3f7fba0e230.tar.gz
opensim-SC_OLD-fa1d79533e22266f8ee7f1aa4d93a3f7fba0e230.tar.bz2
opensim-SC_OLD-fa1d79533e22266f8ee7f1aa4d93a3f7fba0e230.tar.xz
Only allow iar load/save if user is logged in to the region simulator
Diffstat (limited to 'OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs')
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs128
1 files changed, 106 insertions, 22 deletions
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
index 3869de2..2340fad 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
@@ -51,6 +51,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
51 public string Name { get { return "Inventory Archiver Module"; } } 51 public string Name { get { return "Inventory Archiver Module"; } }
52 52
53 public bool IsSharedModule { get { return true; } } 53 public bool IsSharedModule { get { return true; } }
54
55 /// <value>
56 /// Enable or disable checking whether the iar user is actually logged in
57 /// </value>
58 public bool DisablePresenceChecks { get; set; }
54 59
55 public event InventoryArchiveSaved OnInventoryArchiveSaved; 60 public event InventoryArchiveSaved OnInventoryArchiveSaved;
56 61
@@ -70,6 +75,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
70 private Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>(); 75 private Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>();
71 private Scene m_aScene; 76 private Scene m_aScene;
72 77
78 public InventoryArchiverModule() {}
79
80 public InventoryArchiverModule(bool disablePresenceChecks)
81 {
82 DisablePresenceChecks = disablePresenceChecks;
83 }
84
73 public void Initialise(Scene scene, IConfigSource source) 85 public void Initialise(Scene scene, IConfigSource source)
74 { 86 {
75 if (m_scenes.Count == 0) 87 if (m_scenes.Count == 0)
@@ -109,29 +121,57 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
109 handlerInventoryArchiveSaved(id, succeeded, userInfo, invPath, saveStream, reportedException); 121 handlerInventoryArchiveSaved(id, succeeded, userInfo, invPath, saveStream, reportedException);
110 } 122 }
111 123
112 public void ArchiveInventory(Guid id, string firstName, string lastName, string invPath, Stream saveStream) 124 public bool ArchiveInventory(Guid id, string firstName, string lastName, string invPath, Stream saveStream)
113 { 125 {
114 if (m_scenes.Count > 0) 126 if (m_scenes.Count > 0)
115 { 127 {
116 CachedUserInfo userInfo = GetUserInfo(firstName, lastName); 128 CachedUserInfo userInfo = GetUserInfo(firstName, lastName);
117 129
118 if (userInfo != null) 130 if (userInfo != null)
119 new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, saveStream).Execute(); 131 {
120 } 132 if (CheckPresence(userInfo.UserProfile.ID))
133 {
134 new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, saveStream).Execute();
135 return true;
136 }
137 else
138 {
139 m_log.ErrorFormat(
140 "[INVENTORY ARCHIVER]: User {0} {1} not logged in to this region simulator",
141 userInfo.UserProfile.Name, userInfo.UserProfile.ID);
142 }
143 }
144 }
145
146 return false;
121 } 147 }
122 148
123 public void ArchiveInventory(Guid id, string firstName, string lastName, string invPath, string savePath) 149 public bool ArchiveInventory(Guid id, string firstName, string lastName, string invPath, string savePath)
124 { 150 {
125 if (m_scenes.Count > 0) 151 if (m_scenes.Count > 0)
126 { 152 {
127 CachedUserInfo userInfo = GetUserInfo(firstName, lastName); 153 CachedUserInfo userInfo = GetUserInfo(firstName, lastName);
128 154
129 if (userInfo != null) 155 if (userInfo != null)
130 new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, savePath).Execute(); 156 {
131 } 157 if (CheckPresence(userInfo.UserProfile.ID))
158 {
159 new InventoryArchiveWriteRequest(id, this, m_aScene, userInfo, invPath, savePath).Execute();
160 return true;
161 }
162 else
163 {
164 m_log.ErrorFormat(
165 "[INVENTORY ARCHIVER]: User {0} {1} not logged in to this region simulator",
166 userInfo.UserProfile.Name, userInfo.UserProfile.ID);
167 }
168 }
169 }
170
171 return false;
132 } 172 }
133 173
134 public void DearchiveInventory(string firstName, string lastName, string invPath, Stream loadStream) 174 public bool DearchiveInventory(string firstName, string lastName, string invPath, Stream loadStream)
135 { 175 {
136 if (m_scenes.Count > 0) 176 if (m_scenes.Count > 0)
137 { 177 {
@@ -139,14 +179,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
139 179
140 if (userInfo != null) 180 if (userInfo != null)
141 { 181 {
142 InventoryArchiveReadRequest request = 182 if (CheckPresence(userInfo.UserProfile.ID))
143 new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadStream); 183 {
144 UpdateClientWithLoadedNodes(userInfo, request.Execute()); 184 InventoryArchiveReadRequest request =
185 new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadStream);
186 UpdateClientWithLoadedNodes(userInfo, request.Execute());
187
188 return true;
189 }
190 else
191 {
192 m_log.ErrorFormat(
193 "[INVENTORY ARCHIVER]: User {0} {1} not logged in to this region simulator",
194 userInfo.UserProfile.Name, userInfo.UserProfile.ID);
195 }
145 } 196 }
146 } 197 }
198
199 return false;
147 } 200 }
148 201
149 public void DearchiveInventory(string firstName, string lastName, string invPath, string loadPath) 202 public bool DearchiveInventory(string firstName, string lastName, string invPath, string loadPath)
150 { 203 {
151 if (m_scenes.Count > 0) 204 if (m_scenes.Count > 0)
152 { 205 {
@@ -154,11 +207,24 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
154 207
155 if (userInfo != null) 208 if (userInfo != null)
156 { 209 {
157 InventoryArchiveReadRequest request = 210 if (CheckPresence(userInfo.UserProfile.ID))
158 new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadPath); 211 {
159 UpdateClientWithLoadedNodes(userInfo, request.Execute()); 212 InventoryArchiveReadRequest request =
160 } 213 new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadPath);
161 } 214 UpdateClientWithLoadedNodes(userInfo, request.Execute());
215
216 return true;
217 }
218 else
219 {
220 m_log.ErrorFormat(
221 "[INVENTORY ARCHIVER]: User {0} {1} not logged in to this region simulator",
222 userInfo.UserProfile.Name, userInfo.UserProfile.ID);
223 }
224 }
225 }
226
227 return false;
162 } 228 }
163 229
164 /// <summary> 230 /// <summary>
@@ -183,11 +249,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
183 "[INVENTORY ARCHIVER]: Loading archive {0} to inventory path {1} for {2} {3}", 249 "[INVENTORY ARCHIVER]: Loading archive {0} to inventory path {1} for {2} {3}",
184 loadPath, invPath, firstName, lastName); 250 loadPath, invPath, firstName, lastName);
185 251
186 DearchiveInventory(firstName, lastName, invPath, loadPath); 252 if (DearchiveInventory(firstName, lastName, invPath, loadPath))
187 253 m_log.InfoFormat(
188 m_log.InfoFormat( 254 "[INVENTORY ARCHIVER]: Loaded archive {0} for {1} {2}",
189 "[INVENTORY ARCHIVER]: Loaded archive {0} for {1} {2}", 255 loadPath, firstName, lastName);
190 loadPath, firstName, lastName);
191 } 256 }
192 257
193 /// <summary> 258 /// <summary>
@@ -291,5 +356,24 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
291 } 356 }
292 } 357 }
293 } 358 }
359
360 /// <summary>
361 /// Check if the given user is present in any of the scenes.
362 /// </summary>
363 /// <param name="userId">The user to check</param>
364 /// <returns>true if the user is in any of the scenes, false otherwise</returns>
365 protected bool CheckPresence(UUID userId)
366 {
367 if (DisablePresenceChecks)
368 return true;
369
370 foreach (Scene scene in m_scenes.Values)
371 {
372 if (scene.GetScenePresence(userId) != null)
373 return true;
374 }
375
376 return false;
377 }
294 } 378 }
295} 379}