aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/Avatar/Inventory/Transfer
diff options
context:
space:
mode:
authorDr Scofield2009-02-10 13:10:57 +0000
committerDr Scofield2009-02-10 13:10:57 +0000
commit180be7de07014aa33bc6066f12a0819b731c1c9d (patch)
tree3aa13af3cda4b808fa9453655875327699b61311 /OpenSim/Region/Environment/Modules/Avatar/Inventory/Transfer
parentStopgap measure: To use gridlaunch, or GUI, start opensim with (diff)
downloadopensim-SC-180be7de07014aa33bc6066f12a0819b731c1c9d.zip
opensim-SC-180be7de07014aa33bc6066f12a0819b731c1c9d.tar.gz
opensim-SC-180be7de07014aa33bc6066f12a0819b731c1c9d.tar.bz2
opensim-SC-180be7de07014aa33bc6066f12a0819b731c1c9d.tar.xz
this is step 2 of 2 of the OpenSim.Region.Environment refactor.
NOTHING has been deleted or moved off to forge at this point. what has happened is that OpenSim.Region.Environment.Modules has been split in two: - OpenSim.Region.CoreModules: all those modules that are either directly or indirectly referenced from other OpenSim packages, or that provide functionality that the OpenSim developer community considers core functionality: CoreModules/Agent/AssetTransaction CoreModules/Agent/Capabilities CoreModules/Agent/TextureDownload CoreModules/Agent/TextureSender CoreModules/Agent/TextureSender/Tests CoreModules/Agent/Xfer CoreModules/Avatar/AvatarFactory CoreModules/Avatar/Chat/ChatModule CoreModules/Avatar/Combat CoreModules/Avatar/Currency/SampleMoney CoreModules/Avatar/Dialog CoreModules/Avatar/Friends CoreModules/Avatar/Gestures CoreModules/Avatar/Groups CoreModules/Avatar/InstantMessage CoreModules/Avatar/Inventory CoreModules/Avatar/Inventory/Archiver CoreModules/Avatar/Inventory/Transfer CoreModules/Avatar/Lure CoreModules/Avatar/ObjectCaps CoreModules/Avatar/Profiles CoreModules/Communications/Local CoreModules/Communications/REST CoreModules/Framework/EventQueue CoreModules/Framework/InterfaceCommander CoreModules/Hypergrid CoreModules/InterGrid CoreModules/Scripting/DynamicTexture CoreModules/Scripting/EMailModules CoreModules/Scripting/HttpRequest CoreModules/Scripting/LoadImageURL CoreModules/Scripting/VectorRender CoreModules/Scripting/WorldComm CoreModules/Scripting/XMLRPC CoreModules/World/Archiver CoreModules/World/Archiver/Tests CoreModules/World/Estate CoreModules/World/Land CoreModules/World/Permissions CoreModules/World/Serialiser CoreModules/World/Sound CoreModules/World/Sun CoreModules/World/Terrain CoreModules/World/Terrain/DefaultEffects CoreModules/World/Terrain/DefaultEffects/bin CoreModules/World/Terrain/DefaultEffects/bin/Debug CoreModules/World/Terrain/Effects CoreModules/World/Terrain/FileLoaders CoreModules/World/Terrain/FloodBrushes CoreModules/World/Terrain/PaintBrushes CoreModules/World/Terrain/Tests CoreModules/World/Vegetation CoreModules/World/Wind CoreModules/World/WorldMap - OpenSim.Region.OptionalModules: all those modules that are not core modules: OptionalModules/Avatar/Chat/IRC-stuff OptionalModules/Avatar/Concierge OptionalModules/Avatar/Voice/AsterixVoice OptionalModules/Avatar/Voice/SIPVoice OptionalModules/ContentManagementSystem OptionalModules/Grid/Interregion OptionalModules/Python OptionalModules/SvnSerialiser OptionalModules/World/NPC OptionalModules/World/TreePopulator
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Avatar/Inventory/Transfer')
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Inventory/Transfer/InventoryTransferModule.cs389
1 files changed, 0 insertions, 389 deletions
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
deleted file mode 100644
index 62fb3a2..0000000
--- a/OpenSim/Region/Environment/Modules/Avatar/Inventory/Transfer/InventoryTransferModule.cs
+++ /dev/null
@@ -1,389 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Reflection;
32using OpenMetaverse;
33using log4net;
34using Nini.Config;
35using OpenSim.Framework;
36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes;
38using OpenSim.Framework.Communications.Cache;
39
40namespace OpenSim.Region.Environment.Modules.Avatar.Inventory.Transfer
41{
42 public class InventoryTransferModule : IInventoryTransferModule, IRegionModule
43 {
44 private static readonly ILog m_log
45 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46
47 /// <summary>
48 private List<Scene> m_Scenelist = new List<Scene>();
49 private Dictionary<UUID, Scene> m_AgentRegions =
50 new Dictionary<UUID, Scene>();
51
52 private IMessageTransferModule m_TransferModule = null;
53
54 #region IRegionModule Members
55
56 public void Initialise(Scene scene, IConfigSource config)
57 {
58 if (config.Configs["Messaging"] != null)
59 {
60 // Allow disabling this module in config
61 //
62 if (config.Configs["Messaging"].GetString(
63 "InventoryTransferModule", "InventoryTransferModule") !=
64 "InventoryTransferModule")
65 return;
66 }
67
68 if (!m_Scenelist.Contains(scene))
69 {
70 if (m_Scenelist.Count == 0)
71 {
72 m_TransferModule = scene.RequestModuleInterface<IMessageTransferModule>();
73 if (m_TransferModule == null)
74 m_log.Error("[INVENTORY TRANSFER] No Message transfer module found, transfers will be local only");
75 }
76
77 m_Scenelist.Add(scene);
78
79 scene.RegisterModuleInterface<IInventoryTransferModule>(this);
80
81 scene.EventManager.OnNewClient += OnNewClient;
82 scene.EventManager.OnClientClosed += ClientLoggedOut;
83 }
84 }
85
86 public void PostInitialise()
87 {
88 }
89
90 public void Close()
91 {
92 }
93
94 public string Name
95 {
96 get { return "InventoryModule"; }
97 }
98
99 public bool IsSharedModule
100 {
101 get { return true; }
102 }
103
104 #endregion
105
106 private void OnNewClient(IClientAPI client)
107 {
108 // Inventory giving is conducted via instant message
109 client.OnInstantMessage += OnInstantMessage;
110 }
111
112 private Scene FindClientScene(UUID agentId)
113 {
114 lock (m_Scenelist)
115 {
116 foreach (Scene scene in m_Scenelist)
117 {
118 ScenePresence presence = scene.GetScenePresence(agentId);
119 if (presence != null)
120 {
121 if (!presence.IsChildAgent)
122 return scene;
123 }
124 }
125 }
126 return null;
127 }
128
129 private void OnInstantMessage(IClientAPI client, GridInstantMessage im)
130 {
131 Scene scene = FindClientScene(client.AgentId);
132
133 if (scene == null) // Something seriously wrong here.
134 return;
135
136 if (im.dialog == (byte) InstantMessageDialog.InventoryOffered)
137 {
138 //m_log.DebugFormat("Asset type {0}", ((AssetType)im.binaryBucket[0]));
139
140 ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID));
141 UUID copyID;
142
143 // First byte is the asset type
144 AssetType assetType = (AssetType)im.binaryBucket[0];
145
146 if (AssetType.Folder == assetType)
147 {
148 UUID folderID = new UUID(im.binaryBucket, 1);
149
150 m_log.DebugFormat("[AGENT INVENTORY]: Inserting original folder {0} "+
151 "into agent {1}'s inventory",
152 folderID, new UUID(im.toAgentID));
153
154 InventoryFolderImpl folderCopy
155 = scene.GiveInventoryFolder(new UUID(im.toAgentID), client.AgentId, folderID, UUID.Zero);
156
157 if (folderCopy == null)
158 {
159 client.SendAgentAlertMessage("Can't find folder to give. Nothing given.", false);
160 return;
161 }
162
163 // The outgoing binary bucket should contain only the byte which signals an asset folder is
164 // being copied and the following bytes for the copied folder's UUID
165 copyID = folderCopy.ID;
166 byte[] copyIDBytes = copyID.GetBytes();
167 im.binaryBucket = new byte[1 + copyIDBytes.Length];
168 im.binaryBucket[0] = (byte)AssetType.Folder;
169 Array.Copy(copyIDBytes, 0, im.binaryBucket, 1, copyIDBytes.Length);
170
171 if (user != null && !user.IsChildAgent)
172 {
173 user.ControllingClient.SendBulkUpdateInventory(folderCopy);
174 }
175 }
176 else
177 {
178 // First byte of the array is probably the item type
179 // Next 16 bytes are the UUID
180
181 UUID itemID = new UUID(im.binaryBucket, 1);
182
183 m_log.DebugFormat("[AGENT INVENTORY]: Inserting item {0} "+
184 "into agent {1}'s inventory",
185 itemID, new UUID(im.toAgentID));
186
187 InventoryItemBase itemCopy = scene.GiveInventoryItem(
188 new UUID(im.toAgentID),
189 client.AgentId, itemID);
190
191 if (itemCopy == null)
192 {
193 client.SendAgentAlertMessage("Can't find item to give. Nothing given.", false);
194 return;
195 }
196
197 copyID = itemCopy.ID;
198 Array.Copy(copyID.GetBytes(), 0, im.binaryBucket, 1, 16);
199
200 if (user != null && !user.IsChildAgent)
201 {
202 user.ControllingClient.SendBulkUpdateInventory(itemCopy);
203 }
204 }
205
206 // Send the IM to the recipient. The item is already
207 // in their inventory, so it will not be lost if
208 // they are offline.
209 //
210 if (user != null && !user.IsChildAgent)
211 {
212 // And notify. Transaction ID is the item ID. We get that
213 // same ID back on the reply so we know what to act on
214 //
215 user.ControllingClient.SendInstantMessage(
216 new UUID(im.fromAgentID), im.message,
217 new UUID(im.toAgentID),
218 im.fromAgentName, im.dialog, im.timestamp,
219 copyID, false, im.binaryBucket);
220
221 return;
222 }
223 else
224 {
225 if (m_TransferModule != null)
226 m_TransferModule.SendInstantMessage(im, delegate(bool success) {} );
227 }
228 }
229 else if (im.dialog == (byte) InstantMessageDialog.InventoryAccepted)
230 {
231 ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID));
232
233 if (user != null) // Local
234 {
235 user.ControllingClient.SendInstantMessage(
236 new UUID(im.fromAgentID), im.message,
237 new UUID(im.toAgentID),
238 im.fromAgentName, im.dialog, im.timestamp,
239 UUID.Zero, false, im.binaryBucket);
240 }
241 else
242 {
243 if (m_TransferModule != null)
244 m_TransferModule.SendInstantMessage(im, delegate(bool success) {} );
245 }
246 }
247 else if (im.dialog == (byte) InstantMessageDialog.InventoryDeclined)
248 {
249 // Here, the recipient is local and we can assume that the
250 // inventory is loaded. Courtesy of the above bulk update,
251 // It will have been pushed to the client, too
252 //
253
254 CachedUserInfo userInfo =
255 scene.CommsManager.UserProfileCacheService.
256 GetUserDetails(client.AgentId);
257
258 if (userInfo != null)
259 {
260 InventoryFolderImpl trashFolder =
261 userInfo.FindFolderForType((int)AssetType.TrashFolder);
262
263 UUID inventoryEntityID = new UUID(im.imSessionID); // The inventory item/folder, back from it's trip
264
265 InventoryItemBase item = userInfo.RootFolder.FindItem(inventoryEntityID);
266 InventoryFolderBase folder = null;
267
268 if (item != null && trashFolder != null)
269 {
270 item.Folder = trashFolder.ID;
271
272 userInfo.DeleteItem(inventoryEntityID);
273
274 scene.AddInventoryItem(client, item);
275 }
276 else
277 {
278 folder = userInfo.RootFolder.FindFolder(inventoryEntityID);
279
280 if (folder != null & trashFolder != null)
281 {
282 userInfo.MoveFolder(inventoryEntityID, trashFolder.ID);
283 }
284 }
285
286 if ((null == item && null == folder) | null == trashFolder)
287 {
288 string reason = String.Empty;
289
290 if (trashFolder == null)
291 reason += " Trash folder not found.";
292 if (item == null)
293 reason += " Item not found.";
294 if (folder == null)
295 reason += " Folder not found.";
296
297 client.SendAgentAlertMessage("Unable to delete "+
298 "received inventory" + reason, false);
299 }
300 }
301
302 ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID));
303
304 if (user != null) // Local
305 {
306 user.ControllingClient.SendInstantMessage(
307 new UUID(im.fromAgentID), im.message,
308 new UUID(im.toAgentID),
309 im.fromAgentName, im.dialog, im.timestamp,
310 UUID.Zero, false, im.binaryBucket);
311 }
312 else
313 {
314 if (m_TransferModule != null)
315 m_TransferModule.SendInstantMessage(im, delegate(bool success) {} );
316 }
317 }
318 }
319
320 public void SetRootAgentScene(UUID agentID, Scene scene)
321 {
322 m_AgentRegions[agentID] = scene;
323 }
324
325 public bool NeedSceneCacheClear(UUID agentID, Scene scene)
326 {
327 if (!m_AgentRegions.ContainsKey(agentID))
328 {
329 // Since we can get here two ways, we need to scan
330 // the scenes here. This is somewhat more expensive
331 // but helps avoid a nasty bug
332 //
333
334 foreach (Scene s in m_Scenelist)
335 {
336 ScenePresence presence;
337
338 if (s.TryGetAvatar(agentID, out presence))
339 {
340 // If the agent is in this scene, then we
341 // are being called twice in a single
342 // teleport. This is wasteful of cycles
343 // but harmless due to this 2nd level check
344 //
345 // If the agent is found in another scene
346 // then the list wasn't current
347 //
348 // If the agent is totally unknown, then what
349 // are we even doing here??
350 //
351 if (s == scene)
352 {
353 //m_log.Debug("[INVTRANSFERMOD]: s == scene. Returning true in " + scene.RegionInfo.RegionName);
354 return true;
355 }
356 else
357 {
358 //m_log.Debug("[INVTRANSFERMOD]: s != scene. Returning false in " + scene.RegionInfo.RegionName);
359 return false;
360 }
361 }
362 }
363 //m_log.Debug("[INVTRANSFERMOD]: agent not in scene. Returning true in " + scene.RegionInfo.RegionName);
364 return true;
365 }
366
367 // The agent is left in current Scene, so we must be
368 // going to another instance
369 //
370 if (m_AgentRegions[agentID] == scene)
371 {
372 //m_log.Debug("[INVTRANSFERMOD]: m_AgentRegions[agentID] == scene. Returning true in " + scene.RegionInfo.RegionName);
373 m_AgentRegions.Remove(agentID);
374 return true;
375 }
376
377 // Another region has claimed the agent
378 //
379 //m_log.Debug("[INVTRANSFERMOD]: last resort. Returning false in " + scene.RegionInfo.RegionName);
380 return false;
381 }
382
383 public void ClientLoggedOut(UUID agentID)
384 {
385 if (m_AgentRegions.ContainsKey(agentID))
386 m_AgentRegions.Remove(agentID);
387 }
388 }
389}