aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs36
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetTransactions.cs114
-rw-r--r--OpenSim/Framework/Communications/CommunicationsManager.cs2
-rw-r--r--OpenSim/Framework/General/Interfaces/IClientAPI.cs5
-rw-r--r--OpenSim/Framework/General/NullClientAPI.cs2
-rw-r--r--OpenSim/Framework/UserManager/CAPSService.cs38
6 files changed, 186 insertions, 11 deletions
diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs b/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs
index f9f814a..1f5f99d 100644
--- a/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetTransactionManager.cs
@@ -41,14 +41,20 @@ namespace OpenSim.Framework.Communications.Caches
41 public class AssetTransactionManager 41 public class AssetTransactionManager
42 { 42 {
43 // Fields 43 // Fields
44 public CommunicationsManager CommsManager;
44 public Dictionary<LLUUID, AgentAssetTransactions> AgentTransactions = new Dictionary<LLUUID, AgentAssetTransactions>(); 45 public Dictionary<LLUUID, AgentAssetTransactions> AgentTransactions = new Dictionary<LLUUID, AgentAssetTransactions>();
45 46
47 public AssetTransactionManager(CommunicationsManager commsManager)
48 {
49 CommsManager = commsManager;
50 }
51
46 // Methods 52 // Methods
47 public AgentAssetTransactions AddUser(LLUUID userID) 53 public AgentAssetTransactions AddUser(LLUUID userID)
48 { 54 {
49 if (!this.AgentTransactions.ContainsKey(userID)) 55 if (!this.AgentTransactions.ContainsKey(userID))
50 { 56 {
51 AgentAssetTransactions transactions = new AgentAssetTransactions(userID); 57 AgentAssetTransactions transactions = new AgentAssetTransactions(userID, this);
52 this.AgentTransactions.Add(userID, transactions); 58 this.AgentTransactions.Add(userID, transactions);
53 return transactions; 59 return transactions;
54 } 60 }
@@ -64,18 +70,38 @@ namespace OpenSim.Framework.Communications.Caches
64 return null; 70 return null;
65 } 71 }
66 72
67 public void HandleInventoryFromTransaction() 73 public void HandleInventoryFromTransaction(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask)
68 { 74 {
75 AgentAssetTransactions transactions = this.GetUserTransActions(remoteClient.AgentId);
76 if (transactions != null)
77 {
78 transactions.RequestCreateInventoryItem(remoteClient, transactionID, folderID, callbackID, description, name, invType, type, wearableType, nextOwnerMask);
79 }
80
69 } 81 }
70 82
71 public void HandleUDPUploadRequest() 83 public void HandleUDPUploadRequest(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data)
72 { 84 {
85 AgentAssetTransactions transactions = this.GetUserTransActions(remoteClient.AgentId);
86 if (transactions != null)
87 {
88 AgentAssetTransactions.AssetXferUploader uploader = transactions.RequestXferUploader(transaction);
89 if (uploader != null)
90 {
91 uploader.Initialise(remoteClient, assetID, transaction, type, data);
92 }
93 }
73 } 94 }
74 95
75 public void HandleXfer(IClientAPI remoteClient, uint xferID, uint packetID, byte[] data) 96 public void HandleXfer(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data)
76 { 97 {
98 AgentAssetTransactions transactions = this.GetUserTransActions(remoteClient.AgentId);
99 if (transactions != null)
100 {
101 transactions.HandleXfer(xferID, packetID, data);
102 }
77 } 103 }
78 } 104 }
79} 105}
80 106
81 107
diff --git a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs
index 8909bdf..cea6e6e 100644
--- a/OpenSim/Framework/Communications/Cache/AssetTransactions.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetTransactions.cs
@@ -35,6 +35,7 @@ using libsecondlife.Packets;
35using OpenSim.Framework.Interfaces; 35using OpenSim.Framework.Interfaces;
36using OpenSim.Framework.Types; 36using OpenSim.Framework.Types;
37using OpenSim.Framework.Utilities; 37using OpenSim.Framework.Utilities;
38using OpenSim.Framework.Data;
38using OpenSim.Region.Capabilities; 39using OpenSim.Region.Capabilities;
39using OpenSim.Framework.Servers; 40using OpenSim.Framework.Servers;
40 41
@@ -47,11 +48,13 @@ namespace OpenSim.Framework.Communications.Caches
47 public List<NoteCardCapsUpdate> NotecardUpdaters = new List<NoteCardCapsUpdate>(); 48 public List<NoteCardCapsUpdate> NotecardUpdaters = new List<NoteCardCapsUpdate>();
48 public LLUUID UserID; 49 public LLUUID UserID;
49 public Dictionary<LLUUID, AssetXferUploader> XferUploaders = new Dictionary<LLUUID, AssetXferUploader>(); 50 public Dictionary<LLUUID, AssetXferUploader> XferUploaders = new Dictionary<LLUUID, AssetXferUploader>();
51 public AssetTransactionManager Manager;
50 52
51 // Methods 53 // Methods
52 public AgentAssetTransactions(LLUUID agentID) 54 public AgentAssetTransactions(LLUUID agentID, AssetTransactionManager manager)
53 { 55 {
54 this.UserID = agentID; 56 this.UserID = agentID;
57 Manager = manager;
55 } 58 }
56 59
57 public AssetCapsUploader RequestCapsUploader() 60 public AssetCapsUploader RequestCapsUploader()
@@ -70,9 +73,34 @@ namespace OpenSim.Framework.Communications.Caches
70 73
71 public AssetXferUploader RequestXferUploader(LLUUID transactionID) 74 public AssetXferUploader RequestXferUploader(LLUUID transactionID)
72 { 75 {
73 AssetXferUploader uploader = new AssetXferUploader(); 76 if (!this.XferUploaders.ContainsKey(transactionID))
74 this.XferUploaders.Add(transactionID, uploader); 77 {
75 return uploader; 78 AssetXferUploader uploader = new AssetXferUploader(this);
79
80 this.XferUploaders.Add(transactionID, uploader);
81 return uploader;
82 }
83 return null;
84 }
85
86 public void HandleXfer(ulong xferID, uint packetID, byte[] data)
87 {
88 foreach (AssetXferUploader uploader in this.XferUploaders.Values)
89 {
90 if (uploader.XferID == xferID)
91 {
92 uploader.HandleXferPacket(xferID, packetID, data);
93 break;
94 }
95 }
96 }
97
98 public void RequestCreateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask)
99 {
100 if (this.XferUploaders.ContainsKey(transactionID))
101 {
102 this.XferUploaders[transactionID].RequestCreateInventoryItem(remoteClient, transactionID, folderID, callbackID, description, name, invType, type, wearableType, nextOwnerMask);
103 }
76 } 104 }
77 105
78 // Nested Types 106 // Nested Types
@@ -143,10 +171,23 @@ namespace OpenSim.Framework.Communications.Caches
143 private IClientAPI ourClient; 171 private IClientAPI ourClient;
144 public LLUUID TransactionID = LLUUID.Zero; 172 public LLUUID TransactionID = LLUUID.Zero;
145 public bool UploadComplete; 173 public bool UploadComplete;
146 public uint XferID; 174 public ulong XferID;
175 private string m_name = "";
176 private string m_description = "";
177 private sbyte type = 0;
178 private sbyte invType = 0;
179 private uint nextPerm = 0;
180 private bool m_finished = false;
181 private bool m_createItem = false;
182 private AgentAssetTransactions m_userTransactions;
183
184 public AssetXferUploader(AgentAssetTransactions transactions)
185 {
186 this.m_userTransactions = transactions;
187 }
147 188
148 // Methods 189 // Methods
149 public void HandleXferPacket(uint xferID, uint packetID, byte[] data) 190 public void HandleXferPacket(ulong xferID, uint packetID, byte[] data)
150 { 191 {
151 if (this.XferID == xferID) 192 if (this.XferID == xferID)
152 { 193 {
@@ -216,6 +257,67 @@ namespace OpenSim.Framework.Communications.Caches
216 newPack.AssetBlock.Success = true; 257 newPack.AssetBlock.Success = true;
217 newPack.AssetBlock.UUID = this.Asset.FullID; 258 newPack.AssetBlock.UUID = this.Asset.FullID;
218 this.ourClient.OutPacket(newPack); 259 this.ourClient.OutPacket(newPack);
260 this.m_finished = true;
261 if (m_createItem)
262 {
263 DoCreateItem();
264 }
265 Console.WriteLine("upload complete "+ this.TransactionID);
266 //SaveAssetToFile("testudpupload" + Util.RandomClass.Next(1, 1000) + ".dat", this.Asset.Data);
267 }
268 private void SaveAssetToFile(string filename, byte[] data)
269 {
270 FileStream fs = File.Create(filename);
271 BinaryWriter bw = new BinaryWriter(fs);
272 bw.Write(data);
273 bw.Close();
274 fs.Close();
275 }
276
277 public void RequestCreateInventoryItem(IClientAPI remoteClient, LLUUID transactionID, LLUUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask)
278 {
279 if (this.TransactionID == transactionID)
280 {
281 this.InventFolder = folderID;
282 this.m_name = name;
283 this.m_description = description;
284 this.type = type;
285 this.invType = invType;
286 this.nextPerm = nextOwnerMask;
287 this.Asset.Name = name;
288 this.Asset.Description = description;
289 this.Asset.Type = type;
290 this.Asset.InvType = invType;
291 m_createItem = true;
292 if (m_finished)
293 {
294 DoCreateItem();
295 }
296 }
297 }
298
299 private void DoCreateItem()
300 {
301 this.m_userTransactions.Manager.CommsManager.AssetCache.AddAsset(this.Asset);
302 CachedUserInfo userInfo = m_userTransactions.Manager.CommsManager.UserProfiles.GetUserDetails(ourClient.AgentId);
303 if (userInfo != null)
304 {
305 InventoryItemBase item = new InventoryItemBase();
306 item.avatarID = this.ourClient.AgentId;
307 item.creatorsID = ourClient.AgentId;
308 item.inventoryID = LLUUID.Random();
309 item.assetID = Asset.FullID;
310 item.inventoryDescription = this.m_description;
311 item.inventoryName = m_name;
312 item.assetType = type;
313 item.invType = this.invType;
314 item.parentFolderID = this.InventFolder;
315 item.inventoryCurrentPermissions = 2147483647;
316 item.inventoryNextPermissions = this.nextPerm;
317
318 userInfo.AddItem(ourClient.AgentId, item);
319 ourClient.SendInventoryItemUpdate(item);
320 }
219 } 321 }
220 } 322 }
221 323
diff --git a/OpenSim/Framework/Communications/CommunicationsManager.cs b/OpenSim/Framework/Communications/CommunicationsManager.cs
index ac882ba..7676597 100644
--- a/OpenSim/Framework/Communications/CommunicationsManager.cs
+++ b/OpenSim/Framework/Communications/CommunicationsManager.cs
@@ -45,6 +45,7 @@ namespace OpenSim.Framework.Communications
45 public IInventoryServices InventoryServer; 45 public IInventoryServices InventoryServer;
46 public IInterRegionCommunications InterRegion; 46 public IInterRegionCommunications InterRegion;
47 public UserProfileCache UserProfiles; 47 public UserProfileCache UserProfiles;
48 public AssetTransactionManager TransactionsManager;
48 public AssetCache AssetCache; 49 public AssetCache AssetCache;
49 50
50 public NetworkServersInfo ServersInfo; 51 public NetworkServersInfo ServersInfo;
@@ -53,6 +54,7 @@ namespace OpenSim.Framework.Communications
53 ServersInfo = serversInfo; 54 ServersInfo = serversInfo;
54 this.AssetCache = assetCache; 55 this.AssetCache = assetCache;
55 UserProfiles = new UserProfileCache(this); 56 UserProfiles = new UserProfileCache(this);
57 TransactionsManager = new AssetTransactionManager(this);
56 } 58 }
57 59
58 #region Packet Handlers 60 #region Packet Handlers
diff --git a/OpenSim/Framework/General/Interfaces/IClientAPI.cs b/OpenSim/Framework/General/Interfaces/IClientAPI.cs
index 1af96e7..ff794f9 100644
--- a/OpenSim/Framework/General/Interfaces/IClientAPI.cs
+++ b/OpenSim/Framework/General/Interfaces/IClientAPI.cs
@@ -87,6 +87,9 @@ namespace OpenSim.Framework.Interfaces
87 public delegate void FetchInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID ownerID); 87 public delegate void FetchInventory(IClientAPI remoteClient, LLUUID itemID, LLUUID ownerID);
88 public delegate void RequestTaskInventory(IClientAPI remoteClient, uint localID); 88 public delegate void RequestTaskInventory(IClientAPI remoteClient, uint localID);
89 89
90 public delegate void UDPAssetUploadRequest(IClientAPI remoteClient, LLUUID assetID, LLUUID transaction, sbyte type, byte[] data);
91 public delegate void XferReceive(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data);
92
90 public interface IClientAPI 93 public interface IClientAPI
91 { 94 {
92 event ImprovedInstantMessage OnInstantMessage; 95 event ImprovedInstantMessage OnInstantMessage;
@@ -135,6 +138,8 @@ namespace OpenSim.Framework.Interfaces
135 event FetchInventoryDescendents OnFetchInventoryDescendents; 138 event FetchInventoryDescendents OnFetchInventoryDescendents;
136 event FetchInventory OnFetchInventory; 139 event FetchInventory OnFetchInventory;
137 event RequestTaskInventory OnRequestTaskInventory; 140 event RequestTaskInventory OnRequestTaskInventory;
141 event UDPAssetUploadRequest OnAssetUploadRequest;
142 event XferReceive OnXferReceive;
138 143
139 event UUIDNameRequest OnNameFromUUIDRequest; 144 event UUIDNameRequest OnNameFromUUIDRequest;
140 145
diff --git a/OpenSim/Framework/General/NullClientAPI.cs b/OpenSim/Framework/General/NullClientAPI.cs
index 864ea60..876c9b3 100644
--- a/OpenSim/Framework/General/NullClientAPI.cs
+++ b/OpenSim/Framework/General/NullClientAPI.cs
@@ -57,6 +57,8 @@ namespace OpenSim.Framework
57 public event FetchInventoryDescendents OnFetchInventoryDescendents; 57 public event FetchInventoryDescendents OnFetchInventoryDescendents;
58 public event FetchInventory OnFetchInventory; 58 public event FetchInventory OnFetchInventory;
59 public event RequestTaskInventory OnRequestTaskInventory; 59 public event RequestTaskInventory OnRequestTaskInventory;
60 public event UDPAssetUploadRequest OnAssetUploadRequest;
61 public event XferReceive OnXferReceive;
60 62
61 public event UUIDNameRequest OnNameFromUUIDRequest; 63 public event UUIDNameRequest OnNameFromUUIDRequest;
62 64
diff --git a/OpenSim/Framework/UserManager/CAPSService.cs b/OpenSim/Framework/UserManager/CAPSService.cs
new file mode 100644
index 0000000..39af140
--- /dev/null
+++ b/OpenSim/Framework/UserManager/CAPSService.cs
@@ -0,0 +1,38 @@
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using System.Reflection;
5using System.Security.Cryptography;
6using libsecondlife;
7using Nwc.XmlRpc;
8using OpenSim.Framework.Console;
9using OpenSim.Framework.Data;
10using OpenSim.Framework.Interfaces;
11using OpenSim.Framework.Inventory;
12using OpenSim.Framework.Utilities;
13using OpenSim.Framework.Servers;
14
15namespace OpenSim.Framework.UserManagement
16{
17 public class CAPSService
18 {
19 private BaseHttpServer m_server;
20
21 public CAPSService(BaseHttpServer httpServer)
22 {
23 m_server = httpServer;
24 this.AddCapsSeedHandler("/CapsSeed/", CapsRequest);
25 }
26
27 private void AddCapsSeedHandler(string path, RestMethod restMethod)
28 {
29 m_server.AddStreamHandler(new RestStreamHandler("POST", path, restMethod));
30 }
31
32 public string CapsRequest(string request, string path, string param)
33 {
34 System.Console.WriteLine("new caps request " + request +" from path "+ path);
35 return "";
36 }
37 }
38}