diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/Communications/IInventoryServices.cs | 2 | ||||
-rw-r--r-- | OpenSim/Framework/Communications/InventoryServiceBase.cs | 4 | ||||
-rw-r--r-- | OpenSim/Framework/Communications/UserManagerBase.cs | 4 | ||||
-rw-r--r-- | OpenSim/Framework/IUserService.cs | 2 | ||||
-rw-r--r-- | OpenSim/Framework/InventoryConfig.cs | 2 | ||||
-rw-r--r-- | OpenSim/Framework/InventoryItemBase.cs | 19 | ||||
-rw-r--r-- | OpenSim/Framework/Servers/RestObjectPoster.cs | 92 | ||||
-rw-r--r-- | OpenSim/Framework/UserConfig.cs | 10 | ||||
-rw-r--r-- | OpenSim/Grid/InventoryServer/GridInventoryService.cs | 104 | ||||
-rw-r--r-- | OpenSim/Grid/InventoryServer/Main.cs | 34 | ||||
-rw-r--r-- | OpenSim/Grid/UserServer/Main.cs | 19 | ||||
-rw-r--r-- | OpenSim/Grid/UserServer/UserLoginService.cs | 50 | ||||
-rw-r--r-- | OpenSim/Region/Communications/Local/LocalInventoryService.cs | 4 | ||||
-rw-r--r-- | OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs | 110 | ||||
-rw-r--r-- | OpenSim/Region/Communications/OGS1/OGS1UserServices.cs | 3 |
15 files changed, 431 insertions, 28 deletions
diff --git a/OpenSim/Framework/Communications/IInventoryServices.cs b/OpenSim/Framework/Communications/IInventoryServices.cs index fc301c2..96bb7b3 100644 --- a/OpenSim/Framework/Communications/IInventoryServices.cs +++ b/OpenSim/Framework/Communications/IInventoryServices.cs | |||
@@ -39,7 +39,7 @@ namespace OpenSim.Framework.Communications | |||
39 | public interface IInventoryServices | 39 | public interface IInventoryServices |
40 | { | 40 | { |
41 | void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack); | 41 | void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, InventoryItemInfo itemCallBack); |
42 | void AddNewInventoryFolder(LLUUID userID, InventoryFolderImpl folder); | 42 | void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder); |
43 | void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); | 43 | void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); |
44 | void DeleteInventoryItem(LLUUID userID, InventoryItemBase item); | 44 | void DeleteInventoryItem(LLUUID userID, InventoryItemBase item); |
45 | void CreateNewUserInventory(LLUUID user); | 45 | void CreateNewUserInventory(LLUUID user); |
diff --git a/OpenSim/Framework/Communications/InventoryServiceBase.cs b/OpenSim/Framework/Communications/InventoryServiceBase.cs index effe132..091d829 100644 --- a/OpenSim/Framework/Communications/InventoryServiceBase.cs +++ b/OpenSim/Framework/Communications/InventoryServiceBase.cs | |||
@@ -150,7 +150,7 @@ namespace OpenSim.Framework.Communications | |||
150 | } | 150 | } |
151 | } | 151 | } |
152 | 152 | ||
153 | public void deleteItem(InventoryItemBase item) | 153 | public void DeleteItem(InventoryItemBase item) |
154 | { | 154 | { |
155 | foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) | 155 | foreach (KeyValuePair<string, IInventoryData> plugin in m_plugins) |
156 | { | 156 | { |
@@ -231,7 +231,7 @@ namespace OpenSim.Framework.Communications | |||
231 | public abstract void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, | 231 | public abstract void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, |
232 | InventoryItemInfo itemCallBack); | 232 | InventoryItemInfo itemCallBack); |
233 | 233 | ||
234 | public abstract void AddNewInventoryFolder(LLUUID userID, InventoryFolderImpl folder); | 234 | public abstract void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder); |
235 | public abstract void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); | 235 | public abstract void AddNewInventoryItem(LLUUID userID, InventoryItemBase item); |
236 | public abstract void DeleteInventoryItem(LLUUID userID, InventoryItemBase item); | 236 | public abstract void DeleteInventoryItem(LLUUID userID, InventoryItemBase item); |
237 | } | 237 | } |
diff --git a/OpenSim/Framework/Communications/UserManagerBase.cs b/OpenSim/Framework/Communications/UserManagerBase.cs index f1f2c2b..119f8a5 100644 --- a/OpenSim/Framework/Communications/UserManagerBase.cs +++ b/OpenSim/Framework/Communications/UserManagerBase.cs | |||
@@ -366,7 +366,7 @@ namespace OpenSim.Framework.UserManagement | |||
366 | /// | 366 | /// |
367 | /// </summary> | 367 | /// </summary> |
368 | /// <param name="user"></param> | 368 | /// <param name="user"></param> |
369 | public void AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY) | 369 | public LLUUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY) |
370 | { | 370 | { |
371 | UserProfileData user = new UserProfileData(); | 371 | UserProfileData user = new UserProfileData(); |
372 | user.homeLocation = new LLVector3(128, 128, 100); | 372 | user.homeLocation = new LLVector3(128, 128, 100); |
@@ -391,6 +391,8 @@ namespace OpenSim.Framework.UserManagement | |||
391 | MainLog.Instance.Verbose("Unable to add user via " + plugin.Key + "(" + e.ToString() + ")"); | 391 | MainLog.Instance.Verbose("Unable to add user via " + plugin.Key + "(" + e.ToString() + ")"); |
392 | } | 392 | } |
393 | } | 393 | } |
394 | |||
395 | return user.UUID; | ||
394 | } | 396 | } |
395 | 397 | ||
396 | public abstract UserProfileData SetupMasterUser(string firstName, string lastName); | 398 | public abstract UserProfileData SetupMasterUser(string firstName, string lastName); |
diff --git a/OpenSim/Framework/IUserService.cs b/OpenSim/Framework/IUserService.cs index d7857a4..67028a5 100644 --- a/OpenSim/Framework/IUserService.cs +++ b/OpenSim/Framework/IUserService.cs | |||
@@ -46,6 +46,6 @@ namespace OpenSim.Framework | |||
46 | /// | 46 | /// |
47 | /// </summary> | 47 | /// </summary> |
48 | /// <param name="user"></param> | 48 | /// <param name="user"></param> |
49 | void AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY); | 49 | LLUUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY); |
50 | } | 50 | } |
51 | } \ No newline at end of file | 51 | } \ No newline at end of file |
diff --git a/OpenSim/Framework/InventoryConfig.cs b/OpenSim/Framework/InventoryConfig.cs index 1233196..554cd30 100644 --- a/OpenSim/Framework/InventoryConfig.cs +++ b/OpenSim/Framework/InventoryConfig.cs | |||
@@ -38,7 +38,7 @@ namespace OpenSim.Framework | |||
38 | configMember.addConfigurationOption("user_recv_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, | 38 | configMember.addConfigurationOption("user_recv_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, |
39 | "Key to expect from user server", "null", false); | 39 | "Key to expect from user server", "null", false); |
40 | configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING, | 40 | configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING, |
41 | "DLL for database provider", "OpenSim.Framework.Data.MySQL.dll", false); | 41 | "DLL for database provider", "OpenSim.Framework.Data.SQLite.dll", false); |
42 | configMember.addConfigurationOption("http_port", ConfigurationOption.ConfigurationTypes.TYPE_INT32, | 42 | configMember.addConfigurationOption("http_port", ConfigurationOption.ConfigurationTypes.TYPE_INT32, |
43 | "Http Listener port", DefaultHttpPort.ToString(), false); | 43 | "Http Listener port", DefaultHttpPort.ToString(), false); |
44 | } | 44 | } |
diff --git a/OpenSim/Framework/InventoryItemBase.cs b/OpenSim/Framework/InventoryItemBase.cs index 80f631e..0ee30bb 100644 --- a/OpenSim/Framework/InventoryItemBase.cs +++ b/OpenSim/Framework/InventoryItemBase.cs | |||
@@ -245,6 +245,25 @@ namespace OpenSim.Framework | |||
245 | void deleteInventoryFolder(LLUUID folder); | 245 | void deleteInventoryFolder(LLUUID folder); |
246 | } | 246 | } |
247 | 247 | ||
248 | public class InventoryCollection | ||
249 | { | ||
250 | public List<InventoryFolderBase> Folders; | ||
251 | public List<InventoryItemBase> AllItems; | ||
252 | public LLUUID UserID; | ||
253 | |||
254 | public InventoryCollection() | ||
255 | { | ||
256 | Folders = new List<InventoryFolderBase>(); | ||
257 | AllItems = new List<InventoryItemBase>(); | ||
258 | } | ||
259 | |||
260 | public InventoryCollection(List<InventoryFolderBase> folders, List<InventoryItemBase> allItems) | ||
261 | { | ||
262 | Folders = folders; | ||
263 | AllItems = allItems; | ||
264 | } | ||
265 | } | ||
266 | |||
248 | /* | 267 | /* |
249 | * .Net has some issues, serializing a dictionary, so we cannot reuse the InventoryFolder | 268 | * .Net has some issues, serializing a dictionary, so we cannot reuse the InventoryFolder |
250 | * class defined in Communications.Framework.Communications.Caches. So we serialize/deserialize | 269 | * class defined in Communications.Framework.Communications.Caches. So we serialize/deserialize |
diff --git a/OpenSim/Framework/Servers/RestObjectPoster.cs b/OpenSim/Framework/Servers/RestObjectPoster.cs index b77cbcc..07095f3 100644 --- a/OpenSim/Framework/Servers/RestObjectPoster.cs +++ b/OpenSim/Framework/Servers/RestObjectPoster.cs | |||
@@ -8,8 +8,11 @@ using System.Xml.Serialization; | |||
8 | 8 | ||
9 | namespace OpenSim.Framework.Servers | 9 | namespace OpenSim.Framework.Servers |
10 | { | 10 | { |
11 | public delegate void ReturnResponse<T>(T reponse); | ||
12 | |||
11 | public class RestObjectPoster | 13 | public class RestObjectPoster |
12 | { | 14 | { |
15 | |||
13 | public static void BeginPostObject<TRequest>(string requestUrl, TRequest obj) | 16 | public static void BeginPostObject<TRequest>(string requestUrl, TRequest obj) |
14 | { | 17 | { |
15 | Type type = typeof(TRequest); | 18 | Type type = typeof(TRequest); |
@@ -46,4 +49,93 @@ namespace OpenSim.Framework.Servers | |||
46 | } | 49 | } |
47 | } | 50 | } |
48 | } | 51 | } |
52 | |||
53 | public class RestObjectPosterResponse<TResponse> | ||
54 | { | ||
55 | public ReturnResponse<TResponse> ReturnResponseVal; | ||
56 | |||
57 | public void BeginPostObject<TRequest>(string requestUrl, TRequest obj) | ||
58 | { | ||
59 | Type type = typeof(TRequest); | ||
60 | |||
61 | WebRequest request = WebRequest.Create(requestUrl); | ||
62 | request.Method = "POST"; | ||
63 | request.ContentType = "text/xml"; | ||
64 | |||
65 | MemoryStream buffer = new MemoryStream(); | ||
66 | |||
67 | XmlWriterSettings settings = new XmlWriterSettings(); | ||
68 | settings.Encoding = Encoding.UTF8; | ||
69 | |||
70 | using (XmlWriter writer = XmlWriter.Create(buffer, settings)) | ||
71 | { | ||
72 | XmlSerializer serializer = new XmlSerializer(type); | ||
73 | serializer.Serialize(writer, obj); | ||
74 | writer.Flush(); | ||
75 | } | ||
76 | |||
77 | int length = (int)buffer.Length; | ||
78 | request.ContentLength = length; | ||
79 | |||
80 | Stream requestStream = request.GetRequestStream(); | ||
81 | requestStream.Write(buffer.ToArray(), 0, length); | ||
82 | IAsyncResult result = request.BeginGetResponse(AsyncCallback, request); | ||
83 | } | ||
84 | |||
85 | private void AsyncCallback(IAsyncResult result) | ||
86 | { | ||
87 | WebRequest request = (WebRequest)result.AsyncState; | ||
88 | using (WebResponse resp = request.EndGetResponse(result)) | ||
89 | { | ||
90 | TResponse deserial; | ||
91 | XmlSerializer deserializer = new XmlSerializer(typeof(TResponse)); | ||
92 | deserial = (TResponse)deserializer.Deserialize(resp.GetResponseStream()); | ||
93 | |||
94 | if (deserial != null && ReturnResponseVal != null) | ||
95 | { | ||
96 | ReturnResponseVal(deserial); | ||
97 | } | ||
98 | } | ||
99 | } | ||
100 | } | ||
101 | |||
102 | public class SyncRestObjectPoster | ||
103 | { | ||
104 | |||
105 | public static TResponse BeginPostObject<TRequest, TResponse>(string requestUrl, TRequest obj) | ||
106 | { | ||
107 | Type type = typeof(TRequest); | ||
108 | |||
109 | WebRequest request = WebRequest.Create(requestUrl); | ||
110 | request.Method = "POST"; | ||
111 | request.ContentType = "text/xml"; | ||
112 | |||
113 | MemoryStream buffer = new MemoryStream(); | ||
114 | |||
115 | XmlWriterSettings settings = new XmlWriterSettings(); | ||
116 | settings.Encoding = Encoding.UTF8; | ||
117 | |||
118 | using (XmlWriter writer = XmlWriter.Create(buffer, settings)) | ||
119 | { | ||
120 | XmlSerializer serializer = new XmlSerializer(type); | ||
121 | serializer.Serialize(writer, obj); | ||
122 | writer.Flush(); | ||
123 | } | ||
124 | |||
125 | int length = (int)buffer.Length; | ||
126 | request.ContentLength = length; | ||
127 | |||
128 | Stream requestStream = request.GetRequestStream(); | ||
129 | requestStream.Write(buffer.ToArray(), 0, length); | ||
130 | TResponse deserial = default(TResponse); | ||
131 | using (WebResponse resp = request.GetResponse()) | ||
132 | { | ||
133 | |||
134 | XmlSerializer deserializer = new XmlSerializer(typeof(TResponse)); | ||
135 | deserial = (TResponse)deserializer.Deserialize(resp.GetResponseStream()); | ||
136 | } | ||
137 | return deserial; | ||
138 | } | ||
139 | |||
140 | } | ||
49 | } \ No newline at end of file | 141 | } \ No newline at end of file |
diff --git a/OpenSim/Framework/UserConfig.cs b/OpenSim/Framework/UserConfig.cs index d4ee62f..4c6b3b8 100644 --- a/OpenSim/Framework/UserConfig.cs +++ b/OpenSim/Framework/UserConfig.cs | |||
@@ -38,6 +38,8 @@ namespace OpenSim.Framework | |||
38 | public string GridSendKey = ""; | 38 | public string GridSendKey = ""; |
39 | public string GridRecvKey = ""; | 39 | public string GridRecvKey = ""; |
40 | 40 | ||
41 | public string InventoryUrl = ""; | ||
42 | |||
41 | public string DatabaseProvider = ""; | 43 | public string DatabaseProvider = ""; |
42 | 44 | ||
43 | public static uint DefaultHttpPort = 8002; | 45 | public static uint DefaultHttpPort = 8002; |
@@ -68,6 +70,11 @@ namespace OpenSim.Framework | |||
68 | "Key to send to grid server", "null", false); | 70 | "Key to send to grid server", "null", false); |
69 | configMember.addConfigurationOption("grid_recv_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, | 71 | configMember.addConfigurationOption("grid_recv_key", ConfigurationOption.ConfigurationTypes.TYPE_STRING, |
70 | "Key to expect from grid server", "null", false); | 72 | "Key to expect from grid server", "null", false); |
73 | |||
74 | configMember.addConfigurationOption("default_inventory_server", | ||
75 | ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, | ||
76 | "Default Inventory Server URI", | ||
77 | "http://127.0.0.1:8004/", false); | ||
71 | configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING, | 78 | configMember.addConfigurationOption("database_provider", ConfigurationOption.ConfigurationTypes.TYPE_STRING, |
72 | "DLL for database provider", "OpenSim.Framework.Data.MySQL.dll", false); | 79 | "DLL for database provider", "OpenSim.Framework.Data.MySQL.dll", false); |
73 | 80 | ||
@@ -95,6 +102,9 @@ namespace OpenSim.Framework | |||
95 | case "grid_recv_key": | 102 | case "grid_recv_key": |
96 | GridRecvKey = (string) configuration_result; | 103 | GridRecvKey = (string) configuration_result; |
97 | break; | 104 | break; |
105 | case "default_inventory_server": | ||
106 | InventoryUrl = (string)configuration_result; | ||
107 | break; | ||
98 | case "database_provider": | 108 | case "database_provider": |
99 | DatabaseProvider = (string) configuration_result; | 109 | DatabaseProvider = (string) configuration_result; |
100 | break; | 110 | break; |
diff --git a/OpenSim/Grid/InventoryServer/GridInventoryService.cs b/OpenSim/Grid/InventoryServer/GridInventoryService.cs new file mode 100644 index 0000000..dda2f61 --- /dev/null +++ b/OpenSim/Grid/InventoryServer/GridInventoryService.cs | |||
@@ -0,0 +1,104 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using OpenSim.Framework; | ||
5 | using OpenSim.Framework.Communications; | ||
6 | using libsecondlife; | ||
7 | |||
8 | namespace OpenSim.Grid.InventoryServer | ||
9 | { | ||
10 | public class GridInventoryService : InventoryServiceBase | ||
11 | { | ||
12 | public override void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, | ||
13 | InventoryItemInfo itemCallBack) | ||
14 | { | ||
15 | |||
16 | } | ||
17 | |||
18 | private bool TryGetUsersInventory(LLUUID userID, out List<InventoryFolderBase> folderList, out List<InventoryItemBase> itemsList) | ||
19 | { | ||
20 | List<InventoryFolderBase> folders = RequestFirstLevelFolders(userID); | ||
21 | List<InventoryItemBase> allItems = new List<InventoryItemBase>(); | ||
22 | |||
23 | if (folders != null) | ||
24 | { | ||
25 | foreach (InventoryFolderBase folder in folders) | ||
26 | { | ||
27 | if (folder.parentID != LLUUID.Zero) | ||
28 | { | ||
29 | List<InventoryItemBase> items = RequestFolderItems(folder.folderID); | ||
30 | if (items != null) | ||
31 | { | ||
32 | allItems.InsertRange(0, items); | ||
33 | } | ||
34 | } | ||
35 | } | ||
36 | } | ||
37 | |||
38 | folderList = folders; | ||
39 | itemsList = allItems; | ||
40 | if (folderList != null) | ||
41 | { | ||
42 | return true; | ||
43 | } | ||
44 | else | ||
45 | { | ||
46 | return false; | ||
47 | } | ||
48 | } | ||
49 | |||
50 | public InventoryCollection GetUserInventory(LLUUID userID) | ||
51 | { | ||
52 | InventoryCollection invCollection = new InventoryCollection(); | ||
53 | List<InventoryFolderBase> folders; | ||
54 | List<InventoryItemBase> allItems; | ||
55 | if (TryGetUsersInventory(userID, out folders, out allItems)) | ||
56 | { | ||
57 | invCollection.AllItems = allItems; | ||
58 | invCollection.Folders = folders; | ||
59 | invCollection.UserID = userID; | ||
60 | } | ||
61 | return invCollection; | ||
62 | } | ||
63 | |||
64 | public bool CreateUsersInventory(LLUUID user) | ||
65 | { | ||
66 | CreateNewUserInventory(user); | ||
67 | return true; | ||
68 | } | ||
69 | |||
70 | |||
71 | public override void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder) | ||
72 | { | ||
73 | AddFolder(folder); | ||
74 | } | ||
75 | |||
76 | public override void AddNewInventoryItem(LLUUID userID, InventoryItemBase item) | ||
77 | { | ||
78 | AddItem(item); | ||
79 | } | ||
80 | |||
81 | public bool AddInventoryFolder( InventoryFolderBase folder) | ||
82 | { | ||
83 | AddNewInventoryFolder(folder.agentID, folder); | ||
84 | return true; | ||
85 | } | ||
86 | |||
87 | public bool AddInventoryItem( InventoryItemBase item) | ||
88 | { | ||
89 | AddNewInventoryItem(item.avatarID, item); | ||
90 | return true; | ||
91 | } | ||
92 | |||
93 | public override void DeleteInventoryItem(LLUUID userID, InventoryItemBase item) | ||
94 | { | ||
95 | DeleteItem(item); | ||
96 | } | ||
97 | |||
98 | public bool DeleteInvItem( InventoryItemBase item) | ||
99 | { | ||
100 | DeleteInventoryItem(item.avatarID, item); | ||
101 | return true; | ||
102 | } | ||
103 | } | ||
104 | } | ||
diff --git a/OpenSim/Grid/InventoryServer/Main.cs b/OpenSim/Grid/InventoryServer/Main.cs index 1bc396b..8d232c2 100644 --- a/OpenSim/Grid/InventoryServer/Main.cs +++ b/OpenSim/Grid/InventoryServer/Main.cs | |||
@@ -47,6 +47,7 @@ namespace OpenSim.Grid.InventoryServer | |||
47 | LogBase m_console; | 47 | LogBase m_console; |
48 | InventoryManager m_inventoryManager; | 48 | InventoryManager m_inventoryManager; |
49 | InventoryConfig m_config; | 49 | InventoryConfig m_config; |
50 | GridInventoryService m_inventoryService; | ||
50 | 51 | ||
51 | public const string LogName = "INVENTORY"; | 52 | public const string LogName = "INVENTORY"; |
52 | 53 | ||
@@ -69,13 +70,35 @@ namespace OpenSim.Grid.InventoryServer | |||
69 | { | 70 | { |
70 | MainLog.Instance.Notice("Initialising inventory manager..."); | 71 | MainLog.Instance.Notice("Initialising inventory manager..."); |
71 | m_config = new InventoryConfig(LogName, (Path.Combine(Util.configDir(), "InventoryServer_Config.xml"))); | 72 | m_config = new InventoryConfig(LogName, (Path.Combine(Util.configDir(), "InventoryServer_Config.xml"))); |
72 | 73 | ||
73 | m_inventoryManager = new InventoryManager(); | 74 | m_inventoryService = new GridInventoryService(); |
74 | m_inventoryManager.AddDatabasePlugin(m_config.DatabaseProvider); | 75 | // m_inventoryManager = new InventoryManager(); |
76 | m_inventoryService.AddPlugin(m_config.DatabaseProvider); | ||
77 | |||
75 | MainLog.Instance.Notice(LogName, "Starting HTTP server ..."); | 78 | MainLog.Instance.Notice(LogName, "Starting HTTP server ..."); |
76 | BaseHttpServer httpServer = new BaseHttpServer(m_config.HttpPort); | 79 | BaseHttpServer httpServer = new BaseHttpServer(m_config.HttpPort); |
80 | httpServer.AddStreamHandler( | ||
81 | new RestDeserialisehandler<LLUUID, InventoryCollection>("POST", "/GetInventory/", | ||
82 | m_inventoryService.GetUserInventory)); | ||
83 | httpServer.AddStreamHandler( | ||
84 | new RestDeserialisehandler<LLUUID, bool>("POST", "/CreateInventory/", | ||
85 | m_inventoryService.CreateUsersInventory)); | ||
86 | httpServer.AddStreamHandler( | ||
87 | new RestDeserialisehandler<InventoryFolderBase, bool>("POST", "/NewFolder/", | ||
88 | m_inventoryService.AddInventoryFolder)); | ||
89 | |||
90 | httpServer.AddStreamHandler( | ||
91 | new RestDeserialisehandler<InventoryItemBase, bool>("POST", "/NewItem/", | ||
92 | m_inventoryService.AddInventoryItem)); | ||
93 | httpServer.AddStreamHandler( | ||
94 | new RestDeserialisehandler<InventoryItemBase, bool>("POST", "/DeleteItem/", | ||
95 | m_inventoryService.DeleteInvItem)); | ||
77 | 96 | ||
78 | httpServer.AddStreamHandler(new InventoryManager.GetInventory(m_inventoryManager)); | 97 | httpServer.AddStreamHandler( |
98 | new RestDeserialisehandler<LLUUID, List<InventoryFolderBase>>("POST", "/RootFolders/", | ||
99 | m_inventoryService.RequestFirstLevelFolders)); | ||
100 | |||
101 | // httpServer.AddStreamHandler(new InventoryManager.GetInventory(m_inventoryManager)); | ||
79 | 102 | ||
80 | httpServer.Start(); | 103 | httpServer.Start(); |
81 | MainLog.Instance.Notice(LogName, "Started HTTP server"); | 104 | MainLog.Instance.Notice(LogName, "Started HTTP server"); |
@@ -96,6 +119,9 @@ namespace OpenSim.Grid.InventoryServer | |||
96 | switch (cmd) | 119 | switch (cmd) |
97 | { | 120 | { |
98 | case "quit": | 121 | case "quit": |
122 | case "add-user": | ||
123 | m_inventoryService.CreateUsersInventory(LLUUID.Random()); | ||
124 | break; | ||
99 | case "shutdown": | 125 | case "shutdown": |
100 | m_console.Close(); | 126 | m_console.Close(); |
101 | Environment.Exit(0); | 127 | Environment.Exit(0); |
diff --git a/OpenSim/Grid/UserServer/Main.cs b/OpenSim/Grid/UserServer/Main.cs index 779a72b..b00bb76 100644 --- a/OpenSim/Grid/UserServer/Main.cs +++ b/OpenSim/Grid/UserServer/Main.cs | |||
@@ -27,7 +27,9 @@ | |||
27 | */ | 27 | */ |
28 | 28 | ||
29 | using System; | 29 | using System; |
30 | using System.Collections.Generic; | ||
30 | using System.IO; | 31 | using System.IO; |
32 | using libsecondlife; | ||
31 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
32 | using OpenSim.Framework.Console; | 34 | using OpenSim.Framework.Console; |
33 | using OpenSim.Framework.Servers; | 35 | using OpenSim.Framework.Servers; |
@@ -44,6 +46,7 @@ namespace OpenSim.Grid.UserServer | |||
44 | public UserLoginService m_loginService; | 46 | public UserLoginService m_loginService; |
45 | 47 | ||
46 | private LogBase m_console; | 48 | private LogBase m_console; |
49 | private LLUUID m_lastCreatedUser = LLUUID.Random(); | ||
47 | 50 | ||
48 | [STAThread] | 51 | [STAThread] |
49 | public static void Main(string[] args) | 52 | public static void Main(string[] args) |
@@ -123,7 +126,9 @@ namespace OpenSim.Grid.UserServer | |||
123 | 126 | ||
124 | tempMD5Passwd = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + ""); | 127 | tempMD5Passwd = Util.Md5Hash(Util.Md5Hash(tempMD5Passwd) + ":" + ""); |
125 | 128 | ||
126 | m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY); | 129 | LLUUID userID = m_userManager.AddUserProfile(tempfirstname, templastname, tempMD5Passwd, regX, regY); |
130 | RestObjectPoster.BeginPostObject<LLUUID>(m_userManager._config.InventoryUrl + "CreateInventory/", userID); | ||
131 | m_lastCreatedUser = userID; | ||
127 | break; | 132 | break; |
128 | } | 133 | } |
129 | } | 134 | } |
@@ -145,9 +150,21 @@ namespace OpenSim.Grid.UserServer | |||
145 | m_console.Close(); | 150 | m_console.Close(); |
146 | Environment.Exit(0); | 151 | Environment.Exit(0); |
147 | break; | 152 | break; |
153 | |||
154 | case "test-inventory": | ||
155 | // RestObjectPosterResponse<List<InventoryFolderBase>> requester = new RestObjectPosterResponse<List<InventoryFolderBase>>(); | ||
156 | // requester.ReturnResponseVal = TestResponse; | ||
157 | // requester.BeginPostObject<LLUUID>(m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser); | ||
158 | List<InventoryFolderBase> folders = SyncRestObjectPoster.BeginPostObject<LLUUID, List<InventoryFolderBase>>(m_userManager._config.InventoryUrl + "RootFolders/", m_lastCreatedUser); | ||
159 | break; | ||
148 | } | 160 | } |
149 | } | 161 | } |
150 | 162 | ||
163 | public void TestResponse(List<InventoryFolderBase> resp) | ||
164 | { | ||
165 | System.Console.WriteLine("response got"); | ||
166 | } | ||
167 | |||
151 | /*private void ConfigDB(IGenericConfig configData) | 168 | /*private void ConfigDB(IGenericConfig configData) |
152 | { | 169 | { |
153 | try | 170 | try |
diff --git a/OpenSim/Grid/UserServer/UserLoginService.cs b/OpenSim/Grid/UserServer/UserLoginService.cs index 0af5790..d3164ad 100644 --- a/OpenSim/Grid/UserServer/UserLoginService.cs +++ b/OpenSim/Grid/UserServer/UserLoginService.cs | |||
@@ -28,12 +28,16 @@ | |||
28 | 28 | ||
29 | using System; | 29 | using System; |
30 | using System.Collections; | 30 | using System.Collections; |
31 | using System.Collections.Generic; | ||
31 | using System.Net; | 32 | using System.Net; |
32 | using Nwc.XmlRpc; | 33 | using Nwc.XmlRpc; |
34 | using libsecondlife; | ||
33 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Console; | 36 | using OpenSim.Framework.Console; |
37 | using OpenSim.Framework.Servers; | ||
35 | using OpenSim.Framework.Data; | 38 | using OpenSim.Framework.Data; |
36 | using OpenSim.Framework.UserManagement; | 39 | using OpenSim.Framework.UserManagement; |
40 | using InventoryFolder = OpenSim.Framework.InventoryFolder; | ||
37 | 41 | ||
38 | namespace OpenSim.Grid.UserServer | 42 | namespace OpenSim.Grid.UserServer |
39 | { | 43 | { |
@@ -189,5 +193,51 @@ namespace OpenSim.Grid.UserServer | |||
189 | 193 | ||
190 | } | 194 | } |
191 | } | 195 | } |
196 | |||
197 | protected override InventoryData CreateInventoryData(LLUUID userID) | ||
198 | { | ||
199 | List<InventoryFolderBase> folders = SyncRestObjectPoster.BeginPostObject<LLUUID, List<InventoryFolderBase>>(m_config.InventoryUrl + "RootFolders/", userID); | ||
200 | if (folders.Count > 0) | ||
201 | { | ||
202 | LLUUID rootID = LLUUID.Zero; | ||
203 | ArrayList AgentInventoryArray = new ArrayList(); | ||
204 | Hashtable TempHash; | ||
205 | foreach (InventoryFolderBase InvFolder in folders) | ||
206 | { | ||
207 | if (InvFolder.parentID == LLUUID.Zero) | ||
208 | { | ||
209 | rootID = InvFolder.folderID; | ||
210 | } | ||
211 | TempHash = new Hashtable(); | ||
212 | TempHash["name"] = InvFolder.name; | ||
213 | TempHash["parent_id"] = InvFolder.parentID.ToStringHyphenated(); | ||
214 | TempHash["version"] = (Int32)InvFolder.version; | ||
215 | TempHash["type_default"] = (Int32)InvFolder.type; | ||
216 | TempHash["folder_id"] = InvFolder.folderID.ToStringHyphenated(); | ||
217 | AgentInventoryArray.Add(TempHash); | ||
218 | } | ||
219 | return new InventoryData(AgentInventoryArray, rootID); | ||
220 | } | ||
221 | else | ||
222 | { | ||
223 | AgentInventory userInventory = new AgentInventory(); | ||
224 | userInventory.CreateRootFolder(userID, false); | ||
225 | |||
226 | ArrayList AgentInventoryArray = new ArrayList(); | ||
227 | Hashtable TempHash; | ||
228 | foreach (InventoryFolder InvFolder in userInventory.InventoryFolders.Values) | ||
229 | { | ||
230 | TempHash = new Hashtable(); | ||
231 | TempHash["name"] = InvFolder.FolderName; | ||
232 | TempHash["parent_id"] = InvFolder.ParentID.ToStringHyphenated(); | ||
233 | TempHash["version"] = (Int32)InvFolder.Version; | ||
234 | TempHash["type_default"] = (Int32)InvFolder.DefaultType; | ||
235 | TempHash["folder_id"] = InvFolder.FolderID.ToStringHyphenated(); | ||
236 | AgentInventoryArray.Add(TempHash); | ||
237 | } | ||
238 | |||
239 | return new InventoryData(AgentInventoryArray, userInventory.InventoryRoot.FolderID); | ||
240 | } | ||
241 | } | ||
192 | } | 242 | } |
193 | } \ No newline at end of file | 243 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Communications/Local/LocalInventoryService.cs b/OpenSim/Region/Communications/Local/LocalInventoryService.cs index c38e922..40e6601 100644 --- a/OpenSim/Region/Communications/Local/LocalInventoryService.cs +++ b/OpenSim/Region/Communications/Local/LocalInventoryService.cs | |||
@@ -76,7 +76,7 @@ namespace OpenSim.Region.Communications.Local | |||
76 | } | 76 | } |
77 | } | 77 | } |
78 | 78 | ||
79 | public override void AddNewInventoryFolder(LLUUID userID, InventoryFolderImpl folder) | 79 | public override void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder) |
80 | { | 80 | { |
81 | AddFolder(folder); | 81 | AddFolder(folder); |
82 | } | 82 | } |
@@ -88,7 +88,7 @@ namespace OpenSim.Region.Communications.Local | |||
88 | 88 | ||
89 | public override void DeleteInventoryItem(LLUUID userID, InventoryItemBase item) | 89 | public override void DeleteInventoryItem(LLUUID userID, InventoryItemBase item) |
90 | { | 90 | { |
91 | deleteItem(item); | 91 | DeleteItem(item); |
92 | } | 92 | } |
93 | } | 93 | } |
94 | } \ No newline at end of file | 94 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs b/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs index 7597e79..934a814 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1InventoryService.cs | |||
@@ -25,9 +25,11 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | * | 26 | * |
27 | */ | 27 | */ |
28 | using System; | ||
28 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
29 | using libsecondlife; | 30 | using libsecondlife; |
30 | using OpenSim.Framework; | 31 | using OpenSim.Framework; |
32 | using OpenSim.Framework.Servers; | ||
31 | using OpenSim.Framework.Communications; | 33 | using OpenSim.Framework.Communications; |
32 | using OpenSim.Framework.Communications.Cache; | 34 | using OpenSim.Framework.Communications.Cache; |
33 | 35 | ||
@@ -36,6 +38,7 @@ namespace OpenSim.Region.Communications.OGS1 | |||
36 | public class OGS1InventoryService : IInventoryServices | 38 | public class OGS1InventoryService : IInventoryServices |
37 | { | 39 | { |
38 | private string _inventoryServerUrl; | 40 | private string _inventoryServerUrl; |
41 | private Dictionary<LLUUID, InventoryRequest> m_RequestingInventory = new Dictionary<LLUUID, InventoryRequest>(); | ||
39 | 42 | ||
40 | public OGS1InventoryService(string inventoryServerUrl) | 43 | public OGS1InventoryService(string inventoryServerUrl) |
41 | { | 44 | { |
@@ -47,31 +50,96 @@ namespace OpenSim.Region.Communications.OGS1 | |||
47 | public void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, | 50 | public void RequestInventoryForUser(LLUUID userID, InventoryFolderInfo folderCallBack, |
48 | InventoryItemInfo itemCallBack) | 51 | InventoryItemInfo itemCallBack) |
49 | { | 52 | { |
50 | //TODO! Uncomment when all is done | 53 | |
51 | //SerializableInventory userInventory = null; | 54 | if (!m_RequestingInventory.ContainsKey(userID)) |
52 | 55 | { | |
53 | //RestClient inventoryServer = new RestClient(_inventoryServerUrl); | 56 | InventoryRequest request = new InventoryRequest(userID, folderCallBack, itemCallBack); |
54 | //inventoryServer.AddResourcePath("inventory"); | 57 | m_RequestingInventory.Add(userID, request); |
55 | //inventoryServer.AddResourcePath("user"); | 58 | RequestInventory(userID); |
56 | //inventoryServer.AddResourcePath(userID.ToStringHyphenated()); | 59 | } |
57 | |||
58 | //using (Stream userInventoryStream = inventoryServer.Request()) | ||
59 | //{ | ||
60 | // XmlSerializer x = new XmlSerializer(typeof(SerializableInventory)); | ||
61 | // userInventory = (SerializableInventory)x.Deserialize(userInventoryStream); | ||
62 | //} | ||
63 | } | 60 | } |
64 | 61 | ||
65 | public void AddNewInventoryFolder(LLUUID userID, InventoryFolderImpl folder) | 62 | private void RequestInventory(LLUUID userID) |
66 | { | 63 | { |
64 | try | ||
65 | { | ||
66 | RestObjectPosterResponse<InventoryCollection> requester = new RestObjectPosterResponse<InventoryCollection>(); | ||
67 | requester.ReturnResponseVal = InventoryResponse; | ||
68 | requester.BeginPostObject<LLUUID>(_inventoryServerUrl + "/GetInventory/", userID); | ||
69 | } | ||
70 | catch (Exception) | ||
71 | { | ||
72 | } | ||
73 | } | ||
74 | |||
75 | private void InventoryResponse(InventoryCollection response) | ||
76 | { | ||
77 | LLUUID userID = response.UserID; | ||
78 | if (m_RequestingInventory.ContainsKey(userID)) | ||
79 | { | ||
80 | |||
81 | InventoryFolderImpl rootFolder = null; | ||
82 | InventoryRequest request = m_RequestingInventory[userID]; | ||
83 | foreach (InventoryFolderBase folder in response.Folders) | ||
84 | { | ||
85 | if (folder.parentID == LLUUID.Zero) | ||
86 | { | ||
87 | InventoryFolderImpl newfolder = new InventoryFolderImpl(folder); | ||
88 | rootFolder = newfolder; | ||
89 | request.FolderCallBack(userID, newfolder); | ||
90 | } | ||
91 | } | ||
92 | |||
93 | if (rootFolder != null) | ||
94 | { | ||
95 | foreach (InventoryFolderBase folder in response.Folders) | ||
96 | { | ||
97 | if (folder.folderID != rootFolder.folderID) | ||
98 | { | ||
99 | InventoryFolderImpl newfolder = new InventoryFolderImpl(folder); | ||
100 | request.FolderCallBack(userID, newfolder); | ||
101 | } | ||
102 | } | ||
103 | |||
104 | foreach (InventoryItemBase item in response.AllItems) | ||
105 | { | ||
106 | request.ItemCallBack(userID, item); | ||
107 | } | ||
108 | } | ||
109 | } | ||
110 | } | ||
111 | |||
112 | public void AddNewInventoryFolder(LLUUID userID, InventoryFolderBase folder) | ||
113 | { | ||
114 | try | ||
115 | { | ||
116 | RestObjectPoster.BeginPostObject<InventoryFolderBase>(_inventoryServerUrl + "/NewFolder/", folder); | ||
117 | } | ||
118 | catch (Exception) | ||
119 | { | ||
120 | } | ||
67 | } | 121 | } |
68 | 122 | ||
69 | public void AddNewInventoryItem(LLUUID userID, InventoryItemBase item) | 123 | public void AddNewInventoryItem(LLUUID userID, InventoryItemBase item) |
70 | { | 124 | { |
125 | try | ||
126 | { | ||
127 | RestObjectPoster.BeginPostObject<InventoryItemBase>(_inventoryServerUrl + "/NewItem/", item); | ||
128 | } | ||
129 | catch (Exception) | ||
130 | { | ||
131 | } | ||
71 | } | 132 | } |
72 | 133 | ||
73 | public void DeleteInventoryItem(LLUUID userID, InventoryItemBase item) | 134 | public void DeleteInventoryItem(LLUUID userID, InventoryItemBase item) |
74 | { | 135 | { |
136 | try | ||
137 | { | ||
138 | RestObjectPoster.BeginPostObject<InventoryItemBase>(_inventoryServerUrl + "/DeleteItem/", item); | ||
139 | } | ||
140 | catch (Exception) | ||
141 | { | ||
142 | } | ||
75 | } | 143 | } |
76 | 144 | ||
77 | public void CreateNewUserInventory(LLUUID user) | 145 | public void CreateNewUserInventory(LLUUID user) |
@@ -84,5 +152,19 @@ namespace OpenSim.Region.Communications.OGS1 | |||
84 | } | 152 | } |
85 | 153 | ||
86 | #endregion | 154 | #endregion |
155 | |||
156 | public class InventoryRequest | ||
157 | { | ||
158 | public LLUUID UserID; | ||
159 | public InventoryFolderInfo FolderCallBack; | ||
160 | public InventoryItemInfo ItemCallBack; | ||
161 | |||
162 | public InventoryRequest(LLUUID userId, InventoryFolderInfo folderCall, InventoryItemInfo itemCall) | ||
163 | { | ||
164 | UserID = userId; | ||
165 | FolderCallBack = folderCall; | ||
166 | ItemCallBack = itemCall; | ||
167 | } | ||
168 | } | ||
87 | } | 169 | } |
88 | } \ No newline at end of file | 170 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs index 96380f7..9e1206b 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs | |||
@@ -162,9 +162,10 @@ namespace OpenSim.Region.Communications.OGS1 | |||
162 | return data; | 162 | return data; |
163 | } | 163 | } |
164 | 164 | ||
165 | public void AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY) | 165 | public LLUUID AddUserProfile(string firstName, string lastName, string pass, uint regX, uint regY) |
166 | { | 166 | { |
167 | throw new Exception("The method or operation is not implemented."); | 167 | throw new Exception("The method or operation is not implemented."); |
168 | return LLUUID.Zero; | ||
168 | } | 169 | } |
169 | } | 170 | } |
170 | } \ No newline at end of file | 171 | } \ No newline at end of file |