aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/Avatar/Inventory
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Inventory/InventoryModule.cs (renamed from OpenSim/Region/Environment/Modules/InventoryModule.cs)432
1 files changed, 216 insertions, 216 deletions
diff --git a/OpenSim/Region/Environment/Modules/InventoryModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Inventory/InventoryModule.cs
index ff5a02c..42c6238 100644
--- a/OpenSim/Region/Environment/Modules/InventoryModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/Inventory/InventoryModule.cs
@@ -1,216 +1,216 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the 12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 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 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 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 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. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System.Collections.Generic; 28using System.Collections.Generic;
29using System.Reflection; 29using System.Reflection;
30using libsecondlife; 30using libsecondlife;
31using log4net; 31using log4net;
32using Nini.Config; 32using Nini.Config;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Region.Environment.Interfaces; 34using OpenSim.Region.Environment.Interfaces;
35using OpenSim.Region.Environment.Scenes; 35using OpenSim.Region.Environment.Scenes;
36 36
37namespace OpenSim.Region.Environment.Modules 37namespace OpenSim.Region.Environment.Modules.Avatar.Inventory
38{ 38{
39 public class InventoryModule : IRegionModule 39 public class InventoryModule : IRegionModule
40 { 40 {
41 private static readonly ILog m_log 41 private static readonly ILog m_log
42 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 42 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43 43
44 private Scene m_scene; 44 private Scene m_scene;
45 45
46 /// <summary> 46 /// <summary>
47 /// We need to keep track of the pending item offers between clients since the itemId offered only 47 /// We need to keep track of the pending item offers between clients since the itemId offered only
48 /// occurs in the initial offer message, not the accept message. So this dictionary links 48 /// occurs in the initial offer message, not the accept message. So this dictionary links
49 /// IM Session Ids to ItemIds 49 /// IM Session Ids to ItemIds
50 /// </summary> 50 /// </summary>
51 private IDictionary<LLUUID, LLUUID> m_pendingOffers = new Dictionary<LLUUID, LLUUID>(); 51 private IDictionary<LLUUID, LLUUID> m_pendingOffers = new Dictionary<LLUUID, LLUUID>();
52 52
53 public void Initialise(Scene scene, IConfigSource config) 53 public void Initialise(Scene scene, IConfigSource config)
54 { 54 {
55 m_scene = scene; 55 m_scene = scene;
56 scene.EventManager.OnNewClient += OnNewClient; 56 scene.EventManager.OnNewClient += OnNewClient;
57 } 57 }
58 58
59 public void PostInitialise() 59 public void PostInitialise()
60 { 60 {
61 } 61 }
62 62
63 public void Close() 63 public void Close()
64 { 64 {
65 } 65 }
66 66
67 public string Name 67 public string Name
68 { 68 {
69 get { return "InventoryModule"; } 69 get { return "InventoryModule"; }
70 } 70 }
71 71
72 public bool IsSharedModule 72 public bool IsSharedModule
73 { 73 {
74 get { return false; } 74 get { return false; }
75 } 75 }
76 76
77 private void OnNewClient(IClientAPI client) 77 private void OnNewClient(IClientAPI client)
78 { 78 {
79 // Inventory giving is conducted via instant message 79 // Inventory giving is conducted via instant message
80 client.OnInstantMessage += OnInstantMessage; 80 client.OnInstantMessage += OnInstantMessage;
81 } 81 }
82 82
83 private void OnInstantMessage(IClientAPI client, LLUUID fromAgentID, 83 private void OnInstantMessage(IClientAPI client, LLUUID fromAgentID,
84 LLUUID fromAgentSession, LLUUID toAgentID, 84 LLUUID fromAgentSession, LLUUID toAgentID,
85 LLUUID imSessionID, uint timestamp, string fromAgentName, 85 LLUUID imSessionID, uint timestamp, string fromAgentName,
86 string message, byte dialog, bool fromGroup, byte offline, 86 string message, byte dialog, bool fromGroup, byte offline,
87 uint ParentEstateID, LLVector3 Position, LLUUID RegionID, 87 uint ParentEstateID, LLVector3 Position, LLUUID RegionID,
88 byte[] binaryBucket) 88 byte[] binaryBucket)
89 { 89 {
90 if (dialog == (byte)InstantMessageDialog.InventoryOffered) 90 if (dialog == (byte)InstantMessageDialog.InventoryOffered)
91 { 91 {
92 m_log.DebugFormat( 92 m_log.DebugFormat(
93 "[AGENT INVENTORY]: Routing inventory offering message from {0}, {1} to {2}", 93 "[AGENT INVENTORY]: Routing inventory offering message from {0}, {1} to {2}",
94 client.AgentId, client.Name, toAgentID); 94 client.AgentId, client.Name, toAgentID);
95 95
96 if (m_scene.Entities.ContainsKey(toAgentID) && m_scene.Entities[toAgentID] is ScenePresence) 96 if (m_scene.Entities.ContainsKey(toAgentID) && m_scene.Entities[toAgentID] is ScenePresence)
97 { 97 {
98 ScenePresence user = (ScenePresence)m_scene.Entities[toAgentID]; 98 ScenePresence user = (ScenePresence)m_scene.Entities[toAgentID];
99 99
100 if (!user.IsChildAgent) 100 if (!user.IsChildAgent)
101 { 101 {
102 //byte[] rawId = new byte[16]; 102 //byte[] rawId = new byte[16];
103 103
104 // First byte of the array is probably the item type 104 // First byte of the array is probably the item type
105 // Next 16 bytes are the UUID 105 // Next 16 bytes are the UUID
106 //Array.Copy(binaryBucket, 1, rawId, 0, 16); 106 //Array.Copy(binaryBucket, 1, rawId, 0, 16);
107 107
108 //LLUUID itemId = new LLUUID(new Guid(rawId)); 108 //LLUUID itemId = new LLUUID(new Guid(rawId));
109 LLUUID itemId = new LLUUID(binaryBucket, 1); 109 LLUUID itemId = new LLUUID(binaryBucket, 1);
110 110
111 m_log.DebugFormat( 111 m_log.DebugFormat(
112 "[AGENT INVENTORY]: ItemId for giving is {0}", itemId); 112 "[AGENT INVENTORY]: ItemId for giving is {0}", itemId);
113 113
114 m_pendingOffers[imSessionID] = itemId; 114 m_pendingOffers[imSessionID] = itemId;
115 115
116 user.ControllingClient.SendInstantMessage( 116 user.ControllingClient.SendInstantMessage(
117 fromAgentID, fromAgentSession, message, toAgentID, imSessionID, fromAgentName, 117 fromAgentID, fromAgentSession, message, toAgentID, imSessionID, fromAgentName,
118 dialog, timestamp, binaryBucket); 118 dialog, timestamp, binaryBucket);
119 119
120 return; 120 return;
121 } 121 }
122 else 122 else
123 { 123 {
124 m_log.WarnFormat( 124 m_log.WarnFormat(
125 "[AGENT INVENTORY]: Agent {0} targeted for inventory give by {1}, {2} of {3} was a child agent!", 125 "[AGENT INVENTORY]: Agent {0} targeted for inventory give by {1}, {2} of {3} was a child agent!",
126 toAgentID, client.AgentId, client.Name, message); 126 toAgentID, client.AgentId, client.Name, message);
127 } 127 }
128 } 128 }
129 else 129 else
130 { 130 {
131 m_log.WarnFormat( 131 m_log.WarnFormat(
132 "[AGENT INVENTORY]: Could not find agent {0} for user {1}, {2} to give {3}", 132 "[AGENT INVENTORY]: Could not find agent {0} for user {1}, {2} to give {3}",
133 toAgentID, client.AgentId, client.Name, message); 133 toAgentID, client.AgentId, client.Name, message);
134 } 134 }
135 } 135 }
136 else if (dialog == (byte)InstantMessageDialog.InventoryAccepted) 136 else if (dialog == (byte)InstantMessageDialog.InventoryAccepted)
137 { 137 {
138 m_log.DebugFormat( 138 m_log.DebugFormat(
139 "[AGENT INVENTORY]: Routing inventory accepted message from {0}, {1} to {2}", 139 "[AGENT INVENTORY]: Routing inventory accepted message from {0}, {1} to {2}",
140 client.AgentId, client.Name, toAgentID); 140 client.AgentId, client.Name, toAgentID);
141 141
142 if (m_scene.Entities.ContainsKey(toAgentID) && m_scene.Entities[toAgentID] is ScenePresence) 142 if (m_scene.Entities.ContainsKey(toAgentID) && m_scene.Entities[toAgentID] is ScenePresence)
143 { 143 {
144 ScenePresence user = (ScenePresence)m_scene.Entities[toAgentID]; 144 ScenePresence user = (ScenePresence)m_scene.Entities[toAgentID];
145 145
146 if (!user.IsChildAgent) 146 if (!user.IsChildAgent)
147 { 147 {
148 user.ControllingClient.SendInstantMessage( 148 user.ControllingClient.SendInstantMessage(
149 fromAgentID, fromAgentSession, message, toAgentID, imSessionID, fromAgentName, 149 fromAgentID, fromAgentSession, message, toAgentID, imSessionID, fromAgentName,
150 dialog, timestamp, binaryBucket); 150 dialog, timestamp, binaryBucket);
151 151
152 if (m_pendingOffers.ContainsKey(imSessionID)) 152 if (m_pendingOffers.ContainsKey(imSessionID))
153 { 153 {
154 m_log.DebugFormat( 154 m_log.DebugFormat(
155 "[AGENT INVENTORY]: Accepted item id {0}", m_pendingOffers[imSessionID]); 155 "[AGENT INVENTORY]: Accepted item id {0}", m_pendingOffers[imSessionID]);
156 156
157 // Since the message originates from the accepting client, the toAgentID is 157 // Since the message originates from the accepting client, the toAgentID is
158 // the agent giving the item. 158 // the agent giving the item.
159 m_scene.GiveInventoryItem(client, toAgentID, m_pendingOffers[imSessionID]); 159 m_scene.GiveInventoryItem(client, toAgentID, m_pendingOffers[imSessionID]);
160 160
161 m_pendingOffers.Remove(imSessionID); 161 m_pendingOffers.Remove(imSessionID);
162 } 162 }
163 else 163 else
164 { 164 {
165 m_log.ErrorFormat( 165 m_log.ErrorFormat(
166 "[AGENT INVENTORY]: Could not find an item associated with session id {0} to accept", 166 "[AGENT INVENTORY]: Could not find an item associated with session id {0} to accept",
167 imSessionID); 167 imSessionID);
168 } 168 }
169 169
170 return; 170 return;
171 } 171 }
172 else 172 else
173 { 173 {
174 m_log.WarnFormat( 174 m_log.WarnFormat(
175 "[AGENT INVENTORY]: Agent {0} targeted for inventory give by {1}, {2} of {3} was a child agent!", 175 "[AGENT INVENTORY]: Agent {0} targeted for inventory give by {1}, {2} of {3} was a child agent!",
176 toAgentID, client.AgentId, client.Name, message); 176 toAgentID, client.AgentId, client.Name, message);
177 } 177 }
178 } 178 }
179 else 179 else
180 { 180 {
181 m_log.WarnFormat( 181 m_log.WarnFormat(
182 "[AGENT INVENTORY]: Could not find agent {0} for user {1}, {2} to give {3}", 182 "[AGENT INVENTORY]: Could not find agent {0} for user {1}, {2} to give {3}",
183 toAgentID, client.AgentId, client.Name, message); 183 toAgentID, client.AgentId, client.Name, message);
184 } 184 }
185 } 185 }
186 else if (dialog == (byte)InstantMessageDialog.InventoryDeclined) 186 else if (dialog == (byte)InstantMessageDialog.InventoryDeclined)
187 { 187 {
188 if (m_scene.Entities.ContainsKey(toAgentID) && m_scene.Entities[toAgentID] is ScenePresence) 188 if (m_scene.Entities.ContainsKey(toAgentID) && m_scene.Entities[toAgentID] is ScenePresence)
189 { 189 {
190 ScenePresence user = (ScenePresence)m_scene.Entities[toAgentID]; 190 ScenePresence user = (ScenePresence)m_scene.Entities[toAgentID];
191 191
192 if (!user.IsChildAgent) 192 if (!user.IsChildAgent)
193 { 193 {
194 user.ControllingClient.SendInstantMessage( 194 user.ControllingClient.SendInstantMessage(
195 fromAgentID, fromAgentSession, message, toAgentID, imSessionID, fromAgentName, 195 fromAgentID, fromAgentSession, message, toAgentID, imSessionID, fromAgentName,
196 dialog, timestamp, binaryBucket); 196 dialog, timestamp, binaryBucket);
197 197
198 if (m_pendingOffers.ContainsKey(imSessionID)) 198 if (m_pendingOffers.ContainsKey(imSessionID))
199 { 199 {
200 m_log.DebugFormat( 200 m_log.DebugFormat(
201 "[AGENT INVENTORY]: Declined item id {0}", m_pendingOffers[imSessionID]); 201 "[AGENT INVENTORY]: Declined item id {0}", m_pendingOffers[imSessionID]);
202 202
203 m_pendingOffers.Remove(imSessionID); 203 m_pendingOffers.Remove(imSessionID);
204 } 204 }
205 else 205 else
206 { 206 {
207 m_log.ErrorFormat( 207 m_log.ErrorFormat(
208 "[AGENT INVENTORY]: Could not find an item associated with session id {0} to decline", 208 "[AGENT INVENTORY]: Could not find an item associated with session id {0} to decline",
209 imSessionID); 209 imSessionID);
210 } 210 }
211 } 211 }
212 } 212 }
213 } 213 }
214 } 214 }
215 } 215 }
216} 216} \ No newline at end of file