コード例 #1
0
        public StateSave FindScriptStateSave(ScriptData script)
        {
            OSDMap component = m_manager.GetComponentState(script.Part, m_componentName) as OSDMap;

            //Attempt to find the state saves we have
            if (component != null)
            {
                OSD o;
                //If we have one for this item, deserialize it
                if (!component.TryGetValue(script.ItemID.ToString(), out o))
                {
                    if (!component.TryGetValue(script.InventoryItem.OldItemID.ToString(), out o))
                    {
                        if (!component.TryGetValue(script.InventoryItem.ItemID.ToString(), out o))
                        {
                            return(null);
                        }
                    }
                }
                StateSave save = new StateSave();
                save.FromOSD((OSDMap)o);
                return(save);
            }
            return(null);
        }
コード例 #2
0
ファイル: AvatarAttachment.cs プロジェクト: osCore2/osCore2
        public void Unpack(OSDMap args)
        {
            OSD tmpOSD;

            if (args.TryGetValue("point", out tmpOSD))
            {
                AttachPoint = tmpOSD.AsInteger();
            }
            if (args.TryGetValue("item", out tmpOSD))
            {
                ItemID = tmpOSD.AsUUID();
            }
            else
            {
                ItemID = UUID.Zero;
            }

            if (args.TryGetValue("asset", out tmpOSD))
            {
                AssetID = tmpOSD.AsUUID();
            }
            else
            {
                AssetID = UUID.Zero;
            }
        }
コード例 #3
0
        public bool ContainsStore(string ns, string storeName)
        {
            OSD namespaceOsd;

            lock (this)
            {
                if (m_map.TryGetValue(ns, out namespaceOsd))
                {
                    return(((OSDMap)namespaceOsd).ContainsKey(storeName));
                }
            }

            return(false);
        }
コード例 #4
0
        public bool ClassifiedUpdate(OSDMap json, ref JsonRpcResponse response)
        {
            OSD tmpParams;

            if (!json.TryGetValue("params", out tmpParams) || !(tmpParams is OSDMap))
            {
                response.Error.Code    = ErrorCode.ParseError;
                response.Error.Message = "Error parsing classified update request";
                m_log.DebugFormat("Classified Update Request");
                return(false);
            }

            string            result = string.Empty;
            UserClassifiedAdd ad     = new UserClassifiedAdd();
            object            Ad     = ad;

            OSD.DeserializeMembers(ref Ad, (OSDMap)tmpParams);
            //If no maturity bits are set, set PG maturity bit. This works
            // around a viewer bug. It simplifies the ability to search ads
            // based on maturity level. 0x4e is bits 1 (old viewers mature), 2 (pg), 3 (Mature) and 6 (Adult).
            if ((ad.Flags & 0x4e) == 0)
            {
                ad.Flags |= 0x04;
            }

            if (Service.ClassifiedUpdate(ad, ref result))
            {
                response.Result = OSD.SerializeMembers(ad);
                return(true);
            }

            response.Error.Code    = ErrorCode.InternalError;
            response.Error.Message = string.Format("{0}", result);
            return(false);
        }
コード例 #5
0
        public bool AvatarNotesRequest(OSDMap json, ref JsonRpcResponse response)
        {
            OSD tmpParams;

            if (!json.TryGetValue("params", out tmpParams) || !(tmpParams is OSDMap))
            {
                response.Error.Code    = ErrorCode.ParseError;
                response.Error.Message = "Params missing";
                m_log.DebugFormat("Avatar Notes Request");
                return(false);
            }

            UserProfileNotes note = new UserProfileNotes();
            object           Note = (object)note;

            OSD.DeserializeMembers(ref Note, (OSDMap)tmpParams);
            if (Service.AvatarNotesRequest(ref note))
            {
                response.Result = OSD.SerializeMembers(note);
                return(true);
            }

            response.Error.Code    = ErrorCode.InternalError;
            response.Error.Message = "Error reading notes";
            return(false);
        }
コード例 #6
0
        public bool PicksUpdate(OSDMap json, ref JsonRpcResponse response)
        {
            OSD tmpParams;

            if (!json.TryGetValue("params", out tmpParams) || !(tmpParams is OSDMap))
            {
                response.Error.Code    = ErrorCode.ParseError;
                response.Error.Message = "no parameters supplied";
                m_log.DebugFormat("Avatar Picks Update Request");
                return(false);
            }

            string          result = string.Empty;
            UserProfilePick pick   = new UserProfilePick();
            object          Pick   = (object)pick;

            OSD.DeserializeMembers(ref Pick, (OSDMap)tmpParams);
            if (Service.PicksUpdate(ref pick, ref result))
            {
                response.Result = OSD.SerializeMembers(pick);
                return(true);
            }

            response.Error.Code    = ErrorCode.InternalError;
            response.Error.Message = "unable to update pick";

            return(false);
        }
コード例 #7
0
        public OSD GetGeneric(string key)
        {
            OSD value;

            m_Generic.TryGetValue(key, out value);
            return(value);
        }
コード例 #8
0
ファイル: Login.cs プロジェクト: careytews/ALIVE
        public static InventoryFolder[] ParseInventoryFolders(string key, UUID owner, OSDMap reply)
        {
            List <InventoryFolder> folders = new List <InventoryFolder>();

            OSD skeleton;

            if (reply.TryGetValue(key, out skeleton) && skeleton.Type == OSDType.Array)
            {
                OSDArray array = (OSDArray)skeleton;

                for (int i = 0; i < array.Count; i++)
                {
                    if (array[i].Type == OSDType.Map)
                    {
                        OSDMap          map    = (OSDMap)array[i];
                        InventoryFolder folder = new InventoryFolder(map["folder_id"].AsUUID());
                        folder.PreferredType = (AssetType)map["type_default"].AsInteger();
                        folder.Version       = map["version"].AsInteger();
                        folder.OwnerID       = owner;
                        folder.ParentUUID    = map["parent_id"].AsUUID();
                        folder.Name          = map["name"].AsString();

                        folders.Add(folder);
                    }
                }
            }

            return(folders.ToArray());
        }
コード例 #9
0
        public bool CycleFromOSD(OSD osd)
        {
            OSDMap map = osd as OSDMap;

            if (map == null)
            {
                return(false);
            }
            if (!map.TryGetValue("type", out OSD tmp))
            {
                return(false);
            }
            string type = tmp.AsString();

            if (type != "daycycle")
            {
                return(false);
            }
            Cycle = new DayCycle();
            Cycle.FromOSD(map);

            InvalidateCaches();

            return(true);
        }
コード例 #10
0
        /// <summary>
        /// Finds any legacy materials stored in DynAttrs that may exist for this part and add them to 'm_regionMaterials'.
        /// </summary>
        /// <param name="part"></param>
        private void GetLegacyStoredMaterialsInPart(SceneObjectPart part)
        {
            if (part.DynAttrs == null)
            {
                return;
            }

            OSD      OSMaterials = null;
            OSDArray matsArr     = null;

            lock (part.DynAttrs)
            {
                if (part.DynAttrs.ContainsStore("OpenSim", "Materials"))
                {
                    OSDMap materialsStore = part.DynAttrs.GetStore("OpenSim", "Materials");

                    if (materialsStore == null)
                    {
                        return;
                    }

                    materialsStore.TryGetValue("Materials", out OSMaterials);
                }

                if (OSMaterials != null && OSMaterials is OSDArray)
                {
                    matsArr = OSMaterials as OSDArray;
                }
                else
                {
                    return;
                }
            }

            if (matsArr == null)
            {
                return;
            }

            foreach (OSD elemOsd in matsArr)
            {
                if (elemOsd != null && elemOsd is OSDMap)
                {
                    OSDMap matMap = elemOsd as OSDMap;
                    if (matMap.ContainsKey("ID") && matMap.ContainsKey("Material"))
                    {
                        try
                        {
                            lock (m_regionMaterials)
                                m_regionMaterials[matMap["ID"].AsUUID()] = (OSDMap)matMap["Material"];
                        }
                        catch (Exception e)
                        {
                            m_log.Warn("[Materials]: exception decoding persisted legacy material: " + e.ToString());
                        }
                    }
                }
            }
        }
コード例 #11
0
 public void AddOpenSimExtraFeature(string name, OSD value)
 {
     lock (m_features)
     {
         OSDMap extrasMap;
         if (m_features.TryGetValue("OpenSimExtras", out OSD extra))
         {
             extrasMap = extra as OSDMap;
         }
         else
         {
             extrasMap = new OSDMap();
         }
         extrasMap[name]             = value;
         m_features["OpenSimExtras"] = extrasMap;
     }
 }
コード例 #12
0
        /// <summary>
        /// Fill object with data from OSDMap
        /// </summary>
        /// <param name="args"></param>
        public void UnpackUpdateMessage(OSDMap args)
        {
            OSD tmp;

            if (args.TryGetValue("animation", out tmp))
            {
                animID = tmp.AsUUID();
            }
            if (args.TryGetValue("object_id", out tmp))
            {
                objectID = tmp.AsUUID();
            }
            if (args.TryGetValue("seq_num", out tmp))
            {
                sequenceNum = tmp.AsInteger();
            }
        }
コード例 #13
0
        public void Unpack(OSD data)
        {
            OSDMap map = (OSDMap)data;
            OSD    tmpOSD;

            if (map.TryGetValue("InboundVersion", out tmpOSD))
            {
                InboundVersion = (float)tmpOSD.AsReal();
            }
            if (map.TryGetValue("OutboundVersion", out tmpOSD))
            {
                OutboundVersion = (float)tmpOSD.AsReal();
            }
            if (map.TryGetValue("WearablesCount", out tmpOSD))
            {
                WearablesCount = tmpOSD.AsInteger();
            }
        }
コード例 #14
0
ファイル: DAMap.cs プロジェクト: osCore2/osCore2-1
        /// <summary>
        /// Retrieve a Dynamic Attribute store
        /// </summary>
        /// <param name="ns">namespace for the store - use "OpenSim" for in-core modules</param>
        /// <param name="storeName">name of the store within the namespace</param>
        /// <returns>an OSDMap representing the stored data, or null if not found</returns>
        public OSDMap GetStore(string ns, string storeName)
        {
            OSD namespaceOsd;

            lock (this)
            {
                if (m_map.TryGetValue(ns, out namespaceOsd))
                {
                    OSD store;

                    if (((OSDMap)namespaceOsd).TryGetValue(storeName, out store))
                    {
                        return((OSDMap)store);
                    }
                }
            }

            return(null);
        }
コード例 #15
0
        public bool TryGetFeature(string name, out OSD value)
        {
            if (m_log.IsDebugEnabled)
            {
                m_log.DebugFormat("{0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
            }

            lock (m_features)
                return(m_features.TryGetValue(name, out value));
        }
コード例 #16
0
 public bool TryGetFeature(string name, out OSD value)
 {
     m_featuresRwLock.AcquireReaderLock(-1);
     try
     {
         return(m_features.TryGetValue(name, out value));
     }
     finally
     {
         m_featuresRwLock.ReleaseReaderLock();
     }
 }
コード例 #17
0
        private void OnSimulatorFeaturesRequest(UUID agentID, ref OSDMap features)
        {
            if (m_UserManagement != null && !string.IsNullOrEmpty(m_MapImageServerURL) && !m_UserManagement.IsLocalGridUser(agentID))
            {
                OSD extras;
                if (!features.TryGetValue("OpenSimExtras", out extras))
                {
                    extras = new OSDMap();
                }

                ((OSDMap)extras)["map-server-url"] = m_MapImageServerURL;
            }
        }
コード例 #18
0
ファイル: Login.cs プロジェクト: careytews/ALIVE
        public static string ParseString(string key, OSDMap reply)
        {
            OSD osd;

            if (reply.TryGetValue(key, out osd))
            {
                return(osd.AsString());
            }
            else
            {
                return(String.Empty);
            }
        }
コード例 #19
0
ファイル: Login.cs プロジェクト: careytews/ALIVE
        public static UUID ParseUUID(string key, OSDMap reply)
        {
            OSD osd;

            if (reply.TryGetValue(key, out osd))
            {
                return(osd.AsUUID());
            }
            else
            {
                return(UUID.Zero);
            }
        }
コード例 #20
0
ファイル: Login.cs プロジェクト: careytews/ALIVE
        public static uint ParseUInt(string key, OSDMap reply)
        {
            OSD osd;

            if (reply.TryGetValue(key, out osd))
            {
                return((uint)osd.AsInteger());
            }
            else
            {
                return(0);
            }
        }
コード例 #21
0
        protected virtual void UnpackData(OSDMap args, AgentDestinationData data)
        {
            OSD tmpOSD;

            // retrieve the input arguments
            if (args.TryGetValue("destination_x", out tmpOSD) && tmpOSD != null)
            {
                Int32.TryParse(tmpOSD.AsString(), out data.x);
            }
            else
            {
                m_log.WarnFormat("  -- request didn't have destination_x");
            }

            if (args.TryGetValue("destination_y", out tmpOSD) && tmpOSD != null)
            {
                Int32.TryParse(tmpOSD.AsString(), out data.y);
            }
            else
            {
                m_log.WarnFormat("  -- request didn't have destination_y");
            }

            if (args.TryGetValue("destination_uuid", out tmpOSD) && tmpOSD != null)
            {
                UUID.TryParse(tmpOSD.AsString(), out data.uuid);
            }

            if (args.TryGetValue("destination_name", out tmpOSD) && tmpOSD != null)
            {
                data.name = tmpOSD.ToString();
            }

            if (args.TryGetValue("teleport_flags", out tmpOSD) && tmpOSD != null)
            {
                data.flags = tmpOSD.AsUInteger();
            }
        }
コード例 #22
0
        public void FromOSD(OSD osd)
        {
            OSDMap map = osd as OSDMap;

            if (map == null)
            {
                return;
            }

            OSD otmp;

            if (map.TryGetValue("day_cycle", out otmp) && otmp is OSDMap)
            {
                Cycle = new DayCycle();
                Cycle.FromOSD(otmp as OSDMap);
            }
            if (Cycle == null)
            {
                Cycle = new DayCycle();
            }

            if (map.TryGetValue("day_length", out otmp))
            {
                DayLength = otmp;
            }
            if (map.TryGetValue("day_offset", out otmp))
            {
                DayOffset = otmp;
            }
            if (map.TryGetValue("flags", out otmp))
            {
                Flags = otmp;
            }
            if (map.TryGetValue("env_version", out otmp))
            {
                version = otmp;
            }
            else
            {
                ++version;
            }

            if (map.TryGetValue("track_altitudes", out otmp) && otmp is OSDArray)
            {
                OSDArray alt = otmp as OSDArray;

                for (int i = 0; i < alt.Count && i < 3; ++i)
                {
                    Altitudes[i] = alt[i];
                }

                SortAltitudes();
            }

            IsLegacy = false;
            InvalidateCaches();
        }
コード例 #23
0
        public bool FromAssetOSD(string name, OSD osd)
        {
            OSDMap map = osd as OSDMap;

            if (map == null)
            {
                return(false);
            }
            if (!map.TryGetValue("type", out OSD tmp))
            {
                return(false);
            }
            string type = tmp.AsString();

            bool ok = false;

            if (type == "water")
            {
                if (Cycle == null)
                {
                    Cycle = new DayCycle();
                }
                ok = Cycle.replaceWaterFromOSD(name, map);
            }
            else
            {
                if (type == "daycycle")
                {
                    Cycle = new DayCycle();
                    Cycle.FromOSD(map);
                    ok = true;
                }
                else if (type == "sky")
                {
                    if (Cycle == null)
                    {
                        Cycle = new DayCycle();
                    }
                    ok = Cycle.replaceSkyFromOSD(name, map);
                }
            }
            if (ok && !string.IsNullOrWhiteSpace(name))
            {
                Cycle.Name = name;
            }

            InvalidateCaches();
            return(ok);
        }
コード例 #24
0
ファイル: Login.cs プロジェクト: careytews/ALIVE
        public static Vector3 ParseVector3(string key, OSDMap reply)
        {
            OSD osd;

            if (reply.TryGetValue(key, out osd))
            {
                if (osd.Type == OSDType.Array)
                {
                    return(((OSDArray)osd).AsVector3());
                }
                else if (osd.Type == OSDType.String)
                {
                    OSDArray array = (OSDArray)OSDParser.DeserializeLLSDNotation(osd.AsString());
                    return(array.AsVector3());
                }
            }

            return(Vector3.Zero);
        }
コード例 #25
0
        public bool AvatarPicksRequest(OSDMap json, ref JsonRpcResponse response)
        {
            OSD tmpParams;

            if (!json.TryGetValue("params", out tmpParams) || !(tmpParams is OSDMap))
            {
                response.Error.Code = ErrorCode.ParseError;
                m_log.DebugFormat("Avatar Picks Request");
                return(false);
            }

            OSDMap request   = (OSDMap)tmpParams;
            UUID   creatorId = new UUID(request["creatorId"].AsString());

            OSDArray data = (OSDArray)Service.AvatarPicksRequest(creatorId);

            response.Result = data;

            return(true);
        }
コード例 #26
0
ファイル: Login.cs プロジェクト: careytews/ALIVE
        public static UUID ParseMappedUUID(string key, string key2, OSDMap reply)
        {
            OSD folderOSD;

            if (reply.TryGetValue(key, out folderOSD) && folderOSD.Type == OSDType.Array)
            {
                OSDArray array = (OSDArray)folderOSD;
                if (array.Count == 1 && array[0].Type == OSDType.Map)
                {
                    OSDMap map = (OSDMap)array[0];
                    OSD    folder;
                    if (map.TryGetValue(key2, out folder))
                    {
                        return(folder.AsUUID());
                    }
                }
            }

            return(UUID.Zero);
        }
コード例 #27
0
        protected virtual void OnSimulatorFeaturesRequest(UUID agentID, ref OSDMap features)
        {
            OSD extras;

            if (!features.TryGetValue("OpenSimExtras", out extras))
            {
                extras = new OSDMap();
            }

            if (m_SayRange == null)
            {
                // Do this only once
                m_SayRange     = new OSDInteger(m_saydistance);
                m_WhisperRange = new OSDInteger(m_whisperdistance);
                m_ShoutRange   = new OSDInteger(m_shoutdistance);
            }

            ((OSDMap)extras)["say-range"]     = m_SayRange;
            ((OSDMap)extras)["whisper-range"] = m_WhisperRange;
            ((OSDMap)extras)["shout-range"]   = m_ShoutRange;
        }
コード例 #28
0
        public bool PicksDelete(OSDMap json, ref JsonRpcResponse response)
        {
            OSD tmpParams;

            if (!json.TryGetValue("params", out tmpParams) || !(tmpParams is OSDMap))
            {
                response.Error.Code = ErrorCode.ParseError;
                m_log.DebugFormat("Avatar Picks Delete Request");
                return(false);
            }

            OSDMap request = tmpParams as OSDMap;
            UUID   pickId  = new UUID(request["pickId"].AsString());

            if (Service.PicksDelete(pickId))
            {
                return(true);
            }

            response.Error.Code    = ErrorCode.InternalError;
            response.Error.Message = "data error removing record";
            return(false);
        }
コード例 #29
0
        public bool NotesUpdate(OSDMap json, ref JsonRpcResponse response)
        {
            OSD tmpParams;

            if (!json.TryGetValue("params", out tmpParams) || !(tmpParams is OSDMap))
            {
                response.Error.Code    = ErrorCode.ParseError;
                response.Error.Message = "No parameters";
                m_log.DebugFormat("Avatar Notes Update Request");
                return(false);
            }

            string           result = string.Empty;
            UserProfileNotes note   = new UserProfileNotes();
            object           Notes  = (object)note;

            OSD.DeserializeMembers(ref Notes, (OSDMap)tmpParams);
            if (Service.NotesUpdate(ref note, ref result))
            {
                response.Result = OSD.SerializeMembers(note);
                return(true);
            }
            return(true);
        }
コード例 #30
0
ファイル: Login.cs プロジェクト: RavenB/gridsearch
        public static UUID ParseMappedUUID(string key, string key2, OSDMap reply)
        {
            OSD folderOSD;
            if (reply.TryGetValue(key, out folderOSD) && folderOSD.Type == OSDType.Array)
            {
                OSDArray array = (OSDArray)folderOSD;
                if (array.Count == 1 && array[0].Type == OSDType.Map)
                {
                    OSDMap map = (OSDMap)array[0];
                    OSD folder;
                    if (map.TryGetValue(key2, out folder))
                        return folder.AsUUID();
                }
            }

            return UUID.Zero;
        }
コード例 #31
0
ファイル: Login.cs プロジェクト: RavenB/gridsearch
        public static Vector3 ParseVector3(string key, OSDMap reply)
        {
            OSD osd;
            if (reply.TryGetValue(key, out osd))
            {
                if (osd.Type == OSDType.Array)
                {
                    return ((OSDArray)osd).AsVector3();
                }
                else if (osd.Type == OSDType.String)
                {
                    OSDArray array = (OSDArray)OSDParser.DeserializeLLSDNotation(osd.AsString());
                    return array.AsVector3();
                }
            }

            return Vector3.Zero;
        }
コード例 #32
0
ファイル: Login.cs プロジェクト: RavenB/gridsearch
 public static string ParseString(string key, OSDMap reply)
 {
     OSD osd;
     if (reply.TryGetValue(key, out osd))
         return osd.AsString();
     else
         return String.Empty;
 }
コード例 #33
0
ファイル: Login.cs プロジェクト: RavenB/gridsearch
 public static UUID ParseUUID(string key, OSDMap reply)
 {
     OSD osd;
     if (reply.TryGetValue(key, out osd))
         return osd.AsUUID();
     else
         return UUID.Zero;
 }
コード例 #34
0
ファイル: Login.cs プロジェクト: RavenB/gridsearch
 public static uint ParseUInt(string key, OSDMap reply)
 {
     OSD osd;
     if (reply.TryGetValue(key, out osd))
         return osd.AsUInteger();
     else
         return 0;
 }
コード例 #35
0
ファイル: Login.cs プロジェクト: RavenB/gridsearch
        /// <summary>
        /// Parse LLSD Login Reply Data
        /// </summary>
        /// <param name="reply">An <seealso cref="OSDMap"/> 
        /// contaning the login response data</param>
        /// <remarks>XML-RPC logins do not require this as XML-RPC.NET 
        /// automatically populates the struct properly using attributes</remarks>
        public void Parse(OSDMap reply)
        {
            try
            {
                AgentID = ParseUUID("agent_id", reply);
                SessionID = ParseUUID("session_id", reply);
                SecureSessionID = ParseUUID("secure_session_id", reply);
                FirstName = ParseString("first_name", reply).Trim('"');
                LastName = ParseString("last_name", reply).Trim('"');
                StartLocation = ParseString("start_location", reply);
                AgentAccess = ParseString("agent_access", reply);
                LookAt = ParseVector3("look_at", reply);
                Reason = ParseString("reason", reply);
                Message = ParseString("message", reply);

                Login = reply["login"].AsString();
                Success = reply["login"].AsBoolean();
            }
            catch (OSDException e)
            {
                Logger.Log("Login server returned (some) invalid data: " + e.Message, Helpers.LogLevel.Warning);
            }

            // Home
            OSDMap home = null;
            OSD osdHome = OSDParser.DeserializeLLSDNotation(reply["home"].AsString());

            if (osdHome.Type == OSDType.Map)
            {
                home = (OSDMap)osdHome;

                OSD homeRegion;
                if (home.TryGetValue("region_handle", out homeRegion) && homeRegion.Type == OSDType.Array)
                {
                    OSDArray homeArray = (OSDArray)homeRegion;
                    if (homeArray.Count == 2)
                        HomeRegion = Utils.UIntsToLong((uint)homeArray[0].AsInteger(), (uint)homeArray[1].AsInteger());
                    else
                        HomeRegion = 0;
                }

                HomePosition = ParseVector3("position", home);
                HomeLookAt = ParseVector3("look_at", home);
            }
            else
            {
                HomeRegion = 0;
                HomePosition = Vector3.Zero;
                HomeLookAt = Vector3.Zero;
            }

            CircuitCode = (int)ParseUInt("circuit_code", reply);
            RegionX = (int)ParseUInt("region_x", reply);
            RegionY = (int)ParseUInt("region_y", reply);
            SimPort = (short)ParseUInt("sim_port", reply);
            string simIP = ParseString("sim_ip", reply);
            IPAddress.TryParse(simIP, out SimIP);
            SeedCapability = ParseString("seed_capability", reply);

            // Buddy list
            OSD buddyLLSD;
            if (reply.TryGetValue("buddy-list", out buddyLLSD) && buddyLLSD.Type == OSDType.Array)
            {
                List<BuddyListEntry> buddys = new List<BuddyListEntry>();
                OSDArray buddyArray = (OSDArray)buddyLLSD;
                for (int i = 0; i < buddyArray.Count; i++)
                {
                    if (buddyArray[i].Type == OSDType.Map)
                    {
                        BuddyListEntry bud = new BuddyListEntry();
                        OSDMap buddy = (OSDMap)buddyArray[i];

                        bud.buddy_id = buddy["buddy_id"].AsString();
                        bud.buddy_rights_given = (int)ParseUInt("buddy_rights_given", buddy);
                        bud.buddy_rights_has = (int)ParseUInt("buddy_rights_has", buddy);

                        buddys.Add(bud);
                    }
                    BuddyList = buddys.ToArray();
                }
            }

            SecondsSinceEpoch = (int)ParseUInt("seconds_since_epoch", reply);

            InventoryRoot = ParseMappedUUID("inventory-root", "folder_id", reply);
            InventorySkeleton = ParseInventorySkeleton("inventory-skeleton", reply);

            LibraryOwner = ParseMappedUUID("inventory-lib-owner", "agent_id", reply);
            LibraryRoot = ParseMappedUUID("inventory-lib-root", "folder_id", reply);
            LibrarySkeleton = ParseInventorySkeleton("inventory-skel-lib", reply);
        }
コード例 #36
0
ファイル: Login.cs プロジェクト: 3di/3di-viewer-rei-libs
        public void Parse(OSDMap reply)
        {
            try
            {
                AgentID = ParseUUID("agent_id", reply);
                SessionID = ParseUUID("session_id", reply);
                SecureSessionID = ParseUUID("secure_session_id", reply);
                FirstName = ParseString("first_name", reply).Trim('"');
                LastName = ParseString("last_name", reply).Trim('"');
                StartLocation = ParseString("start_location", reply);
                AgentAccess = ParseString("agent_access", reply);
                LookAt = ParseVector3("look_at", reply);
                AssetServerUri = ParseString("asset_server_address", reply);
            }
            catch (OSDException e)
            {
                Logger.DebugLog("Login server returned (some) invalid data: " + e.Message);
            }

            // Home
            OSDMap home = null;
            OSD osdHome = OSDParser.DeserializeLLSDNotation(reply["home"].AsString());

            if (osdHome.Type == OSDType.Map)
            {
                home = (OSDMap)osdHome;

                OSD homeRegion;
                if (home.TryGetValue("region_handle", out homeRegion) && homeRegion.Type == OSDType.Array)
                {
                    OSDArray homeArray = (OSDArray)homeRegion;
                    if (homeArray.Count == 2)
                        HomeRegion = Utils.UIntsToLong((uint)homeArray[0].AsInteger(), (uint)homeArray[1].AsInteger());
                    else
                        HomeRegion = 0;
                }

                HomePosition = ParseVector3("position", home);
                HomeLookAt = ParseVector3("look_at", home);
            }
            else
            {
                HomeRegion = 0;
                HomePosition = Vector3.Zero;
                HomeLookAt = Vector3.Zero;
            }

            CircuitCode = ParseUInt("circuit_code", reply);
            RegionX = ParseUInt("region_x", reply);
            RegionY = ParseUInt("region_y", reply);
            SimPort = (ushort)ParseUInt("sim_port", reply);
            string simIP = ParseString("sim_ip", reply);
            IPAddress.TryParse(simIP, out SimIP);
            SeedCapability = ParseString("seed_capability", reply);

            // Buddy list
            OSD buddyLLSD;
            if (reply.TryGetValue("buddy-list", out buddyLLSD) && buddyLLSD.Type == OSDType.Array)
            {
                OSDArray buddyArray = (OSDArray)buddyLLSD;
                BuddyList = new FriendInfo[buddyArray.Count];

                for (int i = 0; i < buddyArray.Count; i++)
                {
                    if (buddyArray[i].Type == OSDType.Map)
                    {
                        OSDMap buddy = (OSDMap)buddyArray[i];
                        BuddyList[i] = new FriendInfo(
                            ParseUUID("buddy_id", buddy),
                            (FriendRights)ParseUInt("buddy_rights_given", buddy),
                            (FriendRights)ParseUInt("buddy_rights_has", buddy));
                    }
                }
            }

            SecondsSinceEpoch = Utils.UnixTimeToDateTime(ParseUInt("seconds_since_epoch", reply));
            InventoryRoot = ParseMappedUUID("inventory-root", "folder_id", reply);
            InventorySkeleton = ParseInventoryFolders("inventory-skeleton", AgentID, reply);
            LibraryRoot = ParseMappedUUID("inventory-lib-root", "folder_id", reply);
            LibraryOwner = ParseMappedUUID("inventory-lib-owner", "agent_id", reply);
            LibrarySkeleton = ParseInventoryFolders("inventory-skel-lib", LibraryOwner, reply);
        }
コード例 #37
0
ファイル: Login.cs プロジェクト: RavenB/gridsearch
        public InventoryFolder[] ParseInventorySkeleton(string key, OSDMap reply)
        {
            List<InventoryFolder> folders = new List<InventoryFolder>();

            OSD skeleton;
            if (reply.TryGetValue(key, out skeleton) && skeleton.Type == OSDType.Array)
            {
                OSDArray array = (OSDArray)skeleton;
                for (int i = 0; i < array.Count; i++)
                {
                    if (array[i].Type == OSDType.Map)
                    {
                        OSDMap map = (OSDMap)array[i];
                        InventoryFolder folder = new InventoryFolder(map["folder_id"].AsUUID());
                        folder.Name = map["name"].AsString();
                        folder.ParentUUID = map["parent_id"].AsUUID();
                        folder.PreferredType = (AssetType)map["type_default"].AsInteger();
                        folder.Version = map["version"].AsInteger();
                        folders.Add(folder);
                    }
                }
            }
            return folders.ToArray();
        }
コード例 #38
0
ファイル: Login.cs プロジェクト: RavenB/gridsearch
        public static Guid ParseMappedGuid(string key, string key2, OSDMap reply)
        {
            OSD folderOSD;
            if (reply.TryGetValue(key, out folderOSD) && folderOSD.Type == OSDType.Array)
            {
                OSDArray array = (OSDArray)folderOSD;
                if (array.Count == 1 && array[0].Type == OSDType.Map)
                {
                    OSDMap map = (OSDMap)array[0];
                    OSD folder;
                    if (map.TryGetValue(key2, out folder))
                        return folder.AsGuid();
                }
            }

            return Guid.Empty;
        }
コード例 #39
0
        public bool CreateAgent(GridRegion source, GridRegion destination, AgentCircuitData aCircuit, uint flags, EntityTransferContext ctx, out string reason)
        {
            reason = String.Empty;

            if (destination == null)
            {
                reason = "Destination not found";
                m_log.Debug("[REMOTE SIMULATION CONNECTOR]: Create agent destination is null");
                return(false);
            }

            m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: Creating agent at {0}", destination.ServerURI);

            string uri = destination.ServerURI + AgentPath() + aCircuit.AgentID + "/";
            OSD    tmpOSD;

            try
            {
                OSDMap args = aCircuit.PackAgentCircuitData(ctx);
                if (ctx == null)
                {
                    ctx = new EntityTransferContext();
                }
                args["context"] = ctx.Pack();
                PackData(args, source, aCircuit, destination, flags);

                OSDMap result  = WebUtil.PostToServiceCompressed(uri, args, 30000);
                bool   success = result["success"].AsBoolean();
                if (success && result.TryGetValue("_Result", out tmpOSD) && tmpOSD is OSDMap)
                {
                    OSDMap data = (OSDMap)tmpOSD;
                    reason  = data["reason"].AsString();
                    success = data["success"].AsBoolean();
                    return(success);
                }

                // Try the old version, uncompressed
                result = WebUtil.PostToService(uri, args, 30000, false);

                success = result["success"].AsBoolean();
                if (success)
                {
                    if (result.TryGetValue("_Result", out tmpOSD) && tmpOSD is OSDMap)
                    {
                        OSDMap data = (OSDMap)tmpOSD;
                        reason  = data["reason"].AsString();
                        success = data["success"].AsBoolean();

                        m_log.WarnFormat(
                            "[REMOTE SIMULATION CONNECTOR]: Remote simulator {0} did not accept compressed transfer, suggest updating it.", destination.RegionName);
                        return(success);
                    }
                }

                m_log.WarnFormat(
                    "[REMOTE SIMULATION CONNECTOR]: Failed to create agent {0} {1} at remote simulator {2}",
                    aCircuit.firstname, aCircuit.lastname, destination.RegionName);
                reason = result["Message"] != null ? result["Message"].AsString() : "error";
                return(false);
            }
            catch (Exception e)
            {
                m_log.Warn("[REMOTE SIMULATION CONNECTOR]: CreateAgent failed with exception: " + e.ToString());
                reason = e.Message;
            }

            return(false);
        }
コード例 #40
0
ファイル: Login.cs プロジェクト: RavenB/gridsearch
 public static Guid ParseGuid(string key, OSDMap reply)
 {
     OSD osd;
     if (reply.TryGetValue(key, out osd))
         return osd.AsGuid();
     else
         return Guid.Empty;
 }