aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2Handler.cs104
-rw-r--r--OpenSim/Framework/Util.cs1
-rw-r--r--OpenSim/Services/InventoryService/LibraryService.cs32
3 files changed, 76 insertions, 61 deletions
diff --git a/OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2Handler.cs b/OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2Handler.cs
index e239a90..66b46a6 100644
--- a/OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2Handler.cs
+++ b/OpenSim/Capabilities/Handlers/FetchInventory/FetchInventory2Handler.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28using System.Reflection; 28using System.Reflection;
29using System.Text;
29using OpenMetaverse; 30using OpenMetaverse;
30using OpenMetaverse.StructuredData; 31using OpenMetaverse.StructuredData;
31using OpenSim.Framework; 32using OpenSim.Framework;
@@ -59,9 +60,6 @@ namespace OpenSim.Capabilities.Handlers
59 OSDMap requestmap = (OSDMap)OSDParser.DeserializeLLSDXml(Utils.StringToBytes(request)); 60 OSDMap requestmap = (OSDMap)OSDParser.DeserializeLLSDXml(Utils.StringToBytes(request));
60 OSDArray itemsRequested = (OSDArray)requestmap["items"]; 61 OSDArray itemsRequested = (OSDArray)requestmap["items"];
61 62
62 string reply;
63 LLSDFetchInventory llsdReply = new LLSDFetchInventory();
64
65 UUID[] itemIDs = new UUID[itemsRequested.Count]; 63 UUID[] itemIDs = new UUID[itemsRequested.Count];
66 int i = 0; 64 int i = 0;
67 65
@@ -92,55 +90,65 @@ namespace OpenSim.Capabilities.Handlers
92 items[i++] = m_inventoryService.GetItem(UUID.Zero, id); 90 items[i++] = m_inventoryService.GetItem(UUID.Zero, id);
93 } 91 }
94 92
95 foreach (InventoryItemBase item in items) 93 StringBuilder lsl = LLSDxmlEncode.Start(2048);
94 LLSDxmlEncode.AddMap(lsl);
95
96 if(m_agentID == UUID.Zero && items.Length > 0)
97 LLSDxmlEncode.AddElem("agent_id", items[0].Owner, lsl);
98 else
99 LLSDxmlEncode.AddElem("agent_id", m_agentID, lsl);
100
101 if(items == null || items.Length == 0)
102 {
103 LLSDxmlEncode.AddEmptyArray("items",lsl);
104 }
105 else
96 { 106 {
97 if (item != null) 107 LLSDxmlEncode.AddArray("items",lsl);
108 foreach (InventoryItemBase item in items)
98 { 109 {
99 // We don't know the agent that this request belongs to so we'll use the agent id of the item 110 if (item != null)
100 // which will be the same for all items. 111 {
101 llsdReply.agent_id = item.Owner; 112 // this is as FecthLib, possible to move to a shared location later
102 llsdReply.items.Array.Add(ConvertInventoryItem(item)); 113 LLSDxmlEncode.AddMap(lsl);
114 LLSDxmlEncode.AddElem("parent_id", item.Folder, lsl);
115 LLSDxmlEncode.AddElem("asset_id", item.AssetID, lsl);
116 LLSDxmlEncode.AddElem("item_id", item.ID, lsl);
117
118 LLSDxmlEncode.AddMap("permissions",lsl);
119 LLSDxmlEncode.AddElem("creator_id", item.CreatorIdAsUuid, lsl);
120 LLSDxmlEncode.AddElem("owner_id", item.Owner, lsl);
121 LLSDxmlEncode.AddElem("group_id", item.GroupID, lsl);
122 LLSDxmlEncode.AddElem("base_mask", (int)item.CurrentPermissions, lsl);
123 LLSDxmlEncode.AddElem("owner_mask", (int)item.CurrentPermissions, lsl);
124 LLSDxmlEncode.AddElem("group_mask", (int)item.GroupPermissions, lsl);
125 LLSDxmlEncode.AddElem("everyone_mask", (int)item.EveryOnePermissions, lsl);
126 LLSDxmlEncode.AddElem("next_owner_mask", (int)item.NextPermissions, lsl);
127 LLSDxmlEncode.AddElem("is_owner_group", item.GroupOwned, lsl);
128 LLSDxmlEncode.AddEndMap(lsl);
129
130 LLSDxmlEncode.AddElem("type", item.AssetType, lsl);
131 LLSDxmlEncode.AddElem("inv_type", item.InvType, lsl);
132 LLSDxmlEncode.AddElem("flags", ((int)item.Flags) & 0xff, lsl);
133 LLSDxmlEncode.AddElem("flags", ((int)item.Flags) & 0xff, lsl);
134
135 LLSDxmlEncode.AddMap("sale_info",lsl);
136 LLSDxmlEncode.AddElem("sale_price", item.SalePrice, lsl);
137 LLSDxmlEncode.AddElem("sale_type", item.SaleType, lsl);
138 LLSDxmlEncode.AddEndMap(lsl);
139
140 LLSDxmlEncode.AddElem("name", item.Name, lsl);
141 LLSDxmlEncode.AddElem("desc", item.Description, lsl);
142 LLSDxmlEncode.AddElem("created_at", item.CreationDate, lsl);
143
144 LLSDxmlEncode.AddEndMap(lsl);
145 }
103 } 146 }
104 } 147 LLSDxmlEncode.AddEndArray(lsl);
105 148 }
106 reply = LLSDHelpers.SerialiseLLSDReply(llsdReply);
107 149
108 return reply; 150 LLSDxmlEncode.AddEndMap(lsl);
109 } 151 return LLSDxmlEncode.End(lsl);;
110
111 /// <summary>
112 /// Convert an internal inventory item object into an LLSD object.
113 /// </summary>
114 /// <param name="invItem"></param>
115 /// <returns></returns>
116 private LLSDInventoryItem ConvertInventoryItem(InventoryItemBase invItem)
117 {
118 LLSDInventoryItem llsdItem = new LLSDInventoryItem();
119 llsdItem.asset_id = invItem.AssetID;
120 llsdItem.created_at = invItem.CreationDate;
121 llsdItem.desc = invItem.Description;
122 llsdItem.flags = ((int)invItem.Flags) & 0xff;
123 llsdItem.item_id = invItem.ID;
124 llsdItem.name = invItem.Name;
125 llsdItem.parent_id = invItem.Folder;
126 llsdItem.type = invItem.AssetType;
127 llsdItem.inv_type = invItem.InvType;
128
129 llsdItem.permissions = new LLSDPermissions();
130 llsdItem.permissions.creator_id = invItem.CreatorIdAsUuid;
131 llsdItem.permissions.base_mask = (int)invItem.CurrentPermissions;
132 llsdItem.permissions.everyone_mask = (int)invItem.EveryOnePermissions;
133 llsdItem.permissions.group_id = invItem.GroupID;
134 llsdItem.permissions.group_mask = (int)invItem.GroupPermissions;
135 llsdItem.permissions.is_owner_group = invItem.GroupOwned;
136 llsdItem.permissions.next_owner_mask = (int)invItem.NextPermissions;
137 llsdItem.permissions.owner_id = invItem.Owner;
138 llsdItem.permissions.owner_mask = (int)invItem.CurrentPermissions;
139 llsdItem.sale_info = new LLSDSaleInfo();
140 llsdItem.sale_info.sale_price = invItem.SalePrice;
141 llsdItem.sale_info.sale_type = invItem.SaleType;
142
143 return llsdItem;
144 } 152 }
145 } 153 }
146} 154}
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 0685fdc..8e4a953 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -92,6 +92,7 @@ namespace OpenSim.Framework
92 // explicitly given 92 // explicitly given
93 All = 0x8e000, 93 All = 0x8e000,
94 AllAndExport = 0x9e000, 94 AllAndExport = 0x9e000,
95 AllAndExportNoMod = 0x9a000,
95 AllEffective = 0x9e000, 96 AllEffective = 0x9e000,
96 UnfoldedMask = 0x1e000 97 UnfoldedMask = 0x1e000
97 } 98 }
diff --git a/OpenSim/Services/InventoryService/LibraryService.cs b/OpenSim/Services/InventoryService/LibraryService.cs
index c71295d..de1c784 100644
--- a/OpenSim/Services/InventoryService/LibraryService.cs
+++ b/OpenSim/Services/InventoryService/LibraryService.cs
@@ -69,6 +69,11 @@ namespace OpenSim.Services.InventoryService
69 static protected Dictionary<UUID, InventoryItemBase> m_items = new Dictionary<UUID, InventoryItemBase>(256); 69 static protected Dictionary<UUID, InventoryItemBase> m_items = new Dictionary<UUID, InventoryItemBase>(256);
70 static LibraryService m_root; 70 static LibraryService m_root;
71 static object m_rootLock = new object(); 71 static object m_rootLock = new object();
72 static readonly uint m_BasePermissions = (uint)PermissionMask.AllAndExport;
73 static readonly uint m_EveryOnePermissions = (uint)PermissionMask.AllAndExportNoMod;
74 static readonly uint m_CurrentPermissions = (uint)PermissionMask.AllAndExport;
75 static readonly uint m_NextPermissions = (uint)PermissionMask.AllAndExport;
76 static readonly uint m_GroupPermissions = 0;
72 77
73 public LibraryService(IConfigSource config):base(config) 78 public LibraryService(IConfigSource config):base(config)
74 { 79 {
@@ -96,8 +101,8 @@ namespace OpenSim.Services.InventoryService
96 m_LibraryRootFolder.ID = new UUID("00000112-000f-0000-0000-000100bba000"); 101 m_LibraryRootFolder.ID = new UUID("00000112-000f-0000-0000-000100bba000");
97 m_LibraryRootFolder.Name = pLibName; 102 m_LibraryRootFolder.Name = pLibName;
98 m_LibraryRootFolder.ParentID = UUID.Zero; 103 m_LibraryRootFolder.ParentID = UUID.Zero;
99 m_LibraryRootFolder.Type = (short)8; 104 m_LibraryRootFolder.Type = 8;
100 m_LibraryRootFolder.Version = (ushort)1; 105 m_LibraryRootFolder.Version = 1;
101 106
102 libraryFolders.Add(m_LibraryRootFolder.ID, m_LibraryRootFolder); 107 libraryFolders.Add(m_LibraryRootFolder.ID, m_LibraryRootFolder);
103 108
@@ -117,10 +122,11 @@ namespace OpenSim.Services.InventoryService
117 item.AssetType = assetType; 122 item.AssetType = assetType;
118 item.InvType = invType; 123 item.InvType = invType;
119 item.Folder = parentFolderID; 124 item.Folder = parentFolderID;
120 item.BasePermissions = 0x7FFFFFFF; 125 item.BasePermissions = m_BasePermissions;
121 item.EveryOnePermissions = 0x7FFFFFFF; 126 item.EveryOnePermissions = m_EveryOnePermissions;
122 item.CurrentPermissions = 0x7FFFFFFF; 127 item.CurrentPermissions = m_CurrentPermissions;
123 item.NextPermissions = 0x7FFFFFFF; 128 item.NextPermissions = m_NextPermissions;
129 item.GroupPermissions = m_GroupPermissions;
124 return item; 130 return item;
125 } 131 }
126 132
@@ -142,6 +148,7 @@ namespace OpenSim.Services.InventoryService
142 protected void ReadLibraryFromConfig(IConfig config, string path) 148 protected void ReadLibraryFromConfig(IConfig config, string path)
143 { 149 {
144 string basePath = Path.GetDirectoryName(path); 150 string basePath = Path.GetDirectoryName(path);
151 m_LibraryRootFolder.Version = (ushort)config.GetInt("RootVersion", 1);
145 string foldersPath 152 string foldersPath
146 = Path.Combine( 153 = Path.Combine(
147 basePath, config.GetString("foldersFile", String.Empty)); 154 basePath, config.GetString("foldersFile", String.Empty));
@@ -167,9 +174,8 @@ namespace OpenSim.Services.InventoryService
167 folderInfo.Name = config.GetString("name", "unknown"); 174 folderInfo.Name = config.GetString("name", "unknown");
168 folderInfo.ParentID = new UUID(config.GetString("parentFolderID", m_LibraryRootFolder.ID.ToString())); 175 folderInfo.ParentID = new UUID(config.GetString("parentFolderID", m_LibraryRootFolder.ID.ToString()));
169 folderInfo.Type = (short)config.GetInt("type", 8); 176 folderInfo.Type = (short)config.GetInt("type", 8);
170 177 folderInfo.Version = (ushort)config.GetInt("version", 1);
171 folderInfo.Owner = libOwner; 178 folderInfo.Owner = libOwner;
172 folderInfo.Version = 1;
173 179
174 if (libraryFolders.ContainsKey(folderInfo.ParentID)) 180 if (libraryFolders.ContainsKey(folderInfo.ParentID))
175 { 181 {
@@ -205,11 +211,11 @@ namespace OpenSim.Services.InventoryService
205 item.Description = config.GetString("description", item.Name); 211 item.Description = config.GetString("description", item.Name);
206 item.InvType = config.GetInt("inventoryType", 0); 212 item.InvType = config.GetInt("inventoryType", 0);
207 item.AssetType = config.GetInt("assetType", item.InvType); 213 item.AssetType = config.GetInt("assetType", item.InvType);
208 item.CurrentPermissions = (uint)config.GetLong("currentPermissions", (uint)PermissionMask.All); 214 item.CurrentPermissions = (uint)config.GetLong("currentPermissions", m_CurrentPermissions);
209 item.NextPermissions = (uint)config.GetLong("nextPermissions", (uint)PermissionMask.All); 215 item.NextPermissions = (uint)config.GetLong("nextPermissions", m_NextPermissions);
210 item.EveryOnePermissions 216 item.EveryOnePermissions = (uint)config.GetLong("everyonePermissions", m_EveryOnePermissions);
211 = (uint)config.GetLong("everyonePermissions", (uint)PermissionMask.All - (uint)PermissionMask.Modify); 217 item.BasePermissions = (uint)config.GetLong("basePermissions", m_BasePermissions);
212 item.BasePermissions = (uint)config.GetLong("basePermissions", (uint)PermissionMask.All); 218 item.GroupPermissions = (uint)config.GetLong("basePermissions", m_GroupPermissions);;
213 item.Flags = (uint)config.GetInt("flags", 0); 219 item.Flags = (uint)config.GetInt("flags", 0);
214 220
215 if (libraryFolders.ContainsKey(item.Folder)) 221 if (libraryFolders.ContainsKey(item.Folder))