aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules
diff options
context:
space:
mode:
authorAdam Frisby2008-04-30 21:43:47 +0000
committerAdam Frisby2008-04-30 21:43:47 +0000
commitbe20f41637b6c06ce3ab16bc25851b6e43468e12 (patch)
treec41081329891f4c24de704fc760fb9012954ac9d /OpenSim/Region/Environment/Modules
parent* Sometimes you know, you do something really stupid. (diff)
downloadopensim-SC-be20f41637b6c06ce3ab16bc25851b6e43468e12.zip
opensim-SC-be20f41637b6c06ce3ab16bc25851b6e43468e12.tar.gz
opensim-SC-be20f41637b6c06ce3ab16bc25851b6e43468e12.tar.bz2
opensim-SC-be20f41637b6c06ce3ab16bc25851b6e43468e12.tar.xz
* Cruft removal step #1. Cleaning Modules directory.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Environment/Modules/Agent/AssetDownload/AssetDownloadModule.cs37
-rw-r--r--OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs83
-rw-r--r--OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs55
-rw-r--r--OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureDownloadModule.cs66
-rw-r--r--OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureNotFoundSender.cs51
-rw-r--r--OpenSim/Region/Environment/Modules/Agent/TextureDownload/UserTextureDownloadService.cs85
-rw-r--r--OpenSim/Region/Environment/Modules/Agent/TextureSender/TextureSender.cs91
-rw-r--r--OpenSim/Region/Environment/Modules/Agent/Xfer/XferModule.cs68
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Chat/ChatModule.cs349
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs1171
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs165
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Groups/GroupsModule.cs111
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/InstantMessage/InstantMessageModule.cs75
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Inventory/InventoryModule.cs104
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Profiles/AvatarProfilesModule.cs6
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Voice/AsterixVoice/AsteriskVoiceModule.cs81
-rw-r--r--OpenSim/Region/Environment/Modules/Avatar/Voice/SIPVoice/SIPVoiceModule.cs47
-rw-r--r--OpenSim/Region/Environment/Modules/Framework/CommanderTestModule.cs27
-rw-r--r--OpenSim/Region/Environment/Modules/Grid/Interregion/InterregionModule.cs137
-rw-r--r--OpenSim/Region/Environment/Modules/Scripting/DynamicTexture/DynamicTextureModule.cs82
-rw-r--r--OpenSim/Region/Environment/Modules/Scripting/HttpRequest/ScriptsHttpRequests.cs94
-rw-r--r--OpenSim/Region/Environment/Modules/Scripting/LoadImageURL/LoadImageURLModule.cs82
-rw-r--r--OpenSim/Region/Environment/Modules/Scripting/VectorRender/VectorRenderModule.cs132
-rw-r--r--OpenSim/Region/Environment/Modules/Scripting/WorldComm/WorldCommModule.cs79
-rw-r--r--OpenSim/Region/Environment/Modules/Scripting/XMLRPC/XMLRPCModule.cs214
-rw-r--r--OpenSim/Region/Environment/Modules/World/Land/LandChannel.cs364
-rw-r--r--OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs11
-rw-r--r--OpenSim/Region/Environment/Modules/World/Land/LandObject.cs227
-rw-r--r--OpenSim/Region/Environment/Modules/World/Serialiser/SerialiseObjects.cs2
-rw-r--r--OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs20
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GIF.cs1
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/PNG.cs1
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/TIFF.cs1
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs7
-rw-r--r--OpenSim/Region/Environment/Modules/World/TreePopulator/TreePopulatorModule.cs83
35 files changed, 2149 insertions, 2060 deletions
diff --git a/OpenSim/Region/Environment/Modules/Agent/AssetDownload/AssetDownloadModule.cs b/OpenSim/Region/Environment/Modules/Agent/AssetDownload/AssetDownloadModule.cs
index 47c1479..33e917a 100644
--- a/OpenSim/Region/Environment/Modules/Agent/AssetDownload/AssetDownloadModule.cs
+++ b/OpenSim/Region/Environment/Modules/Agent/AssetDownload/AssetDownloadModule.cs
@@ -37,17 +37,18 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetDownload
37{ 37{
38 public class AssetDownloadModule : IRegionModule 38 public class AssetDownloadModule : IRegionModule
39 { 39 {
40 /// <summary>
41 /// Asset requests with data which are ready to be sent back to requesters. This includes textures.
42 /// </summary>
43 private List<AssetRequest> AssetRequests;
44
40 private Scene m_scene; 45 private Scene m_scene;
41 private Dictionary<LLUUID, Scene> RegisteredScenes = new Dictionary<LLUUID, Scene>(); 46 private Dictionary<LLUUID, Scene> RegisteredScenes = new Dictionary<LLUUID, Scene>();
47
42 /// 48 ///
43 /// Assets requests (for each user) which are waiting for asset server data. This includes texture requests 49 /// Assets requests (for each user) which are waiting for asset server data. This includes texture requests
44 /// </summary> 50 /// </summary>
45 private Dictionary<LLUUID, Dictionary<LLUUID,AssetRequest>> RequestedAssets; 51 private Dictionary<LLUUID, Dictionary<LLUUID, AssetRequest>> RequestedAssets;
46
47 /// <summary>
48 /// Asset requests with data which are ready to be sent back to requesters. This includes textures.
49 /// </summary>
50 private List<AssetRequest> AssetRequests;
51 52
52 public AssetDownloadModule() 53 public AssetDownloadModule()
53 { 54 {
@@ -55,6 +56,8 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetDownload
55 AssetRequests = new List<AssetRequest>(); 56 AssetRequests = new List<AssetRequest>();
56 } 57 }
57 58
59 #region IRegionModule Members
60
58 public void Initialise(Scene scene, IConfigSource config) 61 public void Initialise(Scene scene, IConfigSource config)
59 { 62 {
60 if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID)) 63 if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID))
@@ -92,6 +95,8 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetDownload
92 get { return true; } 95 get { return true; }
93 } 96 }
94 97
98 #endregion
99
95 public void NewClient(IClientAPI client) 100 public void NewClient(IClientAPI client)
96 { 101 {
97 // client.OnRequestAsset += AddAssetRequest; 102 // client.OnRequestAsset += AddAssetRequest;
@@ -301,33 +306,37 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetDownload
301 { 306 {
302 // over max number of bytes so split up file 307 // over max number of bytes so split up file
303 long restData = data.LongLength - m_maxPacketSize; 308 long restData = data.LongLength - m_maxPacketSize;
304 int restPackets = (int)((restData + m_maxPacketSize - 1) / m_maxPacketSize); 309 int restPackets = (int) ((restData + m_maxPacketSize - 1) / m_maxPacketSize);
305 numPackets += restPackets; 310 numPackets += restPackets;
306 } 311 }
307 312
308 return numPackets; 313 return numPackets;
309 } 314 }
310 315
316 #region Nested type: AssetRequest
317
311 public class AssetRequest 318 public class AssetRequest
312 { 319 {
313 public IClientAPI RequestUser;
314 public LLUUID RequestAssetID;
315 public AssetBase AssetInf; 320 public AssetBase AssetInf;
316 public AssetBase ImageInfo; 321 public byte AssetRequestSource = 2;
317 public LLUUID TransferRequestID;
318 public long DataPointer = 0; 322 public long DataPointer = 0;
323 public int DiscardLevel = -1;
324 public AssetBase ImageInfo;
325 public bool IsTextureRequest;
319 public int NumPackets = 0; 326 public int NumPackets = 0;
320 public int PacketCounter = 0; 327 public int PacketCounter = 0;
321 public bool IsTextureRequest;
322 public byte AssetRequestSource = 2;
323 public byte[] Params = null; 328 public byte[] Params = null;
329 public LLUUID RequestAssetID;
330 public IClientAPI RequestUser;
331 public LLUUID TransferRequestID;
324 //public bool AssetInCache; 332 //public bool AssetInCache;
325 //public int TimeRequested; 333 //public int TimeRequested;
326 public int DiscardLevel = -1;
327 334
328 public AssetRequest() 335 public AssetRequest()
329 { 336 {
330 } 337 }
331 } 338 }
339
340 #endregion
332 } 341 }
333} \ No newline at end of file 342} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs
index 74bb247..8192be4 100644
--- a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs
+++ b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AgentAssetsTransactions.cs
@@ -42,12 +42,12 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
42 { 42 {
43 //private static readonly log4net.ILog m_log 43 //private static readonly log4net.ILog m_log
44 // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 44 // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
45 45
46 // Fields 46 // Fields
47 private bool m_dumpAssetsToFile;
48 public AgentAssetTransactionsManager Manager;
47 public LLUUID UserID; 49 public LLUUID UserID;
48 public Dictionary<LLUUID, AssetXferUploader> XferUploaders = new Dictionary<LLUUID, AssetXferUploader>(); 50 public Dictionary<LLUUID, AssetXferUploader> XferUploaders = new Dictionary<LLUUID, AssetXferUploader>();
49 public AgentAssetTransactionsManager Manager;
50 private bool m_dumpAssetsToFile;
51 51
52 // Methods 52 // Methods
53 public AgentAssetTransactions(LLUUID agentID, AgentAssetTransactionsManager manager, bool dumpAssetsToFile) 53 public AgentAssetTransactions(LLUUID agentID, AgentAssetTransactionsManager manager, bool dumpAssetsToFile)
@@ -67,7 +67,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
67 { 67 {
68 XferUploaders.Add(transactionID, uploader); 68 XferUploaders.Add(transactionID, uploader);
69 } 69 }
70 70
71 return uploader; 71 return uploader;
72 } 72 }
73 return null; 73 return null;
@@ -76,7 +76,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
76 public void HandleXfer(ulong xferID, uint packetID, byte[] data) 76 public void HandleXfer(ulong xferID, uint packetID, byte[] data)
77 { 77 {
78 // AssetXferUploader uploaderFound = null; 78 // AssetXferUploader uploaderFound = null;
79 79
80 lock (XferUploaders) 80 lock (XferUploaders)
81 { 81 {
82 foreach (AssetXferUploader uploader in XferUploaders.Values) 82 foreach (AssetXferUploader uploader in XferUploaders.Values)
@@ -86,7 +86,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
86 uploader.HandleXferPacket(xferID, packetID, data); 86 uploader.HandleXferPacket(xferID, packetID, data);
87 break; 87 break;
88 } 88 }
89 } 89 }
90 } 90 }
91 } 91 }
92 92
@@ -101,15 +101,15 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
101 wearableType, nextOwnerMask); 101 wearableType, nextOwnerMask);
102 } 102 }
103 } 103 }
104 104
105 public void RequestUpdateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, 105 public void RequestUpdateInventoryItem(IClientAPI remoteClient, LLUUID transactionID,
106 InventoryItemBase item) 106 InventoryItemBase item)
107 { 107 {
108 if (XferUploaders.ContainsKey(transactionID)) 108 if (XferUploaders.ContainsKey(transactionID))
109 { 109 {
110 XferUploaders[transactionID].RequestUpdateInventoryItem(remoteClient, transactionID, item); 110 XferUploaders[transactionID].RequestUpdateInventoryItem(remoteClient, transactionID, item);
111 } 111 }
112 } 112 }
113 113
114 /// <summary> 114 /// <summary>
115 /// Get an uploaded asset. If the data is successfully retrieved, the transaction will be removed. 115 /// Get an uploaded asset. If the data is successfully retrieved, the transaction will be removed.
@@ -122,40 +122,43 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
122 { 122 {
123 AssetXferUploader uploader = XferUploaders[transactionID]; 123 AssetXferUploader uploader = XferUploaders[transactionID];
124 AssetBase asset = uploader.GetAssetData(); 124 AssetBase asset = uploader.GetAssetData();
125 125
126 lock (XferUploaders) 126 lock (XferUploaders)
127 { 127 {
128 XferUploaders.Remove(transactionID); 128 XferUploaders.Remove(transactionID);
129 } 129 }
130 130
131 return asset; 131 return asset;
132 } 132 }
133 133
134 return null; 134 return null;
135 } 135 }
136 136
137 // Nested Types 137 // Nested Types
138
139 #region Nested type: AssetXferUploader
140
138 public class AssetXferUploader 141 public class AssetXferUploader
139 { 142 {
140 // Fields 143 // Fields
141 public bool AddToInventory; 144 public bool AddToInventory;
142 public AssetBase Asset; 145 public AssetBase Asset;
143 public LLUUID InventFolder = LLUUID.Zero; 146 public LLUUID InventFolder = LLUUID.Zero;
147 private sbyte invType = 0;
148 private bool m_createItem = false;
149 private string m_description = String.Empty;
150 private bool m_dumpAssetToFile;
151 private bool m_finished = false;
152 private string m_name = String.Empty;
153 private bool m_storeLocal;
154 private AgentAssetTransactions m_userTransactions;
155 private uint nextPerm = 0;
144 private IClientAPI ourClient; 156 private IClientAPI ourClient;
145 public LLUUID TransactionID = LLUUID.Zero; 157 public LLUUID TransactionID = LLUUID.Zero;
146 public bool UploadComplete;
147 public ulong XferID;
148 private string m_name = String.Empty;
149 private string m_description = String.Empty;
150 private sbyte type = 0; 158 private sbyte type = 0;
151 private sbyte invType = 0; 159 public bool UploadComplete;
152 private byte wearableType = 0; 160 private byte wearableType = 0;
153 private uint nextPerm = 0; 161 public ulong XferID;
154 private bool m_finished = false;
155 private bool m_createItem = false;
156 private AgentAssetTransactions m_userTransactions;
157 private bool m_storeLocal;
158 private bool m_dumpAssetToFile;
159 162
160 public AssetXferUploader(AgentAssetTransactions transactions, bool dumpAssetToFile) 163 public AssetXferUploader(AgentAssetTransactions transactions, bool dumpAssetToFile)
161 { 164 {
@@ -197,7 +200,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
197 return true; 200 return true;
198 } 201 }
199 } 202 }
200 203
201 return false; 204 return false;
202 } 205 }
203 206
@@ -233,7 +236,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
233 { 236 {
234 RequestStartXfer(); 237 RequestStartXfer();
235 } 238 }
236 239
237 return false; 240 return false;
238 } 241 }
239 242
@@ -279,7 +282,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
279 SaveAssetToFile(filename, Asset.Data); 282 SaveAssetToFile(filename, Asset.Data);
280 } 283 }
281 } 284 }
282 285
283 ///Left this in and commented in case there are unforseen issues 286 ///Left this in and commented in case there are unforseen issues
284 //private void SaveAssetToFile(string filename, byte[] data) 287 //private void SaveAssetToFile(string filename, byte[] data)
285 //{ 288 //{
@@ -327,28 +330,28 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
327 } 330 }
328 } 331 }
329 } 332 }
330 333
331 public void RequestUpdateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, 334 public void RequestUpdateInventoryItem(IClientAPI remoteClient, LLUUID transactionID,
332 InventoryItemBase item) 335 InventoryItemBase item)
333 { 336 {
334 if (TransactionID == transactionID) 337 if (TransactionID == transactionID)
335 { 338 {
336 CachedUserInfo userInfo = 339 CachedUserInfo userInfo =
337 m_userTransactions.Manager.MyScene.CommsManager.UserProfileCacheService.GetUserDetails( 340 m_userTransactions.Manager.MyScene.CommsManager.UserProfileCacheService.GetUserDetails(
338 remoteClient.AgentId); 341 remoteClient.AgentId);
339 342
340 if (userInfo != null) 343 if (userInfo != null)
341 { 344 {
342 LLUUID assetID = LLUUID.Combine(transactionID, remoteClient.SecureSessionId); 345 LLUUID assetID = LLUUID.Combine(transactionID, remoteClient.SecureSessionId);
343 346
344 AssetBase asset 347 AssetBase asset
345 = m_userTransactions.Manager.MyScene.CommsManager.AssetCache.GetAsset( 348 = m_userTransactions.Manager.MyScene.CommsManager.AssetCache.GetAsset(
346 assetID, (item.AssetType == (int) AssetType.Texture ? true : false)); 349 assetID, (item.AssetType == (int) AssetType.Texture ? true : false));
347 350
348 if (asset == null) 351 if (asset == null)
349 { 352 {
350 asset = m_userTransactions.GetTransactionAsset(transactionID); 353 asset = m_userTransactions.GetTransactionAsset(transactionID);
351 } 354 }
352 355
353 if (asset != null && asset.FullID == assetID) 356 if (asset != null && asset.FullID == assetID)
354 { 357 {
@@ -359,10 +362,10 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
359 item.AssetID = asset.FullID; 362 item.AssetID = asset.FullID;
360 363
361 m_userTransactions.Manager.MyScene.CommsManager.AssetCache.AddAsset(Asset); 364 m_userTransactions.Manager.MyScene.CommsManager.AssetCache.AddAsset(Asset);
362 } 365 }
363 366
364 userInfo.UpdateItem(remoteClient.AgentId, item); 367 userInfo.UpdateItem(remoteClient.AgentId, item);
365 } 368 }
366 } 369 }
367 } 370 }
368 371
@@ -387,7 +390,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
387 item.BasePermissions = 2147483647; 390 item.BasePermissions = 2147483647;
388 item.CurrentPermissions = 2147483647; 391 item.CurrentPermissions = 2147483647;
389 item.NextPermissions = nextPerm; 392 item.NextPermissions = nextPerm;
390 item.Flags = (uint)wearableType; 393 item.Flags = (uint) wearableType;
391 394
392 userInfo.AddItem(ourClient.AgentId, item); 395 userInfo.AddItem(ourClient.AgentId, item);
393 ourClient.SendInventoryItemCreateUpdate(item); 396 ourClient.SendInventoryItemCreateUpdate(item);
@@ -403,5 +406,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
403 return null; 406 return null;
404 } 407 }
405 } 408 }
409
410 #endregion
406 } 411 }
407} \ No newline at end of file 412} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs
index ef81625..b264c8a 100644
--- a/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs
+++ b/OpenSim/Region/Environment/Modules/Agent/AssetTransaction/AssetTransactionModule.cs
@@ -33,7 +33,6 @@ using log4net;
33using Nini.Config; 33using Nini.Config;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Region.Environment.Interfaces; 35using OpenSim.Region.Environment.Interfaces;
36using OpenSim.Region.Environment.Modules.Agent.AssetTransaction;
37using OpenSim.Region.Environment.Scenes; 36using OpenSim.Region.Environment.Scenes;
38 37
39namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction 38namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
@@ -41,8 +40,8 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
41 public class AssetTransactionModule : IRegionModule, IAgentAssetTransactions 40 public class AssetTransactionModule : IRegionModule, IAgentAssetTransactions
42 { 41 {
43 private readonly Dictionary<LLUUID, Scene> RegisteredScenes = new Dictionary<LLUUID, Scene>(); 42 private readonly Dictionary<LLUUID, Scene> RegisteredScenes = new Dictionary<LLUUID, Scene>();
44 private Scene m_scene = null;
45 private bool m_dumpAssetsToFile = false; 43 private bool m_dumpAssetsToFile = false;
44 private Scene m_scene = null;
46 45
47 private AgentAssetTransactionsManager m_transactionManager; 46 private AgentAssetTransactionsManager m_transactionManager;
48 47
@@ -51,6 +50,31 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
51 // System.Console.WriteLine("creating AgentAssetTransactionModule"); 50 // System.Console.WriteLine("creating AgentAssetTransactionModule");
52 } 51 }
53 52
53 #region IAgentAssetTransactions Members
54
55 public void HandleItemCreationFromTransaction(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID,
56 uint callbackID, string description, string name, sbyte invType,
57 sbyte type, byte wearableType, uint nextOwnerMask)
58 {
59 m_transactionManager.HandleItemCreationFromTransaction(remoteClient, transactionID, folderID, callbackID, description, name, invType, type,
60 wearableType, nextOwnerMask);
61 }
62
63 public void HandleItemUpdateFromTransaction(IClientAPI remoteClient, LLUUID transactionID,
64 InventoryItemBase item)
65 {
66 m_transactionManager.HandleItemUpdateFromTransaction(remoteClient, transactionID, item);
67 }
68
69 public void RemoveAgentAssetTransactions(LLUUID userID)
70 {
71 m_transactionManager.RemoveAgentAssetTransactions(userID);
72 }
73
74 #endregion
75
76 #region IRegionModule Members
77
54 public void Initialise(Scene scene, IConfigSource config) 78 public void Initialise(Scene scene, IConfigSource config)
55 { 79 {
56 if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID)) 80 if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID))
@@ -81,13 +105,11 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
81 { 105 {
82 m_transactionManager = new AgentAssetTransactionsManager(m_scene, false); 106 m_transactionManager = new AgentAssetTransactionsManager(m_scene, false);
83 } 107 }
84
85 } 108 }
86 } 109 }
87 110
88 public void PostInitialise() 111 public void PostInitialise()
89 { 112 {
90
91 } 113 }
92 114
93 public void Close() 115 public void Close()
@@ -104,29 +126,13 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
104 get { return true; } 126 get { return true; }
105 } 127 }
106 128
129 #endregion
130
107 public void NewClient(IClientAPI client) 131 public void NewClient(IClientAPI client)
108 { 132 {
109 client.OnAssetUploadRequest += m_transactionManager.HandleUDPUploadRequest; 133 client.OnAssetUploadRequest += m_transactionManager.HandleUDPUploadRequest;
110 client.OnXferReceive += m_transactionManager.HandleXfer; 134 client.OnXferReceive += m_transactionManager.HandleXfer;
111 } 135 }
112
113 public void HandleItemCreationFromTransaction(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID,
114 uint callbackID, string description, string name, sbyte invType,
115 sbyte type, byte wearableType, uint nextOwnerMask)
116 {
117 m_transactionManager.HandleItemCreationFromTransaction(remoteClient, transactionID, folderID, callbackID, description, name, invType, type, wearableType, nextOwnerMask);
118 }
119
120 public void HandleItemUpdateFromTransaction(IClientAPI remoteClient, LLUUID transactionID,
121 InventoryItemBase item)
122 {
123 m_transactionManager.HandleItemUpdateFromTransaction(remoteClient, transactionID, item);
124 }
125
126 public void RemoveAgentAssetTransactions(LLUUID userID)
127 {
128 m_transactionManager.RemoveAgentAssetTransactions(userID);
129 }
130 } 136 }
131 137
132 public class AgentAssetTransactionsManager 138 public class AgentAssetTransactionsManager
@@ -135,7 +141,6 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
135 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 141 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
136 142
137 // Fields 143 // Fields
138 public Scene MyScene;
139 144
140 /// <summary> 145 /// <summary>
141 /// Each agent has its own singleton collection of transactions 146 /// Each agent has its own singleton collection of transactions
@@ -148,6 +153,8 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
148 /// </summary> 153 /// </summary>
149 private bool m_dumpAssetsToFile; 154 private bool m_dumpAssetsToFile;
150 155
156 public Scene MyScene;
157
151 public AgentAssetTransactionsManager(Scene scene, bool dumpAssetsToFile) 158 public AgentAssetTransactionsManager(Scene scene, bool dumpAssetsToFile)
152 { 159 {
153 MyScene = scene; 160 MyScene = scene;
@@ -260,10 +267,8 @@ namespace OpenSim.Region.Environment.Modules.Agent.AssetTransaction
260 AgentAssetTransactions.AssetXferUploader uploader = transactions.RequestXferUploader(transaction); 267 AgentAssetTransactions.AssetXferUploader uploader = transactions.RequestXferUploader(transaction);
261 if (uploader != null) 268 if (uploader != null)
262 { 269 {
263
264 if (uploader.Initialise(remoteClient, assetID, transaction, type, data, storeLocal, tempFile)) 270 if (uploader.Initialise(remoteClient, assetID, transaction, type, data, storeLocal, tempFile))
265 { 271 {
266
267 } 272 }
268 } 273 }
269 } 274 }
diff --git a/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureDownloadModule.cs b/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureDownloadModule.cs
index b8899d2..ae2df69 100644
--- a/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureDownloadModule.cs
+++ b/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureDownloadModule.cs
@@ -40,14 +40,11 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
40 { 40 {
41 //private static readonly log4net.ILog m_log 41 //private static readonly log4net.ILog m_log
42 // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 42 // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
43
44 private Scene m_scene;
45 private List<Scene> m_scenes = new List<Scene>();
46 43
47 /// <summary> 44 /// <summary>
48 /// There is one queue for all textures waiting to be sent, regardless of the requesting user. 45 /// There is one queue for all textures waiting to be sent, regardless of the requesting user.
49 /// </summary> 46 /// </summary>
50 private readonly BlockingQueue<ITextureSender> m_queueSenders 47 private readonly BlockingQueue<ITextureSender> m_queueSenders
51 = new BlockingQueue<ITextureSender>(); 48 = new BlockingQueue<ITextureSender>();
52 49
53 /// <summary> 50 /// <summary>
@@ -56,12 +53,17 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
56 private readonly Dictionary<LLUUID, UserTextureDownloadService> m_userTextureServices = 53 private readonly Dictionary<LLUUID, UserTextureDownloadService> m_userTextureServices =
57 new Dictionary<LLUUID, UserTextureDownloadService>(); 54 new Dictionary<LLUUID, UserTextureDownloadService>();
58 55
56 private Scene m_scene;
57 private List<Scene> m_scenes = new List<Scene>();
58
59 private Thread m_thread; 59 private Thread m_thread;
60 60
61 public TextureDownloadModule() 61 public TextureDownloadModule()
62 { 62 {
63 } 63 }
64 64
65 #region IRegionModule Members
66
65 public void Initialise(Scene scene, IConfigSource config) 67 public void Initialise(Scene scene, IConfigSource config)
66 { 68 {
67 if (m_scene == null) 69 if (m_scene == null)
@@ -83,6 +85,26 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
83 } 85 }
84 } 86 }
85 87
88 public void PostInitialise()
89 {
90 }
91
92 public void Close()
93 {
94 }
95
96 public string Name
97 {
98 get { return "TextureDownloadModule"; }
99 }
100
101 public bool IsSharedModule
102 {
103 get { return false; }
104 }
105
106 #endregion
107
86 /// <summary> 108 /// <summary>
87 /// Cleanup the texture service related objects for the removed presence. 109 /// Cleanup the texture service related objects for the removed presence.
88 /// </summary> 110 /// </summary>
@@ -102,24 +124,6 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
102 } 124 }
103 } 125 }
104 126
105 public void PostInitialise()
106 {
107 }
108
109 public void Close()
110 {
111 }
112
113 public string Name
114 {
115 get { return "TextureDownloadModule"; }
116 }
117
118 public bool IsSharedModule
119 {
120 get { return false; }
121 }
122
123 public void NewClient(IClientAPI client) 127 public void NewClient(IClientAPI client)
124 { 128 {
125 client.OnRequestTexture += TextureRequest; 129 client.OnRequestTexture += TextureRequest;
@@ -143,7 +147,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
143 147
144 textureService = new UserTextureDownloadService(client, m_scene, m_queueSenders); 148 textureService = new UserTextureDownloadService(client, m_scene, m_queueSenders);
145 m_userTextureServices.Add(client.AgentId, textureService); 149 m_userTextureServices.Add(client.AgentId, textureService);
146 150
147 return true; 151 return true;
148 } 152 }
149 } 153 }
@@ -157,11 +161,11 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
157 { 161 {
158 IClientAPI client = (IClientAPI) sender; 162 IClientAPI client = (IClientAPI) sender;
159 UserTextureDownloadService textureService; 163 UserTextureDownloadService textureService;
160 164
161 if (TryGetUserTextureService(client, out textureService)) 165 if (TryGetUserTextureService(client, out textureService))
162 { 166 {
163 textureService.HandleTextureRequest(e); 167 textureService.HandleTextureRequest(e);
164 } 168 }
165 } 169 }
166 170
167 /// <summary> 171 /// <summary>
@@ -170,11 +174,11 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
170 public void ProcessTextureSenders() 174 public void ProcessTextureSenders()
171 { 175 {
172 ITextureSender sender = null; 176 ITextureSender sender = null;
173 177
174 while (true) 178 while (true)
175 { 179 {
176 sender = m_queueSenders.Dequeue(); 180 sender = m_queueSenders.Dequeue();
177 181
178 if (sender.Cancel) 182 if (sender.Cancel)
179 { 183 {
180 TextureSent(sender); 184 TextureSent(sender);
@@ -193,10 +197,10 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
193 m_queueSenders.Enqueue(sender); 197 m_queueSenders.Enqueue(sender);
194 } 198 }
195 } 199 }
196 200
197 // Make sure that any sender we currently have can get garbage collected 201 // Make sure that any sender we currently have can get garbage collected
198 sender = null; 202 sender = null;
199 203
200 //m_log.InfoFormat("[TEXTURE DOWNLOAD] Texture sender queue size: {0}", m_queueSenders.Count()); 204 //m_log.InfoFormat("[TEXTURE DOWNLOAD] Texture sender queue size: {0}", m_queueSenders.Count());
201 } 205 }
202 } 206 }
@@ -207,9 +211,9 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
207 /// <param name="sender"></param> 211 /// <param name="sender"></param>
208 private void TextureSent(ITextureSender sender) 212 private void TextureSent(ITextureSender sender)
209 { 213 {
210 sender.Sending = false; 214 sender.Sending = false;
211 //m_log.DebugFormat("[TEXTURE DOWNLOAD]: Removing download stat for {0}", sender.assetID); 215 //m_log.DebugFormat("[TEXTURE DOWNLOAD]: Removing download stat for {0}", sender.assetID);
212 m_scene.AddPendingDownloads(-1); 216 m_scene.AddPendingDownloads(-1);
213 } 217 }
214 } 218 }
215} \ No newline at end of file 219} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureNotFoundSender.cs b/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureNotFoundSender.cs
index 6f11f73..b181d20 100644
--- a/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureNotFoundSender.cs
+++ b/OpenSim/Region/Environment/Modules/Agent/TextureDownload/TextureNotFoundSender.cs
@@ -39,55 +39,60 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
39 { 39 {
40 //private static readonly log4net.ILog m_log 40 //private static readonly log4net.ILog m_log
41 // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 41 // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
42 42
43 private LLUUID m_textureId; 43 private bool m_cancel = false;
44 private IClientAPI m_client; 44 private IClientAPI m_client;
45 45
46 // See ITextureSender 46 // See ITextureSender
47 public bool Sending 47
48 { 48 private bool m_sending = false;
49 get { return false; } 49 private LLUUID m_textureId;
50 set { m_sending = value; }
51 }
52
53 private bool m_sending = false;
54 50
55 // See ITextureSender 51 // See ITextureSender
56 public bool Cancel 52
57 {
58 get { return false; }
59 set { m_cancel = value; }
60 }
61
62 private bool m_cancel = false;
63
64 public TextureNotFoundSender(IClientAPI client, LLUUID textureID) 53 public TextureNotFoundSender(IClientAPI client, LLUUID textureID)
65 { 54 {
66 m_client = client; 55 m_client = client;
67 m_textureId = textureID; 56 m_textureId = textureID;
68 } 57 }
69 58
59 #region ITextureSender Members
60
61 public bool Sending
62 {
63 get { return false; }
64 set { m_sending = value; }
65 }
66
67 public bool Cancel
68 {
69 get { return false; }
70 set { m_cancel = value; }
71 }
72
70 // See ITextureSender 73 // See ITextureSender
71 public void UpdateRequest(int discardLevel, uint packetNumber) 74 public void UpdateRequest(int discardLevel, uint packetNumber)
72 { 75 {
73 // Not need to implement since priority changes don't affect this operation 76 // Not need to implement since priority changes don't affect this operation
74 } 77 }
75 78
76 // See ITextureSender 79 // See ITextureSender
77 public bool SendTexturePacket() 80 public bool SendTexturePacket()
78 { 81 {
79 //m_log.InfoFormat( 82 //m_log.InfoFormat(
80 // "[TEXTURE NOT FOUND SENDER]: Informing the client that texture {0} cannot be found", 83 // "[TEXTURE NOT FOUND SENDER]: Informing the client that texture {0} cannot be found",
81 // m_textureId); 84 // m_textureId);
82 85
83 ImageNotInDatabasePacket notFound = new ImageNotInDatabasePacket(); 86 ImageNotInDatabasePacket notFound = new ImageNotInDatabasePacket();
84 notFound.ImageID.ID = m_textureId; 87 notFound.ImageID.ID = m_textureId;
85 88
86 // XXX Temporarily disabling as this appears to be causing client crashes on at least 89 // XXX Temporarily disabling as this appears to be causing client crashes on at least
87 // 1.19.0(5) of the Linden Second Life client. 90 // 1.19.0(5) of the Linden Second Life client.
88 // m_client.OutPacket(notFound, ThrottleOutPacketType.Texture); 91 // m_client.OutPacket(notFound, ThrottleOutPacketType.Texture);
89 92
90 return true; 93 return true;
91 } 94 }
95
96 #endregion
92 } 97 }
93} \ No newline at end of file 98} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/Agent/TextureDownload/UserTextureDownloadService.cs b/OpenSim/Region/Environment/Modules/Agent/TextureDownload/UserTextureDownloadService.cs
index 08a22d6..4f63fd0 100644
--- a/OpenSim/Region/Environment/Modules/Agent/TextureDownload/UserTextureDownloadService.cs
+++ b/OpenSim/Region/Environment/Modules/Agent/TextureDownload/UserTextureDownloadService.cs
@@ -32,8 +32,6 @@ using log4net;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Framework.Communications.Limit; 33using OpenSim.Framework.Communications.Limit;
34using OpenSim.Region.Environment.Interfaces; 34using OpenSim.Region.Environment.Interfaces;
35using OpenSim.Region.Environment.Modules.Agent.TextureDownload;
36using OpenSim.Region.Environment.Modules.Agent.TextureSender;
37using OpenSim.Region.Environment.Scenes; 35using OpenSim.Region.Environment.Scenes;
38 36
39namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload 37namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
@@ -45,7 +43,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
45 /// </summary> 43 /// </summary>
46 public class UserTextureDownloadService 44 public class UserTextureDownloadService
47 { 45 {
48 private static readonly ILog m_log 46 private static readonly ILog m_log
49 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50 48
51 /// <summary> 49 /// <summary>
@@ -56,35 +54,34 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
56 /// sophisticated way. 54 /// sophisticated way.
57 /// </summary> 55 /// </summary>
58 private static readonly int MAX_ALLOWED_TEXTURE_REQUESTS = 5; 56 private static readonly int MAX_ALLOWED_TEXTURE_REQUESTS = 5;
59 57
60 /// <summary>
61 /// We're going to limit requests for the same missing texture.
62 /// XXX This is really a temporary solution to deal with the situation where a client continually requests
63 /// the same missing textures
64 /// </summary>
65 private readonly IRequestLimitStrategy<LLUUID> missingTextureLimitStrategy
66 = new RepeatLimitStrategy<LLUUID>(MAX_ALLOWED_TEXTURE_REQUESTS);
67
68 /// <summary> 58 /// <summary>
69 /// XXX Also going to limit requests for found textures. 59 /// XXX Also going to limit requests for found textures.
70 /// </summary> 60 /// </summary>
71 private readonly IRequestLimitStrategy<LLUUID> foundTextureLimitStrategy 61 private readonly IRequestLimitStrategy<LLUUID> foundTextureLimitStrategy
72 = new RepeatLimitStrategy<LLUUID>(MAX_ALLOWED_TEXTURE_REQUESTS); 62 = new RepeatLimitStrategy<LLUUID>(MAX_ALLOWED_TEXTURE_REQUESTS);
73 63
74 /// <summary> 64 private readonly IClientAPI m_client;
75 /// Holds texture senders before they have received the appropriate texture from the asset cache. 65 private readonly Scene m_scene;
76 /// </summary> 66
77 private readonly Dictionary<LLUUID, TextureSender.TextureSender> m_textureSenders = new Dictionary<LLUUID, TextureSender.TextureSender>();
78
79 /// <summary> 67 /// <summary>
80 /// Texture Senders are placed in this queue once they have received their texture from the asset 68 /// Texture Senders are placed in this queue once they have received their texture from the asset
81 /// cache. Another module actually invokes the send. 69 /// cache. Another module actually invokes the send.
82 /// </summary> 70 /// </summary>
83 private readonly BlockingQueue<ITextureSender> m_sharedSendersQueue; 71 private readonly BlockingQueue<ITextureSender> m_sharedSendersQueue;
84 72
85 private readonly Scene m_scene; 73 /// <summary>
86 74 /// Holds texture senders before they have received the appropriate texture from the asset cache.
87 private readonly IClientAPI m_client; 75 /// </summary>
76 private readonly Dictionary<LLUUID, TextureSender.TextureSender> m_textureSenders = new Dictionary<LLUUID, TextureSender.TextureSender>();
77
78 /// <summary>
79 /// We're going to limit requests for the same missing texture.
80 /// XXX This is really a temporary solution to deal with the situation where a client continually requests
81 /// the same missing textures
82 /// </summary>
83 private readonly IRequestLimitStrategy<LLUUID> missingTextureLimitStrategy
84 = new RepeatLimitStrategy<LLUUID>(MAX_ALLOWED_TEXTURE_REQUESTS);
88 85
89 public UserTextureDownloadService( 86 public UserTextureDownloadService(
90 IClientAPI client, Scene scene, BlockingQueue<ITextureSender> sharedQueue) 87 IClientAPI client, Scene scene, BlockingQueue<ITextureSender> sharedQueue)
@@ -112,19 +109,19 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
112 { 109 {
113 // If we've received new non UUID information for this request and it hasn't dispatched 110 // If we've received new non UUID information for this request and it hasn't dispatched
114 // yet, then update the request accordingly. 111 // yet, then update the request accordingly.
115 textureSender.UpdateRequest(e.DiscardLevel, e.PacketNumber); 112 textureSender.UpdateRequest(e.DiscardLevel, e.PacketNumber);
116 } 113 }
117 else 114 else
118 { 115 {
119 if (!foundTextureLimitStrategy.AllowRequest(e.RequestedAssetID)) 116 if (!foundTextureLimitStrategy.AllowRequest(e.RequestedAssetID))
120 { 117 {
121// m_log.DebugFormat( 118// m_log.DebugFormat(
122// "[USER TEXTURE DOWNLOAD SERVICE]: Refusing request for {0} from client {1}", 119// "[USER TEXTURE DOWNLOAD SERVICE]: Refusing request for {0} from client {1}",
123// e.RequestedAssetID, m_client.AgentId); 120// e.RequestedAssetID, m_client.AgentId);
124 121
125 return; 122 return;
126 } 123 }
127 else if (!missingTextureLimitStrategy.AllowRequest(e.RequestedAssetID)) 124 else if (!missingTextureLimitStrategy.AllowRequest(e.RequestedAssetID))
128 { 125 {
129 if (missingTextureLimitStrategy.IsFirstRefusal(e.RequestedAssetID)) 126 if (missingTextureLimitStrategy.IsFirstRefusal(e.RequestedAssetID))
130 { 127 {
@@ -135,17 +132,17 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
135// m_log.DebugFormat( 132// m_log.DebugFormat(
136// "[USER TEXTURE DOWNLOAD SERVICE]: Dropping requests for notified missing texture {0} for client {1} since we have received more than {2} requests", 133// "[USER TEXTURE DOWNLOAD SERVICE]: Dropping requests for notified missing texture {0} for client {1} since we have received more than {2} requests",
137// e.RequestedAssetID, m_client.AgentId, MAX_ALLOWED_TEXTURE_REQUESTS); 134// e.RequestedAssetID, m_client.AgentId, MAX_ALLOWED_TEXTURE_REQUESTS);
138 } 135 }
139 136
140 return; 137 return;
141 } 138 }
142 139
143 m_scene.AddPendingDownloads(1); 140 m_scene.AddPendingDownloads(1);
144 141
145 TextureSender.TextureSender requestHandler = new TextureSender.TextureSender(m_client, e.DiscardLevel, e.PacketNumber); 142 TextureSender.TextureSender requestHandler = new TextureSender.TextureSender(m_client, e.DiscardLevel, e.PacketNumber);
146 m_textureSenders.Add(e.RequestedAssetID, requestHandler); 143 m_textureSenders.Add(e.RequestedAssetID, requestHandler);
147 144
148 m_scene.AssetCache.GetAsset(e.RequestedAssetID, TextureCallback, true); 145 m_scene.AssetCache.GetAsset(e.RequestedAssetID, TextureCallback, true);
149 } 146 }
150 } 147 }
151 } 148 }
@@ -170,7 +167,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
170 public void TextureCallback(LLUUID textureID, AssetBase texture) 167 public void TextureCallback(LLUUID textureID, AssetBase texture)
171 { 168 {
172 //m_log.DebugFormat("[USER TEXTURE DOWNLOAD SERVICE]: Calling TextureCallback with {0}, texture == null is {1}", textureID, (texture == null ? true : false)); 169 //m_log.DebugFormat("[USER TEXTURE DOWNLOAD SERVICE]: Calling TextureCallback with {0}, texture == null is {1}", textureID, (texture == null ? true : false));
173 170
174 lock (m_textureSenders) 171 lock (m_textureSenders)
175 { 172 {
176 TextureSender.TextureSender textureSender; 173 TextureSender.TextureSender textureSender;
@@ -181,18 +178,18 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
181 // this on to the TextureSender it will blow up, so just discard for now. 178 // this on to the TextureSender it will blow up, so just discard for now.
182 // Needs investigation. 179 // Needs investigation.
183 if (texture == null || texture.Data == null) 180 if (texture == null || texture.Data == null)
184 { 181 {
185 if (!missingTextureLimitStrategy.IsMonitoringRequests(textureID)) 182 if (!missingTextureLimitStrategy.IsMonitoringRequests(textureID))
186 { 183 {
187 missingTextureLimitStrategy.MonitorRequests(textureID); 184 missingTextureLimitStrategy.MonitorRequests(textureID);
188 185
189 m_log.DebugFormat( 186 m_log.DebugFormat(
190 "[USER TEXTURE DOWNLOAD SERVICE]: Queueing first TextureNotFoundSender for {0}, client {1}", 187 "[USER TEXTURE DOWNLOAD SERVICE]: Queueing first TextureNotFoundSender for {0}, client {1}",
191 textureID, m_client.AgentId); 188 textureID, m_client.AgentId);
192 } 189 }
193 190
194 ITextureSender textureNotFoundSender = new TextureNotFoundSender(m_client, textureID); 191 ITextureSender textureNotFoundSender = new TextureNotFoundSender(m_client, textureID);
195 EnqueueTextureSender(textureNotFoundSender); 192 EnqueueTextureSender(textureNotFoundSender);
196 } 193 }
197 else 194 else
198 { 195 {
@@ -200,13 +197,13 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
200 { 197 {
201 textureSender.TextureReceived(texture); 198 textureSender.TextureReceived(texture);
202 EnqueueTextureSender(textureSender); 199 EnqueueTextureSender(textureSender);
203 200
204 foundTextureLimitStrategy.MonitorRequests(textureID); 201 foundTextureLimitStrategy.MonitorRequests(textureID);
205 } 202 }
206 } 203 }
207 204
208 //m_log.InfoFormat("[TEXTURE SENDER] Removing texture sender with uuid {0}", textureID); 205 //m_log.InfoFormat("[TEXTURE SENDER] Removing texture sender with uuid {0}", textureID);
209 m_textureSenders.Remove(textureID); 206 m_textureSenders.Remove(textureID);
210 //m_log.InfoFormat("[TEXTURE SENDER] Current texture senders in dictionary: {0}", m_textureSenders.Count); 207 //m_log.InfoFormat("[TEXTURE SENDER] Current texture senders in dictionary: {0}", m_textureSenders.Count);
211 } 208 }
212 else 209 else
@@ -240,7 +237,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureDownload
240 { 237 {
241 lock (m_textureSenders) 238 lock (m_textureSenders)
242 { 239 {
243 foreach( TextureSender.TextureSender textureSender in m_textureSenders.Values ) 240 foreach (TextureSender.TextureSender textureSender in m_textureSenders.Values)
244 { 241 {
245 textureSender.Cancel = true; 242 textureSender.Cancel = true;
246 } 243 }
diff --git a/OpenSim/Region/Environment/Modules/Agent/TextureSender/TextureSender.cs b/OpenSim/Region/Environment/Modules/Agent/TextureSender/TextureSender.cs
index 37b0652..b6f7095 100644
--- a/OpenSim/Region/Environment/Modules/Agent/TextureSender/TextureSender.cs
+++ b/OpenSim/Region/Environment/Modules/Agent/TextureSender/TextureSender.cs
@@ -40,56 +40,43 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender
40 /// </summary> 40 /// </summary>
41 public class TextureSender : ITextureSender 41 public class TextureSender : ITextureSender
42 { 42 {
43 private static readonly ILog m_log 43 private static readonly ILog m_log
44 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 44 = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 45
46 /// <summary> 46 /// <summary>
47 /// Records the number of times texture send has been called. 47 /// Records the number of times texture send has been called.
48 /// </summary> 48 /// </summary>
49 public int counter = 0; 49 public int counter = 0;
50 50
51 public bool ImageLoaded = false;
52
51 /// <summary> 53 /// <summary>
52 /// Holds the texture asset to send. 54 /// Holds the texture asset to send.
53 /// </summary> 55 /// </summary>
54 private AssetBase m_asset; 56 private AssetBase m_asset;
55 57
56 //public LLUUID assetID { get { return m_asset.FullID; } } 58 //public LLUUID assetID { get { return m_asset.FullID; } }
57 59
60 private bool m_cancel = false;
61
62 // See ITextureSender
63
64 private bool m_sending = false;
65
58 /// <summary> 66 /// <summary>
59 /// This is actually the number of extra packets required to send the texture data! We always assume 67 /// This is actually the number of extra packets required to send the texture data! We always assume
60 /// at least one is required. 68 /// at least one is required.
61 /// </summary> 69 /// </summary>
62 private int NumPackets = 0; 70 private int NumPackets = 0;
63 71
64 /// <summary> 72 /// <summary>
65 /// Holds the packet number to send next. In this case, each packet is 1000 bytes long and starts 73 /// Holds the packet number to send next. In this case, each packet is 1000 bytes long and starts
66 /// at the 600th byte (0th indexed). 74 /// at the 600th byte (0th indexed).
67 /// </summary> 75 /// </summary>
68 private int PacketCounter = 0; 76 private int PacketCounter = 0;
69
70 // See ITextureSender
71 public bool Cancel
72 {
73 get { return false; }
74 set { m_cancel = value; }
75 }
76
77 private bool m_cancel = false;
78
79 // See ITextureSender
80 public bool Sending
81 {
82 get { return false; }
83 set { m_sending = value; }
84 }
85
86 private bool m_sending = false;
87
88 public bool ImageLoaded = false;
89
90 private IClientAPI RequestUser;
91 77
92 private int RequestedDiscardLevel = -1; 78 private int RequestedDiscardLevel = -1;
79 private IClientAPI RequestUser;
93 private uint StartPacketNumber = 0; 80 private uint StartPacketNumber = 0;
94 81
95 public TextureSender(IClientAPI client, int discardLevel, uint packetNumber) 82 public TextureSender(IClientAPI client, int discardLevel, uint packetNumber)
@@ -99,18 +86,18 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender
99 StartPacketNumber = packetNumber; 86 StartPacketNumber = packetNumber;
100 } 87 }
101 88
102 /// <summary> 89 #region ITextureSender Members
103 /// Load up the texture data to send. 90
104 /// </summary> 91 public bool Cancel
105 /// <param name="asset">
106 /// A <see cref="AssetBase"/>
107 /// </param>
108 public void TextureReceived(AssetBase asset)
109 { 92 {
110 m_asset = asset; 93 get { return false; }
111 NumPackets = CalculateNumPackets(asset.Data.Length); 94 set { m_cancel = value; }
112 PacketCounter = (int) StartPacketNumber; 95 }
113 ImageLoaded = true; 96
97 public bool Sending
98 {
99 get { return false; }
100 set { m_sending = value; }
114 } 101 }
115 102
116 // See ITextureSender 103 // See ITextureSender
@@ -125,17 +112,33 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender
125 public bool SendTexturePacket() 112 public bool SendTexturePacket()
126 { 113 {
127 //m_log.DebugFormat("[TEXTURE SENDER]: Sending packet for {0}", m_asset.FullID); 114 //m_log.DebugFormat("[TEXTURE SENDER]: Sending packet for {0}", m_asset.FullID);
128 115
129 SendPacket(); 116 SendPacket();
130 counter++; 117 counter++;
131 if ((NumPackets == 0) || (RequestedDiscardLevel == -1) || (PacketCounter > NumPackets) || 118 if ((NumPackets == 0) || (RequestedDiscardLevel == -1) || (PacketCounter > NumPackets) ||
132 ((RequestedDiscardLevel > 0) && (counter > 50 + (NumPackets/(RequestedDiscardLevel + 1))))) 119 ((RequestedDiscardLevel > 0) && (counter > 50 + (NumPackets / (RequestedDiscardLevel + 1)))))
133 { 120 {
134 return true; 121 return true;
135 } 122 }
136 return false; 123 return false;
137 } 124 }
138 125
126 #endregion
127
128 /// <summary>
129 /// Load up the texture data to send.
130 /// </summary>
131 /// <param name="asset">
132 /// A <see cref="AssetBase"/>
133 /// </param>
134 public void TextureReceived(AssetBase asset)
135 {
136 m_asset = asset;
137 NumPackets = CalculateNumPackets(asset.Data.Length);
138 PacketCounter = (int) StartPacketNumber;
139 ImageLoaded = true;
140 }
141
139 /// <summary> 142 /// <summary>
140 /// Sends a texture packet to the client. 143 /// Sends a texture packet to the client.
141 /// </summary> 144 /// </summary>
@@ -177,17 +180,17 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender
177 im.Header.Reliable = false; 180 im.Header.Reliable = false;
178 im.ImageID.Packet = (ushort) (PacketCounter); 181 im.ImageID.Packet = (ushort) (PacketCounter);
179 im.ImageID.ID = m_asset.FullID; 182 im.ImageID.ID = m_asset.FullID;
180 int size = m_asset.Data.Length - 600 - (1000*(PacketCounter - 1)); 183 int size = m_asset.Data.Length - 600 - (1000 * (PacketCounter - 1));
181 if (size > 1000) size = 1000; 184 if (size > 1000) size = 1000;
182 im.ImageData.Data = new byte[size]; 185 im.ImageData.Data = new byte[size];
183 try 186 try
184 { 187 {
185 Array.Copy(m_asset.Data, 600 + (1000*(PacketCounter - 1)), im.ImageData.Data, 0, size); 188 Array.Copy(m_asset.Data, 600 + (1000 * (PacketCounter - 1)), im.ImageData.Data, 0, size);
186 } 189 }
187 catch (ArgumentOutOfRangeException) 190 catch (ArgumentOutOfRangeException)
188 { 191 {
189 m_log.Error("[TEXTURE SENDER]: Unable to separate texture into multiple packets: Array bounds failure on asset:" + 192 m_log.Error("[TEXTURE SENDER]: Unable to separate texture into multiple packets: Array bounds failure on asset:" +
190 m_asset.FullID.ToString() ); 193 m_asset.FullID.ToString());
191 return; 194 return;
192 } 195 }
193 RequestUser.OutPacket(im, ThrottleOutPacketType.Texture); 196 RequestUser.OutPacket(im, ThrottleOutPacketType.Texture);
@@ -210,7 +213,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.TextureSender
210 { 213 {
211 //over 600 bytes so split up file 214 //over 600 bytes so split up file
212 int restData = (length - 600); 215 int restData = (length - 600);
213 int restPackets = ((restData + 999)/1000); 216 int restPackets = ((restData + 999) / 1000);
214 numPackets = restPackets; 217 numPackets = restPackets;
215 } 218 }
216 219
diff --git a/OpenSim/Region/Environment/Modules/Agent/Xfer/XferModule.cs b/OpenSim/Region/Environment/Modules/Agent/Xfer/XferModule.cs
index b609f93..e35b6f5 100644
--- a/OpenSim/Region/Environment/Modules/Agent/Xfer/XferModule.cs
+++ b/OpenSim/Region/Environment/Modules/Agent/Xfer/XferModule.cs
@@ -37,15 +37,16 @@ namespace OpenSim.Region.Environment.Modules.Agent.Xfer
37{ 37{
38 public class XferModule : IRegionModule, IXfer 38 public class XferModule : IRegionModule, IXfer
39 { 39 {
40 private Scene m_scene;
40 public Dictionary<string, byte[]> NewFiles = new Dictionary<string, byte[]>(); 41 public Dictionary<string, byte[]> NewFiles = new Dictionary<string, byte[]>();
41 public Dictionary<ulong, XferDownLoad> Transfers = new Dictionary<ulong, XferDownLoad>(); 42 public Dictionary<ulong, XferDownLoad> Transfers = new Dictionary<ulong, XferDownLoad>();
42 43
43 private Scene m_scene;
44
45 public XferModule() 44 public XferModule()
46 { 45 {
47 } 46 }
48 47
48 #region IRegionModule Members
49
49 public void Initialise(Scene scene, IConfigSource config) 50 public void Initialise(Scene scene, IConfigSource config)
50 { 51 {
51 m_scene = scene; 52 m_scene = scene;
@@ -72,6 +73,28 @@ namespace OpenSim.Region.Environment.Modules.Agent.Xfer
72 get { return false; } 73 get { return false; }
73 } 74 }
74 75
76 #endregion
77
78 #region IXfer Members
79
80 public bool AddNewFile(string fileName, byte[] data)
81 {
82 lock (NewFiles)
83 {
84 if (NewFiles.ContainsKey(fileName))
85 {
86 NewFiles[fileName] = data;
87 }
88 else
89 {
90 NewFiles.Add(fileName, data);
91 }
92 }
93 return true;
94 }
95
96 #endregion
97
75 public void NewClient(IClientAPI client) 98 public void NewClient(IClientAPI client)
76 { 99 {
77 client.OnRequestXfer += RequestXfer; 100 client.OnRequestXfer += RequestXfer;
@@ -96,7 +119,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.Xfer
96 XferDownLoad transaction = new XferDownLoad(fileName, fileData, xferID, remoteClient); 119 XferDownLoad transaction = new XferDownLoad(fileName, fileData, xferID, remoteClient);
97 Transfers.Add(xferID, transaction); 120 Transfers.Add(xferID, transaction);
98 NewFiles.Remove(fileName); 121 NewFiles.Remove(fileName);
99 122
100 if (transaction.StartSend()) 123 if (transaction.StartSend())
101 { 124 {
102 Transfers.Remove(xferID); 125 Transfers.Remove(xferID);
@@ -119,33 +142,18 @@ namespace OpenSim.Region.Environment.Modules.Agent.Xfer
119 } 142 }
120 } 143 }
121 144
122 public bool AddNewFile(string fileName, byte[] data) 145 #region Nested type: XferDownLoad
123 {
124 lock (NewFiles)
125 {
126 if (NewFiles.ContainsKey(fileName))
127 {
128 NewFiles[fileName] = data;
129 }
130 else
131 {
132 NewFiles.Add(fileName, data);
133 }
134 }
135 return true;
136 }
137
138 146
139 public class XferDownLoad 147 public class XferDownLoad
140 { 148 {
149 public IClientAPI Client;
150 private bool complete;
141 public byte[] Data = new byte[0]; 151 public byte[] Data = new byte[0];
142 public string FileName = String.Empty;
143 public ulong XferID = 0;
144 public int DataPointer = 0; 152 public int DataPointer = 0;
153 public string FileName = String.Empty;
145 public uint Packet = 0; 154 public uint Packet = 0;
146 public IClientAPI Client;
147 public uint Serial = 1; 155 public uint Serial = 1;
148 private bool complete; 156 public ulong XferID = 0;
149 157
150 public XferDownLoad(string fileName, byte[] data, ulong xferID, IClientAPI client) 158 public XferDownLoad(string fileName, byte[] data, ulong xferID, IClientAPI client)
151 { 159 {
@@ -172,7 +180,7 @@ namespace OpenSim.Region.Environment.Modules.Agent.Xfer
172 Array.Copy(Helpers.IntToBytes(Data.Length), 0, transferData, 0, 4); 180 Array.Copy(Helpers.IntToBytes(Data.Length), 0, transferData, 0, 4);
173 Array.Copy(Data, 0, transferData, 4, Data.Length); 181 Array.Copy(Data, 0, transferData, 4, Data.Length);
174 Client.SendXferPacket(XferID, 0 + 0x80000000, transferData); 182 Client.SendXferPacket(XferID, 0 + 0x80000000, transferData);
175 183
176 complete = true; 184 complete = true;
177 } 185 }
178 else 186 else
@@ -182,10 +190,10 @@ namespace OpenSim.Region.Environment.Modules.Agent.Xfer
182 Array.Copy(Data, 0, transferData, 4, 1000); 190 Array.Copy(Data, 0, transferData, 4, 1000);
183 Client.SendXferPacket(XferID, 0, transferData); 191 Client.SendXferPacket(XferID, 0, transferData);
184 Packet++; 192 Packet++;
185 DataPointer = 1000; 193 DataPointer = 1000;
186 } 194 }
187 195
188 return complete; 196 return complete;
189 } 197 }
190 198
191 /// <summary> 199 /// <summary>
@@ -213,13 +221,15 @@ namespace OpenSim.Region.Environment.Modules.Agent.Xfer
213 Client.SendXferPacket(XferID, endPacket, transferData); 221 Client.SendXferPacket(XferID, endPacket, transferData);
214 Packet++; 222 Packet++;
215 DataPointer += (Data.Length - DataPointer); 223 DataPointer += (Data.Length - DataPointer);
216 224
217 complete = true; 225 complete = true;
218 } 226 }
219 } 227 }
220 228
221 return complete; 229 return complete;
222 } 230 }
223 } 231 }
232
233 #endregion
224 } 234 }
225} \ No newline at end of file 235} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Chat/ChatModule.cs
index 1281873..966f5f3 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/Chat/ChatModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/Chat/ChatModule.cs
@@ -44,21 +44,21 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
44 public class ChatModule : IRegionModule, ISimChat 44 public class ChatModule : IRegionModule, ISimChat
45 { 45 {
46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47 47 private string m_defaultzone = null;
48 private List<Scene> m_scenes = new List<Scene>();
49
50 private int m_whisperdistance = 10;
51 private int m_saydistance = 30;
52 private int m_shoutdistance = 100;
53 48
54 private IRCChatModule m_irc = null; 49 private IRCChatModule m_irc = null;
50 private Thread m_irc_connector = null;
55 51
56 private string m_last_new_user = null;
57 private string m_last_leaving_user = null; 52 private string m_last_leaving_user = null;
58 private string m_defaultzone = null; 53 private string m_last_new_user = null;
54 private int m_saydistance = 30;
55 private List<Scene> m_scenes = new List<Scene>();
56 private int m_shoutdistance = 100;
59 internal object m_syncInit = new object(); 57 internal object m_syncInit = new object();
60 internal object m_syncLogout = new object(); 58 internal object m_syncLogout = new object();
61 private Thread m_irc_connector=null; 59 private int m_whisperdistance = 10;
60
61 #region IRegionModule Members
62 62
63 public void Initialise(Scene scene, IConfigSource config) 63 public void Initialise(Scene scene, IConfigSource config)
64 { 64 {
@@ -85,14 +85,17 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
85 85
86 try 86 try
87 { 87 {
88 m_defaultzone = config.Configs["IRC"].GetString("nick","Sim"); 88 m_defaultzone = config.Configs["IRC"].GetString("nick", "Sim");
89 } 89 }
90 catch (Exception) 90 catch (Exception)
91 { 91 {
92 } 92 }
93 93
94 // setup IRC Relay 94 // setup IRC Relay
95 if (m_irc == null) { m_irc = new IRCChatModule(config); } 95 if (m_irc == null)
96 {
97 m_irc = new IRCChatModule(config);
98 }
96 if (m_irc_connector == null) 99 if (m_irc_connector == null)
97 { 100 {
98 m_irc_connector = new Thread(IRCConnectRun); 101 m_irc_connector = new Thread(IRCConnectRun);
@@ -142,83 +145,9 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
142 get { return true; } 145 get { return true; }
143 } 146 }
144 147
145 public void NewClient(IClientAPI client) 148 #endregion
146 {
147 try
148 {
149 client.OnChatFromViewer += SimChat;
150 149
151 if ((m_irc.Enabled) && (m_irc.Connected)) 150 #region ISimChat Members
152 {
153 string clientName = client.FirstName + " " + client.LastName;
154 // handles simple case. May not work for hundred connecting in per second.
155 // and the NewClients calles getting interleved
156 // but filters out multiple reports
157 if (clientName != m_last_new_user)
158 {
159 m_last_new_user = clientName;
160 string clientRegion = FindClientRegion(client.FirstName, client.LastName);
161 m_irc.PrivMsg(m_irc.Nick, "Sim", "notices " + clientName + " in "+clientRegion);
162 }
163 }
164 client.OnLogout += ClientLoggedOut;
165 client.OnConnectionClosed += ClientLoggedOut;
166 client.OnLogout += ClientLoggedOut;
167 }
168 catch (Exception ex)
169 {
170 m_log.Error("[IRC]: NewClient exception trap:" + ex.ToString());
171 }
172 }
173
174 public void ClientLoggedOut(IClientAPI client)
175 {
176 lock (m_syncLogout)
177 {
178 try
179 {
180 if ((m_irc.Enabled) && (m_irc.Connected))
181 {
182 string clientName = client.FirstName + " " + client.LastName;
183 string clientRegion = FindClientRegion(client.FirstName, client.LastName);
184 // handles simple case. May not work for hundred connecting in per second.
185 // and the NewClients calles getting interleved
186 // but filters out multiple reports
187 if (clientName != m_last_leaving_user)
188 {
189 m_last_leaving_user = clientName;
190 m_irc.PrivMsg(m_irc.Nick, "Sim", "notices " + clientName + " left " + clientRegion);
191 m_log.Info("[IRC]: IRC watcher notices " + clientName + " left " + clientRegion);
192 }
193 }
194 }
195 catch (Exception ex)
196 {
197 m_log.Error("[IRC]: ClientLoggedOut exception trap:" + ex.ToString());
198 }
199 }
200 }
201
202 private void TrySendChatMessage(ScenePresence presence, LLVector3 fromPos, LLVector3 regionPos,
203 LLUUID fromAgentID, string fromName, ChatTypeEnum type, string message)
204 {
205 if (!presence.IsChildAgent)
206 {
207 LLVector3 fromRegionPos = fromPos + regionPos;
208 LLVector3 toRegionPos = presence.AbsolutePosition + regionPos;
209 int dis = Math.Abs((int) Util.GetDistanceTo(toRegionPos, fromRegionPos));
210
211 if (type == ChatTypeEnum.Whisper && dis > m_whisperdistance ||
212 type == ChatTypeEnum.Say && dis > m_saydistance ||
213 type == ChatTypeEnum.Shout && dis > m_shoutdistance)
214 {
215 return;
216 }
217
218 // TODO: should change so the message is sent through the avatar rather than direct to the ClientView
219 presence.ControllingClient.SendChatMessage(message, (byte) type, fromPos, fromName, fromAgentID);
220 }
221 }
222 151
223 public void SimChat(Object sender, ChatFromViewerArgs e) 152 public void SimChat(Object sender, ChatFromViewerArgs e)
224 { 153 {
@@ -289,7 +218,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
289 m_irc.PrivMsg(fromName, scene.RegionInfo.RegionName, e.Message); 218 m_irc.PrivMsg(fromName, scene.RegionInfo.RegionName, e.Message);
290 } 219 }
291 } 220 }
292 221
293 foreach (Scene s in m_scenes) 222 foreach (Scene s in m_scenes)
294 { 223 {
295 s.ForEachScenePresence(delegate(ScenePresence presence) 224 s.ForEachScenePresence(delegate(ScenePresence presence)
@@ -301,12 +230,92 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
301 } 230 }
302 } 231 }
303 232
233 #endregion
234
235 public void NewClient(IClientAPI client)
236 {
237 try
238 {
239 client.OnChatFromViewer += SimChat;
240
241 if ((m_irc.Enabled) && (m_irc.Connected))
242 {
243 string clientName = client.FirstName + " " + client.LastName;
244 // handles simple case. May not work for hundred connecting in per second.
245 // and the NewClients calles getting interleved
246 // but filters out multiple reports
247 if (clientName != m_last_new_user)
248 {
249 m_last_new_user = clientName;
250 string clientRegion = FindClientRegion(client.FirstName, client.LastName);
251 m_irc.PrivMsg(m_irc.Nick, "Sim", "notices " + clientName + " in " + clientRegion);
252 }
253 }
254 client.OnLogout += ClientLoggedOut;
255 client.OnConnectionClosed += ClientLoggedOut;
256 client.OnLogout += ClientLoggedOut;
257 }
258 catch (Exception ex)
259 {
260 m_log.Error("[IRC]: NewClient exception trap:" + ex.ToString());
261 }
262 }
263
264 public void ClientLoggedOut(IClientAPI client)
265 {
266 lock (m_syncLogout)
267 {
268 try
269 {
270 if ((m_irc.Enabled) && (m_irc.Connected))
271 {
272 string clientName = client.FirstName + " " + client.LastName;
273 string clientRegion = FindClientRegion(client.FirstName, client.LastName);
274 // handles simple case. May not work for hundred connecting in per second.
275 // and the NewClients calles getting interleved
276 // but filters out multiple reports
277 if (clientName != m_last_leaving_user)
278 {
279 m_last_leaving_user = clientName;
280 m_irc.PrivMsg(m_irc.Nick, "Sim", "notices " + clientName + " left " + clientRegion);
281 m_log.Info("[IRC]: IRC watcher notices " + clientName + " left " + clientRegion);
282 }
283 }
284 }
285 catch (Exception ex)
286 {
287 m_log.Error("[IRC]: ClientLoggedOut exception trap:" + ex.ToString());
288 }
289 }
290 }
291
292 private void TrySendChatMessage(ScenePresence presence, LLVector3 fromPos, LLVector3 regionPos,
293 LLUUID fromAgentID, string fromName, ChatTypeEnum type, string message)
294 {
295 if (!presence.IsChildAgent)
296 {
297 LLVector3 fromRegionPos = fromPos + regionPos;
298 LLVector3 toRegionPos = presence.AbsolutePosition + regionPos;
299 int dis = Math.Abs((int) Util.GetDistanceTo(toRegionPos, fromRegionPos));
300
301 if (type == ChatTypeEnum.Whisper && dis > m_whisperdistance ||
302 type == ChatTypeEnum.Say && dis > m_saydistance ||
303 type == ChatTypeEnum.Shout && dis > m_shoutdistance)
304 {
305 return;
306 }
307
308 // TODO: should change so the message is sent through the avatar rather than direct to the ClientView
309 presence.ControllingClient.SendChatMessage(message, (byte) type, fromPos, fromName, fromAgentID);
310 }
311 }
312
304 // if IRC is enabled then just keep trying using a monitor thread 313 // if IRC is enabled then just keep trying using a monitor thread
305 public void IRCConnectRun() 314 public void IRCConnectRun()
306 { 315 {
307 while(true) 316 while (true)
308 { 317 {
309 if ((m_irc.Enabled)&&(!m_irc.Connected)) 318 if ((m_irc.Enabled) && (!m_irc.Connected))
310 { 319 {
311 m_irc.Connect(m_scenes); 320 m_irc.Connect(m_scenes);
312 } 321 }
@@ -314,54 +323,76 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
314 } 323 }
315 } 324 }
316 325
317 public string FindClientRegion(string client_FirstName,string client_LastName) 326 public string FindClientRegion(string client_FirstName, string client_LastName)
318 { 327 {
319 string sourceRegion = null; 328 string sourceRegion = null;
320 foreach (Scene s in m_scenes) 329 foreach (Scene s in m_scenes)
321 { 330 {
322 s.ForEachScenePresence(delegate(ScenePresence presence) 331 s.ForEachScenePresence(delegate(ScenePresence presence)
323 { 332 {
324 if ((presence.IsChildAgent==false) 333 if ((presence.IsChildAgent == false)
325 &&(presence.Firstname==client_FirstName) 334 && (presence.Firstname == client_FirstName)
326 &&(presence.Lastname==client_LastName)) 335 && (presence.Lastname == client_LastName))
327 { 336 {
328 sourceRegion = presence.Scene.RegionInfo.RegionName; 337 sourceRegion = presence.Scene.RegionInfo.RegionName;
329 //sourceRegion= s.RegionInfo.RegionName; 338 //sourceRegion= s.RegionInfo.RegionName;
330 } 339 }
331 }); 340 });
332 if (sourceRegion != null) return sourceRegion; 341 if (sourceRegion != null) return sourceRegion;
342 }
343 if (m_defaultzone == null)
344 {
345 m_defaultzone = "Sim";
333 } 346 }
334 if (m_defaultzone == null) { m_defaultzone = "Sim"; }
335 return m_defaultzone; 347 return m_defaultzone;
336 } 348 }
337 } 349 }
338 350
339 internal class IRCChatModule 351 internal class IRCChatModule
340 { 352 {
353 #region ErrorReplies enum
354
355 public enum ErrorReplies
356 {
357 NotRegistered = 451, // ":You have not registered"
358 NicknameInUse = 433 // "<nick> :Nickname is already in use"
359 }
360
361 #endregion
362
363 #region Replies enum
364
365 public enum Replies
366 {
367 MotdStart = 375, // ":- <server> Message of the day - "
368 Motd = 372, // ":- <text>"
369 EndOfMotd = 376 // ":End of /MOTD command"
370 }
371
372 #endregion
373
341 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 374 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
375 private Thread listener;
342 376
343 private string m_server = null;
344 private uint m_port = 6668;
345 private string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot";
346 private string m_nick = null;
347 private string m_basenick = null; 377 private string m_basenick = null;
348 private string m_channel = null; 378 private string m_channel = null;
379 private bool m_connected = false;
380 private bool m_enabled = false;
381 private List<Scene> m_last_scenes = null;
382 private string m_nick = null;
383 private uint m_port = 6668;
349 private string m_privmsgformat = "PRIVMSG {0} :<{1} in {2}>: {3}"; 384 private string m_privmsgformat = "PRIVMSG {0} :<{1} in {2}>: {3}";
385 private StreamReader m_reader;
386 private List<Scene> m_scenes = null;
387 private string m_server = null;
350 388
351 private NetworkStream m_stream; 389 private NetworkStream m_stream;
390 internal object m_syncConnect = new object();
352 private TcpClient m_tcp; 391 private TcpClient m_tcp;
392 private string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot";
353 private StreamWriter m_writer; 393 private StreamWriter m_writer;
354 private StreamReader m_reader;
355 394
356 private Thread pingSender; 395 private Thread pingSender;
357 private Thread listener;
358 internal object m_syncConnect = new object();
359
360 private bool m_enabled = false;
361 private bool m_connected = false;
362
363 private List<Scene> m_scenes = null;
364 private List<Scene> m_last_scenes = null;
365 396
366 public IRCChatModule(IConfigSource config) 397 public IRCChatModule(IConfigSource config)
367 { 398 {
@@ -412,6 +443,21 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
412 } 443 }
413 } 444 }
414 445
446 public bool Enabled
447 {
448 get { return m_enabled; }
449 }
450
451 public bool Connected
452 {
453 get { return m_connected; }
454 }
455
456 public string Nick
457 {
458 get { return m_nick; }
459 }
460
415 public bool Connect(List<Scene> scenes) 461 public bool Connect(List<Scene> scenes)
416 { 462 {
417 lock (m_syncConnect) 463 lock (m_syncConnect)
@@ -420,9 +466,12 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
420 { 466 {
421 if (m_connected) return true; 467 if (m_connected) return true;
422 m_scenes = scenes; 468 m_scenes = scenes;
423 if (m_last_scenes == null) { m_last_scenes = scenes; } 469 if (m_last_scenes == null)
470 {
471 m_last_scenes = scenes;
472 }
424 473
425 m_tcp = new TcpClient(m_server, (int)m_port); 474 m_tcp = new TcpClient(m_server, (int) m_port);
426 m_log.Info("[IRC]: Connecting..."); 475 m_log.Info("[IRC]: Connecting...");
427 m_stream = m_tcp.GetStream(); 476 m_stream = m_tcp.GetStream();
428 m_log.Info("[IRC]: Connected to " + m_server); 477 m_log.Info("[IRC]: Connected to " + m_server);
@@ -458,21 +507,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
458 } 507 }
459 } 508 }
460 509
461 public bool Enabled
462 {
463 get { return m_enabled; }
464 }
465
466 public bool Connected
467 {
468 get { return m_connected; }
469 }
470
471 public string Nick
472 {
473 get { return m_nick; }
474 }
475
476 public void Reconnect() 510 public void Reconnect()
477 { 511 {
478 m_connected = false; 512 m_connected = false;
@@ -481,7 +515,10 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
481 m_writer.Close(); 515 m_writer.Close();
482 m_reader.Close(); 516 m_reader.Close();
483 m_tcp.Close(); 517 m_tcp.Close();
484 if (m_enabled) { Connect(m_last_scenes); } 518 if (m_enabled)
519 {
520 Connect(m_last_scenes);
521 }
485 } 522 }
486 523
487 public void PrivMsg(string from, string region, string msg) 524 public void PrivMsg(string from, string region, string msg)
@@ -627,7 +664,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
627 } 664 }
628 } 665 }
629 666
630 public void BroadcastSim(string message,string sender) 667 public void BroadcastSim(string message, string sender)
631 { 668 {
632 LLVector3 pos = new LLVector3(128, 128, 20); 669 LLVector3 pos = new LLVector3(128, 128, 20);
633 try 670 try
@@ -652,23 +689,10 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
652 } 689 }
653 } 690 }
654 691
655 public enum ErrorReplies
656 {
657 NotRegistered = 451, // ":You have not registered"
658 NicknameInUse = 433 // "<nick> :Nickname is already in use"
659 }
660
661 public enum Replies
662 {
663 MotdStart = 375, // ":- <server> Message of the day - "
664 Motd = 372, // ":- <text>"
665 EndOfMotd = 376 // ":End of /MOTD command"
666 }
667
668 public void ProcessIRCCommand(string command) 692 public void ProcessIRCCommand(string command)
669 { 693 {
670 //m_log.Info("[IRC]: ProcessIRCCommand:" + command); 694 //m_log.Info("[IRC]: ProcessIRCCommand:" + command);
671 695
672 string[] commArgs = new string[command.Split(' ').Length]; 696 string[] commArgs = new string[command.Split(' ').Length];
673 string c_server = m_server; 697 string c_server = m_server;
674 698
@@ -690,7 +714,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
690 714
691 if (commArgs[0] == "ERROR") 715 if (commArgs[0] == "ERROR")
692 { 716 {
693 m_log.Error("[IRC]: IRC SERVER ERROR:" + command); 717 m_log.Error("[IRC]: IRC SERVER ERROR:" + command);
694 } 718 }
695 719
696 if (commArgs[0] == "PING") 720 if (commArgs[0] == "PING")
@@ -713,7 +737,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
713 Int32 commandCode = Int32.Parse(commArgs[1]); 737 Int32 commandCode = Int32.Parse(commArgs[1]);
714 switch (commandCode) 738 switch (commandCode)
715 { 739 {
716 case (int)ErrorReplies.NicknameInUse: 740 case (int) ErrorReplies.NicknameInUse:
717 // Gen a new name 741 // Gen a new name
718 m_nick = m_basenick + Util.RandomClass.Next(1, 99); 742 m_nick = m_basenick + Util.RandomClass.Next(1, 99);
719 m_log.Error("[IRC]: IRC SERVER reports NicknameInUse, trying " + m_nick); 743 m_log.Error("[IRC]: IRC SERVER reports NicknameInUse, trying " + m_nick);
@@ -723,9 +747,9 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
723 m_writer.WriteLine("JOIN " + m_channel); 747 m_writer.WriteLine("JOIN " + m_channel);
724 m_writer.Flush(); 748 m_writer.Flush();
725 break; 749 break;
726 case (int)ErrorReplies.NotRegistered: 750 case (int) ErrorReplies.NotRegistered:
727 break; 751 break;
728 case (int)Replies.EndOfMotd: 752 case (int) Replies.EndOfMotd:
729 break; 753 break;
730 } 754 }
731 } 755 }
@@ -733,19 +757,32 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
733 { 757 {
734 } 758 }
735 } 759 }
736 else 760 else
737 { 761 {
738 // Normal message 762 // Normal message
739 string commAct = commArgs[1]; 763 string commAct = commArgs[1];
740 switch (commAct) 764 switch (commAct)
741 { 765 {
742 case "JOIN": eventIrcJoin(commArgs); break; 766 case "JOIN":
743 case "PART": eventIrcPart(commArgs); break; 767 eventIrcJoin(commArgs);
744 case "MODE": eventIrcMode(commArgs); break; 768 break;
745 case "NICK": eventIrcNickChange(commArgs); break; 769 case "PART":
746 case "KICK": eventIrcKick(commArgs); break; 770 eventIrcPart(commArgs);
747 case "QUIT": eventIrcQuit(commArgs); break; 771 break;
748 case "PONG": break; // that's nice 772 case "MODE":
773 eventIrcMode(commArgs);
774 break;
775 case "NICK":
776 eventIrcNickChange(commArgs);
777 break;
778 case "KICK":
779 eventIrcKick(commArgs);
780 break;
781 case "QUIT":
782 eventIrcQuit(commArgs);
783 break;
784 case "PONG":
785 break; // that's nice
749 } 786 }
750 } 787 }
751 } 788 }
@@ -797,7 +834,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Chat
797 { 834 {
798 KickMessage += commArgs[i] + " "; 835 KickMessage += commArgs[i] + " ";
799 } 836 }
800 BroadcastSim(UserKicker + " kicked " + UserKicked +" on "+IrcChannel+" saying "+KickMessage, m_nick); 837 BroadcastSim(UserKicker + " kicked " + UserKicked + " on " + IrcChannel + " saying " + KickMessage, m_nick);
801 if (UserKicked == m_nick) 838 if (UserKicked == m_nick)
802 { 839 {
803 BroadcastSim("Hey, that was me!!!", m_nick); 840 BroadcastSim("Hey, that was me!!!", m_nick);
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs
index 0e058ec..181984e 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/Currency/SampleMoney/SampleMoneyModule.cs
@@ -53,7 +53,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
53 /// Centralized grid structure example using OpenSimWi Redux revision 9+ 53 /// Centralized grid structure example using OpenSimWi Redux revision 9+
54 /// svn co https://opensimwiredux.svn.sourceforge.net/svnroot/opensimwiredux 54 /// svn co https://opensimwiredux.svn.sourceforge.net/svnroot/opensimwiredux
55 /// </summary> 55 /// </summary>
56
57 public delegate void ObjectPaid(LLUUID objectID, LLUUID agentID, int amount); 56 public delegate void ObjectPaid(LLUUID objectID, LLUUID agentID, int amount);
58 57
59 public interface IMoneyModule : IRegionModule 58 public interface IMoneyModule : IRegionModule
@@ -65,37 +64,39 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
65 64
66 public class SampleMoneyModule : IMoneyModule 65 public class SampleMoneyModule : IMoneyModule
67 { 66 {
68 public event ObjectPaid OnObjectPaid;
69
70 private ObjectPaid handerOnObjectPaid;
71
72 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 67 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
73 68
74 /// <summary>
75 /// Region UUIDS indexed by AgentID
76 /// </summary>
77 Dictionary<LLUUID, LLUUID> m_rootAgents = new Dictionary<LLUUID, LLUUID>();
78
79 /// <summary> 69 /// <summary>
80 /// Scenes by Region Handle 70 /// Where Stipends come from and Fees go to.
81 /// </summary> 71 /// </summary>
82 private Dictionary<ulong,Scene> m_scenel = new Dictionary<ulong,Scene>(); 72 private LLUUID EconomyBaseAccount = LLUUID.Zero;
73
74 private float EnergyEfficiency = 0f;
75 private bool gridmode = false;
76 private ObjectPaid handerOnObjectPaid;
77 private bool m_enabled = true;
83 78
84 private IConfigSource m_gConfig; 79 private IConfigSource m_gConfig;
85 80
86 private bool m_keepMoneyAcrossLogins = true; 81 private bool m_keepMoneyAcrossLogins = true;
82 private Dictionary<LLUUID, int> m_KnownClientFunds = new Dictionary<LLUUID, int>();
83 private string m_LandAddress = String.Empty;
87 84
88 private int m_minFundsBeforeRefresh = 100; 85 private int m_minFundsBeforeRefresh = 100;
86 private string m_MoneyAddress = String.Empty;
89 87
90 private int m_stipend = 1000; 88 /// <summary>
89 /// Region UUIDS indexed by AgentID
90 /// </summary>
91 private Dictionary<LLUUID, LLUUID> m_rootAgents = new Dictionary<LLUUID, LLUUID>();
91 92
92 private bool m_enabled = true; 93 /// <summary>
94 /// Scenes by Region Handle
95 /// </summary>
96 private Dictionary<ulong, Scene> m_scenel = new Dictionary<ulong, Scene>();
93 97
94 private Dictionary<LLUUID, int> m_KnownClientFunds = new Dictionary<LLUUID, int>(); 98 private int m_stipend = 1000;
95 99
96 private bool gridmode = false;
97 private Scene XMLRPCHandler;
98 private float EnergyEfficiency = 0f;
99 private int ObjectCapacity = 45000; 100 private int ObjectCapacity = 45000;
100 private int ObjectCount = 0; 101 private int ObjectCount = 0;
101 private int PriceEnergyUnit = 0; 102 private int PriceEnergyUnit = 0;
@@ -111,16 +112,14 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
111 private int PriceRentLight = 0; 112 private int PriceRentLight = 0;
112 private int PriceUpload = 0; 113 private int PriceUpload = 0;
113 private int TeleportMinPrice = 0; 114 private int TeleportMinPrice = 0;
115
116 private float TeleportPriceExponent = 0f;
114 private int UserLevelPaysFees = 2; 117 private int UserLevelPaysFees = 2;
115 private string m_MoneyAddress = String.Empty; 118 private Scene XMLRPCHandler;
116 private string m_LandAddress = String.Empty;
117 119
118 float TeleportPriceExponent = 0f; 120 #region IMoneyModule Members
119 121
120 /// <summary> 122 public event ObjectPaid OnObjectPaid;
121 /// Where Stipends come from and Fees go to.
122 /// </summary>
123 LLUUID EconomyBaseAccount = LLUUID.Zero;
124 123
125 /// <summary> 124 /// <summary>
126 /// Startup 125 /// Startup
@@ -130,12 +129,12 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
130 public void Initialise(Scene scene, IConfigSource config) 129 public void Initialise(Scene scene, IConfigSource config)
131 { 130 {
132 m_gConfig = config; 131 m_gConfig = config;
133 132
134 IConfig startupConfig = m_gConfig.Configs["Startup"]; 133 IConfig startupConfig = m_gConfig.Configs["Startup"];
135 IConfig economyConfig = m_gConfig.Configs["Economy"]; 134 IConfig economyConfig = m_gConfig.Configs["Economy"];
136 135
137 scene.RegisterModuleInterface<IMoneyModule>(this); 136 scene.RegisterModuleInterface<IMoneyModule>(this);
138 137
139 ReadConfigAndPopulate(scene, startupConfig, "Startup"); 138 ReadConfigAndPopulate(scene, startupConfig, "Startup");
140 ReadConfigAndPopulate(scene, economyConfig, "Economy"); 139 ReadConfigAndPopulate(scene, economyConfig, "Economy");
141 140
@@ -167,8 +166,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
167 scene.AddXmlRPCHandler("preflightBuyLandPrep", preflightBuyLandPrep_func); 166 scene.AddXmlRPCHandler("preflightBuyLandPrep", preflightBuyLandPrep_func);
168 scene.AddXmlRPCHandler("buyLandPrep", landBuy_func); 167 scene.AddXmlRPCHandler("buyLandPrep", landBuy_func);
169 } 168 }
170
171
172 } 169 }
173 170
174 if (m_scenel.ContainsKey(scene.RegionInfo.RegionHandle)) 171 if (m_scenel.ContainsKey(scene.RegionInfo.RegionHandle))
@@ -180,7 +177,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
180 m_scenel.Add(scene.RegionInfo.RegionHandle, scene); 177 m_scenel.Add(scene.RegionInfo.RegionHandle, scene);
181 } 178 }
182 } 179 }
183 180
184 scene.EventManager.OnNewClient += OnNewClient; 181 scene.EventManager.OnNewClient += OnNewClient;
185 scene.EventManager.OnMoneyTransfer += MoneyTransferAction; 182 scene.EventManager.OnMoneyTransfer += MoneyTransferAction;
186 scene.EventManager.OnClientClosed += ClientClosed; 183 scene.EventManager.OnClientClosed += ClientClosed;
@@ -189,9 +186,41 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
189 scene.EventManager.OnClientClosed += ClientLoggedOut; 186 scene.EventManager.OnClientClosed += ClientLoggedOut;
190 scene.EventManager.OnValidateLandBuy += ValidateLandBuy; 187 scene.EventManager.OnValidateLandBuy += ValidateLandBuy;
191 scene.EventManager.OnLandBuy += processLandBuy; 188 scene.EventManager.OnLandBuy += processLandBuy;
192
193 } 189 }
194 } 190 }
191
192 public bool ObjectGiveMoney(LLUUID objectID, LLUUID fromID, LLUUID toID, int amount)
193 {
194 string description = String.Format("Object {0} pays {1}", resolveObjectName(objectID), resolveAgentName(toID));
195
196 bool give_result = doMoneyTransfer(fromID, toID, amount, 2, description);
197
198 if (m_MoneyAddress.Length == 0)
199 BalanceUpdate(fromID, toID, give_result, description);
200
201 return give_result;
202 }
203
204 public void PostInitialise()
205 {
206 }
207
208 public void Close()
209 {
210 }
211
212 public string Name
213 {
214 get { return "BetaGridLikeMoneyModule"; }
215 }
216
217 public bool IsSharedModule
218 {
219 get { return true; }
220 }
221
222 #endregion
223
195 /// <summary> 224 /// <summary>
196 /// Parse Configuration 225 /// Parse Configuration
197 /// </summary> 226 /// </summary>
@@ -207,7 +236,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
207 } 236 }
208 237
209 if (config == "Economy" && startupConfig != null) 238 if (config == "Economy" && startupConfig != null)
210 { 239 {
211 ObjectCapacity = startupConfig.GetInt("ObjectCapacity", 45000); 240 ObjectCapacity = startupConfig.GetInt("ObjectCapacity", 45000);
212 PriceEnergyUnit = startupConfig.GetInt("PriceEnergyUnit", 100); 241 PriceEnergyUnit = startupConfig.GetInt("PriceEnergyUnit", 100);
213 PriceObjectClaim = startupConfig.GetInt("PriceObjectClaim", 10); 242 PriceObjectClaim = startupConfig.GetInt("PriceObjectClaim", 10);
@@ -225,7 +254,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
225 PriceParcelRent = startupConfig.GetInt("PriceParcelRent", 1); 254 PriceParcelRent = startupConfig.GetInt("PriceParcelRent", 1);
226 PriceGroupCreate = startupConfig.GetInt("PriceGroupCreate", -1); 255 PriceGroupCreate = startupConfig.GetInt("PriceGroupCreate", -1);
227 string EBA = startupConfig.GetString("EconomyBaseAccount", LLUUID.Zero.ToString()); 256 string EBA = startupConfig.GetString("EconomyBaseAccount", LLUUID.Zero.ToString());
228 Helpers.TryParse(EBA,out EconomyBaseAccount); 257 Helpers.TryParse(EBA, out EconomyBaseAccount);
229 258
230 UserLevelPaysFees = startupConfig.GetInt("UserLevelPaysFees", -1); 259 UserLevelPaysFees = startupConfig.GetInt("UserLevelPaysFees", -1);
231 m_stipend = startupConfig.GetInt("UserStipend", 500); 260 m_stipend = startupConfig.GetInt("UserStipend", 500);
@@ -234,7 +263,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
234 m_MoneyAddress = startupConfig.GetString("CurrencyServer", String.Empty); 263 m_MoneyAddress = startupConfig.GetString("CurrencyServer", String.Empty);
235 m_LandAddress = startupConfig.GetString("LandServer", String.Empty); 264 m_LandAddress = startupConfig.GetString("LandServer", String.Empty);
236 } 265 }
237 266
238 // Send ObjectCapacity to Scene.. Which sends it to the SimStatsReporter. 267 // Send ObjectCapacity to Scene.. Which sends it to the SimStatsReporter.
239 scene.SetObjectCapacity(ObjectCapacity); 268 scene.SetObjectCapacity(ObjectCapacity);
240 } 269 }
@@ -253,7 +282,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
253 { 282 {
254 if (m_MoneyAddress.Length == 0) 283 if (m_MoneyAddress.Length == 0)
255 { 284 {
256
257 CheckExistAndRefreshFunds(client.AgentId); 285 CheckExistAndRefreshFunds(client.AgentId);
258 } 286 }
259 else 287 else
@@ -273,15 +301,16 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
273 //s.RegionInfo.RegionHandle; 301 //s.RegionInfo.RegionHandle;
274 LLUUID agentID = LLUUID.Zero; 302 LLUUID agentID = LLUUID.Zero;
275 int funds = 0; 303 int funds = 0;
276
277 Hashtable hbinfo = GetBalanceForUserFromMoneyServer(client.AgentId, client.SecureSessionId, s.RegionInfo.originRegionID.ToString(), s.RegionInfo.regionSecret);
278 if ((bool)hbinfo["success"] == true)
279 {
280 304
281 Helpers.TryParse((string)hbinfo["agentId"], out agentID); 305 Hashtable hbinfo =
306 GetBalanceForUserFromMoneyServer(client.AgentId, client.SecureSessionId, s.RegionInfo.originRegionID.ToString(),
307 s.RegionInfo.regionSecret);
308 if ((bool) hbinfo["success"] == true)
309 {
310 Helpers.TryParse((string) hbinfo["agentId"], out agentID);
282 try 311 try
283 { 312 {
284 funds = (Int32)hbinfo["funds"]; 313 funds = (Int32) hbinfo["funds"];
285 } 314 }
286 catch (ArgumentException) 315 catch (ArgumentException)
287 { 316 {
@@ -303,340 +332,27 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
303 } 332 }
304 else 333 else
305 { 334 {
306 m_log.WarnFormat("[MONEY]: Getting Money for user {0} failed with the following message:{1}", agentID, (string)hbinfo["errorMessage"]); 335 m_log.WarnFormat("[MONEY]: Getting Money for user {0} failed with the following message:{1}", agentID,
307 client.SendAlertMessage((string)hbinfo["errorMessage"]); 336 (string) hbinfo["errorMessage"]);
337 client.SendAlertMessage((string) hbinfo["errorMessage"]);
308 } 338 }
309 SendMoneyBalance(client, agentID, client.SessionId, LLUUID.Zero); 339 SendMoneyBalance(client, agentID, client.SessionId, LLUUID.Zero);
310
311 } 340 }
312 } 341 }
313
314 } 342 }
315 else 343 else
316 { 344 {
317 CheckExistAndRefreshFunds(client.AgentId); 345 CheckExistAndRefreshFunds(client.AgentId);
318 } 346 }
319 347
320 // Subscribe to Money messages 348 // Subscribe to Money messages
321 client.OnEconomyDataRequest += EconomyDataRequestHandler; 349 client.OnEconomyDataRequest += EconomyDataRequestHandler;
322 client.OnMoneyBalanceRequest += SendMoneyBalance; 350 client.OnMoneyBalanceRequest += SendMoneyBalance;
323 client.OnRequestPayPrice += requestPayPrice; 351 client.OnRequestPayPrice += requestPayPrice;
324 client.OnLogout += ClientClosed; 352 client.OnLogout += ClientClosed;
325
326
327 }
328
329 #region event Handlers
330
331 public void requestPayPrice(IClientAPI client, LLUUID objectID)
332 {
333 Scene scene=LocateSceneClientIn(client.AgentId);
334 if(scene == null)
335 return;
336
337 SceneObjectPart task=scene.GetSceneObjectPart(objectID);
338 if(task == null)
339 return;
340 SceneObjectGroup group=task.ParentGroup;
341 SceneObjectPart root=group.RootPart;
342
343 client.SendPayPrice(objectID, root.PayPrice);
344 }
345
346 /// <summary>
347 /// When the client closes the connection we remove their accounting info from memory to free up resources.
348 /// </summary>
349 /// <param name="AgentID"></param>
350 public void ClientClosed(LLUUID AgentID)
351 {
352 lock (m_KnownClientFunds)
353 {
354 if (m_keepMoneyAcrossLogins && m_MoneyAddress.Length == 0)
355 {
356 }
357 else
358 {
359 m_KnownClientFunds.Remove(AgentID);
360 }
361 }
362 }
363
364 /// <summary>
365 /// Event called Economy Data Request handler.
366 /// </summary>
367 /// <param name="agentId"></param>
368 public void EconomyDataRequestHandler(LLUUID agentId)
369 {
370 IClientAPI user = LocateClientObject(agentId);
371
372 if (user != null)
373 {
374 user.SendEconomyData(EnergyEfficiency, ObjectCapacity, ObjectCount, PriceEnergyUnit, PriceGroupCreate,
375 PriceObjectClaim, PriceObjectRent, PriceObjectScaleFactor, PriceParcelClaim, PriceParcelClaimFactor,
376 PriceParcelRent, PricePublicObjectDecay, PricePublicObjectDelete, PriceRentLight, PriceUpload,
377 TeleportMinPrice, TeleportPriceExponent);
378 }
379 }
380
381 private void ValidateLandBuy (Object osender, EventManager.LandBuyArgs e)
382 {
383 if (m_MoneyAddress.Length == 0)
384 {
385 lock (m_KnownClientFunds)
386 {
387 if (m_KnownClientFunds.ContainsKey(e.agentId))
388 {
389 // Does the sender have enough funds to give?
390 if (m_KnownClientFunds[e.agentId] >= e.parcelPrice)
391 {
392 lock(e)
393 {
394 e.economyValidated=true;
395 }
396 }
397 }
398 }
399 }
400 else
401 {
402 if(GetRemoteBalance(e.agentId) >= e.parcelPrice)
403 {
404 lock(e)
405 {
406 e.economyValidated=true;
407 }
408 }
409 }
410 }
411
412 private void processLandBuy(Object osender, EventManager.LandBuyArgs e)
413 {
414 lock(e)
415 {
416 if(e.economyValidated == true && e.transactionID == 0)
417 {
418 e.transactionID=Util.UnixTimeSinceEpoch();
419
420 if(doMoneyTransfer(e.agentId, e.parcelOwnerID, e.parcelPrice, 0, "Land purchase"))
421 {
422 lock (e)
423 {
424 e.amountDebited = e.parcelPrice;
425 }
426 }
427 }
428 }
429 } 353 }
430 354
431 /// <summary> 355 /// <summary>
432 /// THis method gets called when someone pays someone else as a gift.
433 /// </summary>
434 /// <param name="osender"></param>
435 /// <param name="e"></param>
436 private void MoneyTransferAction (Object osender, EventManager.MoneyTransferArgs e)
437 {
438 IClientAPI sender = null;
439 IClientAPI receiver = null;
440
441 if(m_MoneyAddress.Length > 0) // Handled on server
442 e.description=String.Empty;
443
444 if(e.transactiontype == 5008) // Object gets paid
445 {
446 sender = LocateClientObject(e.sender);
447 if (sender != null)
448 {
449 SceneObjectPart part=findPrim(e.receiver);
450 if(part == null)
451 return;
452
453 string name=resolveAgentName(part.OwnerID);
454 if(name == String.Empty)
455 name="(hippos)";
456
457 receiver = LocateClientObject(part.OwnerID);
458
459 string description=String.Format("Paid {0} via object {1}", name, e.description);
460 bool transactionresult = doMoneyTransfer(e.sender, part.OwnerID, e.amount, e.transactiontype, description);
461
462 if(transactionresult)
463 {
464 ObjectPaid handlerOnObjectPaid = OnObjectPaid;
465 if(handlerOnObjectPaid != null)
466 {
467 handlerOnObjectPaid(e.receiver, e.sender, e.amount);
468 }
469 }
470
471 if (e.sender != e.receiver)
472 {
473 sender.SendMoneyBalance(LLUUID.Random(), transactionresult, Helpers.StringToField(e.description), GetFundsForAgentID(e.sender));
474 }
475 if(receiver != null)
476 {
477 receiver.SendMoneyBalance(LLUUID.Random(), transactionresult, Helpers.StringToField(e.description), GetFundsForAgentID(part.OwnerID));
478 }
479 }
480 return;
481 }
482
483 sender = LocateClientObject(e.sender);
484 if (sender != null)
485 {
486 receiver = LocateClientObject(e.receiver);
487
488 bool transactionresult = doMoneyTransfer(e.sender, e.receiver, e.amount, e.transactiontype, e.description);
489
490 if (e.sender != e.receiver)
491 {
492 if (sender != null)
493 {
494 sender.SendMoneyBalance(LLUUID.Random(), transactionresult, Helpers.StringToField(e.description), GetFundsForAgentID(e.sender));
495 }
496 }
497
498 if (receiver != null)
499 {
500 receiver.SendMoneyBalance(LLUUID.Random(), transactionresult, Helpers.StringToField(e.description), GetFundsForAgentID(e.receiver));
501 }
502 }
503 else
504 {
505 m_log.Warn("[MONEY]: Potential Fraud Warning, got money transfer request for avatar that isn't in this simulator - Details; Sender:" + e.sender.ToString() + " Receiver: " + e.receiver.ToString() + " Amount: " + e.amount.ToString());
506 }
507 }
508
509 /// <summary>
510 /// Event Handler for when a root agent becomes a child agent
511 /// </summary>
512 /// <param name="avatar"></param>
513 private void MakeChildAgent(ScenePresence avatar)
514 {
515 lock (m_rootAgents)
516 {
517 if (m_rootAgents.ContainsKey(avatar.UUID))
518 {
519 if (m_rootAgents[avatar.UUID] == avatar.Scene.RegionInfo.originRegionID)
520 {
521 m_rootAgents.Remove(avatar.UUID);
522 m_log.Info("[MONEY]: Removing " + avatar.Firstname + " " + avatar.Lastname + " as a root agent");
523 }
524
525 }
526 }
527
528 }
529
530 /// <summary>
531 /// Event Handler for when the client logs out.
532 /// </summary>
533 /// <param name="AgentId"></param>
534 private void ClientLoggedOut(LLUUID AgentId)
535 {
536 lock (m_rootAgents)
537 {
538 if (m_rootAgents.ContainsKey(AgentId))
539 {
540 m_rootAgents.Remove(AgentId);
541 //m_log.Info("[MONEY]: Removing " + AgentId + ". Agent logged out.");
542 }
543 }
544 }
545
546 /// <summary>
547 /// Call this when the client disconnects.
548 /// </summary>
549 /// <param name="client"></param>
550 public void ClientClosed(IClientAPI client)
551 {
552 ClientClosed(client.AgentId);
553 }
554
555 /// <summary>
556 /// Event Handler for when an Avatar enters one of the parcels in the simulator.
557 /// </summary>
558 /// <param name="avatar"></param>
559 /// <param name="localLandID"></param>
560 /// <param name="regionID"></param>
561 private void AvatarEnteringParcel(ScenePresence avatar, int localLandID, LLUUID regionID)
562 {
563 lock (m_rootAgents)
564 {
565 if (m_rootAgents.ContainsKey(avatar.UUID))
566 {
567 if (avatar.Scene.RegionInfo.originRegionID != m_rootAgents[avatar.UUID])
568 {
569 m_rootAgents[avatar.UUID] = avatar.Scene.RegionInfo.originRegionID;
570 //m_log.Info("[MONEY]: Claiming " + avatar.Firstname + " " + avatar.Lastname + " in region:" + avatar.RegionHandle + ".");
571 // Claim User! my user! Mine mine mine!
572 if (m_MoneyAddress.Length > 0)
573 {
574 Scene RegionItem = GetSceneByUUID(regionID);
575 if (RegionItem != null)
576 {
577 Hashtable hresult = claim_user(avatar.UUID, avatar.ControllingClient.SecureSessionId, regionID, RegionItem.RegionInfo.regionSecret);
578 if ((bool)hresult["success"] == true)
579 {
580 int funds = 0;
581 try
582 {
583 funds = (Int32)hresult["funds"];
584 }
585 catch (InvalidCastException)
586 {
587
588 }
589 SetLocalFundsForAgentID(avatar.UUID, funds);
590 }
591 else
592 {
593 avatar.ControllingClient.SendAgentAlertMessage((string)hresult["errorMessage"], true);
594 }
595 }
596 }
597 }
598 }
599 else
600 {
601 lock (m_rootAgents)
602 {
603 m_rootAgents.Add(avatar.UUID, avatar.Scene.RegionInfo.originRegionID);
604 }
605 if (m_MoneyAddress.Length > 0)
606 {
607 Scene RegionItem = GetSceneByUUID(regionID);
608 if (RegionItem != null)
609 {
610 Hashtable hresult = claim_user(avatar.UUID, avatar.ControllingClient.SecureSessionId, regionID, RegionItem.RegionInfo.regionSecret);
611 if ((bool)hresult["success"] == true)
612 {
613 int funds = 0;
614 try
615 {
616 funds = (Int32)hresult["funds"];
617 }
618 catch (InvalidCastException)
619 {
620
621 }
622 SetLocalFundsForAgentID(avatar.UUID, funds);
623 }
624 else
625 {
626 avatar.ControllingClient.SendAgentAlertMessage((string)hresult["errorMessage"], true);
627 }
628 }
629 }
630
631 //m_log.Info("[MONEY]: Claiming " + avatar.Firstname + " " + avatar.Lastname + " in region:" + avatar.RegionHandle + ".");
632 }
633 }
634 //m_log.Info("[FRIEND]: " + avatar.Name + " status:" + (!avatar.IsChildAgent).ToString());
635 }
636
637 #endregion
638
639 /// <summary>
640 /// Transfer money 356 /// Transfer money
641 /// </summary> 357 /// </summary>
642 /// <param name="Sender"></param> 358 /// <param name="Sender"></param>
@@ -695,96 +411,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
695 return result; 411 return result;
696 } 412 }
697 413
698 #region Utility Helpers
699 /// <summary>
700 /// Locates a IClientAPI for the client specified
701 /// </summary>
702 /// <param name="AgentID"></param>
703 /// <returns></returns>
704 private IClientAPI LocateClientObject(LLUUID AgentID)
705 {
706 ScenePresence tPresence = null;
707 IClientAPI rclient = null;
708
709 lock (m_scenel)
710 {
711 foreach (Scene _scene in m_scenel.Values)
712 {
713 tPresence = _scene.GetScenePresence(AgentID);
714 if (tPresence != null)
715 {
716 if (!tPresence.IsChildAgent)
717 {
718 rclient = tPresence.ControllingClient;
719 }
720 }
721 if (rclient != null)
722 {
723 return rclient;
724 }
725 }
726
727 }
728 return null;
729 }
730
731 private Scene LocateSceneClientIn(LLUUID AgentId)
732 {
733 lock (m_scenel)
734 {
735 foreach (Scene _scene in m_scenel.Values)
736 {
737 ScenePresence tPresence = _scene.GetScenePresence(AgentId);
738 if (tPresence != null)
739 {
740 if (!tPresence.IsChildAgent)
741 {
742 return _scene;
743 }
744 }
745
746 }
747
748 }
749 return null;
750 }
751
752 /// <summary>
753 /// Utility function Gets a Random scene in the instance. For when which scene exactly you're doing something with doesn't matter
754 /// </summary>
755 /// <returns></returns>
756 public Scene GetRandomScene()
757 {
758 lock (m_scenel)
759 {
760 foreach (Scene rs in m_scenel.Values)
761 return rs;
762 }
763 return null;
764
765 }
766 /// <summary>
767 /// Utility function to get a Scene by RegionID in a module
768 /// </summary>
769 /// <param name="RegionID"></param>
770 /// <returns></returns>
771 public Scene GetSceneByUUID(LLUUID RegionID)
772 {
773 lock (m_scenel)
774 {
775 foreach (Scene rs in m_scenel.Values)
776 {
777 if (rs.RegionInfo.originRegionID == RegionID)
778 {
779 return rs;
780 }
781 }
782 }
783 return null;
784 }
785 #endregion
786
787
788 414
789 /// <summary> 415 /// <summary>
790 /// Sends the the stored money balance to the client 416 /// Sends the the stored money balance to the client
@@ -798,7 +424,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
798 if (client.AgentId == agentID && client.SessionId == SessionID) 424 if (client.AgentId == agentID && client.SessionId == SessionID)
799 { 425 {
800 int returnfunds = 0; 426 int returnfunds = 0;
801 427
802 try 428 try
803 { 429 {
804 returnfunds = GetFundsForAgentID(agentID); 430 returnfunds = GetFundsForAgentID(agentID);
@@ -807,7 +433,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
807 { 433 {
808 client.SendAlertMessage(e.Message + " "); 434 client.SendAlertMessage(e.Message + " ");
809 } 435 }
810 436
811 client.SendMoneyBalance(TransactionID, true, new byte[0], returnfunds); 437 client.SendMoneyBalance(TransactionID, true, new byte[0], returnfunds);
812 } 438 }
813 else 439 else
@@ -816,67 +442,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
816 } 442 }
817 } 443 }
818 444
819 #region local Fund Management
820 /// <summary>
821 /// Ensures that the agent accounting data is set up in this instance.
822 /// </summary>
823 /// <param name="agentID"></param>
824 private void CheckExistAndRefreshFunds(LLUUID agentID)
825 {
826 lock (m_KnownClientFunds)
827 {
828 if (!m_KnownClientFunds.ContainsKey(agentID))
829 {
830 m_KnownClientFunds.Add(agentID, m_stipend);
831 }
832 else
833 {
834 if (m_KnownClientFunds[agentID] <= m_minFundsBeforeRefresh)
835 {
836 m_KnownClientFunds[agentID] = m_stipend;
837 }
838 }
839 }
840 }
841 /// <summary>
842 /// Gets the amount of Funds for an agent
843 /// </summary>
844 /// <param name="AgentID"></param>
845 /// <returns></returns>
846 private int GetFundsForAgentID(LLUUID AgentID)
847 {
848 int returnfunds = 0;
849 lock (m_KnownClientFunds)
850 {
851 if (m_KnownClientFunds.ContainsKey(AgentID))
852 {
853 returnfunds = m_KnownClientFunds[AgentID];
854 }
855 else
856 {
857 //throw new Exception("Unable to get funds.");
858 }
859 }
860 return returnfunds;
861 }
862 private void SetLocalFundsForAgentID(LLUUID AgentID, int amount)
863 {
864 lock (m_KnownClientFunds)
865 {
866 if (m_KnownClientFunds.ContainsKey(AgentID))
867 {
868 m_KnownClientFunds[AgentID] = amount;
869 }
870 else
871 {
872 m_KnownClientFunds.Add(AgentID, amount);
873 }
874 }
875
876 }
877
878 #endregion
879
880 /// <summary> 445 /// <summary>
881 /// Gets the current balance for the user from the Grid Money Server 446 /// Gets the current balance for the user from the Grid Money Server
882 /// </summary> 447 /// </summary>
@@ -887,7 +452,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
887 /// <returns></returns> 452 /// <returns></returns>
888 public Hashtable GetBalanceForUserFromMoneyServer(LLUUID agentId, LLUUID secureSessionID, LLUUID regionId, string regionSecret) 453 public Hashtable GetBalanceForUserFromMoneyServer(LLUUID agentId, LLUUID secureSessionID, LLUUID regionId, string regionSecret)
889 { 454 {
890
891 Hashtable MoneyBalanceRequestParams = new Hashtable(); 455 Hashtable MoneyBalanceRequestParams = new Hashtable();
892 MoneyBalanceRequestParams["agentId"] = agentId.ToString(); 456 MoneyBalanceRequestParams["agentId"] = agentId.ToString();
893 MoneyBalanceRequestParams["secureSessionId"] = secureSessionID.ToString(); 457 MoneyBalanceRequestParams["secureSessionId"] = secureSessionID.ToString();
@@ -899,8 +463,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
899 463
900 return MoneyRespData; 464 return MoneyRespData;
901 } 465 }
902 466
903
904 467
905 /// <summary> 468 /// <summary>
906 /// Generic XMLRPC client abstraction 469 /// Generic XMLRPC client abstraction
@@ -921,7 +484,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
921 } 484 }
922 catch (WebException ex) 485 catch (WebException ex)
923 { 486 {
924
925 m_log.ErrorFormat( 487 m_log.ErrorFormat(
926 "[MONEY]: Unable to connect to Money Server {0}. Exception {1}", 488 "[MONEY]: Unable to connect to Money Server {0}. Exception {1}",
927 m_MoneyAddress, ex); 489 m_MoneyAddress, ex);
@@ -936,7 +498,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
936 } 498 }
937 catch (SocketException ex) 499 catch (SocketException ex)
938 { 500 {
939
940 m_log.ErrorFormat( 501 m_log.ErrorFormat(
941 "[MONEY]: Unable to connect to Money Server {0}. Exception {1}", 502 "[MONEY]: Unable to connect to Money Server {0}. Exception {1}",
942 m_MoneyAddress, ex); 503 m_MoneyAddress, ex);
@@ -961,7 +522,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
961 ErrorHash["errorURI"] = ""; 522 ErrorHash["errorURI"] = "";
962 523
963 return ErrorHash; 524 return ErrorHash;
964
965 } 525 }
966 if (MoneyResp.IsFault) 526 if (MoneyResp.IsFault)
967 { 527 {
@@ -971,12 +531,12 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
971 ErrorHash["errorURI"] = ""; 531 ErrorHash["errorURI"] = "";
972 532
973 return ErrorHash; 533 return ErrorHash;
974
975 } 534 }
976 Hashtable MoneyRespData = (Hashtable)MoneyResp.Value; 535 Hashtable MoneyRespData = (Hashtable) MoneyResp.Value;
977 536
978 return MoneyRespData; 537 return MoneyRespData;
979 } 538 }
539
980 /// <summary> 540 /// <summary>
981 /// This informs the Money Grid Server that the avatar is in this simulator 541 /// This informs the Money Grid Server that the avatar is in this simulator
982 /// </summary> 542 /// </summary>
@@ -987,7 +547,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
987 /// <returns></returns> 547 /// <returns></returns>
988 public Hashtable claim_user(LLUUID agentId, LLUUID secureSessionID, LLUUID regionId, string regionSecret) 548 public Hashtable claim_user(LLUUID agentId, LLUUID secureSessionID, LLUUID regionId, string regionSecret)
989 { 549 {
990
991 Hashtable MoneyBalanceRequestParams = new Hashtable(); 550 Hashtable MoneyBalanceRequestParams = new Hashtable();
992 MoneyBalanceRequestParams["agentId"] = agentId.ToString(); 551 MoneyBalanceRequestParams["agentId"] = agentId.ToString();
993 MoneyBalanceRequestParams["secureSessionId"] = secureSessionID.ToString(); 552 MoneyBalanceRequestParams["secureSessionId"] = secureSessionID.ToString();
@@ -1009,8 +568,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
1009 { 568 {
1010 foreach (Scene s in m_scenel.Values) 569 foreach (Scene s in m_scenel.Values)
1011 { 570 {
1012 SceneObjectPart part=s.GetSceneObjectPart(objectID); 571 SceneObjectPart part = s.GetSceneObjectPart(objectID);
1013 if(part != null) 572 if (part != null)
1014 { 573 {
1015 return part; 574 return part;
1016 } 575 }
@@ -1021,8 +580,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
1021 580
1022 private string resolveObjectName(LLUUID objectID) 581 private string resolveObjectName(LLUUID objectID)
1023 { 582 {
1024 SceneObjectPart part=findPrim(objectID); 583 SceneObjectPart part = findPrim(objectID);
1025 if(part != null) 584 if (part != null)
1026 { 585 {
1027 return part.Name; 586 return part.Name;
1028 } 587 }
@@ -1032,7 +591,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
1032 private string resolveAgentName(LLUUID agentID) 591 private string resolveAgentName(LLUUID agentID)
1033 { 592 {
1034 // try avatar username surname 593 // try avatar username surname
1035 Scene scene=GetRandomScene(); 594 Scene scene = GetRandomScene();
1036 UserProfileData profile = scene.CommsManager.UserService.GetUserProfile(agentID); 595 UserProfileData profile = scene.CommsManager.UserService.GetUserProfile(agentID);
1037 if (profile != null) 596 if (profile != null)
1038 { 597 {
@@ -1042,19 +601,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
1042 return String.Empty; 601 return String.Empty;
1043 } 602 }
1044 603
1045 public bool ObjectGiveMoney(LLUUID objectID, LLUUID fromID, LLUUID toID, int amount)
1046 {
1047 string description=String.Format("Object {0} pays {1}", resolveObjectName(objectID), resolveAgentName(toID));
1048
1049 bool give_result = doMoneyTransfer(fromID, toID, amount, 2, description);
1050
1051 if (m_MoneyAddress.Length == 0)
1052 BalanceUpdate(fromID, toID, give_result, description);
1053
1054 return give_result;
1055
1056
1057 }
1058 private void BalanceUpdate(LLUUID senderID, LLUUID receiverID, bool transactionresult, string description) 604 private void BalanceUpdate(LLUUID senderID, LLUUID receiverID, bool transactionresult, string description)
1059 { 605 {
1060 IClientAPI sender = LocateClientObject(senderID); 606 IClientAPI sender = LocateClientObject(senderID);
@@ -1091,7 +637,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
1091 IClientAPI cli = LocateClientObject(sourceId); 637 IClientAPI cli = LocateClientObject(sourceId);
1092 if (cli != null) 638 if (cli != null)
1093 { 639 {
1094
1095 Scene userScene = null; 640 Scene userScene = null;
1096 lock (m_rootAgents) 641 lock (m_rootAgents)
1097 { 642 {
@@ -1112,18 +657,18 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
1112 ht["flags"] = flags; 657 ht["flags"] = flags;
1113 ht["transactionType"] = transactiontype; 658 ht["transactionType"] = transactiontype;
1114 ht["description"] = description; 659 ht["description"] = description;
1115 660
1116 Hashtable hresult = genericCurrencyXMLRPCRequest(ht, "regionMoveMoney"); 661 Hashtable hresult = genericCurrencyXMLRPCRequest(ht, "regionMoveMoney");
1117 662
1118 if ((bool)hresult["success"] == true) 663 if ((bool) hresult["success"] == true)
1119 { 664 {
1120 int funds1 = 0; 665 int funds1 = 0;
1121 int funds2 = 0; 666 int funds2 = 0;
1122 try 667 try
1123 { 668 {
1124 funds1 = (Int32)hresult["funds"]; 669 funds1 = (Int32) hresult["funds"];
1125 } 670 }
1126 catch(InvalidCastException) 671 catch (InvalidCastException)
1127 { 672 {
1128 funds1 = 0; 673 funds1 = 0;
1129 } 674 }
@@ -1132,7 +677,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
1132 { 677 {
1133 try 678 try
1134 { 679 {
1135 funds2 = (Int32)hresult["funds2"]; 680 funds2 = (Int32) hresult["funds2"];
1136 } 681 }
1137 catch (InvalidCastException) 682 catch (InvalidCastException)
1138 { 683 {
@@ -1146,9 +691,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
1146 } 691 }
1147 else 692 else
1148 { 693 {
1149 cli.SendAgentAlertMessage((string)hresult["errorMessage"], true); 694 cli.SendAgentAlertMessage((string) hresult["errorMessage"], true);
1150 } 695 }
1151
1152 } 696 }
1153 } 697 }
1154 else 698 else
@@ -1157,7 +701,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
1157 } 701 }
1158 702
1159 return rvalue; 703 return rvalue;
1160
1161 } 704 }
1162 705
1163 public int GetRemoteBalance(LLUUID agentId) 706 public int GetRemoteBalance(LLUUID agentId)
@@ -1172,12 +715,14 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
1172 { 715 {
1173 if (m_MoneyAddress.Length > 0) 716 if (m_MoneyAddress.Length > 0)
1174 { 717 {
1175 Hashtable hbinfo = GetBalanceForUserFromMoneyServer(aClient.AgentId, aClient.SecureSessionId, s.RegionInfo.originRegionID.ToString(), s.RegionInfo.regionSecret); 718 Hashtable hbinfo =
1176 if ((bool)hbinfo["success"] == true) 719 GetBalanceForUserFromMoneyServer(aClient.AgentId, aClient.SecureSessionId, s.RegionInfo.originRegionID.ToString(),
720 s.RegionInfo.regionSecret);
721 if ((bool) hbinfo["success"] == true)
1177 { 722 {
1178 try 723 try
1179 { 724 {
1180 funds = (Int32)hbinfo["funds"]; 725 funds = (Int32) hbinfo["funds"];
1181 } 726 }
1182 catch (ArgumentException) 727 catch (ArgumentException)
1183 { 728 {
@@ -1194,12 +739,12 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
1194 { 739 {
1195 funds = 0; 740 funds = 0;
1196 } 741 }
1197
1198 } 742 }
1199 else 743 else
1200 { 744 {
1201 m_log.WarnFormat("[MONEY]: Getting Money for user {0} failed with the following message:{1}", agentId, (string)hbinfo["errorMessage"]); 745 m_log.WarnFormat("[MONEY]: Getting Money for user {0} failed with the following message:{1}", agentId,
1202 aClient.SendAlertMessage((string)hbinfo["errorMessage"]); 746 (string) hbinfo["errorMessage"]);
747 aClient.SendAlertMessage((string) hbinfo["errorMessage"]);
1203 } 748 }
1204 } 749 }
1205 750
@@ -1221,17 +766,16 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
1221 public XmlRpcResponse GridMoneyUpdate(XmlRpcRequest request) 766 public XmlRpcResponse GridMoneyUpdate(XmlRpcRequest request)
1222 { 767 {
1223 m_log.Debug("[MONEY]: Dynamic balance update called."); 768 m_log.Debug("[MONEY]: Dynamic balance update called.");
1224 Hashtable requestData = (Hashtable)request.Params[0]; 769 Hashtable requestData = (Hashtable) request.Params[0];
1225 770
1226 if (requestData.ContainsKey("agentId")) 771 if (requestData.ContainsKey("agentId"))
1227 { 772 {
1228 LLUUID agentId = LLUUID.Zero; 773 LLUUID agentId = LLUUID.Zero;
1229 774
1230 Helpers.TryParse((string)requestData["agentId"], out agentId); 775 Helpers.TryParse((string) requestData["agentId"], out agentId);
1231 if (agentId != LLUUID.Zero) 776 if (agentId != LLUUID.Zero)
1232 { 777 {
1233 GetRemoteBalance(agentId); 778 GetRemoteBalance(agentId);
1234
1235 } 779 }
1236 else 780 else
1237 { 781 {
@@ -1245,7 +789,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
1245 XmlRpcResponse r = new XmlRpcResponse(); 789 XmlRpcResponse r = new XmlRpcResponse();
1246 Hashtable rparms = new Hashtable(); 790 Hashtable rparms = new Hashtable();
1247 rparms["success"] = true; 791 rparms["success"] = true;
1248 792
1249 r.Value = rparms; 793 r.Value = rparms;
1250 return r; 794 return r;
1251 } 795 }
@@ -1257,24 +801,24 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
1257 { 801 {
1258 XmlRpcResponse ret = new XmlRpcResponse(); 802 XmlRpcResponse ret = new XmlRpcResponse();
1259 Hashtable retparam = new Hashtable(); 803 Hashtable retparam = new Hashtable();
1260 Hashtable requestData = (Hashtable)request.Params[0]; 804 Hashtable requestData = (Hashtable) request.Params[0];
1261 805
1262 LLUUID agentId = LLUUID.Zero; 806 LLUUID agentId = LLUUID.Zero;
1263 LLUUID soundId = LLUUID.Zero; 807 LLUUID soundId = LLUUID.Zero;
1264 808
1265 Helpers.TryParse((string)requestData["agentId"], out agentId); 809 Helpers.TryParse((string) requestData["agentId"], out agentId);
1266 Helpers.TryParse((string)requestData["soundId"], out soundId); 810 Helpers.TryParse((string) requestData["soundId"], out soundId);
1267 string text=(string)requestData["text"]; 811 string text = (string) requestData["text"];
1268 string secret=(string)requestData["secret"]; 812 string secret = (string) requestData["secret"];
1269 813
1270 Scene userScene = GetRandomScene(); 814 Scene userScene = GetRandomScene();
1271 if(userScene.RegionInfo.regionSecret.ToString() == secret) 815 if (userScene.RegionInfo.regionSecret.ToString() == secret)
1272 { 816 {
1273 IClientAPI client = LocateClientObject(agentId); 817 IClientAPI client = LocateClientObject(agentId);
1274 818
1275 if (client != null) 819 if (client != null)
1276 { 820 {
1277 if(soundId != LLUUID.Zero) 821 if (soundId != LLUUID.Zero)
1278 client.SendPlayAttachedSound(soundId, LLUUID.Zero, LLUUID.Zero, 1.0f, 0); 822 client.SendPlayAttachedSound(soundId, LLUUID.Zero, LLUUID.Zero, 1.0f, 0);
1279 client.SendBlueBoxMessage(LLUUID.Zero, LLUUID.Zero, "", text); 823 client.SendBlueBoxMessage(LLUUID.Zero, LLUUID.Zero, "", text);
1280 retparam.Add("success", true); 824 retparam.Add("success", true);
@@ -1293,12 +837,11 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
1293 return ret; 837 return ret;
1294 } 838 }
1295 839
1296
1297 # region Standalone box enablers only 840 # region Standalone box enablers only
1298 841
1299 public XmlRpcResponse quote_func(XmlRpcRequest request) 842 public XmlRpcResponse quote_func(XmlRpcRequest request)
1300 { 843 {
1301 Hashtable requestData = (Hashtable)request.Params[0]; 844 Hashtable requestData = (Hashtable) request.Params[0];
1302 LLUUID agentId = LLUUID.Zero; 845 LLUUID agentId = LLUUID.Zero;
1303 int amount = 0; 846 int amount = 0;
1304 Hashtable quoteResponse = new Hashtable(); 847 Hashtable quoteResponse = new Hashtable();
@@ -1306,51 +849,48 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
1306 849
1307 if (requestData.ContainsKey("agentId") && requestData.ContainsKey("currencyBuy")) 850 if (requestData.ContainsKey("agentId") && requestData.ContainsKey("currencyBuy"))
1308 { 851 {
1309 Helpers.TryParse((string)requestData["agentId"], out agentId); 852 Helpers.TryParse((string) requestData["agentId"], out agentId);
1310 try 853 try
1311 { 854 {
1312 amount = (Int32)requestData["currencyBuy"]; 855 amount = (Int32) requestData["currencyBuy"];
1313 } 856 }
1314 catch (InvalidCastException) 857 catch (InvalidCastException)
1315 { 858 {
1316
1317 } 859 }
1318 Hashtable currencyResponse = new Hashtable(); 860 Hashtable currencyResponse = new Hashtable();
1319 currencyResponse.Add("estimatedCost", 0); 861 currencyResponse.Add("estimatedCost", 0);
1320 currencyResponse.Add("currencyBuy", amount); 862 currencyResponse.Add("currencyBuy", amount);
1321 863
1322 quoteResponse.Add("success", true); 864 quoteResponse.Add("success", true);
1323 quoteResponse.Add("currency", currencyResponse); 865 quoteResponse.Add("currency", currencyResponse);
1324 quoteResponse.Add("confirm", "asdfad9fj39ma9fj"); 866 quoteResponse.Add("confirm", "asdfad9fj39ma9fj");
1325 867
1326 returnval.Value = quoteResponse; 868 returnval.Value = quoteResponse;
1327 return returnval; 869 return returnval;
1328 } 870 }
1329 871
1330 872
1331
1332 quoteResponse.Add("success", false); 873 quoteResponse.Add("success", false);
1333 quoteResponse.Add("errorMessage", "Invalid parameters passed to the quote box"); 874 quoteResponse.Add("errorMessage", "Invalid parameters passed to the quote box");
1334 quoteResponse.Add("errorURI", "http://www.opensimulator.org/wiki"); 875 quoteResponse.Add("errorURI", "http://www.opensimulator.org/wiki");
1335 returnval.Value = quoteResponse; 876 returnval.Value = quoteResponse;
1336 return returnval; 877 return returnval;
1337 } 878 }
879
1338 public XmlRpcResponse buy_func(XmlRpcRequest request) 880 public XmlRpcResponse buy_func(XmlRpcRequest request)
1339 { 881 {
1340 882 Hashtable requestData = (Hashtable) request.Params[0];
1341 Hashtable requestData = (Hashtable)request.Params[0];
1342 LLUUID agentId = LLUUID.Zero; 883 LLUUID agentId = LLUUID.Zero;
1343 int amount = 0; 884 int amount = 0;
1344 if (requestData.ContainsKey("agentId") && requestData.ContainsKey("currencyBuy")) 885 if (requestData.ContainsKey("agentId") && requestData.ContainsKey("currencyBuy"))
1345 { 886 {
1346 Helpers.TryParse((string)requestData["agentId"], out agentId); 887 Helpers.TryParse((string) requestData["agentId"], out agentId);
1347 try 888 try
1348 { 889 {
1349 amount = (Int32)requestData["currencyBuy"]; 890 amount = (Int32) requestData["currencyBuy"];
1350 } 891 }
1351 catch (InvalidCastException) 892 catch (InvalidCastException)
1352 { 893 {
1353
1354 } 894 }
1355 if (agentId != LLUUID.Zero) 895 if (agentId != LLUUID.Zero)
1356 { 896 {
@@ -1412,26 +952,25 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
1412 ret.Value = retparam; 952 ret.Value = retparam;
1413 953
1414 return ret; 954 return ret;
1415
1416 } 955 }
956
1417 public XmlRpcResponse landBuy_func(XmlRpcRequest request) 957 public XmlRpcResponse landBuy_func(XmlRpcRequest request)
1418 { 958 {
1419 XmlRpcResponse ret = new XmlRpcResponse(); 959 XmlRpcResponse ret = new XmlRpcResponse();
1420 Hashtable retparam = new Hashtable(); 960 Hashtable retparam = new Hashtable();
1421 Hashtable requestData = (Hashtable)request.Params[0]; 961 Hashtable requestData = (Hashtable) request.Params[0];
1422 962
1423 LLUUID agentId = LLUUID.Zero; 963 LLUUID agentId = LLUUID.Zero;
1424 int amount = 0; 964 int amount = 0;
1425 if (requestData.ContainsKey("agentId") && requestData.ContainsKey("currencyBuy")) 965 if (requestData.ContainsKey("agentId") && requestData.ContainsKey("currencyBuy"))
1426 { 966 {
1427 Helpers.TryParse((string)requestData["agentId"], out agentId); 967 Helpers.TryParse((string) requestData["agentId"], out agentId);
1428 try 968 try
1429 { 969 {
1430 amount = (Int32)requestData["currencyBuy"]; 970 amount = (Int32) requestData["currencyBuy"];
1431 } 971 }
1432 catch (InvalidCastException) 972 catch (InvalidCastException)
1433 { 973 {
1434
1435 } 974 }
1436 if (agentId != LLUUID.Zero) 975 if (agentId != LLUUID.Zero)
1437 { 976 {
@@ -1457,35 +996,475 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney
1457 ret.Value = retparam; 996 ret.Value = retparam;
1458 997
1459 return ret; 998 return ret;
999 }
1000
1001 #endregion
1002
1003 #region local Fund Management
1004
1005 /// <summary>
1006 /// Ensures that the agent accounting data is set up in this instance.
1007 /// </summary>
1008 /// <param name="agentID"></param>
1009 private void CheckExistAndRefreshFunds(LLUUID agentID)
1010 {
1011 lock (m_KnownClientFunds)
1012 {
1013 if (!m_KnownClientFunds.ContainsKey(agentID))
1014 {
1015 m_KnownClientFunds.Add(agentID, m_stipend);
1016 }
1017 else
1018 {
1019 if (m_KnownClientFunds[agentID] <= m_minFundsBeforeRefresh)
1020 {
1021 m_KnownClientFunds[agentID] = m_stipend;
1022 }
1023 }
1024 }
1025 }
1460 1026
1027 /// <summary>
1028 /// Gets the amount of Funds for an agent
1029 /// </summary>
1030 /// <param name="AgentID"></param>
1031 /// <returns></returns>
1032 private int GetFundsForAgentID(LLUUID AgentID)
1033 {
1034 int returnfunds = 0;
1035 lock (m_KnownClientFunds)
1036 {
1037 if (m_KnownClientFunds.ContainsKey(AgentID))
1038 {
1039 returnfunds = m_KnownClientFunds[AgentID];
1040 }
1041 else
1042 {
1043 //throw new Exception("Unable to get funds.");
1044 }
1045 }
1046 return returnfunds;
1461 } 1047 }
1048
1049 private void SetLocalFundsForAgentID(LLUUID AgentID, int amount)
1050 {
1051 lock (m_KnownClientFunds)
1052 {
1053 if (m_KnownClientFunds.ContainsKey(AgentID))
1054 {
1055 m_KnownClientFunds[AgentID] = amount;
1056 }
1057 else
1058 {
1059 m_KnownClientFunds.Add(AgentID, amount);
1060 }
1061 }
1062 }
1063
1462 #endregion 1064 #endregion
1463 1065
1464 public void PostInitialise() 1066 #region Utility Helpers
1067
1068 /// <summary>
1069 /// Locates a IClientAPI for the client specified
1070 /// </summary>
1071 /// <param name="AgentID"></param>
1072 /// <returns></returns>
1073 private IClientAPI LocateClientObject(LLUUID AgentID)
1465 { 1074 {
1075 ScenePresence tPresence = null;
1076 IClientAPI rclient = null;
1077
1078 lock (m_scenel)
1079 {
1080 foreach (Scene _scene in m_scenel.Values)
1081 {
1082 tPresence = _scene.GetScenePresence(AgentID);
1083 if (tPresence != null)
1084 {
1085 if (!tPresence.IsChildAgent)
1086 {
1087 rclient = tPresence.ControllingClient;
1088 }
1089 }
1090 if (rclient != null)
1091 {
1092 return rclient;
1093 }
1094 }
1095 }
1096 return null;
1466 } 1097 }
1467 1098
1468 public void Close() 1099 private Scene LocateSceneClientIn(LLUUID AgentId)
1469 { 1100 {
1101 lock (m_scenel)
1102 {
1103 foreach (Scene _scene in m_scenel.Values)
1104 {
1105 ScenePresence tPresence = _scene.GetScenePresence(AgentId);
1106 if (tPresence != null)
1107 {
1108 if (!tPresence.IsChildAgent)
1109 {
1110 return _scene;
1111 }
1112 }
1113 }
1114 }
1115 return null;
1470 } 1116 }
1471 1117
1472 public string Name 1118 /// <summary>
1119 /// Utility function Gets a Random scene in the instance. For when which scene exactly you're doing something with doesn't matter
1120 /// </summary>
1121 /// <returns></returns>
1122 public Scene GetRandomScene()
1473 { 1123 {
1474 get { return "BetaGridLikeMoneyModule"; } 1124 lock (m_scenel)
1125 {
1126 foreach (Scene rs in m_scenel.Values)
1127 return rs;
1128 }
1129 return null;
1475 } 1130 }
1476 1131
1477 public bool IsSharedModule 1132 /// <summary>
1133 /// Utility function to get a Scene by RegionID in a module
1134 /// </summary>
1135 /// <param name="RegionID"></param>
1136 /// <returns></returns>
1137 public Scene GetSceneByUUID(LLUUID RegionID)
1478 { 1138 {
1479 get { return true; } 1139 lock (m_scenel)
1140 {
1141 foreach (Scene rs in m_scenel.Values)
1142 {
1143 if (rs.RegionInfo.originRegionID == RegionID)
1144 {
1145 return rs;
1146 }
1147 }
1148 }
1149 return null;
1150 }
1151
1152 #endregion
1153
1154 #region event Handlers
1155
1156 public void requestPayPrice(IClientAPI client, LLUUID objectID)
1157 {
1158 Scene scene = LocateSceneClientIn(client.AgentId);
1159 if (scene == null)
1160 return;
1161
1162 SceneObjectPart task = scene.GetSceneObjectPart(objectID);
1163 if (task == null)
1164 return;
1165 SceneObjectGroup group = task.ParentGroup;
1166 SceneObjectPart root = group.RootPart;
1167
1168 client.SendPayPrice(objectID, root.PayPrice);
1169 }
1170
1171 /// <summary>
1172 /// When the client closes the connection we remove their accounting info from memory to free up resources.
1173 /// </summary>
1174 /// <param name="AgentID"></param>
1175 public void ClientClosed(LLUUID AgentID)
1176 {
1177 lock (m_KnownClientFunds)
1178 {
1179 if (m_keepMoneyAcrossLogins && m_MoneyAddress.Length == 0)
1180 {
1181 }
1182 else
1183 {
1184 m_KnownClientFunds.Remove(AgentID);
1185 }
1186 }
1480 } 1187 }
1188
1189 /// <summary>
1190 /// Event called Economy Data Request handler.
1191 /// </summary>
1192 /// <param name="agentId"></param>
1193 public void EconomyDataRequestHandler(LLUUID agentId)
1194 {
1195 IClientAPI user = LocateClientObject(agentId);
1196
1197 if (user != null)
1198 {
1199 user.SendEconomyData(EnergyEfficiency, ObjectCapacity, ObjectCount, PriceEnergyUnit, PriceGroupCreate,
1200 PriceObjectClaim, PriceObjectRent, PriceObjectScaleFactor, PriceParcelClaim, PriceParcelClaimFactor,
1201 PriceParcelRent, PricePublicObjectDecay, PricePublicObjectDelete, PriceRentLight, PriceUpload,
1202 TeleportMinPrice, TeleportPriceExponent);
1203 }
1204 }
1205
1206 private void ValidateLandBuy(Object osender, EventManager.LandBuyArgs e)
1207 {
1208 if (m_MoneyAddress.Length == 0)
1209 {
1210 lock (m_KnownClientFunds)
1211 {
1212 if (m_KnownClientFunds.ContainsKey(e.agentId))
1213 {
1214 // Does the sender have enough funds to give?
1215 if (m_KnownClientFunds[e.agentId] >= e.parcelPrice)
1216 {
1217 lock (e)
1218 {
1219 e.economyValidated = true;
1220 }
1221 }
1222 }
1223 }
1224 }
1225 else
1226 {
1227 if (GetRemoteBalance(e.agentId) >= e.parcelPrice)
1228 {
1229 lock (e)
1230 {
1231 e.economyValidated = true;
1232 }
1233 }
1234 }
1235 }
1236
1237 private void processLandBuy(Object osender, EventManager.LandBuyArgs e)
1238 {
1239 lock (e)
1240 {
1241 if (e.economyValidated == true && e.transactionID == 0)
1242 {
1243 e.transactionID = Util.UnixTimeSinceEpoch();
1244
1245 if (doMoneyTransfer(e.agentId, e.parcelOwnerID, e.parcelPrice, 0, "Land purchase"))
1246 {
1247 lock (e)
1248 {
1249 e.amountDebited = e.parcelPrice;
1250 }
1251 }
1252 }
1253 }
1254 }
1255
1256 /// <summary>
1257 /// THis method gets called when someone pays someone else as a gift.
1258 /// </summary>
1259 /// <param name="osender"></param>
1260 /// <param name="e"></param>
1261 private void MoneyTransferAction(Object osender, EventManager.MoneyTransferArgs e)
1262 {
1263 IClientAPI sender = null;
1264 IClientAPI receiver = null;
1265
1266 if (m_MoneyAddress.Length > 0) // Handled on server
1267 e.description = String.Empty;
1268
1269 if (e.transactiontype == 5008) // Object gets paid
1270 {
1271 sender = LocateClientObject(e.sender);
1272 if (sender != null)
1273 {
1274 SceneObjectPart part = findPrim(e.receiver);
1275 if (part == null)
1276 return;
1277
1278 string name = resolveAgentName(part.OwnerID);
1279 if (name == String.Empty)
1280 name = "(hippos)";
1281
1282 receiver = LocateClientObject(part.OwnerID);
1283
1284 string description = String.Format("Paid {0} via object {1}", name, e.description);
1285 bool transactionresult = doMoneyTransfer(e.sender, part.OwnerID, e.amount, e.transactiontype, description);
1286
1287 if (transactionresult)
1288 {
1289 ObjectPaid handlerOnObjectPaid = OnObjectPaid;
1290 if (handlerOnObjectPaid != null)
1291 {
1292 handlerOnObjectPaid(e.receiver, e.sender, e.amount);
1293 }
1294 }
1295
1296 if (e.sender != e.receiver)
1297 {
1298 sender.SendMoneyBalance(LLUUID.Random(), transactionresult, Helpers.StringToField(e.description), GetFundsForAgentID(e.sender));
1299 }
1300 if (receiver != null)
1301 {
1302 receiver.SendMoneyBalance(LLUUID.Random(), transactionresult, Helpers.StringToField(e.description), GetFundsForAgentID(part.OwnerID));
1303 }
1304 }
1305 return;
1306 }
1307
1308 sender = LocateClientObject(e.sender);
1309 if (sender != null)
1310 {
1311 receiver = LocateClientObject(e.receiver);
1312
1313 bool transactionresult = doMoneyTransfer(e.sender, e.receiver, e.amount, e.transactiontype, e.description);
1314
1315 if (e.sender != e.receiver)
1316 {
1317 if (sender != null)
1318 {
1319 sender.SendMoneyBalance(LLUUID.Random(), transactionresult, Helpers.StringToField(e.description), GetFundsForAgentID(e.sender));
1320 }
1321 }
1322
1323 if (receiver != null)
1324 {
1325 receiver.SendMoneyBalance(LLUUID.Random(), transactionresult, Helpers.StringToField(e.description), GetFundsForAgentID(e.receiver));
1326 }
1327 }
1328 else
1329 {
1330 m_log.Warn("[MONEY]: Potential Fraud Warning, got money transfer request for avatar that isn't in this simulator - Details; Sender:" +
1331 e.sender.ToString() + " Receiver: " + e.receiver.ToString() + " Amount: " + e.amount.ToString());
1332 }
1333 }
1334
1335 /// <summary>
1336 /// Event Handler for when a root agent becomes a child agent
1337 /// </summary>
1338 /// <param name="avatar"></param>
1339 private void MakeChildAgent(ScenePresence avatar)
1340 {
1341 lock (m_rootAgents)
1342 {
1343 if (m_rootAgents.ContainsKey(avatar.UUID))
1344 {
1345 if (m_rootAgents[avatar.UUID] == avatar.Scene.RegionInfo.originRegionID)
1346 {
1347 m_rootAgents.Remove(avatar.UUID);
1348 m_log.Info("[MONEY]: Removing " + avatar.Firstname + " " + avatar.Lastname + " as a root agent");
1349 }
1350 }
1351 }
1352 }
1353
1354 /// <summary>
1355 /// Event Handler for when the client logs out.
1356 /// </summary>
1357 /// <param name="AgentId"></param>
1358 private void ClientLoggedOut(LLUUID AgentId)
1359 {
1360 lock (m_rootAgents)
1361 {
1362 if (m_rootAgents.ContainsKey(AgentId))
1363 {
1364 m_rootAgents.Remove(AgentId);
1365 //m_log.Info("[MONEY]: Removing " + AgentId + ". Agent logged out.");
1366 }
1367 }
1368 }
1369
1370 /// <summary>
1371 /// Call this when the client disconnects.
1372 /// </summary>
1373 /// <param name="client"></param>
1374 public void ClientClosed(IClientAPI client)
1375 {
1376 ClientClosed(client.AgentId);
1377 }
1378
1379 /// <summary>
1380 /// Event Handler for when an Avatar enters one of the parcels in the simulator.
1381 /// </summary>
1382 /// <param name="avatar"></param>
1383 /// <param name="localLandID"></param>
1384 /// <param name="regionID"></param>
1385 private void AvatarEnteringParcel(ScenePresence avatar, int localLandID, LLUUID regionID)
1386 {
1387 lock (m_rootAgents)
1388 {
1389 if (m_rootAgents.ContainsKey(avatar.UUID))
1390 {
1391 if (avatar.Scene.RegionInfo.originRegionID != m_rootAgents[avatar.UUID])
1392 {
1393 m_rootAgents[avatar.UUID] = avatar.Scene.RegionInfo.originRegionID;
1394 //m_log.Info("[MONEY]: Claiming " + avatar.Firstname + " " + avatar.Lastname + " in region:" + avatar.RegionHandle + ".");
1395 // Claim User! my user! Mine mine mine!
1396 if (m_MoneyAddress.Length > 0)
1397 {
1398 Scene RegionItem = GetSceneByUUID(regionID);
1399 if (RegionItem != null)
1400 {
1401 Hashtable hresult =
1402 claim_user(avatar.UUID, avatar.ControllingClient.SecureSessionId, regionID, RegionItem.RegionInfo.regionSecret);
1403 if ((bool) hresult["success"] == true)
1404 {
1405 int funds = 0;
1406 try
1407 {
1408 funds = (Int32) hresult["funds"];
1409 }
1410 catch (InvalidCastException)
1411 {
1412 }
1413 SetLocalFundsForAgentID(avatar.UUID, funds);
1414 }
1415 else
1416 {
1417 avatar.ControllingClient.SendAgentAlertMessage((string) hresult["errorMessage"], true);
1418 }
1419 }
1420 }
1421 }
1422 }
1423 else
1424 {
1425 lock (m_rootAgents)
1426 {
1427 m_rootAgents.Add(avatar.UUID, avatar.Scene.RegionInfo.originRegionID);
1428 }
1429 if (m_MoneyAddress.Length > 0)
1430 {
1431 Scene RegionItem = GetSceneByUUID(regionID);
1432 if (RegionItem != null)
1433 {
1434 Hashtable hresult = claim_user(avatar.UUID, avatar.ControllingClient.SecureSessionId, regionID, RegionItem.RegionInfo.regionSecret);
1435 if ((bool) hresult["success"] == true)
1436 {
1437 int funds = 0;
1438 try
1439 {
1440 funds = (Int32) hresult["funds"];
1441 }
1442 catch (InvalidCastException)
1443 {
1444 }
1445 SetLocalFundsForAgentID(avatar.UUID, funds);
1446 }
1447 else
1448 {
1449 avatar.ControllingClient.SendAgentAlertMessage((string) hresult["errorMessage"], true);
1450 }
1451 }
1452 }
1453
1454 //m_log.Info("[MONEY]: Claiming " + avatar.Firstname + " " + avatar.Lastname + " in region:" + avatar.RegionHandle + ".");
1455 }
1456 }
1457 //m_log.Info("[FRIEND]: " + avatar.Name + " status:" + (!avatar.IsChildAgent).ToString());
1458 }
1459
1460 #endregion
1481 } 1461 }
1482 1462
1483 public enum TransactionType : int 1463 public enum TransactionType : int
1484 { 1464 {
1485 SystemGenerated=0, 1465 SystemGenerated = 0,
1486 RegionMoneyRequest=1, 1466 RegionMoneyRequest = 1,
1487 Gift=2, 1467 Gift = 2,
1488 Purchase=3 1468 Purchase = 3
1489
1490 } 1469 }
1491} \ No newline at end of file 1470} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs
index 3b0cc4c..db38d87 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/Friends/FriendsModule.cs
@@ -42,13 +42,12 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
42 { 42 {
43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44 44
45 private Dictionary<LLUUID, List<FriendListItem>> FriendLists = new Dictionary<LLUUID, List<FriendListItem>>();
46 private Dictionary<LLUUID, LLUUID> m_pendingFriendRequests = new Dictionary<LLUUID, LLUUID>();
47 private Dictionary<LLUUID, ulong> m_rootAgents = new Dictionary<LLUUID, ulong>();
45 private List<Scene> m_scene = new List<Scene>(); 48 private List<Scene> m_scene = new List<Scene>();
46 49
47 Dictionary<LLUUID, ulong> m_rootAgents = new Dictionary<LLUUID, ulong>(); 50 #region IRegionModule Members
48
49 Dictionary<LLUUID, LLUUID> m_pendingFriendRequests = new Dictionary<LLUUID, LLUUID>();
50
51 Dictionary<LLUUID, List<FriendListItem>> FriendLists = new Dictionary<LLUUID, List<FriendListItem>>();
52 51
53 public void Initialise(Scene scene, IConfigSource config) 52 public void Initialise(Scene scene, IConfigSource config)
54 { 53 {
@@ -68,11 +67,33 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
68 scene.EventManager.OnMakeChildAgent += MakeChildAgent; 67 scene.EventManager.OnMakeChildAgent += MakeChildAgent;
69 scene.EventManager.OnClientClosed += ClientLoggedOut; 68 scene.EventManager.OnClientClosed += ClientLoggedOut;
70 } 69 }
70
71 public void PostInitialise()
72 {
73 }
74
75 public void Close()
76 {
77 }
78
79 public string Name
80 {
81 get { return "FriendsModule"; }
82 }
83
84 public bool IsSharedModule
85 {
86 get { return true; }
87 }
88
89 #endregion
90
71 public XmlRpcResponse processPresenceUpdate(XmlRpcRequest req) 91 public XmlRpcResponse processPresenceUpdate(XmlRpcRequest req)
72 { 92 {
73 m_log.Info("[FRIENDS]: Got Notification about a user! OMG"); 93 m_log.Info("[FRIENDS]: Got Notification about a user! OMG");
74 return new XmlRpcResponse(); 94 return new XmlRpcResponse();
75 } 95 }
96
76 private void OnNewClient(IClientAPI client) 97 private void OnNewClient(IClientAPI client)
77 { 98 {
78 // All friends establishment protocol goes over instant message 99 // All friends establishment protocol goes over instant message
@@ -83,7 +104,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
83 // Generated by LoginService. The friends are retreived from the database by the UserManager 104 // Generated by LoginService. The friends are retreived from the database by the UserManager
84 105
85 // Subscribe to instant messages 106 // Subscribe to instant messages
86 107
87 client.OnInstantMessage += OnInstantMessage; 108 client.OnInstantMessage += OnInstantMessage;
88 client.OnApproveFriendRequest += OnApprovedFriendRequest; 109 client.OnApproveFriendRequest += OnApprovedFriendRequest;
89 client.OnDenyFriendRequest += OnDenyFriendRequest; 110 client.OnDenyFriendRequest += OnDenyFriendRequest;
@@ -99,10 +120,10 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
99 { 120 {
100 fl = FriendLists[client.AgentId]; 121 fl = FriendLists[client.AgentId];
101 } 122 }
102 else 123 else
103 { 124 {
104 fl = m_scene[0].GetFriendList(client.AgentId); 125 fl = m_scene[0].GetFriendList(client.AgentId);
105 126
106 //lock (FriendLists) 127 //lock (FriendLists)
107 //{ 128 //{
108 if (!FriendLists.ContainsKey(client.AgentId)) 129 if (!FriendLists.ContainsKey(client.AgentId))
@@ -110,11 +131,11 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
110 //} 131 //}
111 } 132 }
112 } 133 }
113 134
114 List<LLUUID> UpdateUsers = new List<LLUUID>(); 135 List<LLUUID> UpdateUsers = new List<LLUUID>();
115 136
116 foreach (FriendListItem f in fl) 137 foreach (FriendListItem f in fl)
117 { 138 {
118 if (m_rootAgents.ContainsKey(f.Friend)) 139 if (m_rootAgents.ContainsKey(f.Friend))
119 { 140 {
120 if (f.onlinestatus == false) 141 if (f.onlinestatus == false)
@@ -169,10 +190,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
169 onp.AgentBlock = onpb; 190 onp.AgentBlock = onpb;
170 client.OutPacket(onp, ThrottleOutPacketType.Task); 191 client.OutPacket(onp, ThrottleOutPacketType.Task);
171 } 192 }
172
173
174
175
176 } 193 }
177 194
178 private void ClientLoggedOut(LLUUID AgentId) 195 private void ClientLoggedOut(LLUUID AgentId)
@@ -182,7 +199,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
182 if (m_rootAgents.ContainsKey(AgentId)) 199 if (m_rootAgents.ContainsKey(AgentId))
183 { 200 {
184 m_rootAgents.Remove(AgentId); 201 m_rootAgents.Remove(AgentId);
185 m_log.Info("[FRIEND]: Removing " + AgentId + ". Agent logged out."); 202 m_log.Info("[FRIEND]: Removing " + AgentId + ". Agent logged out.");
186 } 203 }
187 } 204 }
188 List<FriendListItem> lfli = new List<FriendListItem>(); 205 List<FriendListItem> lfli = new List<FriendListItem>();
@@ -208,7 +225,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
208 List<FriendListItem> flfli = new List<FriendListItem>(); 225 List<FriendListItem> flfli = new List<FriendListItem>();
209 try 226 try
210 { 227 {
211
212 lock (FriendLists) 228 lock (FriendLists)
213 { 229 {
214 if (FriendLists.ContainsKey(updateUsers[i])) 230 if (FriendLists.ContainsKey(updateUsers[i]))
@@ -231,9 +247,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
231 { 247 {
232 flfli[i].onlinestatus = false; 248 flfli[i].onlinestatus = false;
233 } 249 }
234
235 } 250 }
236 251
237 catch (IndexOutOfRangeException) 252 catch (IndexOutOfRangeException)
238 { 253 {
239 // Ignore the index out of range exception. 254 // Ignore the index out of range exception.
@@ -242,15 +257,13 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
242 m_log.Info("[FRIEND]: Unable to enumerate last friendlist user. User logged off"); 257 m_log.Info("[FRIEND]: Unable to enumerate last friendlist user. User logged off");
243 } 258 }
244 } 259 }
245
246 } 260 }
247 261
248 for (int i = 0; i < updateUsers.Count; i++) 262 for (int i = 0; i < updateUsers.Count; i++)
249 { 263 {
250 ScenePresence av = GetPresenceFromAgentID(updateUsers[i]); 264 ScenePresence av = GetPresenceFromAgentID(updateUsers[i]);
251 if (av != null) 265 if (av != null)
252 { 266 {
253
254 OfflineNotificationPacket onp = new OfflineNotificationPacket(); 267 OfflineNotificationPacket onp = new OfflineNotificationPacket();
255 OfflineNotificationPacket.AgentBlockBlock[] onpb = new OfflineNotificationPacket.AgentBlockBlock[1]; 268 OfflineNotificationPacket.AgentBlockBlock[] onpb = new OfflineNotificationPacket.AgentBlockBlock[1];
256 OfflineNotificationPacket.AgentBlockBlock onpbl = new OfflineNotificationPacket.AgentBlockBlock(); 269 OfflineNotificationPacket.AgentBlockBlock onpbl = new OfflineNotificationPacket.AgentBlockBlock();
@@ -265,7 +278,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
265 { 278 {
266 FriendLists.Remove(AgentId); 279 FriendLists.Remove(AgentId);
267 } 280 }
268
269 } 281 }
270 282
271 private void AvatarEnteringParcel(ScenePresence avatar, int localLandID, LLUUID regionID) 283 private void AvatarEnteringParcel(ScenePresence avatar, int localLandID, LLUUID regionID)
@@ -282,7 +294,6 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
282 { 294 {
283 JId avatarID = new JId(avatar.JID); 295 JId avatarID = new JId(avatar.JID);
284 // REST Post XMPP Stanzas! 296 // REST Post XMPP Stanzas!
285
286 } 297 }
287 // Claim User! my user! Mine mine mine! 298 // Claim User! my user! Mine mine mine!
288 } 299 }
@@ -295,9 +306,9 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
295 } 306 }
296 //m_log.Info("[FRIEND]: " + avatar.Name + " status:" + (!avatar.IsChildAgent).ToString()); 307 //m_log.Info("[FRIEND]: " + avatar.Name + " status:" + (!avatar.IsChildAgent).ToString());
297 } 308 }
309
298 private void MakeChildAgent(ScenePresence avatar) 310 private void MakeChildAgent(ScenePresence avatar)
299 { 311 {
300
301 lock (m_rootAgents) 312 lock (m_rootAgents)
302 { 313 {
303 if (m_rootAgents.ContainsKey(avatar.UUID)) 314 if (m_rootAgents.ContainsKey(avatar.UUID))
@@ -307,30 +318,53 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
307 m_rootAgents.Remove(avatar.UUID); 318 m_rootAgents.Remove(avatar.UUID);
308 m_log.Info("[FRIEND]: Removing " + avatar.Firstname + " " + avatar.Lastname + " as a root agent"); 319 m_log.Info("[FRIEND]: Removing " + avatar.Firstname + " " + avatar.Lastname + " as a root agent");
309 } 320 }
310
311 } 321 }
312 } 322 }
323 }
313 324
325 private ScenePresence GetPresenceFromAgentID(LLUUID AgentID)
326 {
327 ScenePresence returnAgent = null;
328 lock (m_scene)
329 {
330 ScenePresence queryagent = null;
331 for (int i = 0; i < m_scene.Count; i++)
332 {
333 queryagent = m_scene[i].GetScenePresence(AgentID);
334 if (queryagent != null)
335 {
336 if (!queryagent.IsChildAgent)
337 {
338 returnAgent = queryagent;
339 break;
340 }
341 }
342 }
343 }
344 return returnAgent;
314 } 345 }
346
315 #region FriendRequestHandling 347 #region FriendRequestHandling
316 private void OnInstantMessage(IClientAPI client,LLUUID fromAgentID, 348
349 private void OnInstantMessage(IClientAPI client, LLUUID fromAgentID,
317 LLUUID fromAgentSession, LLUUID toAgentID, 350 LLUUID fromAgentSession, LLUUID toAgentID,
318 LLUUID imSessionID, uint timestamp, string fromAgentName, 351 LLUUID imSessionID, uint timestamp, string fromAgentName,
319 string message, byte dialog, bool fromGroup, byte offline, 352 string message, byte dialog, bool fromGroup, byte offline,
320 uint ParentEstateID, LLVector3 Position, LLUUID RegionID, 353 uint ParentEstateID, LLVector3 Position, LLUUID RegionID,
321 byte[] binaryBucket) 354 byte[] binaryBucket)
322 { 355 {
323 // Friend Requests go by Instant Message.. using the dialog param 356 // Friend Requests go by Instant Message.. using the dialog param
324 // https://wiki.secondlife.com/wiki/ImprovedInstantMessage 357 // https://wiki.secondlife.com/wiki/ImprovedInstantMessage
325 358
326 // 38 == Offer friendship 359 // 38 == Offer friendship
327 if (dialog == (byte)38) 360 if (dialog == (byte) 38)
328 { 361 {
329 LLUUID friendTransactionID = LLUUID.Random(); 362 LLUUID friendTransactionID = LLUUID.Random();
330 363
331 m_pendingFriendRequests.Add(friendTransactionID, fromAgentID); 364 m_pendingFriendRequests.Add(friendTransactionID, fromAgentID);
332 365
333 m_log.Info("[FRIEND]: 38 - From:" + fromAgentID.ToString() + " To: " + toAgentID.ToString() + " Session:" + imSessionID.ToString() + " Message:" + message); 366 m_log.Info("[FRIEND]: 38 - From:" + fromAgentID.ToString() + " To: " + toAgentID.ToString() + " Session:" + imSessionID.ToString() + " Message:" +
367 message);
334 GridInstantMessage msg = new GridInstantMessage(); 368 GridInstantMessage msg = new GridInstantMessage();
335 msg.fromAgentID = fromAgentID.UUID; 369 msg.fromAgentID = fromAgentID.UUID;
336 msg.fromAgentSession = fromAgentSession.UUID; 370 msg.fromAgentSession = fromAgentSession.UUID;
@@ -340,11 +374,11 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
340 msg.timestamp = timestamp; 374 msg.timestamp = timestamp;
341 if (client != null) 375 if (client != null)
342 { 376 {
343 msg.fromAgentName = client.FirstName + " " + client.LastName;// fromAgentName; 377 msg.fromAgentName = client.FirstName + " " + client.LastName; // fromAgentName;
344 } 378 }
345 else 379 else
346 { 380 {
347 msg.fromAgentName = "(hippos)";// Added for posterity. This means that we can't figure out who sent it 381 msg.fromAgentName = "(hippos)"; // Added for posterity. This means that we can't figure out who sent it
348 } 382 }
349 msg.message = message; 383 msg.message = message;
350 msg.dialog = dialog; 384 msg.dialog = dialog;
@@ -359,15 +393,17 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
359 } 393 }
360 394
361 // 39 == Accept Friendship 395 // 39 == Accept Friendship
362 if (dialog == (byte)39) 396 if (dialog == (byte) 39)
363 { 397 {
364 m_log.Info("[FRIEND]: 39 - From:" + fromAgentID.ToString() + " To: " + toAgentID.ToString() + " Session:" + imSessionID.ToString() + " Message:" + message); 398 m_log.Info("[FRIEND]: 39 - From:" + fromAgentID.ToString() + " To: " + toAgentID.ToString() + " Session:" + imSessionID.ToString() + " Message:" +
399 message);
365 } 400 }
366 401
367 // 40 == Decline Friendship 402 // 40 == Decline Friendship
368 if (dialog == (byte)40) 403 if (dialog == (byte) 40)
369 { 404 {
370 m_log.Info("[FRIEND]: 40 - From:" + fromAgentID.ToString() + " To: " + toAgentID.ToString() + " Session:" + imSessionID.ToString() + " Message:" + message); 405 m_log.Info("[FRIEND]: 40 - From:" + fromAgentID.ToString() + " To: " + toAgentID.ToString() + " Session:" + imSessionID.ToString() + " Message:" +
406 message);
371 } 407 }
372 } 408 }
373 409
@@ -395,16 +431,16 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
395 msg.imSessionID = transactionID.UUID; 431 msg.imSessionID = transactionID.UUID;
396 msg.message = agentID.UUID.ToString(); 432 msg.message = agentID.UUID.ToString();
397 msg.ParentEstateID = 0; 433 msg.ParentEstateID = 0;
398 msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); 434 msg.timestamp = (uint) Util.UnixTimeSinceEpoch();
399 msg.RegionID = SceneAgentIn.RegionInfo.RegionID.UUID; 435 msg.RegionID = SceneAgentIn.RegionInfo.RegionID.UUID;
400 msg.dialog = (byte)39;// Approved friend request 436 msg.dialog = (byte) 39; // Approved friend request
401 msg.Position = new sLLVector3(); 437 msg.Position = new sLLVector3();
402 msg.offline = (byte)0; 438 msg.offline = (byte) 0;
403 msg.binaryBucket = new byte[0]; 439 msg.binaryBucket = new byte[0];
404 // We don't really care which scene we pipe it through, it goes to the shared IM Module and/or the database 440 // We don't really care which scene we pipe it through, it goes to the shared IM Module and/or the database
405 441
406 SceneAgentIn.TriggerGridInstantMessage(msg, InstantMessageReceiver.IMModule); 442 SceneAgentIn.TriggerGridInstantMessage(msg, InstantMessageReceiver.IMModule);
407 SceneAgentIn.StoreAddFriendship(m_pendingFriendRequests[transactionID], agentID, (uint)1); 443 SceneAgentIn.StoreAddFriendship(m_pendingFriendRequests[transactionID], agentID, (uint) 1);
408 m_pendingFriendRequests.Remove(transactionID); 444 m_pendingFriendRequests.Remove(transactionID);
409 445
410 // TODO: Inform agent that the friend is online 446 // TODO: Inform agent that the friend is online
@@ -433,11 +469,11 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
433 msg.imSessionID = transactionID.UUID; 469 msg.imSessionID = transactionID.UUID;
434 msg.message = agentID.UUID.ToString(); 470 msg.message = agentID.UUID.ToString();
435 msg.ParentEstateID = 0; 471 msg.ParentEstateID = 0;
436 msg.timestamp = (uint)Util.UnixTimeSinceEpoch(); 472 msg.timestamp = (uint) Util.UnixTimeSinceEpoch();
437 msg.RegionID = SceneAgentIn.RegionInfo.RegionID.UUID; 473 msg.RegionID = SceneAgentIn.RegionInfo.RegionID.UUID;
438 msg.dialog = (byte)40;// Deny friend request 474 msg.dialog = (byte) 40; // Deny friend request
439 msg.Position = new sLLVector3(); 475 msg.Position = new sLLVector3();
440 msg.offline = (byte)0; 476 msg.offline = (byte) 0;
441 msg.binaryBucket = new byte[0]; 477 msg.binaryBucket = new byte[0];
442 SceneAgentIn.TriggerGridInstantMessage(msg, InstantMessageReceiver.IMModule); 478 SceneAgentIn.TriggerGridInstantMessage(msg, InstantMessageReceiver.IMModule);
443 m_pendingFriendRequests.Remove(transactionID); 479 m_pendingFriendRequests.Remove(transactionID);
@@ -453,52 +489,13 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Friends
453 private void OnGridInstantMessage(GridInstantMessage msg) 489 private void OnGridInstantMessage(GridInstantMessage msg)
454 { 490 {
455 // Trigger the above event handler 491 // Trigger the above event handler
456 OnInstantMessage(null,new LLUUID(msg.fromAgentID), new LLUUID(msg.fromAgentSession), 492 OnInstantMessage(null, new LLUUID(msg.fromAgentID), new LLUUID(msg.fromAgentSession),
457 new LLUUID(msg.toAgentID), new LLUUID(msg.imSessionID), msg.timestamp, msg.fromAgentName, 493 new LLUUID(msg.toAgentID), new LLUUID(msg.imSessionID), msg.timestamp, msg.fromAgentName,
458 msg.message, msg.dialog, msg.fromGroup, msg.offline, msg.ParentEstateID, 494 msg.message, msg.dialog, msg.fromGroup, msg.offline, msg.ParentEstateID,
459 new LLVector3(msg.Position.x, msg.Position.y, msg.Position.z), new LLUUID(msg.RegionID), 495 new LLVector3(msg.Position.x, msg.Position.y, msg.Position.z), new LLUUID(msg.RegionID),
460 msg.binaryBucket); 496 msg.binaryBucket);
461 } 497 }
462 #endregion
463 private ScenePresence GetPresenceFromAgentID(LLUUID AgentID)
464 {
465 ScenePresence returnAgent = null;
466 lock (m_scene)
467 {
468 ScenePresence queryagent = null;
469 for (int i = 0; i < m_scene.Count; i++)
470 {
471 queryagent = m_scene[i].GetScenePresence(AgentID);
472 if (queryagent != null)
473 {
474 if (!queryagent.IsChildAgent)
475 {
476 returnAgent = queryagent;
477 break;
478 }
479 }
480 }
481 }
482 return returnAgent;
483
484 }
485
486 public void PostInitialise()
487 {
488 }
489
490 public void Close()
491 {
492 }
493 498
494 public string Name 499 #endregion
495 {
496 get { return "FriendsModule"; }
497 }
498
499 public bool IsSharedModule
500 {
501 get { return true; }
502 }
503 } 500 }
504} \ No newline at end of file 501} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Groups/GroupsModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Groups/GroupsModule.cs
index 4b28ad7..c4906d2 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/Groups/GroupsModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/Groups/GroupsModule.cs
@@ -41,10 +41,12 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Groups
41 { 41 {
42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43 43
44 private List<Scene> m_scene = new List<Scene>();
45 private Dictionary<LLUUID, IClientAPI> m_iclientmap = new Dictionary<LLUUID, IClientAPI>();
46 private Dictionary<LLUUID, GroupData> m_groupmap = new Dictionary<LLUUID, GroupData>();
47 private Dictionary<LLUUID, GroupList> m_grouplistmap = new Dictionary<LLUUID, GroupList>(); 44 private Dictionary<LLUUID, GroupList> m_grouplistmap = new Dictionary<LLUUID, GroupList>();
45 private Dictionary<LLUUID, GroupData> m_groupmap = new Dictionary<LLUUID, GroupData>();
46 private Dictionary<LLUUID, IClientAPI> m_iclientmap = new Dictionary<LLUUID, IClientAPI>();
47 private List<Scene> m_scene = new List<Scene>();
48
49 #region IRegionModule Members
48 50
49 public void Initialise(Scene scene, IConfigSource config) 51 public void Initialise(Scene scene, IConfigSource config)
50 { 52 {
@@ -58,6 +60,42 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Groups
58 //scene.EventManager. 60 //scene.EventManager.
59 } 61 }
60 62
63 public void PostInitialise()
64 {
65 }
66
67 public void Close()
68 {
69 m_log.Info("[GROUP]: Shutting down group module.");
70 lock (m_iclientmap)
71 {
72 m_iclientmap.Clear();
73 }
74
75 lock (m_groupmap)
76 {
77 m_groupmap.Clear();
78 }
79
80 lock (m_grouplistmap)
81 {
82 m_grouplistmap.Clear();
83 }
84 GC.Collect();
85 }
86
87 public string Name
88 {
89 get { return "GroupsModule"; }
90 }
91
92 public bool IsSharedModule
93 {
94 get { return true; }
95 }
96
97 #endregion
98
61 private void OnNewClient(IClientAPI client) 99 private void OnNewClient(IClientAPI client)
62 { 100 {
63 // All friends establishment protocol goes over instant message 101 // All friends establishment protocol goes over instant message
@@ -115,7 +153,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Groups
115 string ActiveGroupTitle = ""; 153 string ActiveGroupTitle = "";
116 154
117 bool foundUser = false; 155 bool foundUser = false;
118 156
119 lock (m_iclientmap) 157 lock (m_iclientmap)
120 { 158 {
121 if (m_iclientmap.ContainsKey(remoteClient.AgentId)) 159 if (m_iclientmap.ContainsKey(remoteClient.AgentId))
@@ -139,11 +177,9 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Groups
139 } 177 }
140 178
141 //remoteClient.SendAgentDataUpdate(AgentID, ActiveGroupID, firstname, lastname, ActiveGroupPowers, ActiveGroupName, ActiveGroupTitle); 179 //remoteClient.SendAgentDataUpdate(AgentID, ActiveGroupID, firstname, lastname, ActiveGroupPowers, ActiveGroupName, ActiveGroupTitle);
142
143 } 180 }
144 } 181 }
145 } 182 }
146
147 } 183 }
148 184
149 private void OnInstantMessage(IClientAPI client, LLUUID fromAgentID, 185 private void OnInstantMessage(IClientAPI client, LLUUID fromAgentID,
@@ -183,7 +219,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Groups
183 m_iclientmap.Remove(agentID); 219 m_iclientmap.Remove(agentID);
184 } 220 }
185 } 221 }
186 222
187 lock (m_groupmap) 223 lock (m_groupmap)
188 { 224 {
189 if (m_groupmap.ContainsKey(agentID)) 225 if (m_groupmap.ContainsKey(agentID))
@@ -191,7 +227,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Groups
191 m_groupmap.Remove(agentID); 227 m_groupmap.Remove(agentID);
192 } 228 }
193 } 229 }
194 230
195 lock (m_grouplistmap) 231 lock (m_grouplistmap)
196 { 232 {
197 if (m_grouplistmap.ContainsKey(agentID)) 233 if (m_grouplistmap.ContainsKey(agentID))
@@ -201,63 +237,16 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Groups
201 } 237 }
202 GC.Collect(); 238 GC.Collect();
203 } 239 }
204
205 public void PostInitialise()
206 {
207 }
208
209 public void Close()
210 {
211 m_log.Info("[GROUP]: Shutting down group module.");
212 lock (m_iclientmap)
213 {
214 m_iclientmap.Clear();
215 }
216
217 lock (m_groupmap)
218 {
219 m_groupmap.Clear();
220 }
221
222 lock (m_grouplistmap)
223 {
224 m_grouplistmap.Clear();
225 }
226 GC.Collect();
227 }
228
229 public string Name
230 {
231 get { return "GroupsModule"; }
232 }
233
234 public bool IsSharedModule
235 {
236 get { return true; }
237 }
238
239 } 240 }
240 241
241 public class GroupData 242 public class GroupData
242 { 243 {
244 public string ActiveGroupTitle;
243 public LLUUID GroupID; 245 public LLUUID GroupID;
246 public List<LLUUID> GroupMembers;
244 public string groupName; 247 public string groupName;
245 public string ActiveGroupTitle; 248 public uint groupPowers = (uint) (GroupPowers.LandAllowLandmark | GroupPowers.LandAllowSetHome);
246 public List<string> GroupTitles; 249 public List<string> GroupTitles;
247 public List<LLUUID> GroupMembers;
248 public uint groupPowers = (uint)(GroupPowers.LandAllowLandmark | GroupPowers.LandAllowSetHome);
249
250 public GroupPowers ActiveGroupPowers
251 {
252 set
253 {
254 groupPowers = (uint) value;
255 }
256 get
257 {
258 return (GroupPowers)groupPowers;
259 }
260 }
261 250
262 public GroupData() 251 public GroupData()
263 { 252 {
@@ -265,11 +254,17 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Groups
265 GroupMembers = new List<LLUUID>(); 254 GroupMembers = new List<LLUUID>();
266 } 255 }
267 256
257 public GroupPowers ActiveGroupPowers
258 {
259 set { groupPowers = (uint) value; }
260 get { return (GroupPowers) groupPowers; }
261 }
268 } 262 }
269 263
270 public class GroupList 264 public class GroupList
271 { 265 {
272 public List<LLUUID> m_GroupList; 266 public List<LLUUID> m_GroupList;
267
273 public GroupList() 268 public GroupList()
274 { 269 {
275 m_GroupList = new List<LLUUID>(); 270 m_GroupList = new List<LLUUID>();
diff --git a/OpenSim/Region/Environment/Modules/Avatar/InstantMessage/InstantMessageModule.cs b/OpenSim/Region/Environment/Modules/Avatar/InstantMessage/InstantMessageModule.cs
index 1b82837..cb58b4c 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/InstantMessage/InstantMessageModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/InstantMessage/InstantMessageModule.cs
@@ -38,6 +38,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage
38 { 38 {
39 private readonly List<Scene> m_scenes = new List<Scene>(); 39 private readonly List<Scene> m_scenes = new List<Scene>();
40 40
41 #region IRegionModule Members
42
41 public void Initialise(Scene scene, IConfigSource config) 43 public void Initialise(Scene scene, IConfigSource config)
42 { 44 {
43 lock (m_scenes) 45 lock (m_scenes)
@@ -56,27 +58,47 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage
56 } 58 }
57 } 59 }
58 60
61 public void PostInitialise()
62 {
63 }
64
65 public void Close()
66 {
67 }
68
69 public string Name
70 {
71 get { return "InstantMessageModule"; }
72 }
73
74 public bool IsSharedModule
75 {
76 get { return true; }
77 }
78
79 #endregion
80
59 private void OnNewClient(IClientAPI client) 81 private void OnNewClient(IClientAPI client)
60 { 82 {
61 client.OnInstantMessage += OnInstantMessage; 83 client.OnInstantMessage += OnInstantMessage;
62 } 84 }
63 85
64 private void OnInstantMessage(IClientAPI client,LLUUID fromAgentID, 86 private void OnInstantMessage(IClientAPI client, LLUUID fromAgentID,
65 LLUUID fromAgentSession, LLUUID toAgentID, 87 LLUUID fromAgentSession, LLUUID toAgentID,
66 LLUUID imSessionID, uint timestamp, string fromAgentName, 88 LLUUID imSessionID, uint timestamp, string fromAgentName,
67 string message, byte dialog, bool fromGroup, byte offline, 89 string message, byte dialog, bool fromGroup, byte offline,
68 uint ParentEstateID, LLVector3 Position, LLUUID RegionID, 90 uint ParentEstateID, LLVector3 Position, LLUUID RegionID,
69 byte[] binaryBucket) 91 byte[] binaryBucket)
70 { 92 {
71 bool dialogHandledElsewhere 93 bool dialogHandledElsewhere
72 = ((dialog == 38) || (dialog == 39) || (dialog == 40) 94 = ((dialog == 38) || (dialog == 39) || (dialog == 40)
73 || dialog == (byte)InstantMessageDialog.InventoryOffered 95 || dialog == (byte) InstantMessageDialog.InventoryOffered
74 || dialog == (byte)InstantMessageDialog.InventoryAccepted 96 || dialog == (byte) InstantMessageDialog.InventoryAccepted
75 || dialog == (byte)InstantMessageDialog.InventoryDeclined); 97 || dialog == (byte) InstantMessageDialog.InventoryDeclined);
76 98
77 // IM dialogs need to be pre-processed and have their sessionID filled by the server 99 // IM dialogs need to be pre-processed and have their sessionID filled by the server
78 // so the sim can match the transaction on the return packet. 100 // so the sim can match the transaction on the return packet.
79 101
80 // Don't send a Friend Dialog IM with a LLUUID.Zero session. 102 // Don't send a Friend Dialog IM with a LLUUID.Zero session.
81 if (!(dialogHandledElsewhere && imSessionID == LLUUID.Zero)) 103 if (!(dialogHandledElsewhere && imSessionID == LLUUID.Zero))
82 { 104 {
@@ -86,7 +108,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage
86 if (scene.Entities.ContainsKey(toAgentID) && scene.Entities[toAgentID] is ScenePresence) 108 if (scene.Entities.ContainsKey(toAgentID) && scene.Entities[toAgentID] is ScenePresence)
87 { 109 {
88 // Local message 110 // Local message
89 ScenePresence user = (ScenePresence)scene.Entities[toAgentID]; 111 ScenePresence user = (ScenePresence) scene.Entities[toAgentID];
90 if (!user.IsChildAgent) 112 if (!user.IsChildAgent)
91 { 113 {
92 user.ControllingClient.SendInstantMessage(fromAgentID, fromAgentSession, message, 114 user.ControllingClient.SendInstantMessage(fromAgentID, fromAgentSession, message,
@@ -104,54 +126,33 @@ namespace OpenSim.Region.Environment.Modules.Avatar.InstantMessage
104 if (scene.Entities.ContainsKey(toAgentID) && scene.Entities[toAgentID] is ScenePresence) 126 if (scene.Entities.ContainsKey(toAgentID) && scene.Entities[toAgentID] is ScenePresence)
105 { 127 {
106 // Local message 128 // Local message
107 ScenePresence user = (ScenePresence)scene.Entities[toAgentID]; 129 ScenePresence user = (ScenePresence) scene.Entities[toAgentID];
108 130
109 user.ControllingClient.SendInstantMessage(fromAgentID, fromAgentSession, message, 131 user.ControllingClient.SendInstantMessage(fromAgentID, fromAgentSession, message,
110 toAgentID, imSessionID, fromAgentName, dialog, 132 toAgentID, imSessionID, fromAgentName, dialog,
111 timestamp); 133 timestamp);
112 // Message sent 134 // Message sent
113 return; 135 return;
114
115 } 136 }
116 } 137 }
117
118 } 138 }
119 139
120 140
121 // Still here, try send via Grid 141 // Still here, try send via Grid
122 // TODO 142 // TODO
123 } 143 }
124 144
125 // Trusty OSG1 called method. This method also gets called from the FriendsModule 145 // Trusty OSG1 called method. This method also gets called from the FriendsModule
126 // Turns out the sim has to send an instant message to the user to get it to show an accepted friend. 146 // Turns out the sim has to send an instant message to the user to get it to show an accepted friend.
127 147
128 private void OnGridInstantMessage(GridInstantMessage msg) 148 private void OnGridInstantMessage(GridInstantMessage msg)
129 { 149 {
130 // Trigger the above event handler 150 // Trigger the above event handler
131 OnInstantMessage(null,new LLUUID(msg.fromAgentID), new LLUUID(msg.fromAgentSession), 151 OnInstantMessage(null, new LLUUID(msg.fromAgentID), new LLUUID(msg.fromAgentSession),
132 new LLUUID(msg.toAgentID), new LLUUID(msg.imSessionID), msg.timestamp, msg.fromAgentName, 152 new LLUUID(msg.toAgentID), new LLUUID(msg.imSessionID), msg.timestamp, msg.fromAgentName,
133 msg.message, msg.dialog, msg.fromGroup, msg.offline, msg.ParentEstateID, 153 msg.message, msg.dialog, msg.fromGroup, msg.offline, msg.ParentEstateID,
134 new LLVector3(msg.Position.x,msg.Position.y,msg.Position.z), new LLUUID(msg.RegionID), 154 new LLVector3(msg.Position.x, msg.Position.y, msg.Position.z), new LLUUID(msg.RegionID),
135 msg.binaryBucket); 155 msg.binaryBucket);
136
137 }
138
139 public void PostInitialise()
140 {
141 }
142
143 public void Close()
144 {
145 }
146
147 public string Name
148 {
149 get { return "InstantMessageModule"; }
150 }
151
152 public bool IsSharedModule
153 {
154 get { return true; }
155 } 156 }
156 } 157 }
157} \ No newline at end of file 158} \ No newline at end of file
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
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Profiles/AvatarProfilesModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Profiles/AvatarProfilesModule.cs
index f8b14d3..1955d2a 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/Profiles/AvatarProfilesModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/Profiles/AvatarProfilesModule.cs
@@ -45,6 +45,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Profiles
45 { 45 {
46 } 46 }
47 47
48 #region IRegionModule Members
49
48 public void Initialise(Scene scene, IConfigSource config) 50 public void Initialise(Scene scene, IConfigSource config)
49 { 51 {
50 m_scene = scene; 52 m_scene = scene;
@@ -69,6 +71,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Profiles
69 get { return false; } 71 get { return false; }
70 } 72 }
71 73
74 #endregion
75
72 public void NewClient(IClientAPI client) 76 public void NewClient(IClientAPI client)
73 { 77 {
74 client.OnRequestAvatarProperties += RequestAvatarProperty; 78 client.OnRequestAvatarProperties += RequestAvatarProperty;
@@ -107,7 +111,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Profiles
107 public void UpdateAvatarProperties(IClientAPI remoteClient, UserProfileData newProfile) 111 public void UpdateAvatarProperties(IClientAPI remoteClient, UserProfileData newProfile)
108 { 112 {
109 UserProfileData Profile = m_scene.CommsManager.UserService.GetUserProfile(newProfile.ID); 113 UserProfileData Profile = m_scene.CommsManager.UserService.GetUserProfile(newProfile.ID);
110 114
111 // if it's the profile of the user requesting the update, then we change only a few things. 115 // if it's the profile of the user requesting the update, then we change only a few things.
112 if (remoteClient.AgentId.CompareTo(Profile.ID) == 0) 116 if (remoteClient.AgentId.CompareTo(Profile.ID) == 0)
113 { 117 {
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Voice/AsterixVoice/AsteriskVoiceModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Voice/AsterixVoice/AsteriskVoiceModule.cs
index 0d7de78..44d67e6 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/Voice/AsterixVoice/AsteriskVoiceModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/Voice/AsterixVoice/AsteriskVoiceModule.cs
@@ -44,40 +44,43 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Voice.AsterixVoice
44{ 44{
45 public class AsteriskVoiceModule : IRegionModule 45 public class AsteriskVoiceModule : IRegionModule
46 { 46 {
47 private static readonly ILog m_log = 47 private static readonly ILog m_log =
48 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 48 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49 49
50 private Scene m_scene; 50 private static readonly string m_parcelVoiceInfoRequestPath = "0007/";
51 private IConfig m_config; 51 private static readonly string m_provisionVoiceAccountRequestPath = "0008/";
52
52 private string m_asterisk; 53 private string m_asterisk;
53 private string m_asterisk_password; 54 private string m_asterisk_password;
54 private string m_asterisk_salt; 55 private string m_asterisk_salt;
55 private int m_asterisk_timeout; 56 private int m_asterisk_timeout;
56 private string m_sipDomain;
57 private string m_confDomain; 57 private string m_confDomain;
58 private IConfig m_config;
59 private Scene m_scene;
60 private string m_sipDomain;
58 61
59 private static readonly string m_parcelVoiceInfoRequestPath = "0007/"; 62 #region IRegionModule Members
60 private static readonly string m_provisionVoiceAccountRequestPath = "0008/";
61 63
62 public void Initialise(Scene scene, IConfigSource config) 64 public void Initialise(Scene scene, IConfigSource config)
63 { 65 {
64 m_scene = scene; 66 m_scene = scene;
65 m_config = config.Configs["AsteriskVoice"]; 67 m_config = config.Configs["AsteriskVoice"];
66 68
67 if (null == m_config) 69 if (null == m_config)
68 { 70 {
69 m_log.Info("[ASTERISKVOICE] no config found, plugin disabled"); 71 m_log.Info("[ASTERISKVOICE] no config found, plugin disabled");
70 return; 72 return;
71 } 73 }
72 74
73 if (!m_config.GetBoolean("enabled", false)) 75 if (!m_config.GetBoolean("enabled", false))
74 { 76 {
75 m_log.Info("[ASTERISKVOICE] plugin disabled by configuration"); 77 m_log.Info("[ASTERISKVOICE] plugin disabled by configuration");
76 return; 78 return;
77 } 79 }
78 m_log.Info("[ASTERISKVOICE] plugin enabled"); 80 m_log.Info("[ASTERISKVOICE] plugin enabled");
79 81
80 try { 82 try
83 {
81 m_sipDomain = m_config.GetString("sip_domain", String.Empty); 84 m_sipDomain = m_config.GetString("sip_domain", String.Empty);
82 m_log.InfoFormat("[ASTERISKVOICE] using SIP domain {0}", m_sipDomain); 85 m_log.InfoFormat("[ASTERISKVOICE] using SIP domain {0}", m_sipDomain);
83 86
@@ -91,17 +94,17 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Voice.AsterixVoice
91 if (String.IsNullOrEmpty(m_asterisk)) throw new Exception("missing asterisk_frontend config parameter"); 94 if (String.IsNullOrEmpty(m_asterisk)) throw new Exception("missing asterisk_frontend config parameter");
92 if (String.IsNullOrEmpty(m_asterisk_password)) throw new Exception("missing asterisk_password config parameter"); 95 if (String.IsNullOrEmpty(m_asterisk_password)) throw new Exception("missing asterisk_password config parameter");
93 m_log.InfoFormat("[ASTERISKVOICE] using asterisk front end {0}", m_asterisk); 96 m_log.InfoFormat("[ASTERISKVOICE] using asterisk front end {0}", m_asterisk);
94 97
95 scene.EventManager.OnRegisterCaps += OnRegisterCaps; 98 scene.EventManager.OnRegisterCaps += OnRegisterCaps;
96 } 99 }
97 catch (Exception e) 100 catch (Exception e)
98 { 101 {
99 m_log.ErrorFormat("[ASTERISKVOICE] plugin initialization failed: {0}", e.Message); 102 m_log.ErrorFormat("[ASTERISKVOICE] plugin initialization failed: {0}", e.Message);
100 m_log.DebugFormat("[ASTERISKVOICE] plugin initialization failed: {0}", e.ToString()); 103 m_log.DebugFormat("[ASTERISKVOICE] plugin initialization failed: {0}", e.ToString());
101 return; 104 return;
102 } 105 }
103 } 106 }
104 107
105 public void PostInitialise() 108 public void PostInitialise()
106 { 109 {
107 } 110 }
@@ -120,15 +123,17 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Voice.AsterixVoice
120 get { return false; } 123 get { return false; }
121 } 124 }
122 125
123 public void OnRegisterCaps(LLUUID agentID, Caps caps) 126 #endregion
127
128 public void OnRegisterCaps(LLUUID agentID, Caps caps)
124 { 129 {
125 m_log.DebugFormat("[ASTERISKVOICE] OnRegisterCaps: agentID {0} caps {1}", agentID, caps); 130 m_log.DebugFormat("[ASTERISKVOICE] OnRegisterCaps: agentID {0} caps {1}", agentID, caps);
126 string capsBase = "/CAPS/" + caps.CapsObjectPath; 131 string capsBase = "/CAPS/" + caps.CapsObjectPath;
127 caps.RegisterHandler("ParcelVoiceInfoRequest", 132 caps.RegisterHandler("ParcelVoiceInfoRequest",
128 new RestStreamHandler("POST", capsBase + m_parcelVoiceInfoRequestPath, 133 new RestStreamHandler("POST", capsBase + m_parcelVoiceInfoRequestPath,
129 delegate(string request, string path, string param) 134 delegate(string request, string path, string param)
130 { 135 {
131 return ParcelVoiceInfoRequest(request, path, param, 136 return ParcelVoiceInfoRequest(request, path, param,
132 agentID, caps); 137 agentID, caps);
133 })); 138 }));
134 caps.RegisterHandler("ProvisionVoiceAccountRequest", 139 caps.RegisterHandler("ProvisionVoiceAccountRequest",
@@ -139,7 +144,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Voice.AsterixVoice
139 agentID, caps); 144 agentID, caps);
140 })); 145 }));
141 } 146 }
142 147
143 /// <summary> 148 /// <summary>
144 /// Callback for a client request for ParcelVoiceInfo 149 /// Callback for a client request for ParcelVoiceInfo
145 /// </summary> 150 /// </summary>
@@ -149,30 +154,30 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Voice.AsterixVoice
149 /// <param name="agentID"></param> 154 /// <param name="agentID"></param>
150 /// <param name="caps"></param> 155 /// <param name="caps"></param>
151 /// <returns></returns> 156 /// <returns></returns>
152 public string ParcelVoiceInfoRequest(string request, string path, string param, 157 public string ParcelVoiceInfoRequest(string request, string path, string param,
153 LLUUID agentID, Caps caps) 158 LLUUID agentID, Caps caps)
154 { 159 {
155 // we need to do: 160 // we need to do:
156 // - send channel_uri: as "sip:regionID@m_sipDomain" 161 // - send channel_uri: as "sip:regionID@m_sipDomain"
157 try 162 try
158 { 163 {
159 m_log.DebugFormat("[ASTERISKVOICE][PARCELVOICE]: request: {0}, path: {1}, param: {2}", 164 m_log.DebugFormat("[ASTERISKVOICE][PARCELVOICE]: request: {0}, path: {1}, param: {2}",
160 request, path, param); 165 request, path, param);
161 166
162 167
163 // setup response to client 168 // setup response to client
164 Hashtable creds = new Hashtable(); 169 Hashtable creds = new Hashtable();
165 creds["channel_uri"] = String.Format("sip:{0}@{1}", 170 creds["channel_uri"] = String.Format("sip:{0}@{1}",
166 m_scene.RegionInfo.RegionID, m_sipDomain); 171 m_scene.RegionInfo.RegionID, m_sipDomain);
167 172
168 string regionName = m_scene.RegionInfo.RegionName; 173 string regionName = m_scene.RegionInfo.RegionName;
169 ScenePresence avatar = m_scene.GetScenePresence(agentID); 174 ScenePresence avatar = m_scene.GetScenePresence(agentID);
170 if (null == m_scene.LandChannel) throw new Exception("land data not yet available"); 175 if (null == m_scene.LandChannel) throw new Exception("land data not yet available");
171 LandData land = m_scene.GetLandData(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); 176 LandData land = m_scene.GetLandData(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y);
172 177
173 LLSDParcelVoiceInfoResponse parcelVoiceInfo = 178 LLSDParcelVoiceInfoResponse parcelVoiceInfo =
174 new LLSDParcelVoiceInfoResponse(regionName, land.localID, creds); 179 new LLSDParcelVoiceInfoResponse(regionName, land.localID, creds);
175 180
176 string r = LLSDHelpers.SerialiseLLSDReply(parcelVoiceInfo); 181 string r = LLSDHelpers.SerialiseLLSDReply(parcelVoiceInfo);
177 182
178 183
@@ -183,17 +188,17 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Voice.AsterixVoice
183 if (!String.IsNullOrEmpty(m_confDomain)) 188 if (!String.IsNullOrEmpty(m_confDomain))
184 { 189 {
185 requestData["region"] += String.Format("@{0}", m_confDomain); 190 requestData["region"] += String.Format("@{0}", m_confDomain);
186 } 191 }
187 192
188 ArrayList SendParams = new ArrayList(); 193 ArrayList SendParams = new ArrayList();
189 SendParams.Add(requestData); 194 SendParams.Add(requestData);
190 XmlRpcRequest updateAccountRequest = new XmlRpcRequest("region_update", SendParams); 195 XmlRpcRequest updateAccountRequest = new XmlRpcRequest("region_update", SendParams);
191 XmlRpcResponse updateAccountResponse = updateAccountRequest.Send(m_asterisk, m_asterisk_timeout); 196 XmlRpcResponse updateAccountResponse = updateAccountRequest.Send(m_asterisk, m_asterisk_timeout);
192 Hashtable responseData = (Hashtable)updateAccountResponse.Value; 197 Hashtable responseData = (Hashtable) updateAccountResponse.Value;
193 198
194 if (!responseData.ContainsKey("success")) throw new Exception("region_update call failed"); 199 if (!responseData.ContainsKey("success")) throw new Exception("region_update call failed");
195 200
196 bool success = Convert.ToBoolean((string)responseData["success"]); 201 bool success = Convert.ToBoolean((string) responseData["success"]);
197 if (!success) throw new Exception("region_update failed"); 202 if (!success) throw new Exception("region_update failed");
198 203
199 204
@@ -218,8 +223,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Voice.AsterixVoice
218 /// <param name="agentID"></param> 223 /// <param name="agentID"></param>
219 /// <param name="caps"></param> 224 /// <param name="caps"></param>
220 /// <returns></returns> 225 /// <returns></returns>
221 public string ProvisionVoiceAccountRequest(string request, string path, string param, 226 public string ProvisionVoiceAccountRequest(string request, string path, string param,
222 LLUUID agentID, Caps caps) 227 LLUUID agentID, Caps caps)
223 { 228 {
224 // we need to 229 // we need to
225 // - get user data from UserProfileCacheService 230 // - get user data from UserProfileCacheService
@@ -232,7 +237,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Voice.AsterixVoice
232 // send account details back to client 237 // send account details back to client
233 try 238 try
234 { 239 {
235 m_log.DebugFormat("[ASTERISKVOICE][PROVISIONVOICE]: request: {0}, path: {1}, param: {2}", 240 m_log.DebugFormat("[ASTERISKVOICE][PROVISIONVOICE]: request: {0}, path: {1}, param: {2}",
236 request, path, param); 241 request, path, param);
237 242
238 // get user data & prepare voice account response 243 // get user data & prepare voice account response
@@ -244,7 +249,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Voice.AsterixVoice
244 249
245 // we generate a nonce everytime 250 // we generate a nonce everytime
246 string voicePassword = "$1$" + Util.Md5Hash(DateTime.UtcNow.ToLongTimeString() + m_asterisk_salt); 251 string voicePassword = "$1$" + Util.Md5Hash(DateTime.UtcNow.ToLongTimeString() + m_asterisk_salt);
247 LLSDVoiceAccountResponse voiceAccountResponse = 252 LLSDVoiceAccountResponse voiceAccountResponse =
248 new LLSDVoiceAccountResponse(voiceUser, voicePassword); 253 new LLSDVoiceAccountResponse(voiceUser, voicePassword);
249 string r = LLSDHelpers.SerialiseLLSDReply(voiceAccountResponse); 254 string r = LLSDHelpers.SerialiseLLSDReply(voiceAccountResponse);
250 m_log.DebugFormat("[CAPS][PROVISIONVOICE]: {0}", r); 255 m_log.DebugFormat("[CAPS][PROVISIONVOICE]: {0}", r);
@@ -257,18 +262,18 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Voice.AsterixVoice
257 if (!String.IsNullOrEmpty(m_sipDomain)) 262 if (!String.IsNullOrEmpty(m_sipDomain))
258 { 263 {
259 requestData["username"] += String.Format("@{0}", m_sipDomain); 264 requestData["username"] += String.Format("@{0}", m_sipDomain);
260 } 265 }
261 requestData["password"] = voicePassword; 266 requestData["password"] = voicePassword;
262 267
263 ArrayList SendParams = new ArrayList(); 268 ArrayList SendParams = new ArrayList();
264 SendParams.Add(requestData); 269 SendParams.Add(requestData);
265 XmlRpcRequest updateAccountRequest = new XmlRpcRequest("account_update", SendParams); 270 XmlRpcRequest updateAccountRequest = new XmlRpcRequest("account_update", SendParams);
266 XmlRpcResponse updateAccountResponse = updateAccountRequest.Send(m_asterisk, m_asterisk_timeout); 271 XmlRpcResponse updateAccountResponse = updateAccountRequest.Send(m_asterisk, m_asterisk_timeout);
267 Hashtable responseData = (Hashtable)updateAccountResponse.Value; 272 Hashtable responseData = (Hashtable) updateAccountResponse.Value;
268 273
269 if (!responseData.ContainsKey("success")) throw new Exception("account_update call failed"); 274 if (!responseData.ContainsKey("success")) throw new Exception("account_update call failed");
270 275
271 bool success = Convert.ToBoolean((string)responseData["success"]); 276 bool success = Convert.ToBoolean((string) responseData["success"]);
272 if (!success) throw new Exception("account_update failed"); 277 if (!success) throw new Exception("account_update failed");
273 278
274 return r; 279 return r;
diff --git a/OpenSim/Region/Environment/Modules/Avatar/Voice/SIPVoice/SIPVoiceModule.cs b/OpenSim/Region/Environment/Modules/Avatar/Voice/SIPVoice/SIPVoiceModule.cs
index 8b7c3d0..8d9ba6f 100644
--- a/OpenSim/Region/Environment/Modules/Avatar/Voice/SIPVoice/SIPVoiceModule.cs
+++ b/OpenSim/Region/Environment/Modules/Avatar/Voice/SIPVoice/SIPVoiceModule.cs
@@ -43,22 +43,23 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Voice.SIPVoice
43{ 43{
44 public class SIPVoiceModule : IRegionModule 44 public class SIPVoiceModule : IRegionModule
45 { 45 {
46 private static readonly ILog m_log = 46 private static readonly ILog m_log =
47 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 48
49 private Scene m_scene; 49 private static readonly string m_parcelVoiceInfoRequestPath = "0007/";
50 private static readonly string m_provisionVoiceAccountRequestPath = "0008/";
50 private IConfig m_config; 51 private IConfig m_config;
52 private Scene m_scene;
51 private string m_sipDomain; 53 private string m_sipDomain;
52 54
53 private static readonly string m_parcelVoiceInfoRequestPath = "0007/"; 55 #region IRegionModule Members
54 private static readonly string m_provisionVoiceAccountRequestPath = "0008/";
55 56
56 public void Initialise(Scene scene, IConfigSource config) 57 public void Initialise(Scene scene, IConfigSource config)
57 { 58 {
58 m_scene = scene; 59 m_scene = scene;
59 m_config = config.Configs["Voice"]; 60 m_config = config.Configs["Voice"];
60 61
61 if (null == m_config || !m_config.GetBoolean("enabled", false)) 62 if (null == m_config || !m_config.GetBoolean("enabled", false))
62 { 63 {
63 m_log.Info("[VOICE] plugin disabled"); 64 m_log.Info("[VOICE] plugin disabled");
64 return; 65 return;
@@ -95,15 +96,17 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Voice.SIPVoice
95 get { return false; } 96 get { return false; }
96 } 97 }
97 98
98 public void OnRegisterCaps(LLUUID agentID, Caps caps) 99 #endregion
100
101 public void OnRegisterCaps(LLUUID agentID, Caps caps)
99 { 102 {
100 m_log.DebugFormat("[VOICE] OnRegisterCaps: agentID {0} caps {1}", agentID, caps); 103 m_log.DebugFormat("[VOICE] OnRegisterCaps: agentID {0} caps {1}", agentID, caps);
101 string capsBase = "/CAPS/" + caps.CapsObjectPath; 104 string capsBase = "/CAPS/" + caps.CapsObjectPath;
102 caps.RegisterHandler("ParcelVoiceInfoRequest", 105 caps.RegisterHandler("ParcelVoiceInfoRequest",
103 new RestStreamHandler("POST", capsBase + m_parcelVoiceInfoRequestPath, 106 new RestStreamHandler("POST", capsBase + m_parcelVoiceInfoRequestPath,
104 delegate(string request, string path, string param) 107 delegate(string request, string path, string param)
105 { 108 {
106 return ParcelVoiceInfoRequest(request, path, param, 109 return ParcelVoiceInfoRequest(request, path, param,
107 agentID, caps); 110 agentID, caps);
108 })); 111 }));
109 caps.RegisterHandler("ProvisionVoiceAccountRequest", 112 caps.RegisterHandler("ProvisionVoiceAccountRequest",
@@ -114,7 +117,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Voice.SIPVoice
114 agentID, caps); 117 agentID, caps);
115 })); 118 }));
116 } 119 }
117 120
118 /// <summary> 121 /// <summary>
119 /// Callback for a client request for ParcelVoiceInfo 122 /// Callback for a client request for ParcelVoiceInfo
120 /// </summary> 123 /// </summary>
@@ -124,8 +127,8 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Voice.SIPVoice
124 /// <param name="agentID"></param> 127 /// <param name="agentID"></param>
125 /// <param name="caps"></param> 128 /// <param name="caps"></param>
126 /// <returns></returns> 129 /// <returns></returns>
127 public string ParcelVoiceInfoRequest(string request, string path, string param, 130 public string ParcelVoiceInfoRequest(string request, string path, string param,
128 LLUUID agentID, Caps caps) 131 LLUUID agentID, Caps caps)
129 { 132 {
130 try 133 try
131 { 134 {
@@ -135,15 +138,15 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Voice.SIPVoice
135 Hashtable creds = new Hashtable(); 138 Hashtable creds = new Hashtable();
136 139
137 creds["channel_uri"] = String.Format("sip:{0}@{1}", agentID, m_sipDomain); 140 creds["channel_uri"] = String.Format("sip:{0}@{1}", agentID, m_sipDomain);
138 141
139 string regionName = m_scene.RegionInfo.RegionName; 142 string regionName = m_scene.RegionInfo.RegionName;
140 ScenePresence avatar = m_scene.GetScenePresence(agentID); 143 ScenePresence avatar = m_scene.GetScenePresence(agentID);
141 if (null == m_scene.LandChannel) throw new Exception("land data not yet available"); 144 if (null == m_scene.LandChannel) throw new Exception("land data not yet available");
142 LandData land = m_scene.GetLandData(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); 145 LandData land = m_scene.GetLandData(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y);
143 146
144 LLSDParcelVoiceInfoResponse parcelVoiceInfo = 147 LLSDParcelVoiceInfoResponse parcelVoiceInfo =
145 new LLSDParcelVoiceInfoResponse(regionName, land.localID, creds); 148 new LLSDParcelVoiceInfoResponse(regionName, land.localID, creds);
146 149
147 string r = LLSDHelpers.SerialiseLLSDReply(parcelVoiceInfo); 150 string r = LLSDHelpers.SerialiseLLSDReply(parcelVoiceInfo);
148 m_log.DebugFormat("[VOICE][PARCELVOICE]: {0}", r); 151 m_log.DebugFormat("[VOICE][PARCELVOICE]: {0}", r);
149 152
@@ -153,7 +156,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Voice.SIPVoice
153 { 156 {
154 m_log.ErrorFormat("[CAPS]: {0}, try again later", e.ToString()); 157 m_log.ErrorFormat("[CAPS]: {0}, try again later", e.ToString());
155 } 158 }
156 159
157 return null; 160 return null;
158 } 161 }
159 162
@@ -166,12 +169,12 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Voice.SIPVoice
166 /// <param name="agentID"></param> 169 /// <param name="agentID"></param>
167 /// <param name="caps"></param> 170 /// <param name="caps"></param>
168 /// <returns></returns> 171 /// <returns></returns>
169 public string ProvisionVoiceAccountRequest(string request, string path, string param, 172 public string ProvisionVoiceAccountRequest(string request, string path, string param,
170 LLUUID agentID, Caps caps) 173 LLUUID agentID, Caps caps)
171 { 174 {
172 try 175 try
173 { 176 {
174 m_log.DebugFormat("[VOICE][PROVISIONVOICE]: request: {0}, path: {1}, param: {2}", 177 m_log.DebugFormat("[VOICE][PROVISIONVOICE]: request: {0}, path: {1}, param: {2}",
175 request, path, param); 178 request, path, param);
176 179
177 string voiceUser = "x" + Convert.ToBase64String(agentID.GetBytes()); 180 string voiceUser = "x" + Convert.ToBase64String(agentID.GetBytes());
@@ -180,7 +183,7 @@ namespace OpenSim.Region.Environment.Modules.Avatar.Voice.SIPVoice
180 CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(agentID); 183 CachedUserInfo userInfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(agentID);
181 if (null == userInfo) throw new Exception("cannot get user details"); 184 if (null == userInfo) throw new Exception("cannot get user details");
182 185
183 LLSDVoiceAccountResponse voiceAccountResponse = 186 LLSDVoiceAccountResponse voiceAccountResponse =
184 new LLSDVoiceAccountResponse(voiceUser, "$1$" + userInfo.UserProfile.PasswordHash); 187 new LLSDVoiceAccountResponse(voiceUser, "$1$" + userInfo.UserProfile.PasswordHash);
185 string r = LLSDHelpers.SerialiseLLSDReply(voiceAccountResponse); 188 string r = LLSDHelpers.SerialiseLLSDReply(voiceAccountResponse);
186 m_log.DebugFormat("[CAPS][PROVISIONVOICE]: {0}", r); 189 m_log.DebugFormat("[CAPS][PROVISIONVOICE]: {0}", r);
diff --git a/OpenSim/Region/Environment/Modules/Framework/CommanderTestModule.cs b/OpenSim/Region/Environment/Modules/Framework/CommanderTestModule.cs
index 76bdae3..cf87021 100644
--- a/OpenSim/Region/Environment/Modules/Framework/CommanderTestModule.cs
+++ b/OpenSim/Region/Environment/Modules/Framework/CommanderTestModule.cs
@@ -28,26 +28,29 @@
28using System; 28using System;
29using Nini.Config; 29using Nini.Config;
30using OpenSim.Region.Environment.Interfaces; 30using OpenSim.Region.Environment.Interfaces;
31using OpenSim.Region.Environment.Modules.Framework;
32using OpenSim.Region.Environment.Scenes; 31using OpenSim.Region.Environment.Scenes;
33 32
34namespace OpenSim.Region.Environment.Modules.Framework 33namespace OpenSim.Region.Environment.Modules.Framework
35{ 34{
36 public class CommanderTestModule : IRegionModule, ICommandableModule 35 public class CommanderTestModule : IRegionModule, ICommandableModule
37 { 36 {
38 Commander m_commander = new Commander("CommanderTest"); 37 private Commander m_commander = new Commander("CommanderTest");
39 Scene m_scene; 38 private Scene m_scene;
40 39
41 #region IRegionModule Members 40 #region ICommandableModule Members
42 41
43 public void Initialise(Scene scene, IConfigSource source) 42 public ICommander CommandInterface
44 { 43 {
45 m_scene = scene; 44 get { throw new NotImplementedException(); }
46 } 45 }
47 46
48 private void InterfaceHelloWorld(Object[] args) 47 #endregion
48
49 #region IRegionModule Members
50
51 public void Initialise(Scene scene, IConfigSource source)
49 { 52 {
50 Console.WriteLine("Hello World"); 53 m_scene = scene;
51 } 54 }
52 55
53 public void PostInitialise() 56 public void PostInitialise()
@@ -77,13 +80,9 @@ namespace OpenSim.Region.Environment.Modules.Framework
77 80
78 #endregion 81 #endregion
79 82
80 #region ICommandableModule Members 83 private void InterfaceHelloWorld(Object[] args)
81
82 public ICommander CommandInterface
83 { 84 {
84 get { throw new NotImplementedException(); } 85 Console.WriteLine("Hello World");
85 } 86 }
86
87 #endregion
88 } 87 }
89} \ No newline at end of file 88} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/Grid/Interregion/InterregionModule.cs b/OpenSim/Region/Environment/Modules/Grid/Interregion/InterregionModule.cs
index 1a77ac8..8307e50 100644
--- a/OpenSim/Region/Environment/Modules/Grid/Interregion/InterregionModule.cs
+++ b/OpenSim/Region/Environment/Modules/Grid/Interregion/InterregionModule.cs
@@ -35,61 +35,14 @@ namespace OpenSim.Region.Environment.Modules.Communications.Interregion
35 private readonly Dictionary<Location, string[]> m_neighbourInterfaces = new Dictionary<Location, string[]>(); 35 private readonly Dictionary<Location, string[]> m_neighbourInterfaces = new Dictionary<Location, string[]>();
36 private readonly Dictionary<Location, RemotingObject> m_neighbourRemote = new Dictionary<Location, RemotingObject>(); 36 private readonly Dictionary<Location, RemotingObject> m_neighbourRemote = new Dictionary<Location, RemotingObject>();
37 private IConfigSource m_config; 37 private IConfigSource m_config;
38 private RemotingObject m_myRemote; 38 private bool m_enabled = false;
39 39
40 private Object m_lockObject = new object(); 40 private Object m_lockObject = new object();
41 private RemotingObject m_myRemote;
41 private TcpChannel m_tcpChannel; 42 private TcpChannel m_tcpChannel;
42 private int m_tcpPort = 10101; 43 private int m_tcpPort = 10101;
43 private bool m_enabled = false;
44
45 #region IRegionModule Members
46
47 //TODO: This prevents us from registering new scenes after PostInitialise if we want comms updated.
48 public void Initialise(Scene scene, IConfigSource source)
49 {
50 if (m_enabled)
51 {
52 m_myLocations.Add(new Location((int) scene.RegionInfo.RegionLocX,
53 (int) scene.RegionInfo.RegionLocY));
54 m_config = source;
55
56 scene.RegisterModuleInterface<IInterregionModule>(this);
57 }
58 }
59
60 //TODO: This prevents us from registering new scenes after PostInitialise if we want comms updated.
61 public void PostInitialise()
62 {
63 if (m_enabled)
64 {
65 try
66 {
67 m_tcpPort = m_config.Configs["Comms"].GetInt("remoting_port", m_tcpPort);
68 }
69 catch
70 {
71 }
72
73 internal_CreateRemotingObjects();
74 }
75 }
76
77 public void Close()
78 {
79 ChannelServices.UnregisterChannel(m_tcpChannel);
80 }
81
82 public string Name
83 {
84 get { return "InterregionModule"; }
85 }
86
87 public bool IsSharedModule
88 {
89 get { return true; }
90 }
91 44
92 #endregion 45 #region IInterregionModule Members
93 46
94 public void internal_CreateRemotingObjects() 47 public void internal_CreateRemotingObjects()
95 { 48 {
@@ -106,22 +59,6 @@ namespace OpenSim.Region.Environment.Modules.Communications.Interregion
106 } 59 }
107 } 60 }
108 61
109 public void RegisterRemoteRegion(string uri)
110 {
111 RegisterRemotingInterface((RemotingObject) Activator.GetObject(typeof (RemotingObject), uri));
112 }
113
114 private void RegisterRemotingInterface(RemotingObject remote)
115 {
116 Location[] locs = remote.GetLocations();
117 string[] interfaces = remote.GetInterfaces();
118 foreach (Location loc in locs)
119 {
120 m_neighbourInterfaces[loc] = interfaces;
121 m_neighbourRemote[loc] = remote;
122 }
123 }
124
125 public void RegisterMethod<T>(T e) 62 public void RegisterMethod<T>(T e)
126 { 63 {
127 m_interfaces[typeof (T)] = e; 64 m_interfaces[typeof (T)] = e;
@@ -171,5 +108,73 @@ namespace OpenSim.Region.Environment.Modules.Communications.Interregion
171 { 108 {
172 return new Location(0, 0); 109 return new Location(0, 0);
173 } 110 }
111
112 #endregion
113
114 //TODO: This prevents us from registering new scenes after PostInitialise if we want comms updated.
115
116 #region IRegionModule Members
117
118 public void Initialise(Scene scene, IConfigSource source)
119 {
120 if (m_enabled)
121 {
122 m_myLocations.Add(new Location((int) scene.RegionInfo.RegionLocX,
123 (int) scene.RegionInfo.RegionLocY));
124 m_config = source;
125
126 scene.RegisterModuleInterface<IInterregionModule>(this);
127 }
128 }
129
130 //TODO: This prevents us from registering new scenes after PostInitialise if we want comms updated.
131 public void PostInitialise()
132 {
133 if (m_enabled)
134 {
135 try
136 {
137 m_tcpPort = m_config.Configs["Comms"].GetInt("remoting_port", m_tcpPort);
138 }
139 catch
140 {
141 }
142
143 internal_CreateRemotingObjects();
144 }
145 }
146
147 public void Close()
148 {
149 ChannelServices.UnregisterChannel(m_tcpChannel);
150 }
151
152 public string Name
153 {
154 get { return "InterregionModule"; }
155 }
156
157 public bool IsSharedModule
158 {
159 get { return true; }
160 }
161
162 #endregion
163
164 public void RegisterRemoteRegion(string uri)
165 {
166 RegisterRemotingInterface((RemotingObject) Activator.GetObject(typeof (RemotingObject), uri));
167 }
168
169 private void RegisterRemotingInterface(RemotingObject remote)
170 {
171 Location[] locs = remote.GetLocations();
172 string[] interfaces = remote.GetInterfaces();
173 foreach (Location loc in locs)
174 {
175 m_neighbourInterfaces[loc] = interfaces;
176 m_neighbourRemote[loc] = remote;
177 }
178 }
174 } 179 }
175} \ No newline at end of file 180} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/Scripting/DynamicTexture/DynamicTextureModule.cs b/OpenSim/Region/Environment/Modules/Scripting/DynamicTexture/DynamicTextureModule.cs
index 63eee97..735a3cf 100644
--- a/OpenSim/Region/Environment/Modules/Scripting/DynamicTexture/DynamicTextureModule.cs
+++ b/OpenSim/Region/Environment/Modules/Scripting/DynamicTexture/DynamicTextureModule.cs
@@ -47,32 +47,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.DynamicTexture
47 47
48 private Dictionary<LLUUID, DynamicTextureUpdater> Updaters = new Dictionary<LLUUID, DynamicTextureUpdater>(); 48 private Dictionary<LLUUID, DynamicTextureUpdater> Updaters = new Dictionary<LLUUID, DynamicTextureUpdater>();
49 49
50 public void Initialise(Scene scene, IConfigSource config) 50 #region IDynamicTextureManager Members
51 {
52 if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID))
53 {
54 RegisteredScenes.Add(scene.RegionInfo.RegionID, scene);
55 scene.RegisterModuleInterface<IDynamicTextureManager>(this);
56 }
57 }
58
59 public void PostInitialise()
60 {
61 }
62
63 public void Close()
64 {
65 }
66
67 public string Name
68 {
69 get { return "DynamicTextureModule"; }
70 }
71
72 public bool IsSharedModule
73 {
74 get { return true; }
75 }
76 51
77 public void RegisterRender(string handleType, IDynamicTextureRender render) 52 public void RegisterRender(string handleType, IDynamicTextureRender render)
78 { 53 {
@@ -164,20 +139,55 @@ namespace OpenSim.Region.Environment.Modules.Scripting.DynamicTexture
164 return LLUUID.Zero; 139 return LLUUID.Zero;
165 } 140 }
166 141
142 #endregion
143
144 #region IRegionModule Members
145
146 public void Initialise(Scene scene, IConfigSource config)
147 {
148 if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID))
149 {
150 RegisteredScenes.Add(scene.RegionInfo.RegionID, scene);
151 scene.RegisterModuleInterface<IDynamicTextureManager>(this);
152 }
153 }
154
155 public void PostInitialise()
156 {
157 }
158
159 public void Close()
160 {
161 }
162
163 public string Name
164 {
165 get { return "DynamicTextureModule"; }
166 }
167
168 public bool IsSharedModule
169 {
170 get { return true; }
171 }
172
173 #endregion
174
175 #region Nested type: DynamicTextureUpdater
176
167 public class DynamicTextureUpdater 177 public class DynamicTextureUpdater
168 { 178 {
169 public LLUUID SimUUID; 179 public bool BlendWithOldTexture = false;
170 public LLUUID UpdaterID;
171 public string ContentType;
172 public string Url;
173 public string BodyData; 180 public string BodyData;
174 public LLUUID PrimID; 181 public string ContentType;
175 public int UpdateTimer; 182 public byte FrontAlpha = 255;
176 public LLUUID LastAssetID; 183 public LLUUID LastAssetID;
177 public string Params; 184 public string Params;
178 public bool BlendWithOldTexture = false; 185 public LLUUID PrimID;
179 public bool SetNewFrontAlpha = false; 186 public bool SetNewFrontAlpha = false;
180 public byte FrontAlpha = 255; 187 public LLUUID SimUUID;
188 public LLUUID UpdaterID;
189 public int UpdateTimer;
190 public string Url;
181 191
182 public DynamicTextureUpdater() 192 public DynamicTextureUpdater()
183 { 193 {
@@ -224,7 +234,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.DynamicTexture
224 234
225 LastAssetID = asset.FullID; 235 LastAssetID = asset.FullID;
226 236
227 237
228 part.Shape.Textures = new LLObject.TextureEntry(asset.FullID); 238 part.Shape.Textures = new LLObject.TextureEntry(asset.FullID);
229 part.ScheduleFullUpdate(); 239 part.ScheduleFullUpdate();
230 } 240 }
@@ -273,5 +283,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.DynamicTexture
273 } 283 }
274 } 284 }
275 } 285 }
286
287 #endregion
276 } 288 }
277} \ No newline at end of file 289} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/Environment/Modules/Scripting/HttpRequest/ScriptsHttpRequests.cs
index 4977a86..184e026 100644
--- a/OpenSim/Region/Environment/Modules/Scripting/HttpRequest/ScriptsHttpRequests.cs
+++ b/OpenSim/Region/Environment/Modules/Scripting/HttpRequest/ScriptsHttpRequests.cs
@@ -84,45 +84,20 @@ namespace OpenSim.Region.Environment.Modules.Scripting.HttpRequest
84{ 84{
85 public class HttpRequestModule : IRegionModule, IHttpRequests 85 public class HttpRequestModule : IRegionModule, IHttpRequests
86 { 86 {
87 private Scene m_scene;
88 private Queue<HttpRequestClass> rpcQueue = new Queue<HttpRequestClass>();
89 private object HttpListLock = new object(); 87 private object HttpListLock = new object();
90 private string m_name = "HttpScriptRequests";
91 private int httpTimeout = 30000; 88 private int httpTimeout = 30000;
89 private string m_name = "HttpScriptRequests";
92 90
93 // <request id, HttpRequestClass> 91 // <request id, HttpRequestClass>
94 private Dictionary<LLUUID, HttpRequestClass> m_pendingRequests; 92 private Dictionary<LLUUID, HttpRequestClass> m_pendingRequests;
93 private Scene m_scene;
94 private Queue<HttpRequestClass> rpcQueue = new Queue<HttpRequestClass>();
95 95
96 public HttpRequestModule() 96 public HttpRequestModule()
97 { 97 {
98 } 98 }
99 99
100 public void Initialise(Scene scene, IConfigSource config) 100 #region IHttpRequests Members
101 {
102 m_scene = scene;
103
104 m_scene.RegisterModuleInterface<IHttpRequests>(this);
105
106 m_pendingRequests = new Dictionary<LLUUID, HttpRequestClass>();
107 }
108
109 public void PostInitialise()
110 {
111 }
112
113 public void Close()
114 {
115 }
116
117 public string Name
118 {
119 get { return m_name; }
120 }
121
122 public bool IsSharedModule
123 {
124 get { return true; }
125 }
126 101
127 public LLUUID MakeHttpRequest(string url, string parameters, string body) 102 public LLUUID MakeHttpRequest(string url, string parameters, string body)
128 { 103 {
@@ -141,7 +116,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.HttpRequest
141 if (parameters != null) 116 if (parameters != null)
142 { 117 {
143 string[] parms = parameters.ToArray(); 118 string[] parms = parameters.ToArray();
144 for (int i = 0; i < parms.Length/2; i += 2) 119 for (int i = 0; i < parms.Length / 2; i += 2)
145 { 120 {
146 switch (Int32.Parse(parms[i])) 121 switch (Int32.Parse(parms[i]))
147 { 122 {
@@ -187,7 +162,8 @@ namespace OpenSim.Region.Environment.Modules.Scripting.HttpRequest
187 162
188 public void StopHttpRequest(uint m_localID, LLUUID m_itemID) 163 public void StopHttpRequest(uint m_localID, LLUUID m_itemID)
189 { 164 {
190 if(m_pendingRequests != null) { 165 if (m_pendingRequests != null)
166 {
191 lock (HttpListLock) 167 lock (HttpListLock)
192 { 168 {
193 HttpRequestClass tmpReq; 169 HttpRequestClass tmpReq;
@@ -243,36 +219,68 @@ namespace OpenSim.Region.Environment.Modules.Scripting.HttpRequest
243 } 219 }
244 } 220 }
245 221
222 #endregion
223
224 #region IRegionModule Members
225
226 public void Initialise(Scene scene, IConfigSource config)
227 {
228 m_scene = scene;
229
230 m_scene.RegisterModuleInterface<IHttpRequests>(this);
231
232 m_pendingRequests = new Dictionary<LLUUID, HttpRequestClass>();
233 }
234
235 public void PostInitialise()
236 {
237 }
238
239 public void Close()
240 {
241 }
242
243 public string Name
244 {
245 get { return m_name; }
246 }
247
248 public bool IsSharedModule
249 {
250 get { return true; }
251 }
252
253 #endregion
246 } 254 }
247 255
248 public class HttpRequestClass 256 public class HttpRequestClass
249 { 257 {
250 // Constants for parameters 258 // Constants for parameters
259 public const int HTTP_BODY_MAXLENGTH = 2;
251 public const int HTTP_METHOD = 0; 260 public const int HTTP_METHOD = 0;
252 public const int HTTP_MIMETYPE = 1; 261 public const int HTTP_MIMETYPE = 1;
253 public const int HTTP_BODY_MAXLENGTH = 2;
254 public const int HTTP_VERIFY_CERT = 3; 262 public const int HTTP_VERIFY_CERT = 3;
263 public bool finished;
264 public int httpBodyMaxLen = 2048; // not implemented
255 265
256 // Parameter members and default values 266 // Parameter members and default values
257 public string httpMethod = "GET"; 267 public string httpMethod = "GET";
258 public string httpMIMEType = "text/plain;charset=utf-8"; 268 public string httpMIMEType = "text/plain;charset=utf-8";
259 public int httpBodyMaxLen = 2048; // not implemented 269 private Thread httpThread;
270 public int httpTimeout;
260 public bool httpVerifyCert = true; // not implemented 271 public bool httpVerifyCert = true; // not implemented
261 272
262 // Request info 273 // Request info
263 public uint localID;
264 public LLUUID itemID; 274 public LLUUID itemID;
265 public LLUUID reqID; 275 public uint localID;
266 public int httpTimeout;
267 public string url;
268 public string outbound_body;
269 public DateTime next; 276 public DateTime next;
270 public int status; 277 public string outbound_body;
271 public bool finished; 278 public LLUUID reqID;
272 public List<string> response_metadata;
273 public string response_body;
274 public HttpWebRequest request; 279 public HttpWebRequest request;
275 private Thread httpThread; 280 public string response_body;
281 public List<string> response_metadata;
282 public int status;
283 public string url;
276 284
277 public void process() 285 public void process()
278 { 286 {
diff --git a/OpenSim/Region/Environment/Modules/Scripting/LoadImageURL/LoadImageURLModule.cs b/OpenSim/Region/Environment/Modules/Scripting/LoadImageURL/LoadImageURLModule.cs
index eaf9d36..a0408cd 100644
--- a/OpenSim/Region/Environment/Modules/Scripting/LoadImageURL/LoadImageURLModule.cs
+++ b/OpenSim/Region/Environment/Modules/Scripting/LoadImageURL/LoadImageURLModule.cs
@@ -40,39 +40,10 @@ namespace OpenSim.Region.Environment.Modules.Scripting.LoadImageURL
40 public class LoadImageURLModule : IRegionModule, IDynamicTextureRender 40 public class LoadImageURLModule : IRegionModule, IDynamicTextureRender
41 { 41 {
42 private string m_name = "LoadImageURL"; 42 private string m_name = "LoadImageURL";
43 private IDynamicTextureManager m_textureManager;
44 private Scene m_scene; 43 private Scene m_scene;
44 private IDynamicTextureManager m_textureManager;
45 45
46 public void Initialise(Scene scene, IConfigSource config) 46 #region IDynamicTextureRender Members
47 {
48 if (m_scene == null)
49 {
50 m_scene = scene;
51 }
52 }
53
54 public void PostInitialise()
55 {
56 m_textureManager = m_scene.RequestModuleInterface<IDynamicTextureManager>();
57 if (m_textureManager != null)
58 {
59 m_textureManager.RegisterRender(GetContentType(), this);
60 }
61 }
62
63 public void Close()
64 {
65 }
66
67 public string Name
68 {
69 get { return m_name; }
70 }
71
72 public bool IsSharedModule
73 {
74 get { return true; }
75 }
76 47
77 public string GetName() 48 public string GetName()
78 { 49 {
@@ -110,6 +81,43 @@ namespace OpenSim.Region.Environment.Modules.Scripting.LoadImageURL
110 return false; 81 return false;
111 } 82 }
112 83
84 #endregion
85
86 #region IRegionModule Members
87
88 public void Initialise(Scene scene, IConfigSource config)
89 {
90 if (m_scene == null)
91 {
92 m_scene = scene;
93 }
94 }
95
96 public void PostInitialise()
97 {
98 m_textureManager = m_scene.RequestModuleInterface<IDynamicTextureManager>();
99 if (m_textureManager != null)
100 {
101 m_textureManager.RegisterRender(GetContentType(), this);
102 }
103 }
104
105 public void Close()
106 {
107 }
108
109 public string Name
110 {
111 get { return m_name; }
112 }
113
114 public bool IsSharedModule
115 {
116 get { return true; }
117 }
118
119 #endregion
120
113 private void MakeHttpRequest(string url, LLUUID requestID) 121 private void MakeHttpRequest(string url, LLUUID requestID)
114 { 122 {
115 WebRequest request = HttpWebRequest.Create(url); 123 WebRequest request = HttpWebRequest.Create(url);
@@ -138,8 +146,8 @@ namespace OpenSim.Region.Environment.Modules.Scripting.LoadImageURL
138 else if ((image.Height < 128) && (image.Width < 128)) 146 else if ((image.Height < 128) && (image.Width < 128))
139 { 147 {
140 newsize = new Size(64, 64); 148 newsize = new Size(64, 64);
141 } 149 }
142 else if ((image.Height <256) && (image.Width < 256)) 150 else if ((image.Height < 256) && (image.Width < 256))
143 { 151 {
144 newsize = new Size(128, 128); 152 newsize = new Size(128, 128);
145 } 153 }
@@ -153,8 +161,8 @@ namespace OpenSim.Region.Environment.Modules.Scripting.LoadImageURL
153 } 161 }
154 else 162 else
155 { 163 {
156 newsize = new Size(1024,1024); 164 newsize = new Size(1024, 1024);
157 } 165 }
158 166
159 Bitmap resize = new Bitmap(image, newsize); 167 Bitmap resize = new Bitmap(image, newsize);
160 byte[] imageJ2000 = OpenJPEG.EncodeFromImage(resize, true); 168 byte[] imageJ2000 = OpenJPEG.EncodeFromImage(resize, true);
@@ -163,6 +171,8 @@ namespace OpenSim.Region.Environment.Modules.Scripting.LoadImageURL
163 } 171 }
164 } 172 }
165 173
174 #region Nested type: RequestState
175
166 public class RequestState 176 public class RequestState
167 { 177 {
168 public HttpWebRequest Request = null; 178 public HttpWebRequest Request = null;
@@ -175,5 +185,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.LoadImageURL
175 RequestID = requestID; 185 RequestID = requestID;
176 } 186 }
177 } 187 }
188
189 #endregion
178 } 190 }
179} \ No newline at end of file 191} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/Environment/Modules/Scripting/VectorRender/VectorRenderModule.cs
index 4fba5b9..386c2b5 100644
--- a/OpenSim/Region/Environment/Modules/Scripting/VectorRender/VectorRenderModule.cs
+++ b/OpenSim/Region/Environment/Modules/Scripting/VectorRender/VectorRenderModule.cs
@@ -44,14 +44,56 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
44{ 44{
45 public class VectorRenderModule : IRegionModule, IDynamicTextureRender 45 public class VectorRenderModule : IRegionModule, IDynamicTextureRender
46 { 46 {
47 private Scene m_scene;
48 private string m_name = "VectorRenderModule"; 47 private string m_name = "VectorRenderModule";
48 private Scene m_scene;
49 private IDynamicTextureManager m_textureManager; 49 private IDynamicTextureManager m_textureManager;
50 50
51 public VectorRenderModule() 51 public VectorRenderModule()
52 { 52 {
53 } 53 }
54 54
55 #region IDynamicTextureRender Members
56
57 public string GetContentType()
58 {
59 return ("vector");
60 }
61
62 public string GetName()
63 {
64 return m_name;
65 }
66
67 public bool SupportsAsynchronous()
68 {
69 return true;
70 }
71
72 public byte[] ConvertUrl(string url, string extraParams)
73 {
74 return null;
75 }
76
77 public byte[] ConvertStream(Stream data, string extraParams)
78 {
79 return null;
80 }
81
82 public bool AsyncConvertUrl(LLUUID id, string url, string extraParams)
83 {
84 return false;
85 }
86
87 public bool AsyncConvertData(LLUUID id, string bodyData, string extraParams)
88 {
89 Draw(bodyData, id, extraParams);
90 return true;
91 }
92
93 #endregion
94
95 #region IRegionModule Members
96
55 public void Initialise(Scene scene, IConfigSource config) 97 public void Initialise(Scene scene, IConfigSource config)
56 { 98 {
57 if (m_scene == null) 99 if (m_scene == null)
@@ -83,21 +125,25 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
83 get { return true; } 125 get { return true; }
84 } 126 }
85 127
128 #endregion
129
86 private void Draw(string data, LLUUID id, string extraParams) 130 private void Draw(string data, LLUUID id, string extraParams)
87 { 131 {
88 // TODO: this is a brutal hack. extraParams should actually be parsed reasonably. 132 // TODO: this is a brutal hack. extraParams should actually be parsed reasonably.
89 int size = 256; 133 int size = 256;
90 try { 134 try
135 {
91 size = Convert.ToInt32(extraParams); 136 size = Convert.ToInt32(extraParams);
92 } catch (Exception e) { 137 }
93 138 catch (Exception e)
139 {
94//Ckrinke: Add a WriteLine to remove the warning about 'e' defined but not used 140//Ckrinke: Add a WriteLine to remove the warning about 'e' defined but not used
95 Console.WriteLine("Problem with Draw. Please verify parameters." + e.ToString()); 141 Console.WriteLine("Problem with Draw. Please verify parameters." + e.ToString());
96 } 142 }
97 143
98 if ((size < 128) || (size > 1024)) 144 if ((size < 128) || (size > 1024))
99 size = 256; 145 size = 256;
100 146
101 Bitmap bitmap = new Bitmap(size, size, PixelFormat.Format32bppArgb); 147 Bitmap bitmap = new Bitmap(size, size, PixelFormat.Format32bppArgb);
102 148
103 Graphics graph = Graphics.FromImage(bitmap); 149 Graphics graph = Graphics.FromImage(bitmap);
@@ -121,13 +167,11 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
121 } 167 }
122 } 168 }
123 169
124
125 170
126 GDIDraw(data, graph); 171 GDIDraw(data, graph);
127 172
128 byte[] imageJ2000 = OpenJPEG.EncodeFromImage(bitmap, true); 173 byte[] imageJ2000 = OpenJPEG.EncodeFromImage(bitmap, true);
129 m_textureManager.ReturnData(id, imageJ2000); 174 m_textureManager.ReturnData(id, imageJ2000);
130
131 } 175 }
132 176
133/* 177/*
@@ -175,10 +219,10 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
175 Pen drawPen = new Pen(Color.Black, 7); 219 Pen drawPen = new Pen(Color.Black, 7);
176 Font myFont = new Font("Times New Roman", 14); 220 Font myFont = new Font("Times New Roman", 14);
177 SolidBrush myBrush = new SolidBrush(Color.Black); 221 SolidBrush myBrush = new SolidBrush(Color.Black);
178 char[] lineDelimiter = { ';' }; 222 char[] lineDelimiter = {';'};
179 char[] partsDelimiter = { ',' }; 223 char[] partsDelimiter = {','};
180 string[] lines = data.Split(lineDelimiter); 224 string[] lines = data.Split(lineDelimiter);
181 225
182 foreach (string line in lines) 226 foreach (string line in lines)
183 { 227 {
184 string nextLine = line.Trim(); 228 string nextLine = line.Trim();
@@ -188,16 +232,16 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
188 float x = 0; 232 float x = 0;
189 float y = 0; 233 float y = 0;
190 GetParams(partsDelimiter, ref nextLine, 6, ref x, ref y); 234 GetParams(partsDelimiter, ref nextLine, 6, ref x, ref y);
191 startPoint.X = (int)x; 235 startPoint.X = (int) x;
192 startPoint.Y = (int)y; 236 startPoint.Y = (int) y;
193 } 237 }
194 else if (nextLine.StartsWith("LineTo")) 238 else if (nextLine.StartsWith("LineTo"))
195 { 239 {
196 float x = 0; 240 float x = 0;
197 float y = 0; 241 float y = 0;
198 GetParams(partsDelimiter, ref nextLine, 6, ref x, ref y); 242 GetParams(partsDelimiter, ref nextLine, 6, ref x, ref y);
199 endPoint.X = (int)x; 243 endPoint.X = (int) x;
200 endPoint.Y = (int)y; 244 endPoint.Y = (int) y;
201 graph.DrawLine(drawPen, startPoint, endPoint); 245 graph.DrawLine(drawPen, startPoint, endPoint);
202 startPoint.X = endPoint.X; 246 startPoint.X = endPoint.X;
203 startPoint.Y = endPoint.Y; 247 startPoint.Y = endPoint.Y;
@@ -213,10 +257,10 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
213 float x = 0; 257 float x = 0;
214 float y = 0; 258 float y = 0;
215 GetParams(partsDelimiter, ref nextLine, 5, ref x, ref y); 259 GetParams(partsDelimiter, ref nextLine, 5, ref x, ref y);
216 endPoint.X = (int)x; 260 endPoint.X = (int) x;
217 endPoint.Y = (int)y; 261 endPoint.Y = (int) y;
218 Image image = ImageHttpRequest(nextLine); 262 Image image = ImageHttpRequest(nextLine);
219 graph.DrawImage(image, (float)startPoint.X, (float)startPoint.Y, x, y); 263 graph.DrawImage(image, (float) startPoint.X, (float) startPoint.Y, x, y);
220 startPoint.X += endPoint.X; 264 startPoint.X += endPoint.X;
221 startPoint.Y += endPoint.Y; 265 startPoint.Y += endPoint.Y;
222 } 266 }
@@ -225,8 +269,8 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
225 float x = 0; 269 float x = 0;
226 float y = 0; 270 float y = 0;
227 GetParams(partsDelimiter, ref nextLine, 9, ref x, ref y); 271 GetParams(partsDelimiter, ref nextLine, 9, ref x, ref y);
228 endPoint.X = (int)x; 272 endPoint.X = (int) x;
229 endPoint.Y = (int)y; 273 endPoint.Y = (int) y;
230 graph.DrawRectangle(drawPen, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y); 274 graph.DrawRectangle(drawPen, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y);
231 startPoint.X += endPoint.X; 275 startPoint.X += endPoint.X;
232 startPoint.Y += endPoint.Y; 276 startPoint.Y += endPoint.Y;
@@ -236,8 +280,8 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
236 float x = 0; 280 float x = 0;
237 float y = 0; 281 float y = 0;
238 GetParams(partsDelimiter, ref nextLine, 13, ref x, ref y); 282 GetParams(partsDelimiter, ref nextLine, 13, ref x, ref y);
239 endPoint.X = (int)x; 283 endPoint.X = (int) x;
240 endPoint.Y = (int)y; 284 endPoint.Y = (int) y;
241 graph.FillRectangle(myBrush, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y); 285 graph.FillRectangle(myBrush, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y);
242 startPoint.X += endPoint.X; 286 startPoint.X += endPoint.X;
243 startPoint.Y += endPoint.Y; 287 startPoint.Y += endPoint.Y;
@@ -247,8 +291,8 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
247 float x = 0; 291 float x = 0;
248 float y = 0; 292 float y = 0;
249 GetParams(partsDelimiter, ref nextLine, 7, ref x, ref y); 293 GetParams(partsDelimiter, ref nextLine, 7, ref x, ref y);
250 endPoint.X = (int)x; 294 endPoint.X = (int) x;
251 endPoint.Y = (int)y; 295 endPoint.Y = (int) y;
252 graph.DrawEllipse(drawPen, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y); 296 graph.DrawEllipse(drawPen, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y);
253 startPoint.X += endPoint.X; 297 startPoint.X += endPoint.X;
254 startPoint.Y += endPoint.Y; 298 startPoint.Y += endPoint.Y;
@@ -271,7 +315,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
271 { 315 {
272 nextLine = nextLine.Remove(0, 9); 316 nextLine = nextLine.Remove(0, 9);
273 nextLine = nextLine.Trim(); 317 nextLine = nextLine.Trim();
274 318
275 Color newColour = Color.FromName(nextLine); 319 Color newColour = Color.FromName(nextLine);
276 320
277 myBrush.Color = newColour; 321 myBrush.Color = newColour;
@@ -312,7 +356,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
312 WebRequest request = HttpWebRequest.Create(url); 356 WebRequest request = HttpWebRequest.Create(url);
313//Ckrinke: Comment out for now as 'str' is unused. Bring it back into play later when it is used. 357//Ckrinke: Comment out for now as 'str' is unused. Bring it back into play later when it is used.
314//Ckrinke Stream str = null; 358//Ckrinke Stream str = null;
315 HttpWebResponse response = (HttpWebResponse)(request).GetResponse(); 359 HttpWebResponse response = (HttpWebResponse) (request).GetResponse();
316 if (response.StatusCode == HttpStatusCode.OK) 360 if (response.StatusCode == HttpStatusCode.OK)
317 { 361 {
318 Bitmap image = new Bitmap(response.GetResponseStream()); 362 Bitmap image = new Bitmap(response.GetResponseStream());
@@ -321,41 +365,5 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
321 365
322 return null; 366 return null;
323 } 367 }
324
325 public string GetContentType()
326 {
327 return ("vector");
328 }
329
330 public string GetName()
331 {
332 return m_name;
333 }
334
335 public bool SupportsAsynchronous()
336 {
337 return true;
338 }
339
340 public byte[] ConvertUrl(string url, string extraParams)
341 {
342 return null;
343 }
344
345 public byte[] ConvertStream(Stream data, string extraParams)
346 {
347 return null;
348 }
349
350 public bool AsyncConvertUrl(LLUUID id, string url, string extraParams)
351 {
352 return false;
353 }
354
355 public bool AsyncConvertData(LLUUID id, string bodyData, string extraParams)
356 {
357 Draw(bodyData, id, extraParams);
358 return true;
359 }
360 } 368 }
361} \ No newline at end of file 369} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/Environment/Modules/Scripting/WorldComm/WorldCommModule.cs
index a949fb6..ff3b31e 100644
--- a/OpenSim/Region/Environment/Modules/Scripting/WorldComm/WorldCommModule.cs
+++ b/OpenSim/Region/Environment/Modules/Scripting/WorldComm/WorldCommModule.cs
@@ -67,18 +67,20 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
67{ 67{
68 public class WorldCommModule : IRegionModule, IWorldComm 68 public class WorldCommModule : IRegionModule, IWorldComm
69 { 69 {
70 private Scene m_scene;
71 private object CommListLock = new object(); 70 private object CommListLock = new object();
72 private object ListLock = new object(); 71 private object ListLock = new object();
73 private string m_name = "WorldCommModule";
74 private ListenerManager m_listenerManager; 72 private ListenerManager m_listenerManager;
75 private Queue m_pendingQ; 73 private string m_name = "WorldCommModule";
76 private Queue m_pending; 74 private Queue m_pending;
75 private Queue m_pendingQ;
76 private Scene m_scene;
77 77
78 public WorldCommModule() 78 public WorldCommModule()
79 { 79 {
80 } 80 }
81 81
82 #region IRegionModule Members
83
82 public void Initialise(Scene scene, IConfigSource config) 84 public void Initialise(Scene scene, IConfigSource config)
83 { 85 {
84 m_scene = scene; 86 m_scene = scene;
@@ -107,23 +109,9 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
107 get { return false; } 109 get { return false; }
108 } 110 }
109 111
110 public void NewClient(IClientAPI client) 112 #endregion
111 {
112 client.OnChatFromViewer += DeliverClientMessage;
113 }
114 113
115 /******************************************************************** 114 #region IWorldComm Members
116 *
117 * Listener Stuff
118 *
119 * *****************************************************************/
120 private void DeliverClientMessage(Object sender, ChatFromViewerArgs e)
121 {
122 DeliverMessage(e.Sender.AgentId.ToString(),
123 e.Type, e.Channel,
124 e.Sender.FirstName + " " + e.Sender.LastName,
125 e.Message);
126 }
127 115
128 public int Listen(uint localID, LLUUID itemID, LLUUID hostID, int channel, string name, string id, string msg) 116 public int Listen(uint localID, LLUUID itemID, LLUUID hostID, int channel, string name, string id, string msg)
129 { 117 {
@@ -295,7 +283,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
295 283
296 lock (m_pending.SyncRoot) 284 lock (m_pending.SyncRoot)
297 { 285 {
298 li = (ListenerInfo)m_pending.Dequeue(); 286 li = (ListenerInfo) m_pending.Dequeue();
299 } 287 }
300 288
301 return li; 289 return li;
@@ -303,20 +291,41 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
303 291
304 public uint PeekNextMessageLocalID() 292 public uint PeekNextMessageLocalID()
305 { 293 {
306 return ((ListenerInfo)m_pending.Peek()).GetLocalID(); 294 return ((ListenerInfo) m_pending.Peek()).GetLocalID();
307 } 295 }
308 296
309 public LLUUID PeekNextMessageItemID() 297 public LLUUID PeekNextMessageItemID()
310 { 298 {
311 return ((ListenerInfo)m_pending.Peek()).GetItemID(); 299 return ((ListenerInfo) m_pending.Peek()).GetItemID();
300 }
301
302 #endregion
303
304 public void NewClient(IClientAPI client)
305 {
306 client.OnChatFromViewer += DeliverClientMessage;
307 }
308
309 /********************************************************************
310 *
311 * Listener Stuff
312 *
313 * *****************************************************************/
314
315 private void DeliverClientMessage(Object sender, ChatFromViewerArgs e)
316 {
317 DeliverMessage(e.Sender.AgentId.ToString(),
318 e.Type, e.Channel,
319 e.Sender.FirstName + " " + e.Sender.LastName,
320 e.Message);
312 } 321 }
313 } 322 }
314 323
315 public class ListenerManager 324 public class ListenerManager
316 { 325 {
317 //private Dictionary<int, ListenerInfo> m_listeners; 326 //private Dictionary<int, ListenerInfo> m_listeners;
318 private Hashtable m_listeners = Hashtable.Synchronized(new Hashtable());
319 private object ListenersLock = new object(); 327 private object ListenersLock = new object();
328 private Hashtable m_listeners = Hashtable.Synchronized(new Hashtable());
320 private int m_MaxListeners = 100; 329 private int m_MaxListeners = 100;
321 330
322 public int AddListener(uint localID, LLUUID itemID, LLUUID hostID, int channel, string name, string id, string msg) 331 public int AddListener(uint localID, LLUUID itemID, LLUUID hostID, int channel, string name, string id, string msg)
@@ -363,7 +372,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
363 IDictionaryEnumerator en = m_listeners.GetEnumerator(); 372 IDictionaryEnumerator en = m_listeners.GetEnumerator();
364 while (en.MoveNext()) 373 while (en.MoveNext())
365 { 374 {
366 ListenerInfo li = (ListenerInfo)en.Value; 375 ListenerInfo li = (ListenerInfo) en.Value;
367 if (li.GetItemID().Equals(itemID)) 376 if (li.GetItemID().Equals(itemID))
368 { 377 {
369 removedListeners.Add(li.GetHandle()); 378 removedListeners.Add(li.GetHandle());
@@ -400,12 +409,11 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
400 409
401 public void Activate(int handle) 410 public void Activate(int handle)
402 { 411 {
403
404 if (m_listeners.ContainsKey(handle)) 412 if (m_listeners.ContainsKey(handle))
405 { 413 {
406 lock (m_listeners.SyncRoot) 414 lock (m_listeners.SyncRoot)
407 { 415 {
408 ListenerInfo li = (ListenerInfo)m_listeners[handle]; 416 ListenerInfo li = (ListenerInfo) m_listeners[handle];
409 li.Activate(); 417 li.Activate();
410 } 418 }
411 } 419 }
@@ -413,10 +421,9 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
413 421
414 public void Dectivate(int handle) 422 public void Dectivate(int handle)
415 { 423 {
416
417 if (m_listeners.ContainsKey(handle)) 424 if (m_listeners.ContainsKey(handle))
418 { 425 {
419 ListenerInfo li = (ListenerInfo)m_listeners[handle]; 426 ListenerInfo li = (ListenerInfo) m_listeners[handle];
420 li.Deactivate(); 427 li.Deactivate();
421 } 428 }
422 } 429 }
@@ -432,9 +439,9 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
432 IDictionaryEnumerator en = m_listeners.GetEnumerator(); 439 IDictionaryEnumerator en = m_listeners.GetEnumerator();
433 while (en.MoveNext()) 440 while (en.MoveNext())
434 { 441 {
435 ListenerInfo li = (ListenerInfo)en.Value; 442 ListenerInfo li = (ListenerInfo) en.Value;
436 443
437 if (li.IsActive()) 444 if (li.IsActive())
438 { 445 {
439 if (li.GetHostID().Equals(listenerKey)) 446 if (li.GetHostID().Equals(listenerKey))
440 { 447 {
@@ -478,16 +485,16 @@ namespace OpenSim.Region.Environment.Modules.Scripting.WorldComm
478 485
479 public class ListenerInfo 486 public class ListenerInfo
480 { 487 {
481 private LLUUID m_itemID; // ID of the host script engine 488 private bool m_active; // Listener is active or not
482 private LLUUID m_hostID; // ID of the host/scene part
483 private LLUUID m_sourceItemID; // ID of the scenePart or avatar source of the message
484 private int m_channel; // Channel 489 private int m_channel; // Channel
485 private int m_handle; // Assigned handle of this listener 490 private int m_handle; // Assigned handle of this listener
486 private uint m_localID; // Local ID from script engine 491 private LLUUID m_hostID; // ID of the host/scene part
487 private string m_name; // Object name to filter messages from
488 private LLUUID m_id; // ID to filter messages from 492 private LLUUID m_id; // ID to filter messages from
493 private LLUUID m_itemID; // ID of the host script engine
494 private uint m_localID; // Local ID from script engine
489 private string m_message; // The message 495 private string m_message; // The message
490 private bool m_active; // Listener is active or not 496 private string m_name; // Object name to filter messages from
497 private LLUUID m_sourceItemID; // ID of the scenePart or avatar source of the message
491 498
492 public ListenerInfo(uint localID, int handle, LLUUID ItemID, LLUUID hostID, int channel, string name, LLUUID id, string message) 499 public ListenerInfo(uint localID, int handle, LLUUID ItemID, LLUUID hostID, int channel, string name, LLUUID id, string message)
493 { 500 {
diff --git a/OpenSim/Region/Environment/Modules/Scripting/XMLRPC/XMLRPCModule.cs b/OpenSim/Region/Environment/Modules/Scripting/XMLRPC/XMLRPCModule.cs
index 1139b4b..6ca8136 100644
--- a/OpenSim/Region/Environment/Modules/Scripting/XMLRPC/XMLRPCModule.cs
+++ b/OpenSim/Region/Environment/Modules/Scripting/XMLRPC/XMLRPCModule.cs
@@ -79,20 +79,21 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
79 { 79 {
80 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 80 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
81 81
82 private object XMLRPCListLock = new object();
83 private string m_name = "XMLRPCModule"; 82 private string m_name = "XMLRPCModule";
84 private int RemoteReplyScriptWait = 300;
85 private int RemoteReplyScriptTimeout = 9000;
86 private int m_remoteDataPort = 0;
87 private List<Scene> m_scenes = new List<Scene>();
88 83
89 // <channel id, RPCChannelInfo> 84 // <channel id, RPCChannelInfo>
90 private Dictionary<LLUUID, RPCChannelInfo> m_openChannels; 85 private Dictionary<LLUUID, RPCChannelInfo> m_openChannels;
86 private Dictionary<LLUUID, SendRemoteDataRequest> m_pendingSRDResponses;
87 private int m_remoteDataPort = 0;
91 88
92 private Dictionary<LLUUID, RPCRequestInfo> m_rpcPending; 89 private Dictionary<LLUUID, RPCRequestInfo> m_rpcPending;
93 private Dictionary<LLUUID, RPCRequestInfo> m_rpcPendingResponses; 90 private Dictionary<LLUUID, RPCRequestInfo> m_rpcPendingResponses;
91 private List<Scene> m_scenes = new List<Scene>();
92 private int RemoteReplyScriptTimeout = 9000;
93 private int RemoteReplyScriptWait = 300;
94 private object XMLRPCListLock = new object();
94 95
95 private Dictionary<LLUUID, SendRemoteDataRequest> m_pendingSRDResponses; 96 #region IRegionModule Members
96 97
97 public void Initialise(Scene scene, IConfigSource config) 98 public void Initialise(Scene scene, IConfigSource config)
98 { 99 {
@@ -125,7 +126,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
125 // Attach xmlrpc handlers 126 // Attach xmlrpc handlers
126 m_log.Info("[REMOTE_DATA]: " + 127 m_log.Info("[REMOTE_DATA]: " +
127 "Starting XMLRPC Server on port " + m_remoteDataPort + " for llRemoteData commands."); 128 "Starting XMLRPC Server on port " + m_remoteDataPort + " for llRemoteData commands.");
128 BaseHttpServer httpServer = new BaseHttpServer((uint)m_remoteDataPort); 129 BaseHttpServer httpServer = new BaseHttpServer((uint) m_remoteDataPort);
129 httpServer.AddXmlRPCHandler("llRemoteData", XmlRpcRemoteData); 130 httpServer.AddXmlRPCHandler("llRemoteData", XmlRpcRemoteData);
130 httpServer.Start(); 131 httpServer.Start();
131 } 132 }
@@ -145,6 +146,10 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
145 get { return true; } 146 get { return true; }
146 } 147 }
147 148
149 #endregion
150
151 #region IXMLRPC Members
152
148 public bool IsEnabled() 153 public bool IsEnabled()
149 { 154 {
150 return (m_remoteDataPort > 0); 155 return (m_remoteDataPort > 0);
@@ -196,7 +201,6 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
196 // for when a script is deleted 201 // for when a script is deleted
197 public void DeleteChannels(LLUUID itemID) 202 public void DeleteChannels(LLUUID itemID)
198 { 203 {
199
200 if (m_openChannels != null) 204 if (m_openChannels != null)
201 { 205 {
202 ArrayList tmp = new ArrayList(); 206 ArrayList tmp = new ArrayList();
@@ -212,12 +216,10 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
212 } 216 }
213 217
214 IEnumerator tmpEnumerator = tmp.GetEnumerator(); 218 IEnumerator tmpEnumerator = tmp.GetEnumerator();
215 while ( tmpEnumerator.MoveNext() ) 219 while (tmpEnumerator.MoveNext())
216 m_openChannels.Remove((LLUUID)tmpEnumerator.Current); 220 m_openChannels.Remove((LLUUID) tmpEnumerator.Current);
217 } 221 }
218
219 } 222 }
220
221 } 223 }
222 224
223 /********************************************** 225 /**********************************************
@@ -255,67 +257,6 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
255 } 257 }
256 258
257 259
258 public XmlRpcResponse XmlRpcRemoteData(XmlRpcRequest request)
259 {
260 XmlRpcResponse response = new XmlRpcResponse();
261
262 Hashtable requestData = (Hashtable)request.Params[0];
263 bool GoodXML = (requestData.Contains("Channel") && requestData.Contains("IntValue") &&
264 requestData.Contains("StringValue"));
265
266 if (GoodXML)
267 {
268 LLUUID channel = new LLUUID((string)requestData["Channel"]);
269 RPCChannelInfo rpcChanInfo;
270 if (m_openChannels.TryGetValue(channel, out rpcChanInfo))
271 {
272 string intVal = (string)requestData["IntValue"];
273 string strVal = (string)requestData["StringValue"];
274
275 RPCRequestInfo rpcInfo;
276
277 lock (XMLRPCListLock)
278 {
279 rpcInfo =
280 new RPCRequestInfo(rpcChanInfo.GetLocalID(), rpcChanInfo.GetItemID(), channel, strVal,
281 intVal);
282 m_rpcPending.Add(rpcInfo.GetMessageID(), rpcInfo);
283 }
284
285 int timeoutCtr = 0;
286
287 while (!rpcInfo.IsProcessed() && (timeoutCtr < RemoteReplyScriptTimeout))
288 {
289 Thread.Sleep(RemoteReplyScriptWait);
290 timeoutCtr += RemoteReplyScriptWait;
291 }
292 if (rpcInfo.IsProcessed())
293 {
294 Hashtable param = new Hashtable();
295 param["StringValue"] = rpcInfo.GetStrRetval();
296 param["IntValue"] = Convert.ToString(rpcInfo.GetIntRetval());
297
298 ArrayList parameters = new ArrayList();
299 parameters.Add(param);
300
301 response.Value = parameters;
302 rpcInfo = null;
303 }
304 else
305 {
306 response.SetFault(-1, "Script timeout");
307 rpcInfo = null;
308 }
309 }
310 else
311 {
312 response.SetFault(-1, "Invalid channel");
313 }
314 }
315
316 return response;
317 }
318
319 public bool hasRequests() 260 public bool hasRequests()
320 { 261 {
321 lock (XMLRPCListLock) 262 lock (XMLRPCListLock)
@@ -339,7 +280,6 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
339 280
340 if (m_rpcPending.TryGetValue(luid, out tmpReq)) 281 if (m_rpcPending.TryGetValue(luid, out tmpReq))
341 { 282 {
342
343 if (!tmpReq.IsProcessed()) return tmpReq; 283 if (!tmpReq.IsProcessed()) return tmpReq;
344 } 284 }
345 } 285 }
@@ -367,13 +307,11 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
367 307
368 public LLUUID SendRemoteData(uint localID, LLUUID itemID, string channel, string dest, int idata, string sdata) 308 public LLUUID SendRemoteData(uint localID, LLUUID itemID, string channel, string dest, int idata, string sdata)
369 { 309 {
370
371 SendRemoteDataRequest req = new SendRemoteDataRequest( 310 SendRemoteDataRequest req = new SendRemoteDataRequest(
372 localID, itemID, channel, dest, idata, sdata 311 localID, itemID, channel, dest, idata, sdata
373 ); 312 );
374 m_pendingSRDResponses.Add(req.GetReqID(), req); 313 m_pendingSRDResponses.Add(req.GetReqID(), req);
375 return req.process(); 314 return req.process();
376
377 } 315 }
378 316
379 public SendRemoteDataRequest GetNextCompletedSRDRequest() 317 public SendRemoteDataRequest GetNextCompletedSRDRequest()
@@ -423,19 +361,82 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
423 } 361 }
424 } 362 }
425 } 363 }
364
365 #endregion
366
367 public XmlRpcResponse XmlRpcRemoteData(XmlRpcRequest request)
368 {
369 XmlRpcResponse response = new XmlRpcResponse();
370
371 Hashtable requestData = (Hashtable) request.Params[0];
372 bool GoodXML = (requestData.Contains("Channel") && requestData.Contains("IntValue") &&
373 requestData.Contains("StringValue"));
374
375 if (GoodXML)
376 {
377 LLUUID channel = new LLUUID((string) requestData["Channel"]);
378 RPCChannelInfo rpcChanInfo;
379 if (m_openChannels.TryGetValue(channel, out rpcChanInfo))
380 {
381 string intVal = (string) requestData["IntValue"];
382 string strVal = (string) requestData["StringValue"];
383
384 RPCRequestInfo rpcInfo;
385
386 lock (XMLRPCListLock)
387 {
388 rpcInfo =
389 new RPCRequestInfo(rpcChanInfo.GetLocalID(), rpcChanInfo.GetItemID(), channel, strVal,
390 intVal);
391 m_rpcPending.Add(rpcInfo.GetMessageID(), rpcInfo);
392 }
393
394 int timeoutCtr = 0;
395
396 while (!rpcInfo.IsProcessed() && (timeoutCtr < RemoteReplyScriptTimeout))
397 {
398 Thread.Sleep(RemoteReplyScriptWait);
399 timeoutCtr += RemoteReplyScriptWait;
400 }
401 if (rpcInfo.IsProcessed())
402 {
403 Hashtable param = new Hashtable();
404 param["StringValue"] = rpcInfo.GetStrRetval();
405 param["IntValue"] = Convert.ToString(rpcInfo.GetIntRetval());
406
407 ArrayList parameters = new ArrayList();
408 parameters.Add(param);
409
410 response.Value = parameters;
411 rpcInfo = null;
412 }
413 else
414 {
415 response.SetFault(-1, "Script timeout");
416 rpcInfo = null;
417 }
418 }
419 else
420 {
421 response.SetFault(-1, "Invalid channel");
422 }
423 }
424
425 return response;
426 }
426 } 427 }
427 428
428 public class RPCRequestInfo 429 public class RPCRequestInfo
429 { 430 {
430 private string m_StrVal; 431 private LLUUID m_ChannelKey;
431 private string m_IntVal; 432 private string m_IntVal;
432 private bool m_processed;
433 private string m_respStr;
434 private int m_respInt;
435 private uint m_localID;
436 private LLUUID m_ItemID; 433 private LLUUID m_ItemID;
434 private uint m_localID;
437 private LLUUID m_MessageID; 435 private LLUUID m_MessageID;
438 private LLUUID m_ChannelKey; 436 private bool m_processed;
437 private int m_respInt;
438 private string m_respStr;
439 private string m_StrVal;
439 440
440 public RPCRequestInfo(uint localID, LLUUID itemID, LLUUID channelKey, string strVal, string intVal) 441 public RPCRequestInfo(uint localID, LLUUID itemID, LLUUID channelKey, string strVal, string intVal)
441 { 442 {
@@ -474,6 +475,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
474 { 475 {
475 return m_respStr; 476 return m_respStr;
476 } 477 }
478
477 public void SetIntRetval(int resp) 479 public void SetIntRetval(int resp)
478 { 480 {
479 m_respInt = resp; 481 m_respInt = resp;
@@ -483,6 +485,7 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
483 { 485 {
484 return m_respInt; 486 return m_respInt;
485 } 487 }
488
486 public uint GetLocalID() 489 public uint GetLocalID()
487 { 490 {
488 return m_localID; 491 return m_localID;
@@ -511,9 +514,9 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
511 514
512 public class RPCChannelInfo 515 public class RPCChannelInfo
513 { 516 {
517 private LLUUID m_ChannelKey;
514 private LLUUID m_itemID; 518 private LLUUID m_itemID;
515 private uint m_localID; 519 private uint m_localID;
516 private LLUUID m_ChannelKey;
517 520
518 public RPCChannelInfo(uint localID, LLUUID itemID, LLUUID channelID) 521 public RPCChannelInfo(uint localID, LLUUID itemID, LLUUID channelID)
519 { 522 {
@@ -536,38 +539,34 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
536 { 539 {
537 return m_localID; 540 return m_localID;
538 } 541 }
539
540 } 542 }
541 543
542 public class SendRemoteDataRequest 544 public class SendRemoteDataRequest
543 { 545 {
544 546 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
545 public LLUUID reqID;
546 public string destURL;
547 public string channel; 547 public string channel;
548 public string sdata; 548 public string destURL;
549 public int idata;
550 public bool finished; 549 public bool finished;
551 public string response_sdata;
552 public int response_idata;
553 public XmlRpcRequest request;
554 private Thread httpThread; 550 private Thread httpThread;
551 public int idata;
555 public LLUUID m_itemID; 552 public LLUUID m_itemID;
556 public uint m_localID; 553 public uint m_localID;
557 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 554 public LLUUID reqID;
555 public XmlRpcRequest request;
556 public int response_idata;
557 public string response_sdata;
558 public string sdata;
558 559
559 public SendRemoteDataRequest(uint localID, LLUUID itemID, string channel, string dest, int idata, string sdata) 560 public SendRemoteDataRequest(uint localID, LLUUID itemID, string channel, string dest, int idata, string sdata)
560 { 561 {
561
562 this.channel = channel; 562 this.channel = channel;
563 this.destURL = dest; 563 destURL = dest;
564 this.idata = idata; 564 this.idata = idata;
565 this.sdata = sdata; 565 this.sdata = sdata;
566 m_itemID = itemID; 566 m_itemID = itemID;
567 m_localID = localID; 567 m_localID = localID;
568 568
569 reqID = LLUUID.Random(); 569 reqID = LLUUID.Random();
570
571 } 570 }
572 571
573 public LLUUID process() 572 public LLUUID process()
@@ -581,7 +580,6 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
581 ThreadTracker.Add(httpThread); 580 ThreadTracker.Add(httpThread);
582 581
583 return reqID; 582 return reqID;
584
585 } 583 }
586 584
587 /* 585 /*
@@ -597,8 +595,8 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
597 // if not, use as method name 595 // if not, use as method name
598 LLUUID parseUID; 596 LLUUID parseUID;
599 string mName = "llRemoteData"; 597 string mName = "llRemoteData";
600 if( (channel != null) && (channel != "") ) 598 if ((channel != null) && (channel != ""))
601 if( !LLUUID.TryParse(channel, out parseUID) ) 599 if (!LLUUID.TryParse(channel, out parseUID))
602 mName = channel; 600 mName = channel;
603 else 601 else
604 param["Channel"] = channel; 602 param["Channel"] = channel;
@@ -615,26 +613,28 @@ namespace OpenSim.Region.Environment.Modules.Scripting.XMLRPC
615 if (resp != null) 613 if (resp != null)
616 { 614 {
617 Hashtable respParms; 615 Hashtable respParms;
618 if(resp.Value.GetType().Equals(Type.GetType("System.Collections.Hashtable"))) { 616 if (resp.Value.GetType().Equals(Type.GetType("System.Collections.Hashtable")))
619 respParms = (Hashtable)resp.Value; 617 {
618 respParms = (Hashtable) resp.Value;
620 } 619 }
621 else { 620 else
622 ArrayList respData = (ArrayList)resp.Value; 621 {
623 respParms = (Hashtable)respData[0]; 622 ArrayList respData = (ArrayList) resp.Value;
623 respParms = (Hashtable) respData[0];
624 } 624 }
625 if (respParms != null) 625 if (respParms != null)
626 { 626 {
627 if (respParms.Contains("StringValue")) 627 if (respParms.Contains("StringValue"))
628 { 628 {
629 sdata = (string)respParms["StringValue"]; 629 sdata = (string) respParms["StringValue"];
630 } 630 }
631 if (respParms.Contains("IntValue")) 631 if (respParms.Contains("IntValue"))
632 { 632 {
633 idata = Convert.ToInt32((string)respParms["IntValue"]); 633 idata = Convert.ToInt32((string) respParms["IntValue"]);
634 } 634 }
635 if (respParms.Contains("faultString")) 635 if (respParms.Contains("faultString"))
636 { 636 {
637 sdata = (string)respParms["faultString"]; 637 sdata = (string) respParms["faultString"];
638 } 638 }
639 if (respParms.Contains("faultCode")) 639 if (respParms.Contains("faultCode"))
640 { 640 {
diff --git a/OpenSim/Region/Environment/Modules/World/Land/LandChannel.cs b/OpenSim/Region/Environment/Modules/World/Land/LandChannel.cs
index cbea07a..efc5234 100644
--- a/OpenSim/Region/Environment/Modules/World/Land/LandChannel.cs
+++ b/OpenSim/Region/Environment/Modules/World/Land/LandChannel.cs
@@ -43,61 +43,45 @@ namespace OpenSim.Region.Environment.Modules.World.Land
43 43
44 //Land types set with flags in ParcelOverlay. 44 //Land types set with flags in ParcelOverlay.
45 //Only one of these can be used. 45 //Only one of these can be used.
46 public const byte LAND_TYPE_PUBLIC = (byte)0; //Equals 00000000 46 public const float BAN_LINE_SAFETY_HIEGHT = 100;
47 public const byte LAND_TYPE_OWNED_BY_OTHER = (byte)1; //Equals 00000001 47 public const byte LAND_FLAG_PROPERTY_BORDER_SOUTH = (byte) 128; //Equals 10000000
48 public const byte LAND_TYPE_OWNED_BY_GROUP = (byte)2; //Equals 00000010 48 public const byte LAND_FLAG_PROPERTY_BORDER_WEST = (byte) 64; //Equals 01000000
49 public const byte LAND_TYPE_OWNED_BY_REQUESTER = (byte)3; //Equals 00000011
50 public const byte LAND_TYPE_IS_FOR_SALE = (byte)4; //Equals 00000100
51 public const byte LAND_TYPE_IS_BEING_AUCTIONED = (byte)5; //Equals 00000101
52
53 //Flags that when set, a border on the given side will be placed
54 //NOTE: North and East is assumable by the west and south sides (if land to east has a west border, then I have an east border; etc)
55 //This took forever to figure out -- jeesh. /blame LL for even having to send these
56 public const byte LAND_FLAG_PROPERTY_BORDER_WEST = (byte)64; //Equals 01000000
57 public const byte LAND_FLAG_PROPERTY_BORDER_SOUTH = (byte)128; //Equals 10000000
58 49
59 //RequestResults (I think these are right, they seem to work): 50 //RequestResults (I think these are right, they seem to work):
60 public const int LAND_RESULT_SINGLE = 0; // The request they made contained only a single piece of land
61 public const int LAND_RESULT_MULTIPLE = 1; // The request they made contained more than a single peice of land 51 public const int LAND_RESULT_MULTIPLE = 1; // The request they made contained more than a single peice of land
52 public const int LAND_RESULT_SINGLE = 0; // The request they made contained only a single piece of land
62 53
63 //ParcelSelectObjects 54 //ParcelSelectObjects
64 public const int LAND_SELECT_OBJECTS_OWNER = 2;
65 public const int LAND_SELECT_OBJECTS_GROUP = 4; 55 public const int LAND_SELECT_OBJECTS_GROUP = 4;
66 public const int LAND_SELECT_OBJECTS_OTHER = 8; 56 public const int LAND_SELECT_OBJECTS_OTHER = 8;
57 public const int LAND_SELECT_OBJECTS_OWNER = 2;
58 public const byte LAND_TYPE_IS_BEING_AUCTIONED = (byte) 5; //Equals 00000101
59 public const byte LAND_TYPE_IS_FOR_SALE = (byte) 4; //Equals 00000100
60 public const byte LAND_TYPE_OWNED_BY_GROUP = (byte) 2; //Equals 00000010
61 public const byte LAND_TYPE_OWNED_BY_OTHER = (byte) 1; //Equals 00000001
62 public const byte LAND_TYPE_OWNED_BY_REQUESTER = (byte) 3; //Equals 00000011
63 public const byte LAND_TYPE_PUBLIC = (byte) 0; //Equals 00000000
67 64
68 //These are other constants. Yay! 65 //These are other constants. Yay!
69 public const int START_LAND_LOCAL_ID = 1; 66 public const int START_LAND_LOCAL_ID = 1;
70 67
71 public const float BAN_LINE_SAFETY_HIEGHT = 100;
72
73 #endregion 68 #endregion
74 69
75 private Scene m_scene; 70 private int[,] landIDList = new int[64,64];
76
77 private Dictionary<int, ILandObject> landList = new Dictionary<int, ILandObject>(); 71 private Dictionary<int, ILandObject> landList = new Dictionary<int, ILandObject>();
78 private int lastLandLocalID = START_LAND_LOCAL_ID - 1;
79 private int[,] landIDList = new int[64, 64];
80 72
81 private bool landPrimCountTainted = false; 73 private bool landPrimCountTainted = false;
74 private int lastLandLocalID = START_LAND_LOCAL_ID - 1;
82 75
83 private bool m_allowedForcefulBans = true; 76 private bool m_allowedForcefulBans = true;
84 public bool allowedForcefulBans 77 private Scene m_scene;
85 {
86 get
87 {
88 return m_allowedForcefulBans;
89 }
90 set
91 {
92 m_allowedForcefulBans = value;
93 }
94 }
95 78
96 public LandChannel(Scene scene) 79 public LandChannel(Scene scene)
97 { 80 {
98 m_scene = scene; 81 m_scene = scene;
99 landIDList.Initialize(); 82 landIDList.Initialize();
100 } 83 }
84
101 #region Land Object From Storage Functions 85 #region Land Object From Storage Functions
102 86
103 public void IncomingLandObjectsFromStorage(List<LandData> data) 87 public void IncomingLandObjectsFromStorage(List<LandData> data)
@@ -133,10 +117,64 @@ namespace OpenSim.Region.Environment.Modules.World.Land
133 resetSimLandObjects(); 117 resetSimLandObjects();
134 } 118 }
135 119
136 #endregion 120 #endregion
137 121
138 #region Parcel Add/Remove/Get/Create 122 #region Parcel Add/Remove/Get/Create
139 123
124 public void updateLandObject(int local_id, LandData newData)
125 {
126 if (landList.ContainsKey(local_id))
127 {
128 landList[local_id].landData = newData.Copy();
129 m_scene.EventManager.TriggerLandObjectUpdated((uint) local_id, landList[local_id]);
130 }
131 }
132
133 /// <summary>
134 /// Get the land object at the specified point
135 /// </summary>
136 /// <param name="x">Value between 0 - 256 on the x axis of the point</param>
137 /// <param name="y">Value between 0 - 256 on the y axis of the point</param>
138 /// <returns>Land object at the point supplied</returns>
139 public ILandObject getLandObject(float x_float, float y_float)
140 {
141 int x;
142 int y;
143
144 try
145 {
146 x = Convert.ToInt32(Math.Floor(Convert.ToDouble(x_float) / Convert.ToDouble(4.0)));
147 y = Convert.ToInt32(Math.Floor(Convert.ToDouble(y_float) / Convert.ToDouble(4.0)));
148 }
149 catch (OverflowException)
150 {
151 return null;
152 }
153
154 if (x >= 64 || y >= 64 || x < 0 || y < 0)
155 {
156 return null;
157 }
158 else
159 {
160 return landList[landIDList[x, y]];
161 }
162 }
163
164 public ILandObject getLandObject(int x, int y)
165 {
166 if (x >= Convert.ToInt32(Constants.RegionSize) || y >= Convert.ToInt32(Constants.RegionSize) || x < 0 || y < 0)
167 {
168 // These exceptions here will cause a lot of complaints from the users specifically because
169 // they happen every time at border crossings
170 throw new Exception("Error: Parcel not found at point " + x + ", " + y);
171 }
172 else
173 {
174 return landList[landIDList[x / 4, y / 4]];
175 }
176 }
177
140 /// <summary> 178 /// <summary>
141 /// Creates a basic Parcel object without an owner (a zeroed key) 179 /// Creates a basic Parcel object without an owner (a zeroed key)
142 /// </summary> 180 /// </summary>
@@ -154,7 +192,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
154 { 192 {
155 lastLandLocalID++; 193 lastLandLocalID++;
156 new_land.landData.localID = lastLandLocalID; 194 new_land.landData.localID = lastLandLocalID;
157 landList.Add(lastLandLocalID, (LandObject)new_land.Copy()); 195 landList.Add(lastLandLocalID, (LandObject) new_land.Copy());
158 196
159 197
160 bool[,] landBitmap = new_land.getLandBitmap(); 198 bool[,] landBitmap = new_land.getLandBitmap();
@@ -197,15 +235,6 @@ namespace OpenSim.Region.Environment.Modules.World.Land
197 landList.Remove(local_id); 235 landList.Remove(local_id);
198 } 236 }
199 237
200 public void updateLandObject(int local_id, LandData newData)
201 {
202 if (landList.ContainsKey(local_id))
203 {
204 landList[local_id].landData = newData.Copy();
205 m_scene.EventManager.TriggerLandObjectUpdated((uint)local_id, landList[local_id]);
206 }
207 }
208
209 private void performFinalLandJoin(ILandObject master, ILandObject slave) 238 private void performFinalLandJoin(ILandObject master, ILandObject slave)
210 { 239 {
211 int x, y; 240 int x, y;
@@ -225,66 +254,113 @@ namespace OpenSim.Region.Environment.Modules.World.Land
225 updateLandObject(master.landData.localID, master.landData); 254 updateLandObject(master.landData.localID, master.landData);
226 } 255 }
227 256
228 /// <summary> 257 public ILandObject getLandObject(int parcelLocalID)
229 /// Get the land object at the specified point
230 /// </summary>
231 /// <param name="x">Value between 0 - 256 on the x axis of the point</param>
232 /// <param name="y">Value between 0 - 256 on the y axis of the point</param>
233 /// <returns>Land object at the point supplied</returns>
234 public ILandObject getLandObject(float x_float, float y_float)
235 { 258 {
236 int x; 259 lock (landList)
237 int y;
238
239 try
240 { 260 {
241 x = Convert.ToInt32(Math.Floor(Convert.ToDouble(x_float) / Convert.ToDouble(4.0))); 261 if (landList.ContainsKey(parcelLocalID))
242 y = Convert.ToInt32(Math.Floor(Convert.ToDouble(y_float) / Convert.ToDouble(4.0))); 262 {
263 return landList[parcelLocalID];
264 }
243 } 265 }
244 catch (OverflowException) 266 return null;
267 }
268
269 #endregion
270
271 #region Parcel Modification
272
273 public void resetAllLandPrimCounts()
274 {
275 foreach (LandObject p in landList.Values)
245 { 276 {
246 return null; 277 p.resetLandPrimCounts();
247 } 278 }
279 }
248 280
249 if (x >= 64 || y >= 64 || x < 0 || y < 0) 281 public void setPrimsTainted()
282 {
283 landPrimCountTainted = true;
284 }
285
286 public bool isLandPrimCountTainted()
287 {
288 return landPrimCountTainted;
289 }
290
291 public void addPrimToLandPrimCounts(SceneObjectGroup obj)
292 {
293 LLVector3 position = obj.AbsolutePosition;
294 ILandObject landUnderPrim = getLandObject(position.X, position.Y);
295 if (landUnderPrim != null)
250 { 296 {
251 return null; 297 landUnderPrim.addPrimToCount(obj);
252 } 298 }
253 else 299 }
300
301 public void removePrimFromLandPrimCounts(SceneObjectGroup obj)
302 {
303 foreach (LandObject p in landList.Values)
254 { 304 {
255 return landList[landIDList[x, y]]; 305 p.removePrimFromCount(obj);
256 } 306 }
257 } 307 }
258 308
259 public ILandObject getLandObject(int parcelLocalID) 309 public void finalizeLandPrimCountUpdate()
260 { 310 {
261 lock (landList) 311 //Get Simwide prim count for owner
312 Dictionary<LLUUID, List<LandObject>> landOwnersAndParcels = new Dictionary<LLUUID, List<LandObject>>();
313 foreach (LandObject p in landList.Values)
262 { 314 {
263 if (landList.ContainsKey(parcelLocalID)) 315 if (!landOwnersAndParcels.ContainsKey(p.landData.ownerID))
264 { 316 {
265 return landList[parcelLocalID]; 317 List<LandObject> tempList = new List<LandObject>();
318 tempList.Add(p);
319 landOwnersAndParcels.Add(p.landData.ownerID, tempList);
320 }
321 else
322 {
323 landOwnersAndParcels[p.landData.ownerID].Add(p);
266 } 324 }
267 } 325 }
268 return null;
269 }
270 326
271 public ILandObject getLandObject(int x, int y) 327 foreach (LLUUID owner in landOwnersAndParcels.Keys)
272 {
273 if (x >= Convert.ToInt32(Constants.RegionSize) || y >= Convert.ToInt32(Constants.RegionSize) || x < 0 || y < 0)
274 { 328 {
275 // These exceptions here will cause a lot of complaints from the users specifically because 329 int simArea = 0;
276 // they happen every time at border crossings 330 int simPrims = 0;
277 throw new Exception("Error: Parcel not found at point " + x + ", " + y); 331 foreach (LandObject p in landOwnersAndParcels[owner])
332 {
333 simArea += p.landData.area;
334 simPrims += p.landData.ownerPrims + p.landData.otherPrims + p.landData.groupPrims +
335 p.landData.selectedPrims;
336 }
337
338 foreach (LandObject p in landOwnersAndParcels[owner])
339 {
340 p.landData.simwideArea = simArea;
341 p.landData.simwidePrims = simPrims;
342 }
278 } 343 }
279 else 344 }
345
346 public void updateLandPrimCounts()
347 {
348 foreach (EntityBase obj in m_scene.Entities.Values)
280 { 349 {
281 return landList[landIDList[x / 4, y / 4]]; 350 if (obj is SceneObjectGroup)
351 {
352 m_scene.EventManager.TriggerParcelPrimCountAdd((SceneObjectGroup) obj);
353 }
282 } 354 }
283 } 355 }
284 356
285 #endregion 357 public void performParcelPrimCountUpdate()
286 358 {
287 #region Parcel Modification 359 resetAllLandPrimCounts();
360 m_scene.EventManager.TriggerParcelPrimCountUpdate();
361 finalizeLandPrimCountUpdate();
362 landPrimCountTainted = false;
363 }
288 364
289 /// <summary> 365 /// <summary>
290 /// Subdivides a piece of land 366 /// Subdivides a piece of land
@@ -435,97 +511,6 @@ namespace OpenSim.Region.Environment.Modules.World.Land
435 return true; 511 return true;
436 } 512 }
437 513
438 public void resetAllLandPrimCounts()
439 {
440 foreach (LandObject p in landList.Values)
441 {
442 p.resetLandPrimCounts();
443 }
444 }
445
446 public void setPrimsTainted()
447 {
448 landPrimCountTainted = true;
449 }
450
451 public bool isLandPrimCountTainted()
452 {
453 return landPrimCountTainted;
454 }
455
456 public void addPrimToLandPrimCounts(SceneObjectGroup obj)
457 {
458 LLVector3 position = obj.AbsolutePosition;
459 ILandObject landUnderPrim = getLandObject(position.X, position.Y);
460 if (landUnderPrim != null)
461 {
462 landUnderPrim.addPrimToCount(obj);
463 }
464 }
465
466 public void removePrimFromLandPrimCounts(SceneObjectGroup obj)
467 {
468 foreach (LandObject p in landList.Values)
469 {
470 p.removePrimFromCount(obj);
471 }
472 }
473
474 public void finalizeLandPrimCountUpdate()
475 {
476 //Get Simwide prim count for owner
477 Dictionary<LLUUID, List<LandObject>> landOwnersAndParcels = new Dictionary<LLUUID, List<LandObject>>();
478 foreach (LandObject p in landList.Values)
479 {
480 if (!landOwnersAndParcels.ContainsKey(p.landData.ownerID))
481 {
482 List<LandObject> tempList = new List<LandObject>();
483 tempList.Add(p);
484 landOwnersAndParcels.Add(p.landData.ownerID, tempList);
485 }
486 else
487 {
488 landOwnersAndParcels[p.landData.ownerID].Add(p);
489 }
490 }
491
492 foreach (LLUUID owner in landOwnersAndParcels.Keys)
493 {
494 int simArea = 0;
495 int simPrims = 0;
496 foreach (LandObject p in landOwnersAndParcels[owner])
497 {
498 simArea += p.landData.area;
499 simPrims += p.landData.ownerPrims + p.landData.otherPrims + p.landData.groupPrims +
500 p.landData.selectedPrims;
501 }
502
503 foreach (LandObject p in landOwnersAndParcels[owner])
504 {
505 p.landData.simwideArea = simArea;
506 p.landData.simwidePrims = simPrims;
507 }
508 }
509 }
510
511 public void updateLandPrimCounts()
512 {
513 foreach (EntityBase obj in m_scene.Entities.Values)
514 {
515 if (obj is SceneObjectGroup)
516 {
517 m_scene.EventManager.TriggerParcelPrimCountAdd((SceneObjectGroup)obj);
518 }
519 }
520 }
521
522 public void performParcelPrimCountUpdate()
523 {
524 resetAllLandPrimCounts();
525 m_scene.EventManager.TriggerParcelPrimCountUpdate();
526 finalizeLandPrimCountUpdate();
527 landPrimCountTainted = false;
528 }
529 #endregion 514 #endregion
530 515
531 #region Parcel Updating 516 #region Parcel Updating
@@ -547,7 +532,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
547 { 532 {
548 for (x = 0; x < 64; x++) 533 for (x = 0; x < 64; x++)
549 { 534 {
550 byte tempByte = (byte)0; //This represents the byte for the current 4x4 535 byte tempByte = (byte) 0; //This represents the byte for the current 4x4
551 ILandObject currentParcelBlock = null; 536 ILandObject currentParcelBlock = null;
552 537
553 try 538 try
@@ -623,10 +608,10 @@ namespace OpenSim.Region.Environment.Modules.World.Land
623 if (byteArrayCount >= LAND_BLOCKS_PER_PACKET) 608 if (byteArrayCount >= LAND_BLOCKS_PER_PACKET)
624 { 609 {
625 byteArrayCount = 0; 610 byteArrayCount = 0;
626 packet = (ParcelOverlayPacket)PacketPool.Instance.GetPacket(PacketType.ParcelOverlay); 611 packet = (ParcelOverlayPacket) PacketPool.Instance.GetPacket(PacketType.ParcelOverlay);
627 packet.ParcelData.Data = byteArray; 612 packet.ParcelData.Data = byteArray;
628 packet.ParcelData.SequenceID = sequenceID; 613 packet.ParcelData.SequenceID = sequenceID;
629 remote_client.OutPacket((Packet)packet, ThrottleOutPacketType.Task); 614 remote_client.OutPacket((Packet) packet, ThrottleOutPacketType.Task);
630 sequenceID++; 615 sequenceID++;
631 byteArray = new byte[LAND_BLOCKS_PER_PACKET]; 616 byteArray = new byte[LAND_BLOCKS_PER_PACKET];
632 } 617 }
@@ -652,7 +637,6 @@ namespace OpenSim.Region.Environment.Modules.World.Land
652 { 637 {
653 for (y = 0; y < inc_y; y++) 638 for (y = 0; y < inc_y; y++)
654 { 639 {
655
656 ILandObject currentParcel = null; 640 ILandObject currentParcel = null;
657 try 641 try
658 { 642 {
@@ -693,7 +677,6 @@ namespace OpenSim.Region.Environment.Modules.World.Land
693 if (landList.ContainsKey(packet.ParcelData.LocalID)) 677 if (landList.ContainsKey(packet.ParcelData.LocalID))
694 { 678 {
695 landList[packet.ParcelData.LocalID].updateLandProperties(packet, remote_client); 679 landList[packet.ParcelData.LocalID].updateLandProperties(packet, remote_client);
696
697 } 680 }
698 } 681 }
699 682
@@ -719,6 +702,14 @@ namespace OpenSim.Region.Environment.Modules.World.Land
719 702
720 #endregion 703 #endregion
721 704
705 #region ILandChannel Members
706
707 public bool allowedForcefulBans
708 {
709 get { return m_allowedForcefulBans; }
710 set { m_allowedForcefulBans = value; }
711 }
712
722 /// <summary> 713 /// <summary>
723 /// Resets the sim to the default land object (full sim piece of land owned by the default user) 714 /// Resets the sim to the default land object (full sim piece of land owned by the default user)
724 /// </summary> 715 /// </summary>
@@ -731,7 +722,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
731 722
732 ILandObject fullSimParcel = new LandObject(LLUUID.Zero, false, m_scene); 723 ILandObject fullSimParcel = new LandObject(LLUUID.Zero, false, m_scene);
733 724
734 fullSimParcel.setLandBitmap(fullSimParcel.getSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); 725 fullSimParcel.setLandBitmap(fullSimParcel.getSquareLandBitmap(0, 0, (int) Constants.RegionSize, (int) Constants.RegionSize));
735 fullSimParcel.landData.ownerID = m_scene.RegionInfo.MasterAvatarAssignedUUID; 726 fullSimParcel.landData.ownerID = m_scene.RegionInfo.MasterAvatarAssignedUUID;
736 727
737 addLandObject(fullSimParcel); 728 addLandObject(fullSimParcel);
@@ -816,18 +807,17 @@ namespace OpenSim.Region.Environment.Modules.World.Land
816 { 807 {
817 if (presence.UUID == avatar.AgentId) 808 if (presence.UUID == avatar.AgentId)
818 { 809 {
819
820 List<ILandObject> checkLandParcels = parcelsNearPoint(presence.AbsolutePosition); 810 List<ILandObject> checkLandParcels = parcelsNearPoint(presence.AbsolutePosition);
821 foreach (ILandObject checkBan in checkLandParcels) 811 foreach (ILandObject checkBan in checkLandParcels)
822 { 812 {
823 if (checkBan.isBannedFromLand(avatar.AgentId)) 813 if (checkBan.isBannedFromLand(avatar.AgentId))
824 { 814 {
825 checkBan.sendLandProperties(-30000, false, (int)ParcelManager.ParcelResult.Single, avatar); 815 checkBan.sendLandProperties(-30000, false, (int) ParcelManager.ParcelResult.Single, avatar);
826 return; //Only send one 816 return; //Only send one
827 } 817 }
828 else if (checkBan.isRestrictedFromLand(avatar.AgentId)) 818 else if (checkBan.isRestrictedFromLand(avatar.AgentId))
829 { 819 {
830 checkBan.sendLandProperties(-40000, false, (int)ParcelManager.ParcelResult.Single, avatar); 820 checkBan.sendLandProperties(-40000, false, (int) ParcelManager.ParcelResult.Single, avatar);
831 return; //Only send one 821 return; //Only send one
832 } 822 }
833 } 823 }
@@ -841,8 +831,8 @@ namespace OpenSim.Region.Environment.Modules.World.Land
841 ILandObject over = null; 831 ILandObject over = null;
842 try 832 try
843 { 833 {
844 over = getLandObject((int)Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.X))), 834 over = getLandObject((int) Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.X))),
845 (int)Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.Y)))); 835 (int) Math.Min(255, Math.Max(0, Math.Round(avatar.AbsolutePosition.Y))));
846 } 836 }
847 catch (Exception) 837 catch (Exception)
848 { 838 {
@@ -873,11 +863,12 @@ namespace OpenSim.Region.Environment.Modules.World.Land
873 } 863 }
874 } 864 }
875 } 865 }
866
876 public void sendLandUpdate(ScenePresence avatar) 867 public void sendLandUpdate(ScenePresence avatar)
877 { 868 {
878 sendLandUpdate(avatar, false); 869 sendLandUpdate(avatar, false);
879
880 } 870 }
871
881 public void handleSignificantClientMovement(IClientAPI remote_client) 872 public void handleSignificantClientMovement(IClientAPI remote_client)
882 { 873 {
883 ScenePresence clientAvatar = m_scene.GetScenePresence(remote_client.AgentId); 874 ScenePresence clientAvatar = m_scene.GetScenePresence(remote_client.AgentId);
@@ -949,6 +940,8 @@ namespace OpenSim.Region.Environment.Modules.World.Land
949 } 940 }
950 } 941 }
951 942
943 #endregion
944
952 // If the economy has been validated by the economy module, 945 // If the economy has been validated by the economy module,
953 // and land has been validated as well, this method transfers 946 // and land has been validated as well, this method transfers
954 // the land ownership 947 // the land ownership
@@ -961,7 +954,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
961 { 954 {
962 if (landList.ContainsKey(e.parcelLocalID)) 955 if (landList.ContainsKey(e.parcelLocalID))
963 { 956 {
964 landList[e.parcelLocalID].updateLandSold(e.agentId, e.groupId, e.groupOwned, (uint)e.transactionID, e.parcelPrice, e.parcelArea); 957 landList[e.parcelLocalID].updateLandSold(e.agentId, e.groupId, e.groupOwned, (uint) e.transactionID, e.parcelPrice, e.parcelArea);
965 return; 958 return;
966 } 959 }
967 } 960 }
@@ -989,17 +982,16 @@ namespace OpenSim.Region.Environment.Modules.World.Land
989 LLUUID AuthorizedID = lob.landData.authBuyerID; 982 LLUUID AuthorizedID = lob.landData.authBuyerID;
990 int saleprice = lob.landData.salePrice; 983 int saleprice = lob.landData.salePrice;
991 LLUUID pOwnerID = lob.landData.ownerID; 984 LLUUID pOwnerID = lob.landData.ownerID;
992 985
993 bool landforsale = ((lob.landData.landFlags & (uint)(Parcel.ParcelFlags.ForSale | Parcel.ParcelFlags.ForSaleObjects | Parcel.ParcelFlags.SellParcelObjects)) != 0); 986 bool landforsale = ((lob.landData.landFlags &
987 (uint) (Parcel.ParcelFlags.ForSale | Parcel.ParcelFlags.ForSaleObjects | Parcel.ParcelFlags.SellParcelObjects)) != 0);
994 if ((AuthorizedID == LLUUID.Zero || AuthorizedID == e.agentId) && e.parcelPrice >= saleprice && landforsale) 988 if ((AuthorizedID == LLUUID.Zero || AuthorizedID == e.agentId) && e.parcelPrice >= saleprice && landforsale)
995 { 989 {
996 lock (e) 990 lock (e)
997 { 991 {
998 e.parcelOwnerID = pOwnerID; 992 e.parcelOwnerID = pOwnerID;
999 e.landValidated = true; 993 e.landValidated = true;
1000
1001 } 994 }
1002
1003 } 995 }
1004 } 996 }
1005 } 997 }
diff --git a/OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs b/OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs
index c5ffdca..3f09bd5 100644
--- a/OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs
+++ b/OpenSim/Region/Environment/Modules/World/Land/LandManagementModule.cs
@@ -27,7 +27,6 @@
27 27
28using Nini.Config; 28using Nini.Config;
29using OpenSim.Region.Environment.Interfaces; 29using OpenSim.Region.Environment.Interfaces;
30using OpenSim.Region.Environment.Modules.World.Land;
31using OpenSim.Region.Environment.Scenes; 30using OpenSim.Region.Environment.Scenes;
32 31
33namespace OpenSim.Region.Environment.Modules.World.Land 32namespace OpenSim.Region.Environment.Modules.World.Land
@@ -43,7 +42,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
43 { 42 {
44 m_scene = scene; 43 m_scene = scene;
45 landChannel = new LandChannel(scene); 44 landChannel = new LandChannel(scene);
46 45
47 m_scene.EventManager.OnParcelPrimCountAdd += landChannel.addPrimToLandPrimCounts; 46 m_scene.EventManager.OnParcelPrimCountAdd += landChannel.addPrimToLandPrimCounts;
48 m_scene.EventManager.OnParcelPrimCountUpdate += landChannel.updateLandPrimCounts; 47 m_scene.EventManager.OnParcelPrimCountUpdate += landChannel.updateLandPrimCounts;
49 m_scene.EventManager.OnAvatarEnteringNewParcel += new EventManager.AvatarEnteringNewParcel(landChannel.handleAvatarChangingParcel); 48 m_scene.EventManager.OnAvatarEnteringNewParcel += new EventManager.AvatarEnteringNewParcel(landChannel.handleAvatarChangingParcel);
@@ -53,18 +52,16 @@ namespace OpenSim.Region.Environment.Modules.World.Land
53 52
54 lock (m_scene) 53 lock (m_scene)
55 { 54 {
56 m_scene.LandChannel = (ILandChannel)landChannel; 55 m_scene.LandChannel = (ILandChannel) landChannel;
57 } 56 }
58 } 57 }
59 58
60 public void PostInitialise() 59 public void PostInitialise()
61 { 60 {
62
63 } 61 }
64 62
65 public void Close() 63 public void Close()
66 { 64 {
67
68 } 65 }
69 66
70 public string Name 67 public string Name
@@ -77,10 +74,6 @@ namespace OpenSim.Region.Environment.Modules.World.Land
77 get { return false; } 74 get { return false; }
78 } 75 }
79 76
80
81
82
83
84 #endregion 77 #endregion
85 } 78 }
86} \ No newline at end of file 79} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs b/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs
index 693c55d..368e113 100644
--- a/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs
+++ b/OpenSim/Region/Environment/Modules/World/Land/LandObject.cs
@@ -33,7 +33,6 @@ using libsecondlife.Packets;
33using log4net; 33using log4net;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Region.Environment.Interfaces; 35using OpenSim.Region.Environment.Interfaces;
36using OpenSim.Region.Environment.Modules.World.Land;
37using OpenSim.Region.Environment.Scenes; 36using OpenSim.Region.Environment.Scenes;
38 37
39namespace OpenSim.Region.Environment.Modules.World.Land 38namespace OpenSim.Region.Environment.Modules.World.Land
@@ -46,23 +45,16 @@ namespace OpenSim.Region.Environment.Modules.World.Land
46 #region Member Variables 45 #region Member Variables
47 46
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 private bool[,] m_landBitmap = new bool[64,64];
49 49
50 protected LandData m_landData = new LandData(); 50 protected LandData m_landData = new LandData();
51 protected List<SceneObjectGroup> primsOverMe = new List<SceneObjectGroup>();
52 protected Scene m_scene; 51 protected Scene m_scene;
53 52 protected List<SceneObjectGroup> primsOverMe = new List<SceneObjectGroup>();
54 private bool[,] m_landBitmap = new bool[64,64];
55 53
56 public bool[,] landBitmap 54 public bool[,] landBitmap
57 { 55 {
58 get 56 get { return m_landBitmap; }
59 { 57 set { m_landBitmap = value; }
60 return m_landBitmap;
61 }
62 set
63 {
64 m_landBitmap = value;
65 }
66 } 58 }
67 59
68 #endregion 60 #endregion
@@ -71,25 +63,16 @@ namespace OpenSim.Region.Environment.Modules.World.Land
71 63
72 public LandData landData 64 public LandData landData
73 { 65 {
74 get 66 get { return m_landData; }
75 {
76 return m_landData;
77 }
78 67
79 set 68 set { m_landData = value; }
80 {
81 m_landData = value;
82 }
83 } 69 }
84 70
85 public LLUUID regionUUID 71 public LLUUID regionUUID
86 { 72 {
87 get { return m_scene.RegionInfo.RegionID; } 73 get { return m_scene.RegionInfo.RegionID; }
88 } 74 }
89 75
90 #endregion
91
92
93 #region Constructors 76 #region Constructors
94 77
95 public LandObject(LLUUID owner_id, bool is_group_owned, Scene scene) 78 public LandObject(LLUUID owner_id, bool is_group_owned, Scene scene)
@@ -115,7 +98,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
115 { 98 {
116 if (x >= 0 && y >= 0 && x <= Constants.RegionSize && x <= Constants.RegionSize) 99 if (x >= 0 && y >= 0 && x <= Constants.RegionSize && x <= Constants.RegionSize)
117 { 100 {
118 return (landBitmap[x/4, y/4] == true); 101 return (landBitmap[x / 4, y / 4] == true);
119 } 102 }
120 else 103 else
121 { 104 {
@@ -149,7 +132,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
149 { 132 {
150 ParcelPropertiesPacket updatePacket = (ParcelPropertiesPacket) PacketPool.Instance.GetPacket(PacketType.ParcelProperties); 133 ParcelPropertiesPacket updatePacket = (ParcelPropertiesPacket) PacketPool.Instance.GetPacket(PacketType.ParcelProperties);
151 // TODO: don't create new blocks if recycling an old packet 134 // TODO: don't create new blocks if recycling an old packet
152 135
153 updatePacket.ParcelData.AABBMax = landData.AABBMax; 136 updatePacket.ParcelData.AABBMax = landData.AABBMax;
154 updatePacket.ParcelData.AABBMin = landData.AABBMin; 137 updatePacket.ParcelData.AABBMin = landData.AABBMin;
155 updatePacket.ParcelData.Area = landData.area; 138 updatePacket.ParcelData.Area = landData.area;
@@ -171,7 +154,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
171 { 154 {
172 updatePacket.ParcelData.MaxPrims = 155 updatePacket.ParcelData.MaxPrims =
173 Convert.ToInt32( 156 Convert.ToInt32(
174 Math.Round((Convert.ToDecimal(landData.area)/Convert.ToDecimal(65536))*m_scene.objectCapacity* 157 Math.Round((Convert.ToDecimal(landData.area) / Convert.ToDecimal(65536)) * m_scene.objectCapacity *
175 Convert.ToDecimal(m_scene.RegionInfo.EstateSettings.objectBonusFactor))); 158 Convert.ToDecimal(m_scene.RegionInfo.EstateSettings.objectBonusFactor)));
176 } 159 }
177 else 160 else
@@ -193,7 +176,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
193 updatePacket.ParcelData.PassHours = landData.passHours; 176 updatePacket.ParcelData.PassHours = landData.passHours;
194 updatePacket.ParcelData.PassPrice = landData.passPrice; 177 updatePacket.ParcelData.PassPrice = landData.passPrice;
195 updatePacket.ParcelData.PublicCount = 0; //unemplemented 178 updatePacket.ParcelData.PublicCount = 0; //unemplemented
196 179
197 uint regionFlags = (uint) m_scene.RegionInfo.EstateSettings.regionFlags; 180 uint regionFlags = (uint) m_scene.RegionInfo.EstateSettings.regionFlags;
198 updatePacket.ParcelData.RegionDenyAnonymous = ((regionFlags & (uint) Simulator.RegionFlags.DenyAnonymous) > 181 updatePacket.ParcelData.RegionDenyAnonymous = ((regionFlags & (uint) Simulator.RegionFlags.DenyAnonymous) >
199 0); 182 0);
@@ -255,12 +238,13 @@ namespace OpenSim.Region.Environment.Modules.World.Land
255 newData.snapshotID = packet.ParcelData.SnapshotID; 238 newData.snapshotID = packet.ParcelData.SnapshotID;
256 newData.userLocation = packet.ParcelData.UserLocation; 239 newData.userLocation = packet.ParcelData.UserLocation;
257 newData.userLookAt = packet.ParcelData.UserLookAt; 240 newData.userLookAt = packet.ParcelData.UserLookAt;
258 241
259 m_scene.LandChannel.updateLandObject(landData.localID, newData); 242 m_scene.LandChannel.updateLandObject(landData.localID, newData);
260 243
261 sendLandUpdateToAvatarsOverMe(); 244 sendLandUpdateToAvatarsOverMe();
262 } 245 }
263 } 246 }
247
264 public void updateLandSold(LLUUID avatarID, LLUUID groupID, bool groupOwned, uint AuctionID, int claimprice, int area) 248 public void updateLandSold(LLUUID avatarID, LLUUID groupID, bool groupOwned, uint AuctionID, int claimprice, int area)
265 { 249 {
266 LandData newData = landData.Copy(); 250 LandData newData = landData.Copy();
@@ -272,7 +256,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
272 newData.claimPrice = claimprice; 256 newData.claimPrice = claimprice;
273 newData.salePrice = 0; 257 newData.salePrice = 0;
274 newData.authBuyerID = LLUUID.Zero; 258 newData.authBuyerID = LLUUID.Zero;
275 newData.landFlags &= ~(uint)(Parcel.ParcelFlags.ForSale | Parcel.ParcelFlags.ForSaleObjects | Parcel.ParcelFlags.SellParcelObjects); 259 newData.landFlags &= ~(uint) (Parcel.ParcelFlags.ForSale | Parcel.ParcelFlags.ForSaleObjects | Parcel.ParcelFlags.SellParcelObjects);
276 m_scene.LandChannel.updateLandObject(landData.localID, newData); 260 m_scene.LandChannel.updateLandObject(landData.localID, newData);
277 261
278 sendLandUpdateToAvatarsOverMe(); 262 sendLandUpdateToAvatarsOverMe();
@@ -339,12 +323,13 @@ namespace OpenSim.Region.Environment.Modules.World.Land
339 try 323 try
340 { 324 {
341 over = 325 over =
342 m_scene.LandChannel.getLandObject((int)Math.Max(255,Math.Min(0,Math.Round(avatars[i].AbsolutePosition.X))), 326 m_scene.LandChannel.getLandObject((int) Math.Max(255, Math.Min(0, Math.Round(avatars[i].AbsolutePosition.X))),
343 (int)Math.Max(255,Math.Min(0,Math.Round(avatars[i].AbsolutePosition.Y)))); 327 (int) Math.Max(255, Math.Min(0, Math.Round(avatars[i].AbsolutePosition.Y))));
344 } 328 }
345 catch (Exception) 329 catch (Exception)
346 { 330 {
347 m_log.Warn("[LAND]: " + "unable to get land at x: " + Math.Round(avatars[i].AbsolutePosition.X) + " y: " + Math.Round(avatars[i].AbsolutePosition.Y)); 331 m_log.Warn("[LAND]: " + "unable to get land at x: " + Math.Round(avatars[i].AbsolutePosition.X) + " y: " +
332 Math.Round(avatars[i].AbsolutePosition.Y));
348 } 333 }
349 334
350 if (over != null) 335 if (over != null)
@@ -463,6 +448,25 @@ namespace OpenSim.Region.Environment.Modules.World.Land
463 448
464 #region Update Functions 449 #region Update Functions
465 450
451 public void updateLandBitmapByteArray()
452 {
453 landData.landBitmapByteArray = convertLandBitmapToBytes();
454 }
455
456 /// <summary>
457 /// Update all settings in land such as area, bitmap byte array, etc
458 /// </summary>
459 public void forceUpdateLandInfo()
460 {
461 updateAABBAndAreaValues();
462 updateLandBitmapByteArray();
463 }
464
465 public void setLandBitmapFromByteArray()
466 {
467 landBitmap = convertBytesToLandBitmap();
468 }
469
466 /// <summary> 470 /// <summary>
467 /// Updates the AABBMin and AABBMax values after area/shape modification of the land object 471 /// Updates the AABBMin and AABBMax values after area/shape modification of the land object
468 /// </summary> 472 /// </summary>
@@ -495,8 +499,8 @@ namespace OpenSim.Region.Environment.Modules.World.Land
495 if (ty > 255) 499 if (ty > 255)
496 ty = 255; 500 ty = 255;
497 landData.AABBMin = 501 landData.AABBMin =
498 new LLVector3((float)(min_x * 4), (float)(min_y * 4), 502 new LLVector3((float) (min_x * 4), (float) (min_y * 4),
499 (float)m_scene.Heightmap[tx, ty]); 503 (float) m_scene.Heightmap[tx, ty]);
500 504
501 tx = max_x * 4; 505 tx = max_x * 4;
502 if (tx > 255) 506 if (tx > 255)
@@ -505,30 +509,11 @@ namespace OpenSim.Region.Environment.Modules.World.Land
505 if (ty > 255) 509 if (ty > 255)
506 ty = 255; 510 ty = 255;
507 landData.AABBMax = 511 landData.AABBMax =
508 new LLVector3((float)(max_x * 4), (float)(max_y * 4), 512 new LLVector3((float) (max_x * 4), (float) (max_y * 4),
509 (float)m_scene.Heightmap[tx, ty]); 513 (float) m_scene.Heightmap[tx, ty]);
510 landData.area = tempArea; 514 landData.area = tempArea;
511 } 515 }
512 516
513 public void updateLandBitmapByteArray()
514 {
515 landData.landBitmapByteArray = convertLandBitmapToBytes();
516 }
517
518 /// <summary>
519 /// Update all settings in land such as area, bitmap byte array, etc
520 /// </summary>
521 public void forceUpdateLandInfo()
522 {
523 updateAABBAndAreaValues();
524 updateLandBitmapByteArray();
525 }
526
527 public void setLandBitmapFromByteArray()
528 {
529 landBitmap = convertBytesToLandBitmap();
530 }
531
532 #endregion 517 #endregion
533 518
534 #region Land Bitmap Functions 519 #region Land Bitmap Functions
@@ -562,63 +547,12 @@ namespace OpenSim.Region.Environment.Modules.World.Land
562 } 547 }
563 548
564 /// <summary> 549 /// <summary>
565 /// Converts the land bitmap to a packet friendly byte array
566 /// </summary>
567 /// <returns></returns>
568 private byte[] convertLandBitmapToBytes()
569 {
570 byte[] tempConvertArr = new byte[512];
571 byte tempByte = 0;
572 int x, y, i, byteNum = 0;
573 i = 0;
574 for (y = 0; y < 64; y++)
575 {
576 for (x = 0; x < 64; x++)
577 {
578 tempByte = Convert.ToByte(tempByte | Convert.ToByte(landBitmap[x, y]) << (i++%8));
579 if (i%8 == 0)
580 {
581 tempConvertArr[byteNum] = tempByte;
582 tempByte = (byte) 0;
583 i = 0;
584 byteNum++;
585 }
586 }
587 }
588 return tempConvertArr;
589 }
590
591 private bool[,] convertBytesToLandBitmap()
592 {
593 bool[,] tempConvertMap = new bool[64,64];
594 tempConvertMap.Initialize();
595 byte tempByte = 0;
596 int x = 0, y = 0, i = 0, bitNum = 0;
597 for (i = 0; i < 512; i++)
598 {
599 tempByte = landData.landBitmapByteArray[i];
600 for (bitNum = 0; bitNum < 8; bitNum++)
601 {
602 bool bit = Convert.ToBoolean(Convert.ToByte(tempByte >> bitNum) & (byte) 1);
603 tempConvertMap[x, y] = bit;
604 x++;
605 if (x > 63)
606 {
607 x = 0;
608 y++;
609 }
610 }
611 }
612 return tempConvertMap;
613 }
614
615 /// <summary>
616 /// Full sim land object creation 550 /// Full sim land object creation
617 /// </summary> 551 /// </summary>
618 /// <returns></returns> 552 /// <returns></returns>
619 public bool[,] basicFullRegionLandBitmap() 553 public bool[,] basicFullRegionLandBitmap()
620 { 554 {
621 return getSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize); 555 return getSquareLandBitmap(0, 0, (int) Constants.RegionSize, (int) Constants.RegionSize);
622 } 556 }
623 557
624 /// <summary> 558 /// <summary>
@@ -662,8 +596,8 @@ namespace OpenSim.Region.Environment.Modules.World.Land
662 { 596 {
663 for (x = 0; x < 64; x++) 597 for (x = 0; x < 64; x++)
664 { 598 {
665 if (x >= start_x/4 && x < end_x/4 599 if (x >= start_x / 4 && x < end_x / 4
666 && y >= start_y/4 && y < end_y/4) 600 && y >= start_y / 4 && y < end_y / 4)
667 { 601 {
668 land_bitmap[x, y] = set_value; 602 land_bitmap[x, y] = set_value;
669 } 603 }
@@ -705,6 +639,57 @@ namespace OpenSim.Region.Environment.Modules.World.Land
705 return bitmap_base; 639 return bitmap_base;
706 } 640 }
707 641
642 /// <summary>
643 /// Converts the land bitmap to a packet friendly byte array
644 /// </summary>
645 /// <returns></returns>
646 private byte[] convertLandBitmapToBytes()
647 {
648 byte[] tempConvertArr = new byte[512];
649 byte tempByte = 0;
650 int x, y, i, byteNum = 0;
651 i = 0;
652 for (y = 0; y < 64; y++)
653 {
654 for (x = 0; x < 64; x++)
655 {
656 tempByte = Convert.ToByte(tempByte | Convert.ToByte(landBitmap[x, y]) << (i++ % 8));
657 if (i % 8 == 0)
658 {
659 tempConvertArr[byteNum] = tempByte;
660 tempByte = (byte) 0;
661 i = 0;
662 byteNum++;
663 }
664 }
665 }
666 return tempConvertArr;
667 }
668
669 private bool[,] convertBytesToLandBitmap()
670 {
671 bool[,] tempConvertMap = new bool[64,64];
672 tempConvertMap.Initialize();
673 byte tempByte = 0;
674 int x = 0, y = 0, i = 0, bitNum = 0;
675 for (i = 0; i < 512; i++)
676 {
677 tempByte = landData.landBitmapByteArray[i];
678 for (bitNum = 0; bitNum < 8; bitNum++)
679 {
680 bool bit = Convert.ToBoolean(Convert.ToByte(tempByte >> bitNum) & (byte) 1);
681 tempConvertMap[x, y] = bit;
682 x++;
683 if (x > 63)
684 {
685 x = 0;
686 y++;
687 }
688 }
689 }
690 return tempConvertMap;
691 }
692
708 #endregion 693 #endregion
709 694
710 #region Object Select and Object Owner Listing 695 #region Object Select and Object Owner Listing
@@ -781,7 +766,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
781 public void sendLandObjectOwners(IClientAPI remote_client) 766 public void sendLandObjectOwners(IClientAPI remote_client)
782 { 767 {
783 Dictionary<LLUUID, int> primCount = new Dictionary<LLUUID, int>(); 768 Dictionary<LLUUID, int> primCount = new Dictionary<LLUUID, int>();
784 ParcelObjectOwnersReplyPacket pack 769 ParcelObjectOwnersReplyPacket pack
785 = (ParcelObjectOwnersReplyPacket) PacketPool.Instance.GetPacket(PacketType.ParcelObjectOwnersReply); 770 = (ParcelObjectOwnersReplyPacket) PacketPool.Instance.GetPacket(PacketType.ParcelObjectOwnersReply);
786 // TODO: don't create new blocks if recycling an old packet 771 // TODO: don't create new blocks if recycling an old packet
787 772
@@ -807,21 +792,21 @@ namespace OpenSim.Region.Environment.Modules.World.Land
807 m_log.Error("[LAND]: Unable to match a prim with it's owner."); 792 m_log.Error("[LAND]: Unable to match a prim with it's owner.");
808 } 793 }
809 } 794 }
810 795
811 int notifyCount = primCount.Count; 796 int notifyCount = primCount.Count;
812 797
813 if (notifyCount > 0) 798 if (notifyCount > 0)
814 { 799 {
815 if (notifyCount > 32) 800 if (notifyCount > 32)
816 { 801 {
817 m_log.InfoFormat( 802 m_log.InfoFormat(
818 "[LAND]: More than {0} avatars own prims on this parcel. Only sending back details of first {0}" 803 "[LAND]: More than {0} avatars own prims on this parcel. Only sending back details of first {0}"
819 + " - a developer might want to investigate whether this is a hard limit", 32); 804 + " - a developer might want to investigate whether this is a hard limit", 32);
820 805
821 notifyCount = 32; 806 notifyCount = 32;
822 } 807 }
823 808
824 ParcelObjectOwnersReplyPacket.DataBlock[] dataBlock 809 ParcelObjectOwnersReplyPacket.DataBlock[] dataBlock
825 = new ParcelObjectOwnersReplyPacket.DataBlock[notifyCount]; 810 = new ParcelObjectOwnersReplyPacket.DataBlock[notifyCount];
826 811
827 int num = 0; 812 int num = 0;
@@ -834,16 +819,16 @@ namespace OpenSim.Region.Environment.Modules.World.Land
834 dataBlock[num].OwnerID = owner; 819 dataBlock[num].OwnerID = owner;
835 820
836 num++; 821 num++;
837 822
838 if (num >= notifyCount) 823 if (num >= notifyCount)
839 { 824 {
840 break; 825 break;
841 } 826 }
842 } 827 }
843 828
844 pack.Data = dataBlock; 829 pack.Data = dataBlock;
845 } 830 }
846 831
847 remote_client.OutPacket(pack, ThrottleOutPacketType.Task); 832 remote_client.OutPacket(pack, ThrottleOutPacketType.Task);
848 } 833 }
849 834
@@ -937,7 +922,7 @@ namespace OpenSim.Region.Environment.Modules.World.Land
937 #endregion 922 #endregion
938 923
939 #endregion 924 #endregion
940
941 925
926 #endregion
942 } 927 }
943} \ No newline at end of file 928} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiseObjects.cs b/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiseObjects.cs
index c14ae57..ef90fd4 100644
--- a/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiseObjects.cs
+++ b/OpenSim/Region/Environment/Modules/World/Serialiser/SerialiseObjects.cs
@@ -110,6 +110,7 @@ namespace OpenSim.Region.Environment.Modules.ExportSerialiser
110 private static void CreateCompressedXmlFile(MemoryStream xmlStream, string fileName) 110 private static void CreateCompressedXmlFile(MemoryStream xmlStream, string fileName)
111 { 111 {
112 #region GZip Compressed Version 112 #region GZip Compressed Version
113
113 FileStream objectsFileCompressed = new FileStream(fileName + ".gzs", FileMode.Create); 114 FileStream objectsFileCompressed = new FileStream(fileName + ".gzs", FileMode.Create);
114 MemoryStream gzipMSStream = new MemoryStream(); 115 MemoryStream gzipMSStream = new MemoryStream();
115 GZipStream gzipStream = new GZipStream(gzipMSStream, CompressionMode.Compress); 116 GZipStream gzipStream = new GZipStream(gzipMSStream, CompressionMode.Compress);
@@ -117,6 +118,7 @@ namespace OpenSim.Region.Environment.Modules.ExportSerialiser
117 gzipMSStream.WriteTo(objectsFileCompressed); 118 gzipMSStream.WriteTo(objectsFileCompressed);
118 objectsFileCompressed.Flush(); 119 objectsFileCompressed.Flush();
119 objectsFileCompressed.Close(); 120 objectsFileCompressed.Close();
121
120 #endregion 122 #endregion
121 } 123 }
122 } 124 }
diff --git a/OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs b/OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs
index a465a60..a12118e 100644
--- a/OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs
+++ b/OpenSim/Region/Environment/Modules/World/Sun/SunModule.cs
@@ -39,15 +39,17 @@ namespace OpenSim.Region.Environment.Modules
39 { 39 {
40 //private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 40 //private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
41 41
42 private const double m_real_day = 24.0;
43 private const int m_default_frame = 100; 42 private const int m_default_frame = 100;
44 private int m_frame_mod; 43 private const double m_real_day = 24.0;
45 private double m_day_length; 44 private double m_day_length;
46 private int m_dilation; 45 private int m_dilation;
47 private int m_frame; 46 private int m_frame;
48 private long m_start; 47 private int m_frame_mod;
49 48
50 private Scene m_scene; 49 private Scene m_scene;
50 private long m_start;
51
52 #region IRegionModule Members
51 53
52 public void Initialise(Scene scene, IConfigSource config) 54 public void Initialise(Scene scene, IConfigSource config)
53 { 55 {
@@ -66,7 +68,7 @@ namespace OpenSim.Region.Environment.Modules
66 m_frame_mod = m_default_frame; 68 m_frame_mod = m_default_frame;
67 } 69 }
68 70
69 m_dilation = (int) (m_real_day/m_day_length); 71 m_dilation = (int) (m_real_day / m_day_length);
70 m_scene = scene; 72 m_scene = scene;
71 scene.EventManager.OnFrame += SunUpdate; 73 scene.EventManager.OnFrame += SunUpdate;
72 scene.EventManager.OnNewClient += SunToClient; 74 scene.EventManager.OnNewClient += SunToClient;
@@ -90,6 +92,8 @@ namespace OpenSim.Region.Environment.Modules
90 get { return false; } 92 get { return false; }
91 } 93 }
92 94
95 #endregion
96
93 public void SunToClient(IClientAPI client) 97 public void SunToClient(IClientAPI client)
94 { 98 {
95 client.SendSunPos(SunPos(HourOfTheDay()), new LLVector3(0, 0.0f, 10.0f)); 99 client.SendSunPos(SunPos(HourOfTheDay()), new LLVector3(0, 0.0f, 10.0f));
@@ -121,15 +125,15 @@ namespace OpenSim.Region.Environment.Modules
121 // ticks don't get out of hand 125 // ticks don't get out of hand
122 private double HourOfTheDay() 126 private double HourOfTheDay()
123 { 127 {
124 long m_addticks = (DateTime.Now.Ticks - m_start)*m_dilation; 128 long m_addticks = (DateTime.Now.Ticks - m_start) * m_dilation;
125 DateTime dt = new DateTime(m_start + m_addticks); 129 DateTime dt = new DateTime(m_start + m_addticks);
126 return (double) dt.Hour + ((double) dt.Minute/60.0); 130 return (double) dt.Hour + ((double) dt.Minute / 60.0);
127 } 131 }
128 132
129 private LLVector3 SunPos(double hour) 133 private LLVector3 SunPos(double hour)
130 { 134 {
131 // now we have our radian position 135 // now we have our radian position
132 double rad = (hour/m_real_day)*2*Math.PI - (Math.PI/2.0); 136 double rad = (hour / m_real_day) * 2 * Math.PI - (Math.PI / 2.0);
133 double z = Math.Sin(rad); 137 double z = Math.Sin(rad);
134 double x = Math.Cos(rad); 138 double x = Math.Cos(rad);
135 return new LLVector3((float) x, 0f, (float) z); 139 return new LLVector3((float) x, 0f, (float) z);
@@ -192,4 +196,4 @@ namespace OpenSim.Region.Environment.Modules
192 // // OutPacket(viewertime); 196 // // OutPacket(viewertime);
193 // } 197 // }
194 } 198 }
195} 199} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GIF.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GIF.cs
index 1dd923a..9c2fedc 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GIF.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/GIF.cs
@@ -27,7 +27,6 @@
27using System.Drawing; 27using System.Drawing;
28using System.Drawing.Imaging; 28using System.Drawing.Imaging;
29using OpenSim.Region.Environment.Interfaces; 29using OpenSim.Region.Environment.Interfaces;
30using OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders;
31 30
32namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders 31namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
33{ 32{
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/PNG.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/PNG.cs
index 07072be..2925c7d 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/PNG.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/PNG.cs
@@ -27,7 +27,6 @@
27using System.Drawing; 27using System.Drawing;
28using System.Drawing.Imaging; 28using System.Drawing.Imaging;
29using OpenSim.Region.Environment.Interfaces; 29using OpenSim.Region.Environment.Interfaces;
30using OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders;
31 30
32namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders 31namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
33{ 32{
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/TIFF.cs b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/TIFF.cs
index d206763..3a137ae 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/TIFF.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/FileLoaders/TIFF.cs
@@ -27,7 +27,6 @@
27using System.Drawing; 27using System.Drawing;
28using System.Drawing.Imaging; 28using System.Drawing.Imaging;
29using OpenSim.Region.Environment.Interfaces; 29using OpenSim.Region.Environment.Interfaces;
30using OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders;
31 30
32namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders 31namespace OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders
33{ 32{
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs
index cf85aa4..09c3117 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/TerrainModule.cs
@@ -35,7 +35,6 @@ using Nini.Config;
35using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Region.Environment.Interfaces; 36using OpenSim.Region.Environment.Interfaces;
37using OpenSim.Region.Environment.Modules.Framework; 37using OpenSim.Region.Environment.Modules.Framework;
38using OpenSim.Region.Environment.Modules.World.Terrain;
39using OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders; 38using OpenSim.Region.Environment.Modules.World.Terrain.FileLoaders;
40using OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes; 39using OpenSim.Region.Environment.Modules.World.Terrain.FloodBrushes;
41using OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes; 40using OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes;
@@ -79,9 +78,8 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
79 private readonly Dictionary<StandardTerrainEffects, ITerrainPaintableEffect> m_painteffects = 78 private readonly Dictionary<StandardTerrainEffects, ITerrainPaintableEffect> m_painteffects =
80 new Dictionary<StandardTerrainEffects, ITerrainPaintableEffect>(); 79 new Dictionary<StandardTerrainEffects, ITerrainPaintableEffect>();
81 80
82 private Dictionary<Location, ITerrainChannel> m_channels;
83
84 private ITerrainChannel m_channel; 81 private ITerrainChannel m_channel;
82 private Dictionary<Location, ITerrainChannel> m_channels;
85 private Dictionary<string, ITerrainEffect> m_plugineffects; 83 private Dictionary<string, ITerrainEffect> m_plugineffects;
86 private ITerrainChannel m_revert; 84 private ITerrainChannel m_revert;
87 private Scene m_scene; 85 private Scene m_scene;
@@ -252,7 +250,8 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
252 { 250 {
253 m_plugineffects.Add(pluginType.Name, terEffect); 251 m_plugineffects.Add(pluginType.Name, terEffect);
254 m_log.Info("E ... " + pluginType.Name); 252 m_log.Info("E ... " + pluginType.Name);
255 } else 253 }
254 else
256 { 255 {
257 m_log.Warn("E ... " + pluginType.Name + " (Already added)"); 256 m_log.Warn("E ... " + pluginType.Name + " (Already added)");
258 } 257 }
diff --git a/OpenSim/Region/Environment/Modules/World/TreePopulator/TreePopulatorModule.cs b/OpenSim/Region/Environment/Modules/World/TreePopulator/TreePopulatorModule.cs
index ce93060..f144444 100644
--- a/OpenSim/Region/Environment/Modules/World/TreePopulator/TreePopulatorModule.cs
+++ b/OpenSim/Region/Environment/Modules/World/TreePopulator/TreePopulatorModule.cs
@@ -44,13 +44,14 @@ namespace OpenSim.Region.Environment.Modules
44 /// </summary> 44 /// </summary>
45 public class TreePopulatorModule : IRegionModule 45 public class TreePopulatorModule : IRegionModule
46 { 46 {
47 private Scene m_scene;
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49 48 private Scene m_scene;
50 private List<LLUUID> m_trees;
51 49
52 public double m_tree_density = 50.0; // Aim for this many per region 50 public double m_tree_density = 50.0; // Aim for this many per region
53 public double m_tree_updates = 1000.0; // MS between updates 51 public double m_tree_updates = 1000.0; // MS between updates
52 private List<LLUUID> m_trees;
53
54 #region IRegionModule Members
54 55
55 public void Initialise(Scene scene, IConfigSource config) 56 public void Initialise(Scene scene, IConfigSource config)
56 { 57 {
@@ -59,7 +60,8 @@ namespace OpenSim.Region.Environment.Modules
59 m_tree_density = config.Configs["Trees"].GetDouble("tree_density", m_tree_density); 60 m_tree_density = config.Configs["Trees"].GetDouble("tree_density", m_tree_density);
60 } 61 }
61 catch (Exception) 62 catch (Exception)
62 { } 63 {
64 }
63 65
64 m_trees = new List<LLUUID>(); 66 m_trees = new List<LLUUID>();
65 m_scene = scene; 67 m_scene = scene;
@@ -72,7 +74,27 @@ namespace OpenSim.Region.Environment.Modules
72 m_log.Debug("[TREES]: Initialised tree module"); 74 m_log.Debug("[TREES]: Initialised tree module");
73 } 75 }
74 76
75 void EventManager_OnPluginConsole(string[] args) 77 public void PostInitialise()
78 {
79 }
80
81 public void Close()
82 {
83 }
84
85 public string Name
86 {
87 get { return "TreePopulatorModule"; }
88 }
89
90 public bool IsSharedModule
91 {
92 get { return false; }
93 }
94
95 #endregion
96
97 private void EventManager_OnPluginConsole(string[] args)
76 { 98 {
77 if (args[0] == "tree") 99 if (args[0] == "tree")
78 { 100 {
@@ -81,13 +103,13 @@ namespace OpenSim.Region.Environment.Modules
81 } 103 }
82 } 104 }
83 105
84 void growTrees() 106 private void growTrees()
85 { 107 {
86 foreach (LLUUID tree in m_trees) 108 foreach (LLUUID tree in m_trees)
87 { 109 {
88 if (m_scene.Entities.ContainsKey(tree)) 110 if (m_scene.Entities.ContainsKey(tree))
89 { 111 {
90 SceneObjectPart s_tree = ((SceneObjectGroup)m_scene.Entities[tree]).RootPart; 112 SceneObjectPart s_tree = ((SceneObjectGroup) m_scene.Entities[tree]).RootPart;
91 113
92 // 100 seconds to grow 1m 114 // 100 seconds to grow 1m
93 s_tree.Scale += new LLVector3(0.1f, 0.1f, 0.1f); 115 s_tree.Scale += new LLVector3(0.1f, 0.1f, 0.1f);
@@ -101,13 +123,13 @@ namespace OpenSim.Region.Environment.Modules
101 } 123 }
102 } 124 }
103 125
104 void seedTrees() 126 private void seedTrees()
105 { 127 {
106 foreach (LLUUID tree in m_trees) 128 foreach (LLUUID tree in m_trees)
107 { 129 {
108 if (m_scene.Entities.ContainsKey(tree)) 130 if (m_scene.Entities.ContainsKey(tree))
109 { 131 {
110 SceneObjectPart s_tree = ((SceneObjectGroup)m_scene.Entities[tree]).RootPart; 132 SceneObjectPart s_tree = ((SceneObjectGroup) m_scene.Entities[tree]).RootPart;
111 133
112 if (s_tree.Scale.X > 0.5) 134 if (s_tree.Scale.X > 0.5)
113 { 135 {
@@ -116,7 +138,6 @@ namespace OpenSim.Region.Environment.Modules
116 SpawnChild(s_tree); 138 SpawnChild(s_tree);
117 } 139 }
118 } 140 }
119
120 } 141 }
121 else 142 else
122 { 143 {
@@ -125,7 +146,7 @@ namespace OpenSim.Region.Environment.Modules
125 } 146 }
126 } 147 }
127 148
128 void killTrees() 149 private void killTrees()
129 { 150 {
130 foreach (LLUUID tree in m_trees) 151 foreach (LLUUID tree in m_trees)
131 { 152 {
@@ -133,7 +154,7 @@ namespace OpenSim.Region.Environment.Modules
133 154
134 if (m_scene.Entities.ContainsKey(tree)) 155 if (m_scene.Entities.ContainsKey(tree))
135 { 156 {
136 SceneObjectPart selectedTree = ((SceneObjectGroup)m_scene.Entities[tree]).RootPart; 157 SceneObjectPart selectedTree = ((SceneObjectGroup) m_scene.Entities[tree]).RootPart;
137 double selectedTreeScale = Math.Sqrt(Math.Pow(selectedTree.Scale.X, 2) + 158 double selectedTreeScale = Math.Sqrt(Math.Pow(selectedTree.Scale.X, 2) +
138 Math.Pow(selectedTree.Scale.Y, 2) + 159 Math.Pow(selectedTree.Scale.Y, 2) +
139 Math.Pow(selectedTree.Scale.Z, 2)); 160 Math.Pow(selectedTree.Scale.Z, 2));
@@ -142,7 +163,7 @@ namespace OpenSim.Region.Environment.Modules
142 { 163 {
143 if (picktree != tree) 164 if (picktree != tree)
144 { 165 {
145 SceneObjectPart pickedTree = ((SceneObjectGroup)m_scene.Entities[picktree]).RootPart; 166 SceneObjectPart pickedTree = ((SceneObjectGroup) m_scene.Entities[picktree]).RootPart;
146 167
147 double pickedTreeScale = Math.Sqrt(Math.Pow(pickedTree.Scale.X, 2) + 168 double pickedTreeScale = Math.Sqrt(Math.Pow(pickedTree.Scale.X, 2) +
148 Math.Pow(pickedTree.Scale.Y, 2) + 169 Math.Pow(pickedTree.Scale.Y, 2) +
@@ -162,10 +183,10 @@ namespace OpenSim.Region.Environment.Modules
162 m_trees.Remove(selectedTree.ParentGroup.UUID); 183 m_trees.Remove(selectedTree.ParentGroup.UUID);
163 184
164 m_scene.ForEachClient(delegate(IClientAPI controller) 185 m_scene.ForEachClient(delegate(IClientAPI controller)
165 { 186 {
166 controller.SendKillObject(m_scene.RegionInfo.RegionHandle, 187 controller.SendKillObject(m_scene.RegionInfo.RegionHandle,
167 selectedTree.LocalId); 188 selectedTree.LocalId);
168 }); 189 });
169 190
170 break; 191 break;
171 } 192 }
@@ -199,15 +220,15 @@ namespace OpenSim.Region.Environment.Modules
199 double randX = ((Util.RandomClass.NextDouble() * 2.0) - 1.0) * (s_tree.Scale.X * 3); 220 double randX = ((Util.RandomClass.NextDouble() * 2.0) - 1.0) * (s_tree.Scale.X * 3);
200 double randY = ((Util.RandomClass.NextDouble() * 2.0) - 1.0) * (s_tree.Scale.X * 3); 221 double randY = ((Util.RandomClass.NextDouble() * 2.0) - 1.0) * (s_tree.Scale.X * 3);
201 222
202 position.X += (float)randX; 223 position.X += (float) randX;
203 position.Y += (float)randY; 224 position.Y += (float) randY;
204 225
205 CreateTree(position); 226 CreateTree(position);
206 } 227 }
207 228
208 private void CreateTree(LLVector3 position) 229 private void CreateTree(LLVector3 position)
209 { 230 {
210 position.Z = (float)m_scene.Heightmap[(int)position.X, (int)position.Y]; 231 position.Z = (float) m_scene.Heightmap[(int) position.X, (int) position.Y];
211 232
212 SceneObjectGroup tree = 233 SceneObjectGroup tree =
213 m_scene.AddTree(new LLVector3(0.1f, 0.1f, 0.1f), 234 m_scene.AddTree(new LLVector3(0.1f, 0.1f, 0.1f),
@@ -220,29 +241,11 @@ namespace OpenSim.Region.Environment.Modules
220 tree.SendGroupFullUpdate(); 241 tree.SendGroupFullUpdate();
221 } 242 }
222 243
223 void CalculateTrees_Elapsed(object sender, ElapsedEventArgs e) 244 private void CalculateTrees_Elapsed(object sender, ElapsedEventArgs e)
224 { 245 {
225 growTrees(); 246 growTrees();
226 seedTrees(); 247 seedTrees();
227 killTrees(); 248 killTrees();
228 } 249 }
229
230 public void PostInitialise()
231 {
232 }
233
234 public void Close()
235 {
236 }
237
238 public string Name
239 {
240 get { return "TreePopulatorModule"; }
241 }
242
243 public bool IsSharedModule
244 {
245 get { return false; }
246 }
247 } 250 }
248} 251} \ No newline at end of file