aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/Avatar/Inventory/InventoryModule.cs
diff options
context:
space:
mode:
authorJeff Ames2008-05-01 14:31:30 +0000
committerJeff Ames2008-05-01 14:31:30 +0000
commitd51ce47b2d7635b17f3dd429158e8f59b78b83aa (patch)
treed3595bd5194199184059aa398b91a51dc6c799cf /OpenSim/Region/Environment/Modules/Avatar/Inventory/InventoryModule.cs
parent* Looks like I had the bamboo build right in the first place - it was just th... (diff)
downloadopensim-SC_OLD-d51ce47b2d7635b17f3dd429158e8f59b78b83aa.zip
opensim-SC_OLD-d51ce47b2d7635b17f3dd429158e8f59b78b83aa.tar.gz
opensim-SC_OLD-d51ce47b2d7635b17f3dd429158e8f59b78b83aa.tar.bz2
opensim-SC_OLD-d51ce47b2d7635b17f3dd429158e8f59b78b83aa.tar.xz
Update svn properties. Minor formatting cleanup.
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Avatar/Inventory/InventoryModule.cs')
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Inventory/InventoryModule.cs438
1 files changed, 219 insertions, 219 deletions
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Inventory/InventoryModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Inventory/InventoryModule.cs
index 2844450..624f307 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/Inventory/InventoryModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/Inventory/InventoryModule.cs
@@ -1,220 +1,220 @@
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.Avatar.Inventory 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 /// <summary> 44 /// <summary>
45 /// 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
46 /// 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
47 /// IM Session Ids to ItemIds 47 /// IM Session Ids to ItemIds
48 /// </summary> 48 /// </summary>
49 private IDictionary<LLUUID, LLUUID> m_pendingOffers = new Dictionary<LLUUID, LLUUID>(); 49 private IDictionary<LLUUID, LLUUID> m_pendingOffers = new Dictionary<LLUUID, LLUUID>();
50 50
51 private Scene m_scene; 51 private Scene m_scene;
52 52
53 #region IRegionModule Members 53 #region IRegionModule Members
54 54
55 public void Initialise(Scene scene, IConfigSource config) 55 public void Initialise(Scene scene, IConfigSource config)
56 { 56 {
57 m_scene = scene; 57 m_scene = scene;
58 scene.EventManager.OnNewClient += OnNewClient; 58 scene.EventManager.OnNewClient += OnNewClient;
59 } 59 }
60 60
61 public void PostInitialise() 61 public void PostInitialise()
62 { 62 {
63 } 63 }
64 64
65 public void Close() 65 public void Close()
66 { 66 {
67 } 67 }
68 68
69 public string Name 69 public string Name
70 { 70 {
71 get { return "InventoryModule"; } 71 get { return "InventoryModule"; }
72 } 72 }
73 73
74 public bool IsSharedModule 74 public bool IsSharedModule
75 { 75 {
76 get { return false; } 76 get { return false; }
77 } 77 }
78 78
79 #endregion 79 #endregion
80 80
81 private void OnNewClient(IClientAPI client) 81 private void OnNewClient(IClientAPI client)
82 { 82 {
83 // Inventory giving is conducted via instant message 83 // Inventory giving is conducted via instant message
84 client.OnInstantMessage += OnInstantMessage; 84 client.OnInstantMessage += OnInstantMessage;
85 } 85 }
86 86
87 private void OnInstantMessage(IClientAPI client, LLUUID fromAgentID, 87 private void OnInstantMessage(IClientAPI client, LLUUID fromAgentID,
88 LLUUID fromAgentSession, LLUUID toAgentID, 88 LLUUID fromAgentSession, LLUUID toAgentID,
89 LLUUID imSessionID, uint timestamp, string fromAgentName, 89 LLUUID imSessionID, uint timestamp, string fromAgentName,
90 string message, byte dialog, bool fromGroup, byte offline, 90 string message, byte dialog, bool fromGroup, byte offline,
91 uint ParentEstateID, LLVector3 Position, LLUUID RegionID, 91 uint ParentEstateID, LLVector3 Position, LLUUID RegionID,
92 byte[] binaryBucket) 92 byte[] binaryBucket)
93 { 93 {
94 if (dialog == (byte) InstantMessageDialog.InventoryOffered) 94 if (dialog == (byte) InstantMessageDialog.InventoryOffered)
95 { 95 {
96 m_log.DebugFormat( 96 m_log.DebugFormat(
97 "[AGENT INVENTORY]: Routing inventory offering message from {0}, {1} to {2}", 97 "[AGENT INVENTORY]: Routing inventory offering message from {0}, {1} to {2}",
98 client.AgentId, client.Name, toAgentID); 98 client.AgentId, client.Name, toAgentID);
99 99
100 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)
101 { 101 {
102 ScenePresence user = (ScenePresence) m_scene.Entities[toAgentID]; 102 ScenePresence user = (ScenePresence) m_scene.Entities[toAgentID];
103 103
104 if (!user.IsChildAgent) 104 if (!user.IsChildAgent)
105 { 105 {
106 //byte[] rawId = new byte[16]; 106 //byte[] rawId = new byte[16];
107 107
108 // First byte of the array is probably the item type 108 // First byte of the array is probably the item type
109 // Next 16 bytes are the UUID 109 // Next 16 bytes are the UUID
110 //Array.Copy(binaryBucket, 1, rawId, 0, 16); 110 //Array.Copy(binaryBucket, 1, rawId, 0, 16);
111 111
112 //LLUUID itemId = new LLUUID(new Guid(rawId)); 112 //LLUUID itemId = new LLUUID(new Guid(rawId));
113 LLUUID itemId = new LLUUID(binaryBucket, 1); 113 LLUUID itemId = new LLUUID(binaryBucket, 1);
114 114
115 m_log.DebugFormat( 115 m_log.DebugFormat(
116 "[AGENT INVENTORY]: ItemId for giving is {0}", itemId); 116 "[AGENT INVENTORY]: ItemId for giving is {0}", itemId);
117 117
118 m_pendingOffers[imSessionID] = itemId; 118 m_pendingOffers[imSessionID] = itemId;
119 119
120 user.ControllingClient.SendInstantMessage( 120 user.ControllingClient.SendInstantMessage(
121 fromAgentID, fromAgentSession, message, toAgentID, imSessionID, fromAgentName, 121 fromAgentID, fromAgentSession, message, toAgentID, imSessionID, fromAgentName,
122 dialog, timestamp, binaryBucket); 122 dialog, timestamp, binaryBucket);
123 123
124 return; 124 return;
125 } 125 }
126 else 126 else
127 { 127 {
128 m_log.WarnFormat( 128 m_log.WarnFormat(
129 "[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!",
130 toAgentID, client.AgentId, client.Name, message); 130 toAgentID, client.AgentId, client.Name, message);
131 } 131 }
132 } 132 }
133 else 133 else
134 { 134 {
135 m_log.WarnFormat( 135 m_log.WarnFormat(
136 "[AGENT INVENTORY]: Could not find agent {0} for user {1}, {2} to give {3}", 136 "[AGENT INVENTORY]: Could not find agent {0} for user {1}, {2} to give {3}",
137 toAgentID, client.AgentId, client.Name, message); 137 toAgentID, client.AgentId, client.Name, message);
138 } 138 }
139 } 139 }
140 else if (dialog == (byte) InstantMessageDialog.InventoryAccepted) 140 else if (dialog == (byte) InstantMessageDialog.InventoryAccepted)
141 { 141 {
142 m_log.DebugFormat( 142 m_log.DebugFormat(
143 "[AGENT INVENTORY]: Routing inventory accepted message from {0}, {1} to {2}", 143 "[AGENT INVENTORY]: Routing inventory accepted message from {0}, {1} to {2}",
144 client.AgentId, client.Name, toAgentID); 144 client.AgentId, client.Name, toAgentID);
145 145
146 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)
147 { 147 {
148 ScenePresence user = (ScenePresence) m_scene.Entities[toAgentID]; 148 ScenePresence user = (ScenePresence) m_scene.Entities[toAgentID];
149 149
150 if (!user.IsChildAgent) 150 if (!user.IsChildAgent)
151 { 151 {
152 user.ControllingClient.SendInstantMessage( 152 user.ControllingClient.SendInstantMessage(
153 fromAgentID, fromAgentSession, message, toAgentID, imSessionID, fromAgentName, 153 fromAgentID, fromAgentSession, message, toAgentID, imSessionID, fromAgentName,
154 dialog, timestamp, binaryBucket); 154 dialog, timestamp, binaryBucket);
155 155
156 if (m_pendingOffers.ContainsKey(imSessionID)) 156 if (m_pendingOffers.ContainsKey(imSessionID))
157 { 157 {
158 m_log.DebugFormat( 158 m_log.DebugFormat(
159 "[AGENT INVENTORY]: Accepted item id {0}", m_pendingOffers[imSessionID]); 159 "[AGENT INVENTORY]: Accepted item id {0}", m_pendingOffers[imSessionID]);
160 160
161 // Since the message originates from the accepting client, the toAgentID is 161 // Since the message originates from the accepting client, the toAgentID is
162 // the agent giving the item. 162 // the agent giving the item.
163 m_scene.GiveInventoryItem(client, toAgentID, m_pendingOffers[imSessionID]); 163 m_scene.GiveInventoryItem(client, toAgentID, m_pendingOffers[imSessionID]);
164 164
165 m_pendingOffers.Remove(imSessionID); 165 m_pendingOffers.Remove(imSessionID);
166 } 166 }
167 else 167 else
168 { 168 {
169 m_log.ErrorFormat( 169 m_log.ErrorFormat(
170 "[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",
171 imSessionID); 171 imSessionID);
172 } 172 }
173 173
174 return; 174 return;
175 } 175 }
176 else 176 else
177 { 177 {
178 m_log.WarnFormat( 178 m_log.WarnFormat(
179 "[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!",
180 toAgentID, client.AgentId, client.Name, message); 180 toAgentID, client.AgentId, client.Name, message);
181 } 181 }
182 } 182 }
183 else 183 else
184 { 184 {
185 m_log.WarnFormat( 185 m_log.WarnFormat(
186 "[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}",
187 toAgentID, client.AgentId, client.Name, message); 187 toAgentID, client.AgentId, client.Name, message);
188 } 188 }
189 } 189 }
190 else if (dialog == (byte) InstantMessageDialog.InventoryDeclined) 190 else if (dialog == (byte) InstantMessageDialog.InventoryDeclined)
191 { 191 {
192 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)
193 { 193 {
194 ScenePresence user = (ScenePresence) m_scene.Entities[toAgentID]; 194 ScenePresence user = (ScenePresence) m_scene.Entities[toAgentID];
195 195
196 if (!user.IsChildAgent) 196 if (!user.IsChildAgent)
197 { 197 {
198 user.ControllingClient.SendInstantMessage( 198 user.ControllingClient.SendInstantMessage(
199 fromAgentID, fromAgentSession, message, toAgentID, imSessionID, fromAgentName, 199 fromAgentID, fromAgentSession, message, toAgentID, imSessionID, fromAgentName,
200 dialog, timestamp, binaryBucket); 200 dialog, timestamp, binaryBucket);
201 201
202 if (m_pendingOffers.ContainsKey(imSessionID)) 202 if (m_pendingOffers.ContainsKey(imSessionID))
203 { 203 {
204 m_log.DebugFormat( 204 m_log.DebugFormat(
205 "[AGENT INVENTORY]: Declined item id {0}", m_pendingOffers[imSessionID]); 205 "[AGENT INVENTORY]: Declined item id {0}", m_pendingOffers[imSessionID]);
206 206
207 m_pendingOffers.Remove(imSessionID); 207 m_pendingOffers.Remove(imSessionID);
208 } 208 }
209 else 209 else
210 { 210 {
211 m_log.ErrorFormat( 211 m_log.ErrorFormat(
212 "[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",
213 imSessionID); 213 imSessionID);
214 } 214 }
215 } 215 }
216 } 216 }
217 } 217 }
218 } 218 }
219 } 219 }
220} \ No newline at end of file 220} \ No newline at end of file