aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMelanie2010-01-04 20:52:44 +0000
committerMelanie2010-01-04 20:53:28 +0000
commit1ae9bfc0746b97f57031f282d4f6721b08c27f0c (patch)
tree859626a5f85201933fd75b6d54400a6db81f9685 /OpenSim
parentFirst stage port of the XInventoryService (diff)
downloadopensim-SC_OLD-1ae9bfc0746b97f57031f282d4f6721b08c27f0c.zip
opensim-SC_OLD-1ae9bfc0746b97f57031f282d4f6721b08c27f0c.tar.gz
opensim-SC_OLD-1ae9bfc0746b97f57031f282d4f6721b08c27f0c.tar.bz2
opensim-SC_OLD-1ae9bfc0746b97f57031f282d4f6721b08c27f0c.tar.xz
Finish conversion if XInventoryService
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Data/IXInventoryData.cs4
-rw-r--r--OpenSim/Data/MySQL/MySQLXInventoryData.cs55
-rw-r--r--OpenSim/Services/InventoryService/XInventoryService.cs58
3 files changed, 98 insertions, 19 deletions
diff --git a/OpenSim/Data/IXInventoryData.cs b/OpenSim/Data/IXInventoryData.cs
index 88174d9..cd9273e 100644
--- a/OpenSim/Data/IXInventoryData.cs
+++ b/OpenSim/Data/IXInventoryData.cs
@@ -77,6 +77,8 @@ namespace OpenSim.Data
77 bool DeleteFolders(string field, string val); 77 bool DeleteFolders(string field, string val);
78 bool DeleteItems(string field, string val); 78 bool DeleteItems(string field, string val);
79 79
80 bool MoveItem(string principalID, string id, string newParent); 80 bool MoveItem(string id, string newParent);
81 XInventoryItem[] GetActiveGestures(UUID principalID);
82 int GetAssetPermissions(UUID principalID, UUID assetID);
81 } 83 }
82} 84}
diff --git a/OpenSim/Data/MySQL/MySQLXInventoryData.cs b/OpenSim/Data/MySQL/MySQLXInventoryData.cs
index dd3e6ea..0eebc9c 100644
--- a/OpenSim/Data/MySQL/MySQLXInventoryData.cs
+++ b/OpenSim/Data/MySQL/MySQLXInventoryData.cs
@@ -85,9 +85,19 @@ namespace OpenSim.Data.MySQL
85 return m_Items.Delete(field, val); 85 return m_Items.Delete(field, val);
86 } 86 }
87 87
88 public bool MoveItem(string principalID, string id, string newParent) 88 public bool MoveItem(string id, string newParent)
89 { 89 {
90 return m_Items.MoveItem(principalID, id, newParent); 90 return m_Items.MoveItem(id, newParent);
91 }
92
93 public XInventoryItem[] GetActiveGestures(UUID principalID)
94 {
95 return m_Items.GetActiveGestures(principalID);
96 }
97
98 public int GetAssetPermissions(UUID principalID, UUID assetID)
99 {
100 return m_Items.GetAssetPermissions(principalID, assetID);
91 } 101 }
92 } 102 }
93 103
@@ -98,16 +108,49 @@ namespace OpenSim.Data.MySQL
98 { 108 {
99 } 109 }
100 110
101 public bool MoveItem(string principalID, string id, string newParent) 111 public bool MoveItem(string id, string newParent)
102 { 112 {
103 MySqlCommand cmd = new MySqlCommand(); 113 MySqlCommand cmd = new MySqlCommand();
104 114
105 cmd.CommandText = String.Format("update {0} set parentFolderID = ?ParentFolderID where agentID = ?AgentID and folderID = ?FolderID"); 115 cmd.CommandText = String.Format("update {0} set parentFolderID = ?ParentFolderID where inventoryID = ?InventoryID", m_Realm);
106 cmd.Parameters.AddWithValue("?ParentFolderID", newParent); 116 cmd.Parameters.AddWithValue("?ParentFolderID", newParent);
107 cmd.Parameters.AddWithValue("?FolderID", id); 117 cmd.Parameters.AddWithValue("?InventoryID", id);
108 cmd.Parameters.AddWithValue("?AgentID", principalID);
109 118
110 return ExecuteNonQuery(cmd) == 0 ? false : true; 119 return ExecuteNonQuery(cmd) == 0 ? false : true;
111 } 120 }
121
122 public XInventoryItem[] GetActiveGestures(UUID principalID)
123 {
124 MySqlCommand cmd = new MySqlCommand();
125 cmd.CommandText = String.Format("select * from inventoryitems where avatarId = ?uuid and assetType = ?type and flags = 1", m_Realm);
126
127 cmd.Parameters.AddWithValue("?uuid", principalID.ToString());
128 cmd.Parameters.AddWithValue("?type", (int)AssetType.Gesture);
129
130 return DoQuery(cmd);
131 }
132
133 public int GetAssetPermissions(UUID principalID, UUID assetID)
134 {
135 MySqlCommand cmd = new MySqlCommand();
136
137 cmd.CommandText = String.Format("select bit_or(inventoryCurrentPermissions) as inventoryCurrentPermissions from inventoryitems where avatarID = ?PrincipalID and assetID = ?AssetID group by assetID", m_Realm);
138 cmd.Parameters.AddWithValue("?PrincipalID", principalID.ToString());
139 cmd.Parameters.AddWithValue("?AssetID", assetID.ToString());
140
141 IDataReader reader = ExecuteReader(cmd);
142
143 int perms = 0;
144
145 if (reader.Read())
146 {
147 perms = Convert.ToInt32(reader["inventoryCurrentPermissions"]);
148 }
149
150 reader.Close();
151 CloseReaderCommand(cmd);
152
153 return perms;
154 }
112 } 155 }
113} 156}
diff --git a/OpenSim/Services/InventoryService/XInventoryService.cs b/OpenSim/Services/InventoryService/XInventoryService.cs
index 1e7f206..2c79c77 100644
--- a/OpenSim/Services/InventoryService/XInventoryService.cs
+++ b/OpenSim/Services/InventoryService/XInventoryService.cs
@@ -183,7 +183,10 @@ namespace OpenSim.Services.InventoryService
183 List<InventoryFolderBase> folders = new List<InventoryFolderBase>(); 183 List<InventoryFolderBase> folders = new List<InventoryFolderBase>();
184 184
185 foreach (XInventoryFolder x in allFolders) 185 foreach (XInventoryFolder x in allFolders)
186 {
187 m_log.DebugFormat("[INVENTORY]: Adding folder {0} to skeleton", x.folderName);
186 folders.Add(ConvertToOpenSim(x)); 188 folders.Add(ConvertToOpenSim(x));
189 }
187 190
188 return folders; 191 return folders;
189 } 192 }
@@ -214,35 +217,48 @@ namespace OpenSim.Services.InventoryService
214 217
215 public InventoryCollection GetFolderContent(UUID principalID, UUID folderID) 218 public InventoryCollection GetFolderContent(UUID principalID, UUID folderID)
216 { 219 {
220 // This method doesn't receive a valud principal id from the
221 // connector. So we disregard the principal and look
222 // by ID.
223 //
224 m_log.DebugFormat("[INVENTORY]: Fetch contents for folder {0}", folderID.ToString());
217 InventoryCollection inventory = new InventoryCollection(); 225 InventoryCollection inventory = new InventoryCollection();
218 inventory.UserID = principalID; 226 inventory.UserID = principalID;
219 inventory.Folders = new List<InventoryFolderBase>(); 227 inventory.Folders = new List<InventoryFolderBase>();
220 inventory.Items = new List<InventoryItemBase>(); 228 inventory.Items = new List<InventoryItemBase>();
221 229
222 XInventoryFolder[] folders = m_Database.GetFolders( 230 XInventoryFolder[] folders = m_Database.GetFolders(
223 new string[] { "agentID", "parentFolderID"}, 231 new string[] { "parentFolderID"},
224 new string[] { principalID.ToString(), UUID.Zero.ToString() }); 232 new string[] { folderID.ToString() });
225 233
226 foreach (XInventoryFolder x in folders) 234 foreach (XInventoryFolder x in folders)
235 {
236 m_log.DebugFormat("[INVENTORY]: Adding folder {0} to response", x.folderName);
227 inventory.Folders.Add(ConvertToOpenSim(x)); 237 inventory.Folders.Add(ConvertToOpenSim(x));
238 }
228 239
229 XInventoryItem[] items = m_Database.GetItems( 240 XInventoryItem[] items = m_Database.GetItems(
230 new string[] { "avatarID", "parentFolderID"}, 241 new string[] { "parentFolderID"},
231 new string[] { principalID.ToString(), UUID.Zero.ToString() }); 242 new string[] { folderID.ToString() });
232 243
233 foreach (XInventoryItem i in items) 244 foreach (XInventoryItem i in items)
245 {
246 m_log.DebugFormat("[INVENTORY]: Adding item {0} to response", i.inventoryName);
234 inventory.Items.Add(ConvertToOpenSim(i)); 247 inventory.Items.Add(ConvertToOpenSim(i));
248 }
235 249
236 return inventory; 250 return inventory;
237 } 251 }
238 252
239 public List<InventoryItemBase> GetFolderItems(UUID principalID, UUID folderID) 253 public List<InventoryItemBase> GetFolderItems(UUID principalID, UUID folderID)
240 { 254 {
255 // Since we probably don't get a valid principal here, either ...
256 //
241 List<InventoryItemBase> invItems = new List<InventoryItemBase>(); 257 List<InventoryItemBase> invItems = new List<InventoryItemBase>();
242 258
243 XInventoryItem[] items = m_Database.GetItems( 259 XInventoryItem[] items = m_Database.GetItems(
244 new string[] { "avatarID", "parentFolderID"}, 260 new string[] { "parentFolderID"},
245 new string[] { principalID.ToString(), UUID.Zero.ToString() }); 261 new string[] { UUID.Zero.ToString() });
246 262
247 foreach (XInventoryItem i in items) 263 foreach (XInventoryItem i in items)
248 invItems.Add(ConvertToOpenSim(i)); 264 invItems.Add(ConvertToOpenSim(i));
@@ -279,6 +295,8 @@ namespace OpenSim.Services.InventoryService
279 // 295 //
280 public bool DeleteFolders(UUID principalID, List<UUID> folderIDs) 296 public bool DeleteFolders(UUID principalID, List<UUID> folderIDs)
281 { 297 {
298 // Ignore principal ID, it's bogus at connector level
299 //
282 foreach (UUID id in folderIDs) 300 foreach (UUID id in folderIDs)
283 { 301 {
284 InventoryFolderBase f = new InventoryFolderBase(); 302 InventoryFolderBase f = new InventoryFolderBase();
@@ -297,7 +315,10 @@ namespace OpenSim.Services.InventoryService
297 new string[] { folder.ID.ToString() }); 315 new string[] { folder.ID.ToString() });
298 316
299 foreach (XInventoryFolder x in subFolders) 317 foreach (XInventoryFolder x in subFolders)
318 {
300 PurgeFolder(ConvertToOpenSim(x)); 319 PurgeFolder(ConvertToOpenSim(x));
320 m_Database.DeleteFolders("folderID", x.folderID.ToString());
321 }
301 322
302 m_Database.DeleteItems("parentFolderID", folder.ID.ToString()); 323 m_Database.DeleteItems("parentFolderID", folder.ID.ToString());
303 324
@@ -316,10 +337,11 @@ namespace OpenSim.Services.InventoryService
316 337
317 public bool MoveItems(UUID principalID, List<InventoryItemBase> items) 338 public bool MoveItems(UUID principalID, List<InventoryItemBase> items)
318 { 339 {
340 // Principal is b0rked. *sigh*
341 //
319 foreach (InventoryItemBase i in items) 342 foreach (InventoryItemBase i in items)
320 { 343 {
321 m_Database.MoveItem(principalID.ToString(), i.ID.ToString(), 344 m_Database.MoveItem(i.ID.ToString(), i.Folder.ToString());
322 i.Folder.ToString());
323 } 345 }
324 346
325 return true; 347 return true;
@@ -327,6 +349,8 @@ namespace OpenSim.Services.InventoryService
327 349
328 public bool DeleteItems(UUID principalID, List<UUID> itemIDs) 350 public bool DeleteItems(UUID principalID, List<UUID> itemIDs)
329 { 351 {
352 // Just use the ID... *facepalms*
353 //
330 foreach (UUID id in itemIDs) 354 foreach (UUID id in itemIDs)
331 m_Database.DeleteItems("inventoryID", id.ToString()); 355 m_Database.DeleteItems("inventoryID", id.ToString());
332 356
@@ -357,14 +381,24 @@ namespace OpenSim.Services.InventoryService
357 return ConvertToOpenSim(folders[0]); 381 return ConvertToOpenSim(folders[0]);
358 } 382 }
359 383
360 public List<InventoryItemBase> GetActiveGestures(UUID userId) 384 public List<InventoryItemBase> GetActiveGestures(UUID principalID)
361 { 385 {
362 return null; 386 XInventoryItem[] items = m_Database.GetActiveGestures(principalID);
387
388 if (items.Length == 0)
389 return null;
390
391 List<InventoryItemBase> ret = new List<InventoryItemBase>();
392
393 foreach (XInventoryItem x in items)
394 ret.Add(ConvertToOpenSim(x));
395
396 return ret;
363 } 397 }
364 398
365 public int GetAssetPermissions(UUID userID, UUID assetID) 399 public int GetAssetPermissions(UUID principalID, UUID assetID)
366 { 400 {
367 return 0; 401 return m_Database.GetAssetPermissions(principalID, assetID);
368 } 402 }
369 403
370 // CM never needed those. Left unimplemented. 404 // CM never needed those. Left unimplemented.