aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/Avatar/Inventory/InventoryModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Avatar/Inventory/InventoryModule.cs')
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Inventory/InventoryModule.cs104
1 files changed, 54 insertions, 50 deletions
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Inventory/InventoryModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Inventory/InventoryModule.cs
index 42c6238..2844450 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/Inventory/InventoryModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/Inventory/InventoryModule.cs
@@ -38,11 +38,9 @@ namespace 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;
45
46 /// <summary> 44 /// <summary>
47 /// We need to keep track of the pending item offers between clients since the itemId offered only 45 /// 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 46 /// occurs in the initial offer message, not the accept message. So this dictionary links
@@ -50,10 +48,14 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory
50 /// </summary> 48 /// </summary>
51 private IDictionary<LLUUID, LLUUID> m_pendingOffers = new Dictionary<LLUUID, LLUUID>(); 49 private IDictionary<LLUUID, LLUUID> m_pendingOffers = new Dictionary<LLUUID, LLUUID>();
52 50
51 private Scene m_scene;
52
53 #region IRegionModule Members
54
53 public void Initialise(Scene scene, IConfigSource config) 55 public void Initialise(Scene scene, IConfigSource config)
54 { 56 {
55 m_scene = scene; 57 m_scene = scene;
56 scene.EventManager.OnNewClient += OnNewClient; 58 scene.EventManager.OnNewClient += OnNewClient;
57 } 59 }
58 60
59 public void PostInitialise() 61 public void PostInitialise()
@@ -73,59 +75,61 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory
73 { 75 {
74 get { return false; } 76 get { return false; }
75 } 77 }
76 78
79 #endregion
80
77 private void OnNewClient(IClientAPI client) 81 private void OnNewClient(IClientAPI client)
78 { 82 {
79 // Inventory giving is conducted via instant message 83 // Inventory giving is conducted via instant message
80 client.OnInstantMessage += OnInstantMessage; 84 client.OnInstantMessage += OnInstantMessage;
81 } 85 }
82 86
83 private void OnInstantMessage(IClientAPI client, LLUUID fromAgentID, 87 private void OnInstantMessage(IClientAPI client, LLUUID fromAgentID,
84 LLUUID fromAgentSession, LLUUID toAgentID, 88 LLUUID fromAgentSession, LLUUID toAgentID,
85 LLUUID imSessionID, uint timestamp, string fromAgentName, 89 LLUUID imSessionID, uint timestamp, string fromAgentName,
86 string message, byte dialog, bool fromGroup, byte offline, 90 string message, byte dialog, bool fromGroup, byte offline,
87 uint ParentEstateID, LLVector3 Position, LLUUID RegionID, 91 uint ParentEstateID, LLVector3 Position, LLUUID RegionID,
88 byte[] binaryBucket) 92 byte[] binaryBucket)
89 { 93 {
90 if (dialog == (byte)InstantMessageDialog.InventoryOffered) 94 if (dialog == (byte) InstantMessageDialog.InventoryOffered)
91 { 95 {
92 m_log.DebugFormat( 96 m_log.DebugFormat(
93 "[AGENT INVENTORY]: Routing inventory offering message from {0}, {1} to {2}", 97 "[AGENT INVENTORY]: Routing inventory offering message from {0}, {1} to {2}",
94 client.AgentId, client.Name, toAgentID); 98 client.AgentId, client.Name, toAgentID);
95 99
96 if (m_scene.Entities.ContainsKey(toAgentID) && m_scene.Entities[toAgentID] is ScenePresence) 100 if (m_scene.Entities.ContainsKey(toAgentID) && m_scene.Entities[toAgentID] is ScenePresence)
97 { 101 {
98 ScenePresence user = (ScenePresence)m_scene.Entities[toAgentID]; 102 ScenePresence user = (ScenePresence) m_scene.Entities[toAgentID];
99 103
100 if (!user.IsChildAgent) 104 if (!user.IsChildAgent)
101 { 105 {
102 //byte[] rawId = new byte[16]; 106 //byte[] rawId = new byte[16];
103 107
104 // First byte of the array is probably the item type 108 // First byte of the array is probably the item type
105 // Next 16 bytes are the UUID 109 // Next 16 bytes are the UUID
106 //Array.Copy(binaryBucket, 1, rawId, 0, 16); 110 //Array.Copy(binaryBucket, 1, rawId, 0, 16);
107 111
108 //LLUUID itemId = new LLUUID(new Guid(rawId)); 112 //LLUUID itemId = new LLUUID(new Guid(rawId));
109 LLUUID itemId = new LLUUID(binaryBucket, 1); 113 LLUUID itemId = new LLUUID(binaryBucket, 1);
110 114
111 m_log.DebugFormat( 115 m_log.DebugFormat(
112 "[AGENT INVENTORY]: ItemId for giving is {0}", itemId); 116 "[AGENT INVENTORY]: ItemId for giving is {0}", itemId);
113 117
114 m_pendingOffers[imSessionID] = itemId; 118 m_pendingOffers[imSessionID] = itemId;
115 119
116 user.ControllingClient.SendInstantMessage( 120 user.ControllingClient.SendInstantMessage(
117 fromAgentID, fromAgentSession, message, toAgentID, imSessionID, fromAgentName, 121 fromAgentID, fromAgentSession, message, toAgentID, imSessionID, fromAgentName,
118 dialog, timestamp, binaryBucket); 122 dialog, timestamp, binaryBucket);
119 123
120 return; 124 return;
121 } 125 }
122 else 126 else
123 { 127 {
124 m_log.WarnFormat( 128 m_log.WarnFormat(
125 "[AGENT INVENTORY]: Agent {0} targeted for inventory give by {1}, {2} of {3} was a child agent!", 129 "[AGENT INVENTORY]: Agent {0} targeted for inventory give by {1}, {2} of {3} was a child agent!",
126 toAgentID, client.AgentId, client.Name, message); 130 toAgentID, client.AgentId, client.Name, message);
127 } 131 }
128 } 132 }
129 else 133 else
130 { 134 {
131 m_log.WarnFormat( 135 m_log.WarnFormat(
@@ -133,84 +137,84 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Inventory
133 toAgentID, client.AgentId, client.Name, message); 137 toAgentID, client.AgentId, client.Name, message);
134 } 138 }
135 } 139 }
136 else if (dialog == (byte)InstantMessageDialog.InventoryAccepted) 140 else if (dialog == (byte) InstantMessageDialog.InventoryAccepted)
137 { 141 {
138 m_log.DebugFormat( 142 m_log.DebugFormat(
139 "[AGENT INVENTORY]: Routing inventory accepted message from {0}, {1} to {2}", 143 "[AGENT INVENTORY]: Routing inventory accepted message from {0}, {1} to {2}",
140 client.AgentId, client.Name, toAgentID); 144 client.AgentId, client.Name, toAgentID);
141 145
142 if (m_scene.Entities.ContainsKey(toAgentID) && m_scene.Entities[toAgentID] is ScenePresence) 146 if (m_scene.Entities.ContainsKey(toAgentID) && m_scene.Entities[toAgentID] is ScenePresence)
143 { 147 {
144 ScenePresence user = (ScenePresence)m_scene.Entities[toAgentID]; 148 ScenePresence user = (ScenePresence) m_scene.Entities[toAgentID];
145 149
146 if (!user.IsChildAgent) 150 if (!user.IsChildAgent)
147 { 151 {
148 user.ControllingClient.SendInstantMessage( 152 user.ControllingClient.SendInstantMessage(
149 fromAgentID, fromAgentSession, message, toAgentID, imSessionID, fromAgentName, 153 fromAgentID, fromAgentSession, message, toAgentID, imSessionID, fromAgentName,
150 dialog, timestamp, binaryBucket); 154 dialog, timestamp, binaryBucket);
151 155
152 if (m_pendingOffers.ContainsKey(imSessionID)) 156 if (m_pendingOffers.ContainsKey(imSessionID))
153 { 157 {
154 m_log.DebugFormat( 158 m_log.DebugFormat(
155 "[AGENT INVENTORY]: Accepted item id {0}", m_pendingOffers[imSessionID]); 159 "[AGENT INVENTORY]: Accepted item id {0}", m_pendingOffers[imSessionID]);
156 160
157 // Since the message originates from the accepting client, the toAgentID is 161 // Since the message originates from the accepting client, the toAgentID is
158 // the agent giving the item. 162 // the agent giving the item.
159 m_scene.GiveInventoryItem(client, toAgentID, m_pendingOffers[imSessionID]); 163 m_scene.GiveInventoryItem(client, toAgentID, m_pendingOffers[imSessionID]);
160 164
161 m_pendingOffers.Remove(imSessionID); 165 m_pendingOffers.Remove(imSessionID);
162 } 166 }
163 else 167 else
164 { 168 {
165 m_log.ErrorFormat( 169 m_log.ErrorFormat(
166 "[AGENT INVENTORY]: Could not find an item associated with session id {0} to accept", 170 "[AGENT INVENTORY]: Could not find an item associated with session id {0} to accept",
167 imSessionID); 171 imSessionID);
168 } 172 }
169 173
170 return; 174 return;
171 } 175 }
172 else 176 else
173 { 177 {
174 m_log.WarnFormat( 178 m_log.WarnFormat(
175 "[AGENT INVENTORY]: Agent {0} targeted for inventory give by {1}, {2} of {3} was a child agent!", 179 "[AGENT INVENTORY]: Agent {0} targeted for inventory give by {1}, {2} of {3} was a child agent!",
176 toAgentID, client.AgentId, client.Name, message); 180 toAgentID, client.AgentId, client.Name, message);
177 } 181 }
178 } 182 }
179 else 183 else
180 { 184 {
181 m_log.WarnFormat( 185 m_log.WarnFormat(
182 "[AGENT INVENTORY]: Could not find agent {0} for user {1}, {2} to give {3}", 186 "[AGENT INVENTORY]: Could not find agent {0} for user {1}, {2} to give {3}",
183 toAgentID, client.AgentId, client.Name, message); 187 toAgentID, client.AgentId, client.Name, message);
184 } 188 }
185 } 189 }
186 else if (dialog == (byte)InstantMessageDialog.InventoryDeclined) 190 else if (dialog == (byte) InstantMessageDialog.InventoryDeclined)
187 { 191 {
188 if (m_scene.Entities.ContainsKey(toAgentID) && m_scene.Entities[toAgentID] is ScenePresence) 192 if (m_scene.Entities.ContainsKey(toAgentID) && m_scene.Entities[toAgentID] is ScenePresence)
189 { 193 {
190 ScenePresence user = (ScenePresence)m_scene.Entities[toAgentID]; 194 ScenePresence user = (ScenePresence) m_scene.Entities[toAgentID];
191 195
192 if (!user.IsChildAgent) 196 if (!user.IsChildAgent)
193 { 197 {
194 user.ControllingClient.SendInstantMessage( 198 user.ControllingClient.SendInstantMessage(
195 fromAgentID, fromAgentSession, message, toAgentID, imSessionID, fromAgentName, 199 fromAgentID, fromAgentSession, message, toAgentID, imSessionID, fromAgentName,
196 dialog, timestamp, binaryBucket); 200 dialog, timestamp, binaryBucket);
197 201
198 if (m_pendingOffers.ContainsKey(imSessionID)) 202 if (m_pendingOffers.ContainsKey(imSessionID))
199 { 203 {
200 m_log.DebugFormat( 204 m_log.DebugFormat(
201 "[AGENT INVENTORY]: Declined item id {0}", m_pendingOffers[imSessionID]); 205 "[AGENT INVENTORY]: Declined item id {0}", m_pendingOffers[imSessionID]);
202 206
203 m_pendingOffers.Remove(imSessionID); 207 m_pendingOffers.Remove(imSessionID);
204 } 208 }
205 else 209 else
206 { 210 {
207 m_log.ErrorFormat( 211 m_log.ErrorFormat(
208 "[AGENT INVENTORY]: Could not find an item associated with session id {0} to decline", 212 "[AGENT INVENTORY]: Could not find an item associated with session id {0} to decline",
209 imSessionID); 213 imSessionID);
210 } 214 }
211 } 215 }
212 } 216 }
213 } 217 }
214 } 218 }
215 } 219 }
216} \ No newline at end of file 220} \ No newline at end of file