From 6892fc41f71a00327336dec7158f3ce809ce32a4 Mon Sep 17 00:00:00 2001
From: John Hurliman
Date: Tue, 13 Apr 2010 18:59:05 -0700
Subject: Applying patch from lkalif to add support for inventory links to the
 SimianGrid connectors

---
 OpenSim/Framework/SLUtil.cs                        | 33 ++++++++++++++++++++++
 .../SimianGrid/SimianInventoryServiceConnector.cs  | 12 ++++++++
 2 files changed, 45 insertions(+)

diff --git a/OpenSim/Framework/SLUtil.cs b/OpenSim/Framework/SLUtil.cs
index f6d6a7c..a489806 100644
--- a/OpenSim/Framework/SLUtil.cs
+++ b/OpenSim/Framework/SLUtil.cs
@@ -106,6 +106,39 @@ namespace OpenSim.Framework
             }
         }
 
+        public static string SLInvTypeToContentType(int invType)
+        {
+            switch ((InventoryType)invType)
+            {
+                case InventoryType.Animation:
+                    return "application/vnd.ll.animation";
+                case InventoryType.CallingCard:
+                    return "application/vnd.ll.callingcard";
+                case InventoryType.Folder:
+                    return "application/vnd.ll.folder";
+                case InventoryType.Gesture:
+                    return "application/vnd.ll.gesture";
+                case InventoryType.Landmark:
+                    return "application/vnd.ll.landmark";
+                case InventoryType.LSL:
+                    return "application/vnd.ll.lsltext";
+                case InventoryType.Notecard:
+                    return "application/vnd.ll.notecard";
+                case InventoryType.Attachment:
+                case InventoryType.Object:
+                    return "application/vnd.ll.primitive";
+                case InventoryType.Sound:
+                    return "application/ogg";
+                case InventoryType.Snapshot:
+                case InventoryType.Texture:
+                    return "image/x-j2c";
+                case InventoryType.Wearable:
+                    return "application/vnd.ll.clothing";
+                default:
+                    return "application/octet-stream";
+            }
+        }
+
         public static sbyte ContentTypeToSLAssetType(string contentType)
         {
             switch (contentType)
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs
index 56e7475..9005e94 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianInventoryServiceConnector.cs
@@ -583,6 +583,14 @@ namespace OpenSim.Services.Connectors.SimianGrid
                 { "Permissions", permissions }
             };
 
+            // Add different asset type only if it differs from inventory type
+            // (needed for links)
+            string invContentType = SLUtil.SLInvTypeToContentType(item.InvType);
+            string assetContentType = SLUtil.SLAssetTypeToContentType(item.AssetType);
+
+            if (invContentType != assetContentType)
+                extraData["LinkedItemType"] = OSD.FromString(assetContentType);
+
             NameValueCollection requestArgs = new NameValueCollection
             {
                 { "RequestMethod", "AddInventoryItem" },
@@ -593,6 +601,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
                 { "Name", item.Name },
                 { "Description", item.Description },
                 { "CreatorID", item.CreatorId },
+                { "ContentType", invContentType },
                 { "ExtraData", OSDParser.SerializeJsonString(extraData) }
             };
 
@@ -781,6 +790,9 @@ namespace OpenSim.Services.Connectors.SimianGrid
                             invItem.GroupPermissions = perms["GroupMask"].AsUInteger();
                             invItem.NextPermissions = perms["NextOwnerMask"].AsUInteger();
                         }
+
+                        if (extraData.ContainsKey("LinkedItemType"))
+                            invItem.AssetType = extraData["LinkedItemType"].AsInteger();
                     }
 
                     if (invItem.BasePermissions == 0)
-- 
cgit v1.1