示例#1
0
        protected override void UnpackData(OSDMap args, AgentDestinationData d, Hashtable request)
        {
            base.UnpackData(args, d, request);
            ExtendedAgentDestinationData data = (ExtendedAgentDestinationData)d;
            try
            {
                if (args.ContainsKey("gatekeeper_host") && args["gatekeeper_host"] != null)
                    data.host = args["gatekeeper_host"].AsString();
                if (args.ContainsKey("gatekeeper_port") && args["gatekeeper_port"] != null)
                    Int32.TryParse(args["gatekeeper_port"].AsString(), out data.port);
                if (args.ContainsKey("gatekeeper_serveruri") && args["gatekeeper_serveruri"] != null)
                    data.gatekeeperServerURI = args["gatekeeper_serveruri"];
                if (args.ContainsKey("destination_serveruri") && args["destination_serveruri"] != null)
                    data.destinationServerURI = args["destination_serveruri"];

            }
            catch (InvalidCastException)
            {
                m_log.ErrorFormat("[HOME AGENT HANDLER]: Bad cast in UnpackData");
            }

            string callerIP = GetCallerIP(request);
            // Verify if this call came from the login server
            if (callerIP == m_LoginServerIP)
                data.fromLogin = true;

        }
示例#2
0
        public void Unpack(OSDMap args)
        {
            if (args["point"] != null)
                AttachPoint = args["point"].AsInteger();

            ItemID = args.ContainsKey("item") ? args["item"].AsUUID() : UUID.Zero;
            AssetID = args.ContainsKey("asset") ? args["asset"].AsUUID() : UUID.Zero;
        }
        public override void FromOSD(OSDMap map)
        {
            AgentInfo = new IAgentInfo();
            AgentInfo.FromOSD((OSDMap) (map["AgentInfo"]));
            UserAccount = new UserAccount();
            UserAccount.FromOSD((OSDMap)(map["UserAccount"]));
            if (!map.ContainsKey("ActiveGroup"))
                ActiveGroup = null;
            else
            {
                ActiveGroup = new GroupMembershipData();
                ActiveGroup.FromOSD((OSDMap)(map["ActiveGroup"]));
            }

            GroupMemberships = ((OSDArray) map["GroupMemberships"]).ConvertAll<GroupMembershipData>((o) =>
                                                                                                        {
                                                                                                            GroupMembershipData
                                                                                                                group =
                                                                                                                    new GroupMembershipData
                                                                                                                        ();
                                                                                                            group
                                                                                                                .FromOSD
                                                                                                                ((OSDMap
                                                                                                                 ) o);
                                                                                                            return group;
                                                                                                        });
            OfflineMessages = ((OSDArray) map["OfflineMessages"]).ConvertAll<GridInstantMessage>((o) =>
                                                                                                     {
                                                                                                         GridInstantMessage
                                                                                                             group =
                                                                                                                 new GridInstantMessage
                                                                                                                     ();
                                                                                                         group.FromOSD(
                                                                                                             (OSDMap) o);
                                                                                                         return group;
                                                                                                     });
            MuteList = ((OSDArray) map["MuteList"]).ConvertAll<MuteList>((o) =>
                                                                             {
                                                                                 MuteList group = new MuteList();
                                                                                 group.FromOSD((OSDMap) o);
                                                                                 return group;
                                                                             });

            if (map.ContainsKey("Appearance"))
            {
                Appearance = new AvatarAppearance();
                Appearance.FromOSD((OSDMap)map["Appearance"]);
            }

            if (map.ContainsKey("FriendOnlineStatuses"))
                FriendOnlineStatuses = ((OSDArray)map["FriendOnlineStatuses"]).ConvertAll<UUID>((o) => { return o; });

            if (map.ContainsKey("Friends"))
                Friends = ((OSDArray)map["Friends"]).ConvertAll<FriendInfo>((o) =>
                { 
                    FriendInfo f = new FriendInfo();
                    f.FromOSD((OSDMap)o);
                    return f; 
                });
        }
        /// <summary>
        ///     Region side
        /// </summary>
        /// <param name="message"></param>
        /// <returns></returns>
        protected OSDMap OnMessageReceived(OSDMap message)
        {
            //We need to check and see if this is an AgentStatusChange
            if (message.ContainsKey("Method") && message["Method"] == "UpdateAvatarAppearance")
            {
                var appearance = new AvatarAppearance(message["AgentID"], (OSDMap)message["Appearance"]);
                ISceneManager manager = m_registry.RequestModuleInterface<ISceneManager>();

                if (manager != null)
                {
                    foreach (IScene scene in manager.Scenes)
                    {
                        IScenePresence sp = scene.GetScenePresence(appearance.Owner);
                        if (sp != null && !sp.IsChildAgent)
                        {
                            var avappmodule = sp.RequestModuleInterface<IAvatarAppearanceModule>();
                            if (avappmodule != null)
                            {
                                avappmodule.Appearance = appearance;
                                avappmodule.SendAppearanceToAgent(sp);
                                avappmodule.SendAppearanceToAllOtherAgents();
                            }
                        }
                    }
                }
            }

            return null;
        }
示例#5
0
        OSDMap GetParcelsByRegion (OSDMap map)
        {
            var resp = new OSDMap ();
            resp ["Parcels"] = new OSDArray ();
            resp ["Total"] = OSD.FromInteger (0);

            var directory = DataPlugins.RequestPlugin<IDirectoryServiceConnector> ();

            if (directory != null && map.ContainsKey ("Region") == true) {
                UUID regionID = UUID.Parse (map ["Region"]);
                UUID scopeID = map.ContainsKey ("ScopeID") ? UUID.Parse (map ["ScopeID"].ToString ()) : UUID.Zero;
                UUID owner = map.ContainsKey ("Owner") ? UUID.Parse (map ["Owner"].ToString ()) : UUID.Zero;
                uint start = map.ContainsKey ("Start") ? uint.Parse (map ["Start"].ToString ()) : 0;
                uint count = map.ContainsKey ("Count") ? uint.Parse (map ["Count"].ToString ()) : 10;
                ParcelFlags flags = map.ContainsKey ("Flags") ? (ParcelFlags)int.Parse (map ["Flags"].ToString ()) : ParcelFlags.None;
                ParcelCategory category = map.ContainsKey ("Category") ? (ParcelCategory)uint.Parse (map ["Flags"].ToString ()) : ParcelCategory.Any;
                uint total = directory.GetNumberOfParcelsByRegion (regionID, owner, flags, category);

                if (total > 0) {
                    resp ["Total"] = OSD.FromInteger ((int)total);
                    if (count == 0) {
                        return resp;
                    }
                    List<LandData> regionParcels = directory.GetParcelsByRegion (start, count, regionID, owner, flags, category);
                    OSDArray parcels = new OSDArray (regionParcels.Count);
                    regionParcels.ForEach (delegate (LandData parcel) {
                        parcels.Add (LandData2WebOSD (parcel));
                    });
                    resp ["Parcels"] = parcels;
                }
            }

            return resp;
        }
示例#6
0
 public void UnpackUpdateMessage(OSDMap args)
 {
     if (args.ContainsKey("animation"))
         animID = args["animation"].AsUUID();
     if (args.ContainsKey("object_id"))
         objectID = args["object_id"].AsUUID();
     if (args.ContainsKey("seq_num"))
         sequenceNum = args["seq_num"].AsInteger();
 }
示例#7
0
        OSDMap GetGroups (OSDMap map)
        {
            var resp = new OSDMap ();
            var start = map.ContainsKey ("Start") ? map ["Start"].AsUInteger () : 0;
            resp ["Start"] = start;
            resp ["Total"] = 0;

            var groups = DataPlugins.RequestPlugin<IGroupsServiceConnector> ();
            var Groups = new OSDArray ();

            if (groups != null) {
                var sort = new Dictionary<string, bool> ();
                var boolFields = new Dictionary<string, bool> ();

                if (map.ContainsKey ("Sort") && map ["Sort"].Type == OSDType.Map) {
                    var fields = (OSDMap)map ["Sort"];
                    foreach (string field in fields.Keys) {
                        sort [field] = int.Parse (fields [field]) != 0;
                    }
                }
                if (map.ContainsKey ("BoolFields") && map ["BoolFields"].Type == OSDType.Map) {
                    var fields = (OSDMap)map ["BoolFields"];
                    foreach (string field in fields.Keys) {
                        boolFields [field] = int.Parse (fields [field]) != 0;
                    }
                }
                var reply = groups.GetGroupRecords (
                    AdminAgentID,
                    start,
                    map.ContainsKey ("Count") ? map ["Count"].AsUInteger () : 10,
                    sort,
                    boolFields
                );
                if (reply.Count > 0) {
                    foreach (GroupRecord groupReply in reply) {
                        Groups.Add (GroupRecord2OSDMap (groupReply));
                    }
                }
                resp ["Total"] = groups.GetNumberOfGroups (AdminAgentID, boolFields);
            }

            resp ["Groups"] = Groups;
            return resp;
        }
 OSDMap LocalSimulationServiceConnector_OnMessageReceived(OSDMap message)
 {
     if (!message.ContainsKey("Method"))
         return null;
     switch (message["Method"].AsString())
     {
         case "CreateAgentRequest":
             CreateAgentRequest createAgentRequest = new CreateAgentRequest();
             createAgentRequest.FromOSD(message);
             CreateAgentResponse createAgentResponse = new CreateAgentResponse();
             createAgentResponse.Success = CreateAgent(createAgentRequest.Destination, createAgentRequest.CircuitData, createAgentRequest.TeleportFlags, out createAgentResponse);
             return createAgentResponse.ToOSD();
         case "UpdateAgentPositionRequest":
             UpdateAgentPositionRequest updateAgentPositionRequest = new UpdateAgentPositionRequest();
             updateAgentPositionRequest.FromOSD(message);
             return new OSDMap() { new KeyValuePair<string, OSD>("Success", UpdateAgent(updateAgentPositionRequest.Destination, updateAgentPositionRequest.Update)) };
         case "UpdateAgentDataRequest":
             UpdateAgentDataRequest updateAgentDataRequest = new UpdateAgentDataRequest();
             updateAgentDataRequest.FromOSD(message);
             return new OSDMap() { new KeyValuePair<string, OSD>("Success", UpdateAgent(updateAgentDataRequest.Destination, updateAgentDataRequest.Update)) };
         case "FailedToMoveAgentIntoNewRegionRequest":
             FailedToMoveAgentIntoNewRegionRequest failedToMoveAgentIntoNewRegionRequest = new FailedToMoveAgentIntoNewRegionRequest();
             failedToMoveAgentIntoNewRegionRequest.FromOSD(message);
             FailedToMoveAgentIntoNewRegion(failedToMoveAgentIntoNewRegionRequest.AgentID, failedToMoveAgentIntoNewRegionRequest.RegionID);
             break;
         case "CloseAgentRequest":
             CloseAgentRequest closeAgentRequest = new CloseAgentRequest();
             closeAgentRequest.FromOSD(message);
             CloseAgent(closeAgentRequest.Destination, closeAgentRequest.AgentID);
             break;
         case "MakeChildAgentRequest":
             MakeChildAgentRequest makeChildAgentRequest = new MakeChildAgentRequest();
             makeChildAgentRequest.FromOSD(message);
             MakeChildAgent(makeChildAgentRequest.AgentID, makeChildAgentRequest.Destination, makeChildAgentRequest.IsCrossing);
             break;
         case "FailedToTeleportAgentRequest":
             FailedToTeleportAgentRequest failedToTeleportAgentRequest = new FailedToTeleportAgentRequest();
             failedToTeleportAgentRequest.FromOSD(message);
             FailedToTeleportAgent(failedToTeleportAgentRequest.Destination, failedToTeleportAgentRequest.FailedRegionID,
                 failedToTeleportAgentRequest.AgentID, failedToTeleportAgentRequest.Reason, failedToTeleportAgentRequest.IsCrossing);
             break;
         case "RetrieveAgentRequest":
             RetrieveAgentRequest retrieveAgentRequest = new RetrieveAgentRequest();
             retrieveAgentRequest.FromOSD(message);
             RetrieveAgentResponse retrieveAgentResponse = new RetrieveAgentResponse();
             retrieveAgentResponse.Success = RetrieveAgent(retrieveAgentRequest.Destination, retrieveAgentRequest.AgentID, retrieveAgentRequest.AgentIsLeaving,
                 out retrieveAgentResponse.AgentData, out retrieveAgentResponse.CircuitData);
             return retrieveAgentResponse.ToOSD();
         case "CreateObjectRequest":
             CreateObjectRequest createObjectRequest = new CreateObjectRequest();
             createObjectRequest.Scene = Scene;
             createObjectRequest.FromOSD(message);
             return new OSDMap() { new KeyValuePair<string, OSD>("Success", CreateObject(createObjectRequest.Destination, createObjectRequest.Object)) };
     }
     return null;
 }
        /// <summary>
        /// Attempts to convert an LLSD structure to a known Packet type
        /// </summary>
        /// <param name="capsEventName">Event name, this must match an actual
        /// packet name for a Packet to be successfully built</param>
        /// <param name="body">LLSD to convert to a Packet</param>
        /// <returns>A Packet on success, otherwise null</returns>
        public static Packet BuildPacket(string capsEventName, OSDMap body)
        {
            Assembly assembly = Assembly.GetExecutingAssembly();

            // Check if we have a subclass of packet with the same name as this event
            Type type = assembly.GetType("OpenMetaverse.Packets." + capsEventName + "Packet", false);
            if (type == null)
                return null;

            Packet packet = null;

            try
            {
                // Create an instance of the object
                packet = (Packet)Activator.CreateInstance(type);

                // Iterate over all of the fields in the packet class, looking for matches in the LLSD
                foreach (FieldInfo field in type.GetFields())
                {
                    if (body.ContainsKey(field.Name))
                    {
                        Type blockType = field.FieldType;

                        if (blockType.IsArray)
                        {
                            OSDArray array = (OSDArray)body[field.Name];
                            Type elementType = blockType.GetElementType();
                            object[] blockArray = (object[])Array.CreateInstance(elementType, array.Count);

                            for (int i = 0; i < array.Count; i++)
                            {
                                OSDMap map = (OSDMap)array[i];
                                blockArray[i] = ParseLLSDBlock(map, elementType);
                            }

                            field.SetValue(packet, blockArray);
                        }
                        else
                        {
                            OSDMap map = (OSDMap)((OSDArray)body[field.Name])[0];
                            field.SetValue(packet, ParseLLSDBlock(map, blockType));
                        }
                    }
                }
            }
            catch (Exception)
            {
                //FIXME Logger.Log(e.Message, Helpers.LogLevel.Error, e);
            }

            return packet;
        }
        protected OSDMap OnMessageReceived(OSDMap message)
        {
            //If it is an async message request, make sure that the request is valid and check it
            if (message["Method"] == "AsyncMessageRequest")
            {
                try
                {
                    ICapsService service = m_registry.RequestModuleInterface<ICapsService>();
                    OSDMap response = new OSDMap();
                    OSDMap mapresponse = new OSDMap();

                    if (message.ContainsKey("RegionHandles"))
                    {
                        OSDArray handles = (OSDArray)message["RegionHandles"];

                        for (int i = 0; i < handles.Count; i += 2)
                        {
                            ulong regionHandle = handles[i].AsULong();
                            IRegionCapsService region = service.GetCapsForRegion(regionHandle);
                            if (region != null)
                            {
                                bool verified = (region.Region.SessionID == handles[i + 1].AsUUID());
                                if (verified)
                                {
                                    if (m_regionMessages.ContainsKey(regionHandle))
                                    {
                                        //Get the array, then remove it
                                        OSDArray array = m_regionMessages[regionHandle];
                                        m_regionMessages.Remove(regionHandle);
                                        mapresponse[regionHandle.ToString()] = array;
                                    }
                                }
                            }
                        }
                    }

                    response["Messages"] = mapresponse;
                    return response;
                }
                catch
                {
                }
            }
            return null;
        }
 /// <summary>
 ///     Region side
 /// </summary>
 /// <param name="message"></param>
 /// <returns></returns>
 protected OSDMap OnMessageReceived(OSDMap message)
 {
     //We need to check and see if this is an AgentStatusChange
     if (message.ContainsKey("Method") && message["Method"] == "UpdateAvatarAppearance")
     {
         AvatarAppearance appearance = new AvatarAppearance(message["AgentID"], (OSDMap)message["Appearance"]);
         ISceneManager manager = m_registry.RequestModuleInterface<ISceneManager>();
         if (manager != null && manager.Scene != null)
         {
             IAvatarFactory factory = manager.Scene.RequestModuleInterface<IAvatarFactory>();
             IScenePresence sp = manager.Scene.GetScenePresence(appearance.Owner);
             sp.RequestModuleInterface<IAvatarAppearanceModule>().Appearance = appearance;
             sp.RequestModuleInterface<IAvatarAppearanceModule>().SendAppearanceToAgent(sp);
             sp.RequestModuleInterface<IAvatarAppearanceModule>().SendAppearanceToAllOtherAgents();
         }
     }
     return null;
 }
示例#12
0
 public override void FromOSD (OSDMap map)
 {
     State = map["State"].AsString ();
     Source = map["Source"].AsString ();
     ItemID = map["ItemID"].AsUUID ();
     Running = map["Running"].AsBoolean ();
     Disabled = map["Disabled"].AsBoolean ();
     Variables = map["Variables"].AsString ();
     Plugins = (OSDMap)map["Plugins"];
     PermsGranter = map["PermsGranter"].AsUUID ();
     PermsMask = map["PermsMask"].AsInteger ();
     MinEventDelay = map["MinEventDelay"].AsReal ();
     AssemblyName = map["AssemblyName"].AsString ();
     UserInventoryID = map["UserInventoryID"].AsUUID ();
     TargetOmegaWasSet = map["TargetOmegaWasSet"].AsBoolean ();
     if(map.ContainsKey("Compiled"))
         Compiled = map["Compiled"].AsBoolean ();
 }
 /// <summary>
 /// Request avatar's classified ads.
 /// </summary>
 /// <returns>
 /// An array containing all the calassified uuid and it's name created by the creator id
 /// </returns>
 /// <param name='json'>
 /// Our parameters are in the OSDMap json["params"]
 /// </param>
 /// <param name='response'>
 /// If set to <c>true</c> response.
 /// </param>
 public bool AvatarClassifiedsRequest(OSDMap json, ref JsonRpcResponse response)
 {
     if(!json.ContainsKey("params"))
     {
         response.Error.Code = ErrorCode.ParseError;
         m_log.DebugFormat ("Classified Request");
         return false;
     }
     
     OSDMap request = (OSDMap)json["params"];
     UUID creatorId = new UUID(request["creatorId"].AsString());
     
     
     OSDArray data = (OSDArray) Service.AvatarClassifiedsRequest(creatorId);
     response.Result = data;
     
     return true;
 }
示例#14
0
        OSDMap GetRegions (OSDMap map)
        {
            OSDMap resp = new OSDMap ();
            RegionFlags type = map.Keys.Contains ("RegionFlags") ? (RegionFlags)map ["RegionFlags"].AsInteger () : RegionFlags.RegionOnline;
            int start = map.Keys.Contains ("Start") ? map ["Start"].AsInteger () : 0;
            if (start < 0) {
                start = 0;
            }
            int count = map.Keys.Contains ("Count") ? map ["Count"].AsInteger () : 10;
            if (count < 0) {
                count = 1;
            }

            var regiondata = DataPlugins.RequestPlugin<IRegionData> ();

            Dictionary<string, bool> sort = new Dictionary<string, bool> ();

            string [] supportedSort = {
                "SortRegionName",
                "SortLocX",
                "SortLocY"
            };

            foreach (string sortable in supportedSort) {
                if (map.ContainsKey (sortable)) {
                    sort [sortable.Substring (4)] = map [sortable].AsBoolean ();
                }
            }

            List<GridRegion> regions = regiondata.Get (type, sort);
            OSDArray Regions = new OSDArray ();
            if (start < regions.Count) {
                int i = 0;
                int j = regions.Count <= (start + count) ? regions.Count : (start + count);
                for (i = start; i < j; ++i) {
                    Regions.Add (regions [i].ToOSD ());
                }
            }
            resp ["Start"] = OSD.FromInteger (start);
            resp ["Count"] = OSD.FromInteger (count);
            resp ["Total"] = OSD.FromInteger (regions.Count);
            resp ["Regions"] = Regions;
            return resp;
        }
示例#15
0
 public override void FromOSD(OSDMap map)
 {
     AgentInfo = new IAgentInfo();
     AgentInfo.FromOSD((OSDMap)(map["AgentInfo"]));
     UserAccount = new UserAccount();
     UserAccount.FromOSD((OSDMap)(map["UserAccount"]));
     if (!map.ContainsKey("ActiveGroup"))
         ActiveGroup = null;
     else
     {
         ActiveGroup = new GroupMembershipData();
         ActiveGroup.FromOSD((OSDMap)(map["ActiveGroup"]));
     }
     GroupMemberships = ((OSDArray)map["GroupMemberships"]).ConvertAll<GroupMembershipData>((o) => 
         {
             GroupMembershipData group = new GroupMembershipData();
             group.FromOSD((OSDMap)o);
             return group;
         });
 }
示例#16
0
 protected OSDMap OnMessageReceived(OSDMap message)
 {
     //We need to check and see if this is an GroupSessionAgentUpdate
     if(message.ContainsKey("Method") && message["Method"] == "GroupSessionAgentUpdate")
     {
         //Send it on to whomever it concerns
         OSDMap innerMessage = (OSDMap)message["Message"];
         if(innerMessage["message"] == "ChatterBoxSessionAgentListUpdates")//ONLY forward on this type of message
         {
             UUID agentID = message["AgentID"];
             IEventQueueService eqs = m_registry.RequestModuleInterface<IEventQueueService>();
             ICapsService caps = m_registry.RequestModuleInterface<ICapsService>();
             if(caps != null)
             {
                 IClientCapsService clientCaps = caps.GetClientCapsService(agentID);
                 if(clientCaps != null && clientCaps.GetRootCapsService() != null)
                     eqs.Enqueue(innerMessage, agentID, clientCaps.GetRootCapsService().RegionHandle);
             }
         }
     }
     return null;
 }
示例#17
0
        public void Unpack(OSDMap args)
        {
            if (args.ContainsKey("region_handle"))
                UInt64.TryParse(args["region_handle"].AsString(), out RegionHandle);

            if (args["circuit_code"] != null)
                UInt32.TryParse((string)args["circuit_code"].AsString(), out CircuitCode);

            if (args["agent_uuid"] != null)
                AgentID = args["agent_uuid"].AsUUID();

            if (args["session_uuid"] != null)
                SessionID = args["session_uuid"].AsUUID();

            if (args["position"] != null)
                Vector3.TryParse(args["position"].AsString(), out Position);

            if (args["velocity"] != null)
                Vector3.TryParse(args["velocity"].AsString(), out Velocity);

            if (args["center"] != null)
                Vector3.TryParse(args["center"].AsString(), out Center);

            if (args["size"] != null)
                Vector3.TryParse(args["size"].AsString(), out Size);

            if (args["at_axis"] != null)
                Vector3.TryParse(args["at_axis"].AsString(), out AtAxis);

            if (args["left_axis"] != null)
                Vector3.TryParse(args["left_axis"].AsString(), out LeftAxis);

            if (args["up_axis"] != null)
                Vector3.TryParse(args["up_axis"].AsString(), out UpAxis);

            if (args["changed_grid"] != null)
                ChangedGrid = args["changed_grid"].AsBoolean();

            if (args["far"] != null)
                Far = (float)(args["far"].AsReal());

            if (args["throttles"] != null)
                Throttles = args["throttles"].AsBinary();
        }
示例#18
0
        public byte[] HandleMap(OSDMap args)
        {
            if (args.ContainsKey("Method"))
            {
                string method = args["Method"].AsString();
                try
                {
                    MethodImplementation methodInfo;
                    if (GetMethodInfo(method, args.Count - 1, out methodInfo))
                    {
                        if (m_SessionID == "")
                        {
                            if (methodInfo.Attribute.ThreatLevel != ThreatLevel.None)
                            {
                                return(MainServer.BadRequest);
                            }
                        }
                        else if (!m_urlModule.CheckThreatLevel(m_SessionID, method, methodInfo.Attribute.ThreatLevel))
                        {
                            return(MainServer.BadRequest);
                        }
                        if (methodInfo.Attribute.UsePassword)
                        {
                            if (!methodInfo.Reference.CheckPassword(args["Password"].AsString()))
                            {
                                return(MainServer.BadRequest);
                            }
                        }
                        if (methodInfo.Attribute.OnlyCallableIfUserInRegion)
                        {
                            UUID userID = args["UserID"].AsUUID();
                            IClientCapsService clientCaps = m_capsService.GetClientCapsService(userID);
                            if (userID == UUID.Zero || clientCaps == null || clientCaps.GetRootCapsService().RegionHandle != ulong.Parse(m_SessionID))
                            {
                                return(MainServer.BadRequest);
                            }
                        }

                        ParameterInfo[] paramInfo  = methodInfo.Method.GetParameters();
                        object[]        parameters = new object[paramInfo.Length];
                        int             paramNum   = 0;
                        foreach (ParameterInfo param in paramInfo)
                        {
                            if (param.ParameterType == typeof(OSD))
                            {
                                parameters[paramNum++] = args[param.Name];
                            }
                            else
                            {
                                parameters[paramNum++] = Util.OSDToObject(args[param.Name], param.ParameterType);
                            }
                        }

                        object o        = methodInfo.Method.FastInvoke(paramInfo, methodInfo.Reference, parameters);
                        OSDMap response = new OSDMap();
                        if (o == null)//void method
                        {
                            response["Value"] = "null";
                        }
                        else
                        {
                            response["Value"] = Util.MakeOSD(o, methodInfo.Method.ReturnType);
                        }
                        response["Success"] = true;
                        return(Encoding.UTF8.GetBytes(OSDParser.SerializeJsonString(response, true)));
                    }
                }
                catch (Exception ex)
                {
                    MainConsole.Instance.WarnFormat("[ServerHandler]: Error occured for method {0}: {1}", method, ex.ToString());
                }
            }
            else
            {
                MainConsole.Instance.Warn("[ServerHandler]: Post did not have a method block");
            }

            return(MainServer.BadRequest);
        }
示例#19
0
        private byte[] ProcessEnqueueEQMMessage(OSDMap request)
        {
            OSDMap response = new OSDMap();
            response["success"] = false;
            try
            {
                UUID agentID = request["AgentID"].AsUUID();
                ulong regionHandle = m_ourRegionHandle == 0 ? request["RegionHandle"].AsULong() : m_ourRegionHandle;
                OSDArray events = new OSDArray();
                if (request.ContainsKey("Events") && request["Events"].Type == OSDType.Array)
                    events = (OSDArray) request["Events"];

#if (!ISWIN)
                List<OSD> OSDEvents = new List<OSD>();
                foreach (OSD ev in events)
                    OSDEvents.Add(OSDParser.DeserializeLLSDXml(ev.AsString()));
#else
                List<OSD> OSDEvents = events.Select(ev => OSDParser.DeserializeLLSDXml(ev.AsString())).ToList();
#endif

                IClientCapsService clientCaps = m_capsService.GetClientCapsService(agentID);
                if (clientCaps != null)
                {
                    IRegionClientCapsService regionClient = clientCaps.GetCapsService(regionHandle);
                    if (regionClient != null)
                    {
                        bool enqueueResult = false;
                        foreach (OSD ev in OSDEvents)
                        {
                            enqueueResult = m_eventQueueService.Enqueue(ev, agentID, regionHandle);
                            if (!enqueueResult) //Break if one fails
                                break;
                        }
                        response["success"] = enqueueResult;
                    }
                    else
                        MainConsole.Instance.Error("[EQMHandler]: ERROR IN THE HANDLER, FAILED TO FIND CLIENT'S REGION");
                }
                else
                {
                    MainConsole.Instance.Error("[EQMHandler]: ERROR IN THE HANDLER, FAILED TO FIND CLIENT, IWC/HG OR BOT?");
                    bool enqueueResult = false;
                    foreach (OSD ev in OSDEvents)
                    {
                        enqueueResult = m_eventQueueService.Enqueue(ev, agentID, regionHandle);
                        if (!enqueueResult) //Break if one fails
                            break;
                    }
                    response["success"] = enqueueResult;
                }
            }
            catch (Exception ex)
            {
                MainConsole.Instance.Error("[EQMHandler]: ERROR IN THE HANDLER: " + ex);
                response = new OSDMap();
                response["success"] = false;
            }
            string resp = OSDParser.SerializeJsonString(response);
            if (resp == "")
                return MainServer.BlankResponse;
            return Util.UTF8.GetBytes(resp);
        }
示例#20
0
        public string RenderMaterialsPostCap(string request, UUID agentID)
        {
            OSDMap req  = (OSDMap)OSDParser.DeserializeLLSDXml(request);
            OSDMap resp = new OSDMap();

            OSDMap materialsFromViewer = null;

            OSDArray respArr = new OSDArray();

            if (req.ContainsKey("Zipped"))
            {
                OSD osd = null;

                byte[] inBytes = req["Zipped"].AsBinary();

                try
                {
                    osd = ZDecompressBytesToOsd(inBytes);

                    if (osd != null)
                    {
                        if (osd is OSDArray) // assume array of MaterialIDs designating requested material entries
                        {
                            foreach (OSD elem in (OSDArray)osd)
                            {
                                try
                                {
                                    UUID id = new UUID(elem.AsBinary(), 0);

                                    lock (m_regionMaterials)
                                    {
                                        if (m_regionMaterials.ContainsKey(id))
                                        {
                                            OSDMap matMap = new OSDMap();
                                            matMap["ID"]       = OSD.FromBinary(id.GetBytes());
                                            matMap["Material"] = m_regionMaterials[id];
                                            respArr.Add(matMap);
                                        }
                                        else
                                        {
                                            m_log.Warn("[Materials]: request for unknown material ID: " + id.ToString());

                                            // Theoretically we could try to load the material from the assets service,
                                            // but that shouldn't be necessary because the viewer should only request
                                            // materials that exist in a prim on the region, and all of these materials
                                            // are already stored in m_regionMaterials.
                                        }
                                    }
                                }
                                catch (Exception e)
                                {
                                    m_log.Error("Error getting materials in response to viewer request", e);
                                    continue;
                                }
                            }
                        }
                        else if (osd is OSDMap) // request to assign a material
                        {
                            materialsFromViewer = osd as OSDMap;

                            if (materialsFromViewer.ContainsKey("FullMaterialsPerFace"))
                            {
                                OSD matsOsd = materialsFromViewer["FullMaterialsPerFace"];
                                if (matsOsd is OSDArray)
                                {
                                    OSDArray matsArr = matsOsd as OSDArray;

                                    try
                                    {
                                        foreach (OSDMap matsMap in matsArr)
                                        {
                                            uint primLocalID = 0;
                                            try {
                                                primLocalID = matsMap["ID"].AsUInteger();
                                            }
                                            catch (Exception e) {
                                                m_log.Warn("[Materials]: cannot decode \"ID\" from matsMap: " + e.Message);
                                                continue;
                                            }

                                            OSDMap mat = null;
                                            try
                                            {
                                                mat = matsMap["Material"] as OSDMap;
                                            }
                                            catch (Exception e)
                                            {
                                                m_log.Warn("[Materials]: cannot decode \"Material\" from matsMap: " + e.Message);
                                                continue;
                                            }

                                            SceneObjectPart sop = m_scene.GetSceneObjectPart(primLocalID);
                                            if (sop == null)
                                            {
                                                m_log.WarnFormat("[Materials]: SOP not found for localId: {0}", primLocalID.ToString());
                                                continue;
                                            }

                                            if (!m_scene.Permissions.CanEditObject(sop.UUID, agentID))
                                            {
                                                m_log.WarnFormat("User {0} can't edit object {1} {2}", agentID, sop.Name, sop.UUID);
                                                continue;
                                            }

                                            Primitive.TextureEntry te = new Primitive.TextureEntry(sop.Shape.TextureEntry, 0, sop.Shape.TextureEntry.Length);
                                            if (te == null)
                                            {
                                                m_log.WarnFormat("[Materials]: Error in TextureEntry for SOP {0} {1}", sop.Name, sop.UUID);
                                                continue;
                                            }


                                            UUID id;
                                            if (mat == null)
                                            {
                                                // This happens then the user removes a material from a prim
                                                id = UUID.Zero;
                                            }
                                            else
                                            {
                                                id = StoreMaterialAsAsset(agentID, mat, sop);
                                            }


                                            int face = -1;

                                            if (matsMap.ContainsKey("Face"))
                                            {
                                                face = matsMap["Face"].AsInteger();
                                                Primitive.TextureEntryFace faceEntry = te.CreateFace((uint)face);
                                                faceEntry.MaterialID = id;
                                            }
                                            else
                                            {
                                                if (te.DefaultTexture == null)
                                                {
                                                    m_log.WarnFormat("[Materials]: TextureEntry.DefaultTexture is null in {0} {1}", sop.Name, sop.UUID);
                                                }
                                                else
                                                {
                                                    te.DefaultTexture.MaterialID = id;
                                                }
                                            }

                                            //m_log.DebugFormat("[Materials]: in \"{0}\" {1}, setting material ID for face {2} to {3}", sop.Name, sop.UUID, face, id);

                                            // We can't use sop.UpdateTextureEntry(te) because it filters, so do it manually
                                            sop.Shape.TextureEntry = te.GetBytes();

                                            if (sop.ParentGroup != null)
                                            {
                                                sop.TriggerScriptChangedEvent(Changed.TEXTURE);
                                                sop.UpdateFlag = UpdateRequired.FULL;
                                                sop.ParentGroup.HasGroupChanged = true;
                                                sop.ScheduleFullUpdate();
                                            }
                                        }
                                    }
                                    catch (Exception e)
                                    {
                                        m_log.Warn("[Materials]: exception processing received material ", e);
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    m_log.Warn("[Materials]: exception decoding zipped CAP payload ", e);
                    //return "";
                }
            }


            resp["Zipped"] = ZCompressOSD(respArr, false);
            string response = OSDParser.SerializeLLSDXmlString(resp);

            //m_log.Debug("[Materials]: cap request: " + request);
            //m_log.Debug("[Materials]: cap request (zipped portion): " + ZippedOsdBytesToString(req["Zipped"].AsBinary()));
            //m_log.Debug("[Materials]: cap response: " + response);
            return(response);
        }
示例#21
0
        protected void DoAgentPost(Hashtable request, Hashtable responsedata, UUID id)
        {
            OSDMap args = WebUtils.GetOSDMap((string)request["body"]);

            if (args == null)
            {
                responsedata["int_response_code"]   = HttpStatusCode.BadRequest;
                responsedata["str_response_string"] = "Bad request";
                return;
            }

            // retrieve the input arguments
            int        x = 0, y = 0;
            UUID       uuid                  = UUID.Zero;
            string     regionname            = string.Empty;
            string     gatekeeper_host       = string.Empty;
            string     gatekeeper_serveruri  = string.Empty;
            string     destination_serveruri = string.Empty;
            int        gatekeeper_port       = 0;
            IPEndPoint client_ipaddress      = null;

            if (args.ContainsKey("gatekeeper_host") && args["gatekeeper_host"] != null)
            {
                gatekeeper_host = args["gatekeeper_host"].AsString();
            }
            if (args.ContainsKey("gatekeeper_port") && args["gatekeeper_port"] != null)
            {
                Int32.TryParse(args["gatekeeper_port"].AsString(), out gatekeeper_port);
            }
            if (args.ContainsKey("gatekeeper_serveruri") && args["gatekeeper_serveruri"] != null)
            {
                gatekeeper_serveruri = args["gatekeeper_serveruri"];
            }
            if (args.ContainsKey("destination_serveruri") && args["destination_serveruri"] != null)
            {
                destination_serveruri = args["destination_serveruri"];
            }

            GridRegion gatekeeper = new GridRegion();

            gatekeeper.ServerURI        = gatekeeper_serveruri;
            gatekeeper.ExternalHostName = gatekeeper_host;
            gatekeeper.HttpPort         = (uint)gatekeeper_port;
            gatekeeper.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), 0);

            if (args.ContainsKey("destination_x") && args["destination_x"] != null)
            {
                Int32.TryParse(args["destination_x"].AsString(), out x);
            }
            else
            {
                MainConsole.Instance.WarnFormat("  -- request didn't have destination_x");
            }
            if (args.ContainsKey("destination_y") && args["destination_y"] != null)
            {
                Int32.TryParse(args["destination_y"].AsString(), out y);
            }
            else
            {
                MainConsole.Instance.WarnFormat("  -- request didn't have destination_y");
            }
            if (args.ContainsKey("destination_uuid") && args["destination_uuid"] != null)
            {
                UUID.TryParse(args["destination_uuid"].AsString(), out uuid);
            }
            if (args.ContainsKey("destination_name") && args["destination_name"] != null)
            {
                regionname = args["destination_name"].ToString();
            }

            if (args.ContainsKey("client_ip") && args["client_ip"] != null)
            {
                string ip_str = args["client_ip"].ToString();
                try
                {
                    string callerIP = GetCallerIP(request);
                    // Verify if this caller has authority to send the client IP
                    if (callerIP == m_loginServerIP)
                    {
                        client_ipaddress = new IPEndPoint(IPAddress.Parse(ip_str), 0);
                    }
                    else // leaving this for now, but this warning should be removed
                    {
                        MainConsole.Instance.WarnFormat("[HOME AGENT HANDLER]: Unauthorized machine {0} tried to set client ip to {1}", callerIP, ip_str);
                    }
                }
                catch
                {
                    MainConsole.Instance.DebugFormat("[HOME AGENT HANDLER]: Exception parsing client ip address from {0}", ip_str);
                }
            }

            GridRegion destination = new GridRegion();

            destination.RegionID   = uuid;
            destination.RegionLocX = x;
            destination.RegionLocY = y;
            destination.RegionName = regionname;
            destination.ServerURI  = destination_serveruri;

            AgentCircuitData aCircuit = new AgentCircuitData();

            try
            {
                aCircuit.UnpackAgentCircuitData(args);
            }
            catch (Exception ex)
            {
                MainConsole.Instance.InfoFormat("[HOME AGENT HANDLER]: exception on unpacking ChildCreate message {0}", ex.Message);
                responsedata["int_response_code"]   = HttpStatusCode.BadRequest;
                responsedata["str_response_string"] = "Bad request";
                return;
            }

            OSDMap resp   = new OSDMap(2);
            string reason = String.Empty;

            bool result = m_UserAgentService.LoginAgentToGrid(aCircuit, gatekeeper, destination, client_ipaddress, out reason);

            resp["reason"]  = OSD.FromString(reason);
            resp["success"] = OSD.FromBoolean(result);

            // TODO: add reason if not String.Empty?
            responsedata["int_response_code"]   = HttpStatusCode.OK;
            responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp);
        }
        private static object ParseLLSDBlock(OSDMap blockData, Type blockType)
        {
            object block = Activator.CreateInstance(blockType);

            // Iterate over each field and set the value if a match was found in the LLSD
            foreach (FieldInfo field in blockType.GetFields())
            {
                if (blockData.ContainsKey(field.Name))
                {
                    Type fieldType = field.FieldType;

                    if (fieldType == typeof(ulong))
                    {
                        // ulongs come in as a byte array, convert it manually here
                        byte[] bytes = blockData[field.Name].AsBinary();
                        ulong value = Utils.BytesToUInt64(bytes);
                        field.SetValue(block, value);
                    }
                    else if (fieldType == typeof(uint))
                    {
                        // uints come in as a byte array, convert it manually here
                        byte[] bytes = blockData[field.Name].AsBinary();
                        uint value = Utils.BytesToUInt(bytes);
                        field.SetValue(block, value);
                    }
                    else if (fieldType == typeof(ushort))
                    {
                        // Just need a bit of manual typecasting love here
                        field.SetValue(block, (ushort)blockData[field.Name].AsInteger());
                    }
                    else if (fieldType == typeof(byte))
                    {
                        // Just need a bit of manual typecasting love here
                        field.SetValue(block, (byte)blockData[field.Name].AsInteger());
                    }
                    else if (fieldType == typeof(sbyte))
                    {
                        field.SetValue(block, (sbyte)blockData[field.Name].AsInteger());
                    }
                    else if (fieldType == typeof(short))
                    {
                        field.SetValue(block, (short)blockData[field.Name].AsInteger());
                    }
                    else if (fieldType == typeof(string))
                    {
                        field.SetValue(block, blockData[field.Name].AsString());
                    }
                    else if (fieldType == typeof(bool))
                    {
                        field.SetValue(block, blockData[field.Name].AsBoolean());
                    }
                    else if (fieldType == typeof(float))
                    {
                        field.SetValue(block, (float)blockData[field.Name].AsReal());
                    }
                    else if (fieldType == typeof(double))
                    {
                        field.SetValue(block, blockData[field.Name].AsReal());
                    }
                    else if (fieldType == typeof(int))
                    {
                        field.SetValue(block, blockData[field.Name].AsInteger());
                    }
                    else if (fieldType == typeof(UUID))
                    {
                        field.SetValue(block, blockData[field.Name].AsUUID());
                    }
                    else if (fieldType == typeof(Vector3))
                    {
                        Vector3 vec = ((OSDArray)blockData[field.Name]).AsVector3();
                        field.SetValue(block, vec);
                    }
                    else if (fieldType == typeof(Vector4))
                    {
                        Vector4 vec = ((OSDArray)blockData[field.Name]).AsVector4();
                        field.SetValue(block, vec);
                    }
                    else if (fieldType == typeof(Quaternion))
                    {
                        Quaternion quat = ((OSDArray)blockData[field.Name]).AsQuaternion();
                        field.SetValue(block, quat);
                    }
                    else if (fieldType == typeof(byte[]) && blockData[field.Name].Type == OSDType.String)
                    {
                        field.SetValue(block, Utils.StringToBytes(blockData[field.Name]));
                    }
                }
            }

            // Additional fields come as properties, Handle those as well.
            foreach (PropertyInfo property in blockType.GetProperties())
            {
                if (blockData.ContainsKey(property.Name))
                {
                    OSDType proptype = blockData[property.Name].Type;
                    MethodInfo set = property.GetSetMethod();

                    if (proptype.Equals(OSDType.Binary))
                    {
                        set.Invoke(block, new object[] { blockData[property.Name].AsBinary() });
                    }
                    else
                        set.Invoke(block, new object[] { Utils.StringToBytes(blockData[property.Name].AsString()) });
                }
            }

            return block;
        }
示例#23
0
        public virtual bool CreateAgent(GridRegion destination, ref AgentCircuitData aCircuit, uint teleportFlags,
                                        AgentData data, out int requestedUDPPort, out string reason)
        {
            reason = String.Empty;
            // Try local first
            if (m_localBackend.CreateAgent(destination, ref aCircuit, teleportFlags, data, out requestedUDPPort,
                                           out reason))
            {
                return(true);
            }
            requestedUDPPort = destination.ExternalEndPoint.Port; //Just make sure..

            reason = String.Empty;

            string uri = MakeUri(destination, true) + aCircuit.AgentID + "/";

            try
            {
                OSDMap args = aCircuit.PackAgentCircuitData();

                args["destination_x"]    = OSD.FromString(destination.RegionLocX.ToString());
                args["destination_y"]    = OSD.FromString(destination.RegionLocY.ToString());
                args["destination_name"] = OSD.FromString(destination.RegionName);
                args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString());
                args["teleport_flags"]   = OSD.FromString(teleportFlags.ToString());
                if (data != null)
                {
                    args["agent_data"] = data.Pack();
                }

                OSDMap result  = WebUtils.PostToService(uri, args, true, false);
                OSDMap results = WebUtils.GetOSDMap(result["_RawResult"].AsString());
                //Pull out the result and set it as the reason
                if (results == null)
                {
                    return(false);
                }
                reason = results["reason"] != null ? results["reason"].AsString() : "";
                if (result["Success"].AsBoolean())
                {
                    //Not right... don't return true except for opensim combatibility :/
                    if (reason == "")
                    {
                        return(true);
                    }
                    //We were able to contact the region
                    try
                    {
                        //We send the CapsURLs through, so we need these
                        OSDMap responseMap = (OSDMap)OSDParser.DeserializeJson(reason);
                        if (responseMap.ContainsKey("Reason"))
                        {
                            reason = responseMap["Reason"].AsString();
                        }
                        if (responseMap.ContainsKey("requestedUDPPort"))
                        {
                            requestedUDPPort = responseMap["requestedUDPPort"];
                        }
                        return(results["success"].AsBoolean());
                    }
                    catch
                    {
                        //Something went wrong
                        return(false);
                    }
                }

                reason = result.ContainsKey("Message") ? result["Message"].AsString() : "Could not contact the region";
                return(false);
            }
            catch (Exception e)
            {
                MainConsole.Instance.Warn("[REMOTE SIMULATION CONNECTOR]: CreateAgent failed with exception: " + e);
                reason = e.Message;
            }

            return(false);
        }
示例#24
0
        public bool CreateAgent(GridRegion source, GridRegion destination, AgentCircuitData aCircuit, uint flags, out string myipaddress, out string reason)
        {
            m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: Creating agent at {0}", destination.ServerURI);
            reason      = String.Empty;
            myipaddress = String.Empty;

            if (destination == null)
            {
                m_log.Debug("[REMOTE SIMULATION CONNECTOR]: Given destination is null");
                return(false);
            }

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

            try
            {
                OSDMap args = aCircuit.PackAgentCircuitData();
                PackData(args, source, aCircuit, destination, flags);

                OSDMap result  = WebUtil.PostToServiceCompressed(uri, args, 30000);
                bool   success = result["success"].AsBoolean();
                if (success && result.ContainsKey("_Result"))
                {
                    OSDMap data = (OSDMap)result["_Result"];

                    reason      = data["reason"].AsString();
                    success     = data["success"].AsBoolean();
                    myipaddress = data["your_ip"].AsString();
                    return(success);
                }

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

                if (result["Success"].AsBoolean())
                {
                    if (result.ContainsKey("_Result"))
                    {
                        OSDMap data = (OSDMap)result["_Result"];

                        reason      = data["reason"].AsString();
                        success     = data["success"].AsBoolean();
                        myipaddress = data["your_ip"].AsString();
                        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);
        }
示例#25
0
        public bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, Vector3 position, string myversion, out string version, out string reason)
        {
            reason  = "Failed to contact destination";
            version = "Unknown";

            // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: QueryAccess start, position={0}", position);

            IPEndPoint ext = destination.ExternalEndPoint;

            if (ext == null)
            {
                return(false);
            }

            // Eventually, we want to use a caps url instead of the agentID
            string uri = destination.ServerURI + AgentPath() + agentID + "/" + destination.RegionID.ToString() + "/";

            OSDMap request = new OSDMap();

            request.Add("position", OSD.FromString(position.ToString()));
            request.Add("my_version", OSD.FromString(myversion));
            if (agentHomeURI != null)
            {
                request.Add("agent_home_uri", OSD.FromString(agentHomeURI));
            }

            try
            {
                OSDMap result  = WebUtil.ServiceOSDRequest(uri, request, "QUERYACCESS", 30000, false, false);
                bool   success = result["success"].AsBoolean();
                if (result.ContainsKey("_Result"))
                {
                    OSDMap data = (OSDMap)result["_Result"];

                    // FIXME: If there is a _Result map then it's the success key here that indicates the true success
                    // or failure, not the sibling result node.
                    success = data["success"];

                    reason = data["reason"].AsString();
                    if (data["version"] != null && data["version"].AsString() != string.Empty)
                    {
                        version = data["version"].AsString();
                    }

                    m_log.DebugFormat(
                        "[REMOTE SIMULATION CONNECTOR]: QueryAccess to {0} returned {1}, reason {2}, version {3} ({4})",
                        uri, success, reason, version, data["version"].AsString());
                }

                if (!success)
                {
                    // If we don't check this then OpenSimulator 0.7.3.1 and some period before will never see the
                    // actual failure message
                    if (!result.ContainsKey("_Result"))
                    {
                        if (result.ContainsKey("Message"))
                        {
                            string message = result["Message"].AsString();
                            if (message == "Service request failed: [MethodNotAllowed] MethodNotAllowed") // Old style region
                            {
                                m_log.Info("[REMOTE SIMULATION CONNECTOR]: The above web util error was caused by a TP to a sim that doesn't support QUERYACCESS and can be ignored");
                                return(true);
                            }

                            reason = result["Message"];
                        }
                        else
                        {
                            reason = "Communications failure";
                        }
                    }

                    return(false);
                }

                return(success);
            }
            catch (Exception e)
            {
                m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR] QueryAcesss failed with exception; {0}", e.ToString());
            }

            return(false);
        }
示例#26
0
        private static object ParseLLSDBlock(OSDMap blockData, Type blockType)
        {
            object block = Activator.CreateInstance(blockType);

            // Iterate over each field and set the value if a match was found in the LLSD
            foreach (FieldInfo field in blockType.GetFields())
            {
                if (blockData.ContainsKey(field.Name))
                {
                    Type fieldType = field.FieldType;

                    if (fieldType == typeof(ulong))
                    {
                        // ulongs come in as a byte array, convert it manually here
                        byte[] bytes = blockData[field.Name].AsBinary();
                        ulong  value = Utils.BytesToUInt64(bytes);
                        field.SetValue(block, value);
                    }
                    else if (fieldType == typeof(uint))
                    {
                        // uints come in as a byte array, convert it manually here
                        byte[] bytes = blockData[field.Name].AsBinary();
                        uint   value = Utils.BytesToUInt(bytes);
                        field.SetValue(block, value);
                    }
                    else if (fieldType == typeof(ushort))
                    {
                        // Just need a bit of manual typecasting love here
                        field.SetValue(block, (ushort)blockData[field.Name].AsInteger());
                    }
                    else if (fieldType == typeof(byte))
                    {
                        // Just need a bit of manual typecasting love here
                        field.SetValue(block, (byte)blockData[field.Name].AsInteger());
                    }
                    else if (fieldType == typeof(sbyte))
                    {
                        field.SetValue(block, (sbyte)blockData[field.Name].AsInteger());
                    }
                    else if (fieldType == typeof(short))
                    {
                        field.SetValue(block, (short)blockData[field.Name].AsInteger());
                    }
                    else if (fieldType == typeof(string))
                    {
                        field.SetValue(block, blockData[field.Name].AsString());
                    }
                    else if (fieldType == typeof(bool))
                    {
                        field.SetValue(block, blockData[field.Name].AsBoolean());
                    }
                    else if (fieldType == typeof(float))
                    {
                        field.SetValue(block, (float)blockData[field.Name].AsReal());
                    }
                    else if (fieldType == typeof(double))
                    {
                        field.SetValue(block, blockData[field.Name].AsReal());
                    }
                    else if (fieldType == typeof(int))
                    {
                        field.SetValue(block, blockData[field.Name].AsInteger());
                    }
                    else if (fieldType == typeof(UUID))
                    {
                        field.SetValue(block, blockData[field.Name].AsUUID());
                    }
                    else if (fieldType == typeof(Vector3))
                    {
                        Vector3 vec = ((OSDArray)blockData[field.Name]).AsVector3();
                        field.SetValue(block, vec);
                    }
                    else if (fieldType == typeof(Vector4))
                    {
                        Vector4 vec = ((OSDArray)blockData[field.Name]).AsVector4();
                        field.SetValue(block, vec);
                    }
                    else if (fieldType == typeof(Quaternion))
                    {
                        Quaternion quat = ((OSDArray)blockData[field.Name]).AsQuaternion();
                        field.SetValue(block, quat);
                    }
                    else if (fieldType == typeof(byte[]) && blockData[field.Name].Type == OSDType.String)
                    {
                        field.SetValue(block, Utils.StringToBytes(blockData[field.Name]));
                    }
                }
            }

            // Additional fields come as properties, Handle those as well.
            foreach (PropertyInfo property in blockType.GetProperties())
            {
                if (blockData.ContainsKey(property.Name))
                {
                    OSDType    proptype = blockData[property.Name].Type;
                    MethodInfo set      = property.GetSetMethod();

                    if (proptype.Equals(OSDType.Binary))
                    {
                        set.Invoke(block, new object[] { blockData[property.Name].AsBinary() });
                    }
                    else
                    {
                        set.Invoke(block, new object[] { Utils.StringToBytes(blockData[property.Name].AsString()) });
                    }
                }
            }

            return(block);
        }
示例#27
0
        protected OSDMap OnMessageReceived(OSDMap message)
        {
            if (!message.ContainsKey("Method"))
            {
                return(null);                        // nothing to do here...
            }
            var method = message ["Method"].AsString();

            ISyncMessagePosterService asyncPost = m_registry.RequestModuleInterface <ISyncMessagePosterService> ();

            //We need to check and see if this is an AgentStatusChange
            if (method == "AgentStatusChange")
            {
                OSDMap innerMessage = (OSDMap)message ["Message"];
                //We got a message, now pass it on to the clients that need it
                UUID AgentID          = innerMessage ["AgentID"].AsUUID();
                UUID FriendToInformID = innerMessage ["FriendToInformID"].AsUUID();
                bool NewStatus        = innerMessage ["NewStatus"].AsBoolean();

                //Do this since IFriendsModule is a scene module, not a ISimulationBase module (not interchangeable)
                ISceneManager manager = m_registry.RequestModuleInterface <ISceneManager> ();
                if (manager != null)
                {
                    foreach (IScene scene in manager.Scenes)
                    {
                        if (scene.GetScenePresence(FriendToInformID) != null &&
                            !scene.GetScenePresence(FriendToInformID).IsChildAgent)
                        {
                            IFriendsModule friendsModule = scene.RequestModuleInterface <IFriendsModule> ();
                            if (friendsModule != null)
                            {
                                //Send the message
                                friendsModule.SendFriendsStatusMessage(FriendToInformID, new [] { AgentID }, NewStatus);
                            }
                        }
                    }
                }
            }
            else if (method == "AgentStatusChanges")
            {
                OSDMap innerMessage = (OSDMap)message ["Message"];
                //We got a message, now pass it on to the clients that need it
                List <UUID> AgentIDs         = ((OSDArray)innerMessage ["AgentIDs"]).ConvertAll <UUID> ((o) => o);
                UUID        FriendToInformID = innerMessage ["FriendToInformID"].AsUUID();
                bool        NewStatus        = innerMessage ["NewStatus"].AsBoolean();

                //Do this since IFriendsModule is a scene module, not a ISimulationBase module (not interchangeable)
                ISceneManager manager = m_registry.RequestModuleInterface <ISceneManager> ();
                if (manager != null)
                {
                    foreach (IScene scene in manager.Scenes)
                    {
                        if (scene.GetScenePresence(FriendToInformID) != null &&
                            !scene.GetScenePresence(FriendToInformID).IsChildAgent)
                        {
                            IFriendsModule friendsModule = scene.RequestModuleInterface <IFriendsModule> ();
                            if (friendsModule != null)
                            {
                                //Send the message
                                friendsModule.SendFriendsStatusMessage(FriendToInformID, AgentIDs.ToArray(), NewStatus);
                            }
                        }
                    }
                }
            }
            else if (method == "FriendGrantRights")
            {
                OSDMap            body             = (OSDMap)message ["Message"];
                UUID              targetID         = body ["Target"].AsUUID();
                IAgentInfoService agentInfoService = m_registry.RequestModuleInterface <IAgentInfoService> ();
                UserInfo          info;
                if (agentInfoService != null && (info = agentInfoService.GetUserInfo(targetID.ToString())) != null &&
                    info.IsOnline)
                {
                    //Forward the message
                    asyncPost.Post(info.CurrentRegionURI, message);
                }
            }
            else if (method == "FriendshipOffered")
            {
                OSDMap            body             = (OSDMap)message ["Message"];
                UUID              targetID         = body ["Friend"].AsUUID();
                IAgentInfoService agentInfoService = m_registry.RequestModuleInterface <IAgentInfoService> ();
                UserInfo          info;
                if (agentInfoService != null &&
                    (info = agentInfoService.GetUserInfo(targetID.ToString())) != null &&
                    info.IsOnline)
                {
                    //Forward the message
                    asyncPost.Post(info.CurrentRegionURI, message);
                }
            }
            else if (method == "FriendTerminated")
            {
                OSDMap            body             = (OSDMap)message ["Message"];
                UUID              targetID         = body ["ExFriend"].AsUUID();
                IAgentInfoService agentInfoService = m_registry.RequestModuleInterface <IAgentInfoService> ();
                UserInfo          info;
                if (agentInfoService != null &&
                    (info = agentInfoService.GetUserInfo(targetID.ToString())) != null &&
                    info.IsOnline)
                {
                    //Forward the message
                    asyncPost.Post(info.CurrentRegionURI, message);
                }
            }
            else if (method == "FriendshipDenied")
            {
                OSDMap            body             = (OSDMap)message ["Message"];
                UUID              targetID         = body ["FriendID"].AsUUID();
                IAgentInfoService agentInfoService = m_registry.RequestModuleInterface <IAgentInfoService> ();
                UserInfo          info;
                if (agentInfoService != null &&
                    (info = agentInfoService.GetUserInfo(targetID.ToString())) != null &&
                    info.IsOnline)
                {
                    //Forward the message
                    asyncPost.Post(info.CurrentRegionURI, message);
                }
            }
            else if (method == "FriendshipApproved")
            {
                OSDMap            body             = (OSDMap)message ["Message"];
                UUID              targetID         = body ["FriendID"].AsUUID();
                IAgentInfoService agentInfoService = m_registry.RequestModuleInterface <IAgentInfoService> ();
                UserInfo          info;
                if (agentInfoService != null &&
                    (info = agentInfoService.GetUserInfo(targetID.ToString())) != null &&
                    info.IsOnline)
                {
                    //Forward the message
                    asyncPost.Post(info.CurrentRegionURI, message);
                }
            }
            return(null);
        }
示例#28
0
        /// <summary>
        /// </summary>
        /// <param name="assetName"></param>
        /// <param name="assetDescription"></param>
        /// <param name="assetID"></param>
        /// <param name="inventoryItem"></param>
        /// <param name="parentFolder"></param>
        /// <param name="data"></param>
        /// <param name="inventoryType"></param>
        /// <param name="assetType"></param>
        /// <param name="everyoneMask"></param>
        /// <param name="groupMask"></param>
        /// <param name="nextOwnerMask"></param>
        public UUID UploadCompleteHandler(string assetName, string assetDescription, UUID assetID,
                                          UUID inventoryItem, UUID parentFolder, byte [] data, string inventoryType,
                                          string assetType, uint everyoneMask, uint groupMask, uint nextOwnerMask)
        {
            sbyte assType = 0;
            sbyte inType  = 0;

            switch (inventoryType)
            {
            case "sound":
                inType  = 1;
                assType = 1;
                break;

            case "animation":
                inType  = 19;
                assType = 20;
                break;

            case "snapshot":
                inType  = 15;
                assType = 0;
                break;

            case "wearable":
                inType = 18;
                switch (assetType)
                {
                case "bodypart":
                    assType = 13;
                    break;

                case "clothing":
                    assType = 5;
                    break;
                }
                break;

            case "object": {
                inType  = (sbyte)InventoryType.Object;
                assType = (sbyte)AssetType.Object;

                List <Vector3>    positions     = new List <Vector3> ();
                List <Quaternion> rotations     = new List <Quaternion> ();
                OSDMap            request       = (OSDMap)OSDParser.DeserializeLLSDXml(data);
                OSDArray          instance_list = (OSDArray)request ["instance_list"];
                OSDArray          mesh_list     = (OSDArray)request ["mesh_list"];
                OSDArray          texture_list  = (OSDArray)request ["texture_list"];
                SceneObjectGroup  grp           = null;

                List <UUID> textures = new List <UUID> ();
                foreach (
                    AssetBase textureAsset in
                    texture_list.Select(t => new AssetBase(UUID.Random(), assetName, AssetType.Texture,
                                                           m_agentID)
                    {
                        Data = t.AsBinary()
                    }))
                {
                    textureAsset.ID = m_assetService.Store(textureAsset);
                    textures.Add(textureAsset.ID);
                }

                InventoryFolderBase meshFolder = m_inventoryService.GetFolderForType(m_agentID, InventoryType.Mesh, FolderType.Mesh);
                for (int i = 0; i < mesh_list.Count; i++)
                {
                    PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox();

                    Primitive.TextureEntry textureEntry =
                        new Primitive.TextureEntry(Primitive.TextureEntry.WHITE_TEXTURE);
                    OSDMap inner_instance_list = (OSDMap)instance_list [i];

                    OSDArray face_list = (OSDArray)inner_instance_list ["face_list"];
                    for (uint face = 0; face < face_list.Count; face++)
                    {
                        OSDMap faceMap = (OSDMap)face_list [(int)face];
                        Primitive.TextureEntryFace f = pbs.Textures.CreateFace(face);
                        if (faceMap.ContainsKey("fullbright"))
                        {
                            f.Fullbright = faceMap ["fullbright"].AsBoolean();
                        }
                        if (faceMap.ContainsKey("diffuse_color"))
                        {
                            f.RGBA = faceMap ["diffuse_color"].AsColor4();
                        }

                        int   textureNum = faceMap ["image"].AsInteger();
                        float imagerot   = faceMap ["imagerot"].AsInteger();
                        float offsets    = (float)faceMap ["offsets"].AsReal();
                        float offsett    = (float)faceMap ["offsett"].AsReal();
                        float scales     = (float)faceMap ["scales"].AsReal();
                        float scalet     = (float)faceMap ["scalet"].AsReal();

                        if (imagerot != 0)
                        {
                            f.Rotation = imagerot;
                        }
                        if (offsets != 0)
                        {
                            f.OffsetU = offsets;
                        }
                        if (offsett != 0)
                        {
                            f.OffsetV = offsett;
                        }
                        if (scales != 0)
                        {
                            f.RepeatU = scales;
                        }
                        if (scalet != 0)
                        {
                            f.RepeatV = scalet;
                        }
                        f.TextureID = textures.Count > textureNum
                                                  ? textures [textureNum]
                                                  : Primitive.TextureEntry.WHITE_TEXTURE;
                        textureEntry.FaceTextures [face] = f;
                    }
                    pbs.TextureEntry = textureEntry.GetBytes();

                    AssetBase meshAsset = new AssetBase(UUID.Random(), assetName, AssetType.Mesh, m_agentID)
                    {
                        Data = mesh_list [i].AsBinary()
                    };
                    meshAsset.ID = m_assetService.Store(meshAsset);

                    if (meshFolder == null)
                    {
                        m_inventoryService.CreateUserInventory(m_agentID, false);
                        meshFolder = m_inventoryService.GetFolderForType(m_agentID, InventoryType.Mesh, FolderType.Mesh);
                    }

                    InventoryItemBase itemBase = new InventoryItemBase(UUID.Random(), m_agentID)
                    {
                        AssetType           = (sbyte)AssetType.Mesh,
                        AssetID             = meshAsset.ID,
                        CreatorId           = m_agentID.ToString(),
                        Folder              = meshFolder.ID,
                        InvType             = (int)InventoryType.Texture,
                        Name                = "(Mesh) - " + assetName,
                        CurrentPermissions  = (uint)PermissionMask.All,
                        BasePermissions     = (uint)PermissionMask.All,
                        EveryOnePermissions = everyoneMask,
                        GroupPermissions    = groupMask,
                        NextPermissions     = nextOwnerMask
                    };
                    //Bad... but whatever
                    m_inventoryService.AddItem(itemBase);

                    pbs.SculptEntry   = true;
                    pbs.SculptTexture = meshAsset.ID;
                    pbs.SculptType    = (byte)SculptType.Mesh;
                    pbs.SculptData    = meshAsset.Data;

                    Vector3    position = inner_instance_list ["position"].AsVector3();
                    Vector3    scale    = inner_instance_list ["scale"].AsVector3();
                    Quaternion rotation = inner_instance_list ["rotation"].AsQuaternion();

                    int physicsShapeType = inner_instance_list ["physics_shape_type"].AsInteger();
                    // not currently used                        int material = inner_instance_list["material"].AsInteger();
                    // not currently used                        int mesh = inner_instance_list["mesh"].AsInteger();

                    SceneObjectPart prim = new SceneObjectPart(m_agentID, pbs, position, Quaternion.Identity,
                                                               Vector3.Zero, assetName)
                    {
                        Scale = scale, AbsolutePosition = position
                    };

                    rotations.Add(rotation);
                    positions.Add(position);
                    prim.UUID         = UUID.Random();
                    prim.CreatorID    = m_agentID;
                    prim.OwnerID      = m_agentID;
                    prim.GroupID      = UUID.Zero;
                    prim.LastOwnerID  = m_agentID;
                    prim.CreationDate = Util.UnixTimeSinceEpoch();
                    prim.Name         = assetName;
                    prim.Description  = "";
                    prim.PhysicsType  = (byte)physicsShapeType;

                    prim.BaseMask      = (uint)PermissionMask.All;
                    prim.EveryoneMask  = everyoneMask;
                    prim.NextOwnerMask = nextOwnerMask;
                    prim.GroupMask     = groupMask;
                    prim.OwnerMask     = (uint)PermissionMask.All;

                    if (grp == null)
                    {
                        grp = new SceneObjectGroup(prim, null);
                    }
                    else
                    {
                        grp.AddChild(prim, i + 1);
                    }
                    grp.RootPart.IsAttachment = false;
                }
                if (grp != null)                    // unlikely not to have anything but itis possible
                {
                    if (grp.ChildrenList.Count > 1) //Fix first link #
                    {
                        grp.RootPart.LinkNum++;
                    }

                    Vector3 rootPos = positions [0];
                    grp.SetAbsolutePosition(false, rootPos);
                    for (int i = 0; i < positions.Count; i++)
                    {
                        Vector3 offset = positions [i] - rootPos;
                        grp.ChildrenList [i].SetOffsetPosition(offset);
                    }
                    //grp.Rotation = rotations[0];
                    for (int i = 0; i < rotations.Count; i++)
                    {
                        if (i != 0)
                        {
                            grp.ChildrenList [i].SetRotationOffset(false, rotations [i], false);
                        }
                    }
                    grp.UpdateGroupRotationR(rotations [0]);
                    data = Encoding.ASCII.GetBytes(grp.ToXml2());
                }
            }
            break;
            }
            AssetBase asset = new AssetBase(assetID, assetName, (AssetType)assType, m_agentID)
            {
                Data = data
            };

            asset.ID = m_assetService.Store(asset);
            assetID  = asset.ID;

            InventoryItemBase item = new InventoryItemBase {
                Owner               = m_agentID,
                CreatorId           = m_agentID.ToString(),
                ID                  = inventoryItem,
                AssetID             = asset.ID,
                Description         = assetDescription,
                Name                = assetName,
                AssetType           = assType,
                InvType             = inType,
                Folder              = parentFolder,
                CurrentPermissions  = (uint)PermissionMask.All,
                BasePermissions     = (uint)PermissionMask.All,
                EveryOnePermissions = everyoneMask,
                NextPermissions     = nextOwnerMask,
                GroupPermissions    = groupMask,
                CreationDate        = Util.UnixTimeSinceEpoch()
            };

            m_inventoryService.AddItem(item);

            return(assetID);
        }
        public override byte[] Handle(string path, Stream requestData,
                                      OSHttpRequest httpRequest, OSHttpResponse httpResponse)
        {
            StreamReader sr   = new StreamReader(requestData);
            string       body = sr.ReadToEnd();

            sr.Close();
            body = body.Trim();

            OSDMap args = WebUtils.GetOSDMap(body);

            if (args.ContainsKey("Method"))
            {
                IGridRegistrationService urlModule =
                    m_registry.RequestModuleInterface <IGridRegistrationService> ();
                string method = args["Method"].AsString();
                switch (method)
                {
                    #region Profile
                case "getprofile":
                    if (urlModule != null)
                    {
                        if (!urlModule.CheckThreatLevel("", m_regionHandle, method, ThreatLevel.None))
                        {
                            return(FailureResult());
                        }
                    }
                    return(ProfileHandler.GetProfile(args));

                case "updateprofile":
                    if (urlModule != null)
                    {
                        if (!urlModule.CheckThreatLevel("", m_regionHandle, method, ThreatLevel.High))
                        {
                            return(FailureResult());
                        }
                    }
                    return(ProfileHandler.UpdateProfile(args));

                case "getclassified":
                    if (urlModule != null)
                    {
                        if (!urlModule.CheckThreatLevel("", m_regionHandle, method, ThreatLevel.High))
                        {
                            return(FailureResult());
                        }
                    }
                    return(ProfileHandler.GetClassifed(args));

                case "getclassifieds":
                    if (urlModule != null)
                    {
                        if (!urlModule.CheckThreatLevel("", m_regionHandle, method, ThreatLevel.High))
                        {
                            return(FailureResult());
                        }
                    }
                    return(ProfileHandler.GetClassifieds(args));

                case "getpick":
                    if (urlModule != null)
                    {
                        if (!urlModule.CheckThreatLevel("", m_regionHandle, method, ThreatLevel.High))
                        {
                            return(FailureResult());
                        }
                    }
                    return(ProfileHandler.GetPick(args));

                case "getpicks":
                    if (urlModule != null)
                    {
                        if (!urlModule.CheckThreatLevel("", m_regionHandle, method, ThreatLevel.High))
                        {
                            return(FailureResult());
                        }
                    }
                    return(ProfileHandler.GetPicks(args));

                case "removepick":
                    if (urlModule != null)
                    {
                        if (!urlModule.CheckThreatLevel("", m_regionHandle, method, ThreatLevel.High))
                        {
                            return(FailureResult());
                        }
                    }
                    return(ProfileHandler.RemovePick(args));

                case "removeclassified":
                    if (urlModule != null)
                    {
                        if (!urlModule.CheckThreatLevel("", m_regionHandle, method, ThreatLevel.High))
                        {
                            return(FailureResult());
                        }
                    }
                    return(ProfileHandler.RemoveClassified(args));

                case "addclassified":
                    if (urlModule != null)
                    {
                        if (!urlModule.CheckThreatLevel("", m_regionHandle, method, ThreatLevel.High))
                        {
                            return(FailureResult());
                        }
                    }
                    return(ProfileHandler.AddClassified(args));

                case "addpick":
                    if (urlModule != null)
                    {
                        if (!urlModule.CheckThreatLevel("", m_regionHandle, method, ThreatLevel.High))
                        {
                            return(FailureResult());
                        }
                    }
                    return(ProfileHandler.AddPick(args));

                    #endregion
                }
            }

            return(FailureResult());
        }
        private List <InventoryItemBase> GetItemsFromResponse(OSDArray items)
        {
            List <InventoryItemBase> invItems = new List <InventoryItemBase>(items.Count);

            for (int i = 0; i < items.Count; i++)
            {
                OSDMap item = items[i] as OSDMap;

                if (item != null && item["Type"].AsString() == "Item")
                {
                    InventoryItemBase invItem = new InventoryItemBase();

                    invItem.AssetID         = item["AssetID"].AsUUID();
                    invItem.AssetType       = SLUtil.ContentTypeToSLAssetType(item["ContentType"].AsString());
                    invItem.CreationDate    = item["CreationDate"].AsInteger();
                    invItem.CreatorId       = item["CreatorID"].AsString();
                    invItem.CreatorIdAsUuid = item["CreatorID"].AsUUID();
                    invItem.Description     = item["Description"].AsString();
                    invItem.Folder          = item["ParentID"].AsUUID();
                    invItem.ID      = item["ID"].AsUUID();
                    invItem.InvType = SLUtil.ContentTypeToSLInvType(item["ContentType"].AsString());
                    invItem.Name    = item["Name"].AsString();
                    invItem.Owner   = item["OwnerID"].AsUUID();

                    OSDMap extraData = item["ExtraData"] as OSDMap;
                    if (extraData != null && extraData.Count > 0)
                    {
                        invItem.Flags      = extraData["Flags"].AsUInteger();
                        invItem.GroupID    = extraData["GroupID"].AsUUID();
                        invItem.GroupOwned = extraData["GroupOwned"].AsBoolean();
                        invItem.SalePrice  = extraData["SalePrice"].AsInteger();
                        invItem.SaleType   = (byte)extraData["SaleType"].AsInteger();

                        OSDMap perms = extraData["Permissions"] as OSDMap;
                        if (perms != null)
                        {
                            invItem.BasePermissions     = perms["BaseMask"].AsUInteger();
                            invItem.CurrentPermissions  = perms["OwnerMask"].AsUInteger();
                            invItem.EveryOnePermissions = perms["EveryoneMask"].AsUInteger();
                            invItem.GroupPermissions    = perms["GroupMask"].AsUInteger();
                            invItem.NextPermissions     = perms["NextOwnerMask"].AsUInteger();
                        }

                        if (extraData.ContainsKey("LinkedItemType"))
                        {
                            invItem.AssetType = SLUtil.ContentTypeToSLAssetType(extraData["LinkedItemType"].AsString());
                        }
                    }

                    if (invItem.BasePermissions == 0)
                    {
                        m_log.InfoFormat("[SIMIAN INVENTORY CONNECTOR]: Forcing item permissions to full for item {0} ({1})",
                                         invItem.Name, invItem.ID);
                        invItem.BasePermissions     = (uint)PermissionMask.All;
                        invItem.CurrentPermissions  = (uint)PermissionMask.All;
                        invItem.EveryOnePermissions = (uint)PermissionMask.All;
                        invItem.GroupPermissions    = (uint)PermissionMask.All;
                        invItem.NextPermissions     = (uint)PermissionMask.All;
                    }

                    invItems.Add(invItem);
                }
            }

            m_log.Debug("[SIMIAN INVENTORY CONNECTOR]: Parsed " + invItems.Count + " items from SimianGrid response");
            return(invItems);
        }
示例#31
0
        public void FromOSD(OSDMap map)
        {
            if (map.ContainsKey("uuid"))
                RegionID = map["uuid"].AsUUID();

            if (map.ContainsKey("locX"))
                RegionLocX = map["locX"].AsInteger();

            if (map.ContainsKey("locY"))
                RegionLocY = map["locY"].AsInteger();

            if (map.ContainsKey("locZ"))
                RegionLocZ = map["locZ"].AsInteger();

            if (map.ContainsKey("regionName"))
                RegionName = map["regionName"].AsString();

            if (map.ContainsKey("regionType"))
                RegionType = map["regionType"].AsString();

            if (map.ContainsKey("serverIP"))
            {
                //int port = 0;
                //Int32.TryParse((string)kvp["serverPort"], out port);
                //IPEndPoint ep = new IPEndPoint(IPAddress.Parse((string)kvp["serverIP"]), port);
                ExternalHostName = map["serverIP"].AsString();
            }
            else
                ExternalHostName = "127.0.0.1";

            if (map.ContainsKey("serverPort"))
            {
                Int32 port = map["serverPort"].AsInteger();
                InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), port);
            }

            if (map.ContainsKey("serverHttpPort"))
            {
                UInt32 port = map["serverHttpPort"].AsUInteger();
                HttpPort = port;
            }

            if (map.ContainsKey("serverURI"))
                ServerURI = map["serverURI"];

            if (map.ContainsKey("regionMapTexture"))
                TerrainImage = map["regionMapTexture"].AsUUID();

            if (map.ContainsKey("regionTerrainTexture"))
                TerrainMapImage = map["regionTerrainTexture"].AsUUID();

            if (map.ContainsKey("access"))
                Access = (byte)map["access"].AsInteger();

            if (map.ContainsKey("owner_uuid"))
                EstateOwner = map["owner_uuid"].AsUUID();

            if (map.ContainsKey("AuthToken"))
                AuthToken = map["AuthToken"].AsString();

            if (map.ContainsKey("sizeX"))
                m_RegionSizeX = map["sizeX"].AsInteger();

            if (map.ContainsKey("sizeY"))
                m_RegionSizeY = map["sizeY"].AsInteger();

            if (map.ContainsKey("sizeZ"))
                m_RegionSizeZ = map["sizeZ"].AsInteger();

            if (map.ContainsKey("LastSeen"))
                LastSeen = map["LastSeen"].AsInteger();

            if (map.ContainsKey("SessionID"))
                SessionID = map["SessionID"].AsUUID();

            if (map.ContainsKey("Flags"))
                Flags = map["Flags"].AsInteger();

            if (map.ContainsKey("GenericMap"))
                GenericMap = (OSDMap)map["GenericMap"];

            if (map.ContainsKey("remoteEndPointIP"))
            {
                IPAddress add = new IPAddress(map["remoteEndPointIP"].AsBinary());
                int port = map["remoteEndPointPort"].AsInteger();
                m_remoteEndPoint = new IPEndPoint(add, port);
            }
        }
示例#32
0
        public void UnpackRegionInfoData(OSDMap args)
        {
            if (args.ContainsKey("region_id"))
            {
                RegionID = args["region_id"].AsUUID();
            }
            if (args.ContainsKey("region_name"))
            {
                RegionName = args["region_name"].AsString();
            }
            if (args.ContainsKey("http_port"))
            {
                UInt32.TryParse(args["http_port"].AsString(), out m_httpPort);
            }
            if (args.ContainsKey("region_xloc"))
            {
                int locx;
                Int32.TryParse(args["region_xloc"].AsString(), out locx);
                RegionLocX = locx;
            }
            if (args.ContainsKey("region_yloc"))
            {
                int locy;
                Int32.TryParse(args["region_yloc"].AsString(), out locy);
                RegionLocY = locy;
            }
            if (args.ContainsKey("region_type"))
            {
                m_regionType = args["region_type"].AsString();
            }

            if (args.ContainsKey("scope_id"))
            {
                ScopeID = args["scope_id"].AsUUID();
            }
            if (args.ContainsKey("all_scope_ids"))
            {
                AllScopeIDs = ((OSDArray)args["all_scope_ids"]).ConvertAll <UUID>(o => o);
            }

            if (args.ContainsKey("region_size_x"))
            {
                RegionSizeX = args["region_size_x"].AsInteger();
            }
            if (args.ContainsKey("region_size_y"))
            {
                RegionSizeY = args["region_size_y"].AsInteger();
            }
            if (args.ContainsKey("region_size_z"))
            {
                RegionSizeZ = args["region_size_z"].AsInteger();
            }

            if (args.ContainsKey("object_capacity"))
            {
                m_objectCapacity = args["object_capacity"].AsInteger();
            }
            if (args.ContainsKey("region_type"))
            {
                RegionType = args["region_type"].AsString();
            }
            if (args.ContainsKey("see_into_this_sim_from_neighbor"))
            {
                SeeIntoThisSimFromNeighbor = args["see_into_this_sim_from_neighbor"].AsBoolean();
            }
            if (args.ContainsKey("startupType"))
            {
                Startup = (StartupType)args["startupType"].AsInteger();
            }
            if (args.ContainsKey("InfiniteRegion"))
            {
                InfiniteRegion = args["InfiniteRegion"].AsBoolean();
            }
            if (args.ContainsKey("RegionSettings"))
            {
                RegionSettings = new RegionSettings();
                RegionSettings.FromOSD((OSDMap)args["RegionSettings"]);
            }
            if (args.ContainsKey("GridSecureSessionID"))
            {
                GridSecureSessionID = args["GridSecureSessionID"];
            }
            if (args.ContainsKey("OpenRegionSettings"))
            {
                OpenRegionSettings = new OpenRegionSettings();
                OpenRegionSettings.FromOSD((OSDMap)args["OpenRegionSettings"]);
            }
            else
            {
                OpenRegionSettings = new OpenRegionSettings();
            }
            if (args.ContainsKey("EnvironmentSettings"))
            {
                EnvironmentSettings = args["EnvironmentSettings"];
            }
            if (args.ContainsKey("region_terrain"))
            {
                m_regionTerrain = args["region_terrain"].AsString();
            }
            if (args.ContainsKey("region_area"))
            {
                RegionArea = (uint)args["region_area"].AsInteger();
            }
        }
示例#33
0
        public void UnpackRegionInfoData(OSDMap args)
        {
            if (args.ContainsKey("region_id"))
                RegionID = args["region_id"].AsUUID();
            if (args.ContainsKey("region_name"))
                RegionName = args["region_name"].AsString();
            if (args.ContainsKey("http_port"))
                UInt32.TryParse(args["http_port"].AsString(), out m_httpPort);
            if (args.ContainsKey("region_xloc"))
            {
                int locx;
                Int32.TryParse(args["region_xloc"].AsString(), out locx);
                RegionLocX = locx;
            }
            if (args.ContainsKey("region_yloc"))
            {
                int locy;
                Int32.TryParse(args["region_yloc"].AsString(), out locy);
                RegionLocY = locy;
            }
            IPAddress ip_addr = null;
            if (args.ContainsKey("internal_ep_address"))
            {
                IPAddress.TryParse(args["internal_ep_address"].AsString(), out ip_addr);
            }
            int port = 0;
            if (args.ContainsKey("internal_ep_port"))
            {
                Int32.TryParse(args["internal_ep_port"].AsString(), out port);
            }
            InternalEndPoint = new IPEndPoint(ip_addr, port);
            if (args.ContainsKey("region_type"))
                m_regionType = args["region_type"].AsString();

            if (args.ContainsKey("scope_id"))
                ScopeID = args["scope_id"].AsUUID();
            if (args.ContainsKey("all_scope_ids"))
                AllScopeIDs = ((OSDArray) args["all_scope_ids"]).ConvertAll<UUID>(o => o);

            if (args.ContainsKey("region_size_x"))
                RegionSizeX = args["region_size_x"].AsInteger();
            if (args.ContainsKey("region_size_y"))
                RegionSizeY = args["region_size_y"].AsInteger();
            if (args.ContainsKey("region_size_z"))
                RegionSizeZ = args["region_size_z"].AsInteger();

            if (args.ContainsKey("object_capacity"))
                m_objectCapacity = args["object_capacity"].AsInteger();
            if (args.ContainsKey("region_type"))
                RegionType = args["region_type"].AsString();
            if (args.ContainsKey("see_into_this_sim_from_neighbor"))
                SeeIntoThisSimFromNeighbor = args["see_into_this_sim_from_neighbor"].AsBoolean();
            if (args.ContainsKey("startupType"))
                Startup = (StartupType) args["startupType"].AsInteger();
            if (args.ContainsKey("InfiniteRegion"))
                InfiniteRegion = args["InfiniteRegion"].AsBoolean();
            if (args.ContainsKey("RegionSettings"))
            {
                RegionSettings = new RegionSettings();
                RegionSettings.FromOSD((OSDMap) args["RegionSettings"]);
            }
            if (args.ContainsKey("GridSecureSessionID"))
                GridSecureSessionID = args["GridSecureSessionID"];
            if (args.ContainsKey("OpenRegionSettings"))
            {
                OpenRegionSettings = new OpenRegionSettings();
                OpenRegionSettings.FromOSD((OSDMap) args["OpenRegionSettings"]);
            }
            else
                OpenRegionSettings = new OpenRegionSettings();
            if (args.ContainsKey("EnvironmentSettings"))
                EnvironmentSettings = args["EnvironmentSettings"];
        }
示例#34
0
        public void UnpackRegionInfoData(OSDMap args)
        {
            if (args["region_id"] != null)
            {
                RegionID = args["region_id"].AsUUID();
            }
            if (args["region_name"] != null)
            {
                RegionName = args["region_name"].AsString();
            }
            if (args["external_host_name"] != null)
            {
                ExternalHostName = args["external_host_name"].AsString();
            }
            if (args["http_port"] != null)
            {
                UInt32.TryParse(args["http_port"].AsString(), out m_httpPort);
            }
            if (args["server_uri"] != null)
            {
                ServerURI = args["server_uri"].AsString();
            }
            if (args["region_xloc"] != null)
            {
                uint locx;
                UInt32.TryParse(args["region_xloc"].AsString(), out locx);
                RegionLocX = locx;
            }
            if (args["region_yloc"] != null)
            {
                uint locy;
                UInt32.TryParse(args["region_yloc"].AsString(), out locy);
                RegionLocY = locy;
            }
            if (args.ContainsKey("region_size_x"))
            {
                RegionSizeX = (uint)args["region_size_x"].AsInteger();
            }
            if (args.ContainsKey("region_size_y"))
            {
                RegionSizeY = (uint)args["region_size_y"].AsInteger();
            }
            if (args.ContainsKey("region_size_z"))
            {
                RegionSizeZ = (uint)args["region_size_z"].AsInteger();
            }

            IPAddress ip_addr = null;

            if (args["internal_ep_address"] != null)
            {
                IPAddress.TryParse(args["internal_ep_address"].AsString(), out ip_addr);
            }
            int port = 0;

            if (args["internal_ep_port"] != null)
            {
                Int32.TryParse(args["internal_ep_port"].AsString(), out port);
            }
            InternalEndPoint = new IPEndPoint(ip_addr, port);
            if (args["remoting_address"] != null)
            {
                RemotingAddress = args["remoting_address"].AsString();
            }
            if (args["remoting_port"] != null)
            {
                UInt32.TryParse(args["remoting_port"].AsString(), out m_remotingPort);
            }
            if (args["proxy_url"] != null)
            {
                proxyUrl = args["proxy_url"].AsString();
            }
            if (args["region_type"] != null)
            {
                m_regionType = args["region_type"].AsString();
            }
        }
示例#35
0
        private void OSDMapToSessions(OSDMap map)
        {
            if (!map.ContainsKey("sessions"))
                return;

            if (listViewSessions.InvokeRequired)
                listViewSessions.BeginInvoke((MethodInvoker)(() => OSDMapToSessions(map)));
            else
            {
                OSDArray sessionsArray = (OSDArray)map["sessions"];

                progressBar1.Maximum = sessionsArray.Count;
                progressBar1.Value = 0;
                progressBar1.Step = 1;

                panelActionProgress.Visible = true;

                listViewSessions.VirtualListSize = 0;
                m_SessionViewItems.Clear();

                ClearCache();

                for (int i = 0; i < sessionsArray.Count; i++)
                {
                    OSDMap session = (OSDMap)sessionsArray[i];
                    
                        Session importedSession = (Session)m_CurrentAssembly.CreateInstance("WinGridProxy." + session["type"].AsString());
                        if (importedSession == null)
                        {

                          //  System.Diagnostics.Debug.Assert(importedSession != null, session["type"].AsString() + );
                        }                        
                        
                        importedSession.Deserialize(session["tag"].AsBinary());
                        m_SessionViewItems.Add(importedSession);
                        progressBar1.PerformStep();                    
                }

                listViewSessions.VirtualListSize = m_SessionViewItems.Count;

                listViewSessions.Invalidate();

                // resize columns to fit whats currently on screen
                listViewSessions.Columns[0].Width =
                    listViewSessions.Columns[1].Width =
                    listViewSessions.Columns[2].Width =
                    listViewSessions.Columns[3].Width =
                    listViewSessions.Columns[5].Width = -2;

                panelActionProgress.Visible = false;

                map = null;
            }
        }
示例#36
0
        /// <summary>
        /// Unpack agent circuit data map into an AgentCiruitData object
        /// </summary>
        /// <param name="args"></param>
        public void UnpackAgentCircuitData(OSDMap args)
        {
            if (m_log.IsDebugEnabled)
            {
                m_log.DebugFormat("{0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
            }

            if (args["agent_id"] != null)
            {
                AgentID = args["agent_id"].AsUUID();
            }
            if (args["base_folder"] != null)
            {
                BaseFolder = args["base_folder"].AsUUID();
            }
            if (args["caps_path"] != null)
            {
                CapsPath = args["caps_path"].AsString();
            }

            if ((args["children_seeds"] != null) && (args["children_seeds"].Type == OSDType.Array))
            {
                OSDArray childrenSeeds = (OSDArray)(args["children_seeds"]);
                ChildrenCapSeeds = new Dictionary <ulong, string>();
                foreach (OSD o in childrenSeeds)
                {
                    if (o.Type == OSDType.Map)
                    {
                        ulong  handle = 0;
                        string seed   = "";
                        OSDMap pair   = (OSDMap)o;
                        if (pair["handle"] != null)
                        {
                            if (!UInt64.TryParse(pair["handle"].AsString(), out handle))
                            {
                                continue;
                            }
                        }
                        if (pair["seed"] != null)
                        {
                            seed = pair["seed"].AsString();
                        }
                        if (!ChildrenCapSeeds.ContainsKey(handle))
                        {
                            ChildrenCapSeeds.Add(handle, seed);
                        }
                    }
                }
            }
            else
            {
                ChildrenCapSeeds = new Dictionary <ulong, string>();
            }

            if (args["child"] != null)
            {
                child = args["child"].AsBoolean();
            }
            if (args["circuit_code"] != null)
            {
                UInt32.TryParse(args["circuit_code"].AsString(), out circuitcode);
            }
            if (args["first_name"] != null)
            {
                firstname = args["first_name"].AsString();
            }
            if (args["last_name"] != null)
            {
                lastname = args["last_name"].AsString();
            }
            if (args["inventory_folder"] != null)
            {
                InventoryFolder = args["inventory_folder"].AsUUID();
            }
            if (args["secure_session_id"] != null)
            {
                SecureSessionID = args["secure_session_id"].AsUUID();
            }
            if (args["session_id"] != null)
            {
                SessionID = args["session_id"].AsUUID();
            }
            if (args["service_session_id"] != null)
            {
                ServiceSessionID = args["service_session_id"].AsString();
            }
            if (args["client_ip"] != null)
            {
                IPAddress = args["client_ip"].AsString();
            }
            if (args["viewer"] != null)
            {
                Viewer = args["viewer"].AsString();
            }
            if (args["channel"] != null)
            {
                Channel = args["channel"].AsString();
            }
            if (args["mac"] != null)
            {
                Mac = args["mac"].AsString();
            }
            if (args["id0"] != null)
            {
                Id0 = args["id0"].AsString();
            }

            if (args["start_pos"] != null)
            {
                Vector3.TryParse(args["start_pos"].AsString(), out startpos);
            }

            //m_log.InfoFormat("[AGENTCIRCUITDATA]: agentid={0}, child={1}, startpos={2}", AgentID, child, startpos);

            try
            {
                // Unpack various appearance elements
                Appearance = new AvatarAppearance();

                // Eventually this code should be deprecated, use full appearance
                // packing in packed_appearance
                if (args["appearance_serial"] != null)
                {
                    Appearance.Serial = args["appearance_serial"].AsInteger();
                }

                if (args.ContainsKey("packed_appearance") && (args["packed_appearance"].Type == OSDType.Map))
                {
                    Appearance.Unpack((OSDMap)args["packed_appearance"]);
//                    m_log.InfoFormat("[AGENTCIRCUITDATA] unpacked appearance");
                }
                else
                {
                    m_log.Warn("[AGENTCIRCUITDATA]: failed to find a valid packed_appearance");
                }
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[AGENTCIRCUITDATA] failed to unpack appearance; {0}", e.Message);
            }

            ServiceURLs = new Dictionary <string, object>();
            // Try parse the new way, OSDMap
            if (args.ContainsKey("serviceurls") && args["serviceurls"] != null && (args["serviceurls"]).Type == OSDType.Map)
            {
                OSDMap urls = (OSDMap)(args["serviceurls"]);
                foreach (KeyValuePair <String, OSD> kvp in urls)
                {
                    ServiceURLs[kvp.Key] = kvp.Value.AsString();
                    //System.Console.WriteLine("XXX " + kvp.Key + "=" + ServiceURLs[kvp.Key]);
                }
            }
            // else try the old way, OSDArray
            // OBSOLETE -- soon to be deleted
            else if (args.ContainsKey("service_urls") && args["service_urls"] != null && (args["service_urls"]).Type == OSDType.Array)
            {
                OSDArray urls = (OSDArray)(args["service_urls"]);
                for (int i = 0; i < urls.Count / 2; i++)
                {
                    ServiceURLs[urls[i * 2].AsString()] = urls[(i * 2) + 1].AsString();
                    //System.Console.WriteLine("XXX " + urls[i * 2].AsString() + "=" + urls[(i * 2) + 1].AsString());
                }
            }
        }
示例#37
0
        /// <summary>
        /// Plugin start-up entry.
        /// </summary>
        /// <param name="inst"></param>
        /// <remarks>Called by Radegast at start-up</remarks>
        public void StartPlugin(RadegastInstance inst)
        {
            instance = inst;

            // Get configuration settings, and initialize if not found.
            config = instance.GlobalSettings["plugin.speech"] as OSDMap;

            if (config == null)
            {
                config = new OSDMap
                {
                    ["enabled"]       = new OSDBoolean(false),
                    ["voices"]        = new OSDMap(),
                    ["properties"]    = new OSDMap(),
                    ["substitutions"] = new OSDMap()
                };
                instance.GlobalSettings["plugin.speech"] = config;
            }

            if (!config.ContainsKey("enabled_for_inventory"))
            {
                config["enabled_for_inventory"] = true;
            }

            if (!config.ContainsKey("enabled_for_objects"))
            {
                config["enabled_for_objects"] = true;
            }

            if (!config.ContainsKey("enabled_for_friends"))
            {
                config["enabled_for_friends"] = true;
            }

            OSDMap props = (OSDMap)config["properties"];

            if (props["voice_speed"] == "")
            {
                props["voice_speed"] = "medium";
            }

            #region Buttons on the plugin menu
            // SpeechButton = new ToolStripMenuItem("Speech", null, OnSpeechMenuButtonClicked);
            SpeechButton = new ToolStripMenuItem("Speech");
            instance.MainForm.PluginsMenu.DropDownItems.Add(SpeechButton);

            SpeechButton.Checked = config["enabled"].AsBoolean();

            // Enabled sub menu
            {
                ToolStripMenuItem button = new ToolStripMenuItem("Enabled", null, (sender, e) =>
                {
                    OnSpeechMenuButtonClicked(SpeechButton, EventArgs.Empty);
                    ((ToolStripMenuItem)sender).Checked = SpeechButton.Checked;
                });

                button.Checked = SpeechButton.Checked;

                SpeechButton.DropDownItems.Add(button);
            }

            SpeechButton.DropDownItems.Add(new ToolStripSeparator());

            // Voice rate
            {
                ToolStripMenuItem slowButton = new ToolStripMenuItem("Slow");
                slowButton.Name = "slow";
                if (props["voice_speed"] == "slow")
                {
                    slowButton.Checked = true;
                }

                ToolStripMenuItem mediumButton = new ToolStripMenuItem("Medium");
                if (props["voice_speed"] == "medium")
                {
                    mediumButton.Checked = true;
                }
                mediumButton.Name = "medium";

                ToolStripMenuItem fastButton = new ToolStripMenuItem("Fast");
                if (props["voice_speed"] == "fast")
                {
                    fastButton.Checked = true;
                }
                fastButton.Name = "fast";

                slowButton.Click += (sender, e) =>
                {
                    slowButton.Checked = !slowButton.Checked;
                    if (slowButton.Checked)
                    {
                        props["voice_speed"] = "slow";
                        mediumButton.Checked = false;
                        fastButton.Checked   = false;
                    }
                };

                mediumButton.Click += (sender, e) =>
                {
                    mediumButton.Checked = !mediumButton.Checked;
                    if (mediumButton.Checked)
                    {
                        props["voice_speed"] = "medium";
                        slowButton.Checked   = false;
                        fastButton.Checked   = false;
                    }
                };

                fastButton.Click += (sender, e) =>
                {
                    fastButton.Checked = !fastButton.Checked;
                    if (fastButton.Checked)
                    {
                        props["voice_speed"] = "fast";
                        slowButton.Checked   = false;
                        mediumButton.Checked = false;
                    }
                };

                SpeechButton.DropDownItems.Add(slowButton);
                SpeechButton.DropDownItems.Add(mediumButton);
                SpeechButton.DropDownItems.Add(fastButton);
            }

            SpeechButton.DropDownItems.Add(new ToolStripSeparator());

            // Enable / disable for inventory tab
            {
                ToolStripMenuItem button = new ToolStripMenuItem("Inventory", null, (sender, e) =>
                {
                    var me     = (ToolStripMenuItem)sender;
                    me.Checked = !me.Checked;
                    config["enabled_for_inventory"] = me.Checked;
                });
                button.Name           = "speech_for_inventory";
                button.AccessibleName = "Speech for inventory";
                button.Checked        = config["enabled_for_inventory"].AsBoolean();

                SpeechButton.DropDownItems.Add(button);
            }

            // Enable / disable for objects tab
            {
                ToolStripMenuItem button = new ToolStripMenuItem("Objects", null, (sender, e) =>
                {
                    var me     = (ToolStripMenuItem)sender;
                    me.Checked = !me.Checked;
                    config["enabled_for_objects"] = me.Checked;
                });
                button.Name           = "speech_for_objects";
                button.AccessibleName = "Speech for objects";
                button.Checked        = config["enabled_for_objects"].AsBoolean();

                SpeechButton.DropDownItems.Add(button);
            }

            // Enable / disable for friends tab
            {
                ToolStripMenuItem button = new ToolStripMenuItem("Friends", null, (sender, e) =>
                {
                    var me     = (ToolStripMenuItem)sender;
                    me.Checked = !me.Checked;
                    config["enabled_for_friends"] = me.Checked;
                });
                button.Name           = "speech_for_friends";
                button.AccessibleName = "Speech for friends";
                button.Checked        = config["enabled_for_friends"].AsBoolean();

                SpeechButton.DropDownItems.Add(button);
            }

            SpeechButton.DropDownItems.Add(new ToolStripSeparator());

            // 3D Sound sub menu
            {
                ToolStripMenuItem button = new ToolStripMenuItem("3D Sound", null, (sender, e) =>
                {
                    var me             = (ToolStripMenuItem)sender;
                    me.Checked         = !me.Checked;
                    config["3d_sound"] = me.Checked;
                    instance.GlobalSettings.Save();
                    Radegast.Media.Speech.Surround = me.Checked;
                });

                button.Checked = config["3d_sound"].AsBoolean();
                Radegast.Media.Speech.Surround = button.Checked;

                SpeechButton.DropDownItems.Add(button);
            }
            #endregion Buttons on the plugin menu

            if (SpeechButton.Checked)
            {
                Initialize();
            }

            instance.GlobalSettings.Save();

            instance.MainForm.KeyDown += MainForm_KeyDown;
        }
示例#38
0
        protected virtual OSDMap OnMessageReceived(OSDMap message)
        {
            if (!message.ContainsKey("Method"))
                return null;

            UUID AgentID = message["AgentID"].AsUUID();
            ulong requestingRegion = message["RequestingRegion"].AsULong();
            ICapsService capsService = m_registry.RequestModuleInterface<ICapsService>();
            if (capsService == null)
                return new OSDMap();

            IClientCapsService clientCaps = capsService.GetClientCapsService(AgentID);

            IRegionClientCapsService regionCaps = null;
            if (clientCaps != null)
                regionCaps = clientCaps.GetCapsService(requestingRegion);
            if (message["Method"] == "LogoutRegionAgents")
            {
                LogOutAllAgentsForRegion(requestingRegion);
            }
            else if (message["Method"] == "RegionIsOnline")
                //This gets fired when the scene is fully finished starting up
            {
                //Log out all the agents first, then add any child agents that should be in this region
                LogOutAllAgentsForRegion(requestingRegion);
                IGridService GridService = m_registry.RequestModuleInterface<IGridService>();
                if (GridService != null)
                {
                    int x, y;
                    Util.UlongToInts(requestingRegion, out x, out y);
                    GridRegion requestingGridRegion = GridService.GetRegionByPosition(null, x, y);
                    if (requestingGridRegion != null)
                        Util.FireAndForget((o) => EnableChildAgentsForRegion(requestingGridRegion));
                }
            }
            else if (message["Method"] == "DisableSimulator")
            {
                //KILL IT!
                if (regionCaps == null || clientCaps == null)
                    return null;
                IEventQueueService eventQueue = m_registry.RequestModuleInterface<IEventQueueService>();
                eventQueue.DisableSimulator(regionCaps.AgentID, regionCaps.RegionHandle);
                //regionCaps.Close();
                //clientCaps.RemoveCAPS(requestingRegion);
                regionCaps.Disabled = true;
            }
            else if (message["Method"] == "ArrivedAtDestination")
            {
                if (regionCaps == null || clientCaps == null)
                    return null;
                //Recieved a callback
                if (clientCaps.InTeleport) //Only set this if we are in a teleport, 
                    //  otherwise (such as on login), this won't check after the first tp!
                    clientCaps.CallbackHasCome = true;

                regionCaps.Disabled = false;

                //The agent is getting here for the first time (eg. login)
                OSDMap body = ((OSDMap) message["Message"]);

                //Parse the OSDMap
                int DrawDistance = body["DrawDistance"].AsInteger();

                AgentCircuitData circuitData = new AgentCircuitData();
                circuitData.UnpackAgentCircuitData((OSDMap) body["Circuit"]);

                //Now do the creation
                EnableChildAgents(AgentID, requestingRegion, DrawDistance, circuitData);
            }
            else if (message["Method"] == "CancelTeleport")
            {
                if (regionCaps == null || clientCaps == null)
                    return null;
                //Only the region the client is root in can do this
                IRegionClientCapsService rootCaps = clientCaps.GetRootCapsService();
                if (rootCaps != null && rootCaps.RegionHandle == regionCaps.RegionHandle)
                {
                    //The user has requested to cancel the teleport, stop them.
                    clientCaps.RequestToCancelTeleport = true;
                    regionCaps.Disabled = false;
                }
            }
            else if (message["Method"] == "AgentLoggedOut")
            {
                //ONLY if the agent is root do we even consider it
                if (regionCaps != null)
                {
                    if (regionCaps.RootAgent)
                    {
                        LogoutAgent(regionCaps, false); //The root is killing itself
                    }
                }
            }
            else if (message["Method"] == "SendChildAgentUpdate")
            {
                if (regionCaps == null || clientCaps == null)
                    return null;
                IRegionClientCapsService rootCaps = clientCaps.GetRootCapsService();
                if (rootCaps != null && rootCaps.RegionHandle == regionCaps.RegionHandle) //Has to be root
                {
                    OSDMap body = ((OSDMap) message["Message"]);

                    AgentPosition pos = new AgentPosition();
                    pos.Unpack((OSDMap) body["AgentPos"]);

                    SendChildAgentUpdate(pos, regionCaps);
                    regionCaps.Disabled = false;
                }
            }
            else if (message["Method"] == "TeleportAgent")
            {
                if (regionCaps == null || clientCaps == null)
                    return null;
                IRegionClientCapsService rootCaps = clientCaps.GetRootCapsService();
                if (rootCaps != null && rootCaps.RegionHandle == regionCaps.RegionHandle)
                {
                    OSDMap body = ((OSDMap) message["Message"]);

                    GridRegion destination = new GridRegion();
                    destination.FromOSD((OSDMap) body["Region"]);

                    uint TeleportFlags = body["TeleportFlags"].AsUInteger();
                    int DrawDistance = body["DrawDistance"].AsInteger();

                    AgentCircuitData Circuit = new AgentCircuitData();
                    Circuit.UnpackAgentCircuitData((OSDMap) body["Circuit"]);

                    AgentData AgentData = new AgentData();
                    AgentData.Unpack((OSDMap) body["AgentData"]);
                    regionCaps.Disabled = false;
                    string ResponseURL = message["ResponseURL"].AsString();
                    if (ResponseURL == "")
                    {
                        OSDMap result = new OSDMap();
                        string reason = "";
                        result["success"] = TeleportAgent(ref destination, TeleportFlags, DrawDistance,
                                                          Circuit, AgentData, AgentID, requestingRegion, out reason);
                        result["Reason"] = reason;
                        //Remove the region flags, not the regions problem
                        destination.Flags = 0;
                        result["Destination"] = destination.ToOSD(); //Send back the new destination
                        return result;
                    }
                    else
                    {
                        Util.FireAndForget(delegate
                        {
                            OSDMap result = new OSDMap();
                            string reason = "";
                            result["success"] = TeleportAgent(ref destination, TeleportFlags, DrawDistance,
                                                              Circuit, AgentData, AgentID, requestingRegion, out reason);
                            result["Reason"] = reason;
                            //Remove the region flags, not the regions problem
                            destination.Flags = 0;
                            result["Destination"] = destination.ToOSD(); //Send back the new destination
                            WebUtils.PostToService(ResponseURL, result);
                        });
                        return new OSDMap() { new KeyValuePair<string, OSD>("WillHaveResponse", true) };
                    }
                }
            }
            else if (message["Method"] == "CrossAgent")
            {
                if (regionCaps == null || clientCaps == null)
                    return null;
                IRegionClientCapsService rootCaps = clientCaps.GetRootCapsService();
                if (rootCaps == null || rootCaps.RegionHandle == regionCaps.RegionHandle)
                {
                    //This is a simulator message that tells us to cross the agent
                    OSDMap body = ((OSDMap) message["Message"]);

                    Vector3 pos = body["Pos"].AsVector3();
                    Vector3 Vel = body["Vel"].AsVector3();
                    GridRegion Region = new GridRegion();
                    Region.FromOSD((OSDMap) body["Region"]);
                    AgentCircuitData Circuit = new AgentCircuitData();
                    Circuit.UnpackAgentCircuitData((OSDMap) body["Circuit"]);
                    AgentData AgentData = new AgentData();
                    AgentData.Unpack((OSDMap) body["AgentData"]);
                    regionCaps.Disabled = false;

                    string ResponseURL = message["ResponseURL"].AsString();
                    if (ResponseURL == "")
                    {
                        OSDMap result = new OSDMap();
                        string reason = "";
                        result["success"] = CrossAgent(Region, pos, Vel, Circuit, AgentData,
                                                       AgentID, requestingRegion, out reason);
                        result["reason"] = reason;
                        return result;
                    }
                    else
                    {
                        Util.FireAndForget(delegate
                        {
                            OSDMap result = new OSDMap();
                            string reason = "";
                            result["success"] = CrossAgent(Region, pos, Vel, Circuit, AgentData,
                                                           AgentID, requestingRegion, out reason);
                            result["reason"] = reason;
                            if (ResponseURL != null)
                                WebUtils.PostToService(ResponseURL, result);
                        });
                        return new OSDMap() { new KeyValuePair<string, OSD>("WillHaveResponse", true) };
                    }
                }
                else if (clientCaps.InTeleport)
                {
                    OSDMap result = new OSDMap();
                    result["success"] = false;
                    result["Note"] = false;
                    return result;
                }
                else
                {
                    OSDMap result = new OSDMap();
                    result["success"] = false;
                    result["Note"] = false;
                    return result;
                }
            }
            return null;
        }
        public bool QueryAccess(GridRegion destination, UUID agentID, string agentHomeURI, bool viaTeleport, Vector3 position, List <UUID> featuresAvailable, EntityTransferContext ctx, out string reason)
        {
            Culture.SetCurrentCulture();

            reason = "Failed to contact destination";

            // m_log.DebugFormat("[REMOTE SIMULATION CONNECTOR]: QueryAccess start, position={0}", position);

            // Eventually, we want to use a caps url instead of the agentID
            string uri = destination.ServerURI + AgentPath() + agentID + "/" + destination.RegionID.ToString() + "/";

            OSDMap request = new OSDMap();

            request.Add("viaTeleport", OSD.FromBoolean(viaTeleport));
            request.Add("position", OSD.FromString(position.ToString()));
            // To those who still understad this field, we're telling them
            // the lowest version just to be safe
            request.Add("my_version", OSD.FromString(String.Format("SIMULATION/{0}", VersionInfo.SimulationServiceVersionSupportedMin)));
            // New simulation service negotiation
            request.Add("simulation_service_supported_min", OSD.FromReal(VersionInfo.SimulationServiceVersionSupportedMin));
            request.Add("simulation_service_supported_max", OSD.FromReal(VersionInfo.SimulationServiceVersionSupportedMax));
            request.Add("simulation_service_accepted_min", OSD.FromReal(VersionInfo.SimulationServiceVersionAcceptedMin));
            request.Add("simulation_service_accepted_max", OSD.FromReal(VersionInfo.SimulationServiceVersionAcceptedMax));

            request.Add("context", ctx.Pack());

            OSDArray features = new OSDArray();

            foreach (UUID feature in featuresAvailable)
            {
                features.Add(OSD.FromString(feature.ToString()));
            }

            request.Add("features", features);

            if (agentHomeURI != null)
            {
                request.Add("agent_home_uri", OSD.FromString(agentHomeURI));
            }

            try
            {
                OSDMap result  = WebUtil.ServiceOSDRequest(uri, request, "QUERYACCESS", 30000, false, false);
                bool   success = result["success"].AsBoolean();
                if (result.ContainsKey("_Result"))
                {
                    OSDMap data = (OSDMap)result["_Result"];

                    // FIXME: If there is a _Result map then it's the success key here that indicates the true success
                    // or failure, not the sibling result node.
                    success = data["success"].AsBoolean();

                    reason = data["reason"].AsString();
                    // We will need to plumb this and start sing the outbound version as well
                    // TODO: lay the pipe for version plumbing
                    if (data.ContainsKey("negotiated_inbound_version") && data["negotiated_inbound_version"] != null)
                    {
                        ctx.InboundVersion  = (float)data["negotiated_inbound_version"].AsReal();
                        ctx.OutboundVersion = (float)data["negotiated_outbound_version"].AsReal();
                    }
                    else if (data["version"] != null && data["version"].AsString() != string.Empty)
                    {
                        string   versionString = data["version"].AsString();
                        String[] parts         = versionString.Split(new char[] { '/' });
                        if (parts.Length > 1)
                        {
                            ctx.InboundVersion  = float.Parse(parts[1], Culture.FormatProvider);
                            ctx.OutboundVersion = float.Parse(parts[1], Culture.FormatProvider);
                        }
                    }

                    m_log.DebugFormat(
                        "[REMOTE SIMULATION CONNECTOR]: QueryAccess to {0} returned {1}, reason {2}, version {3}/{4}",
                        uri, success, reason, ctx.InboundVersion, ctx.OutboundVersion);
                }

                if (!success || ctx.InboundVersion == 0f || ctx.OutboundVersion == 0f)
                {
                    // If we don't check this then OpenSimulator 0.7.3.1 and some period before will never see the
                    // actual failure message
                    if (!result.ContainsKey("_Result"))
                    {
                        if (result.ContainsKey("Message"))
                        {
                            string message = result["Message"].AsString();
                            if (message == "Service request failed: [MethodNotAllowed] MethodNotAllowed") // Old style region
                            {
                                m_log.Info("[REMOTE SIMULATION CONNECTOR]: The above web util error was caused by a TP to a sim that doesn't support QUERYACCESS and can be ignored");
                                return(true);
                            }

                            reason = result["Message"];
                        }
                        else
                        {
                            reason = "Communications failure";
                        }
                    }

                    return(false);
                }

                featuresAvailable.Clear();

                if (result.ContainsKey("features"))
                {
                    OSDArray array = (OSDArray)result["features"];

                    foreach (OSD o in array)
                    {
                        featuresAvailable.Add(new UUID(o.AsString()));
                    }
                }

                // Version stuff
                if (ctx.OutboundVersion < 0.5)
                {
                    ctx.WearablesCount = AvatarWearable.LEGACY_VERSION_MAX_WEARABLES;
                }
                else if (ctx.OutboundVersion < 0.6)
                {
                    ctx.WearablesCount = AvatarWearable.LEGACY_VERSION_MAX_WEARABLES + 1;
                }
                else
                {
                    ctx.WearablesCount = -1; // send all (just in case..)
                }
                return(success);
            }
            catch (Exception e)
            {
                m_log.WarnFormat("[REMOTE SIMULATION CONNECTOR] QueryAcesss failed with exception; {0}", e.ToString());
            }

            return(false);
        }
        protected virtual void DoAgentPut(Hashtable request, Hashtable responsedata)
        {
            OSDMap args = RegionClient.GetOSDMap((string)request["body"]);

            if (args == null)
            {
                responsedata["int_response_code"]   = 400;
                responsedata["str_response_string"] = "false";
                return;
            }

            // retrieve the regionhandle
            ulong regionhandle = 0;

            if (args.ContainsKey("destination_handle"))
            {
                UInt64.TryParse(args["destination_handle"].AsString(), out regionhandle);
            }

            string messageType;

            if (args.ContainsKey("message_type"))
            {
                messageType = args["message_type"].AsString();
            }
            else
            {
                m_log.Warn("[REST COMMS]: Agent Put Message Type not found. ");
                messageType = "AgentData";
            }

            bool result = true;

            if ("AgentData".Equals(messageType))
            {
                AgentData agent = new AgentData();
                try
                {
                    agent.Unpack(args);
                }
                catch (Exception ex)
                {
                    m_log.InfoFormat("[REST COMMS]: exception on unpacking ChildAgentUpdate message {0}", ex.Message);
                    return;
                }

                //agent.Dump();
                // This is one of the meanings of PUT agent
                result = m_localBackend.SendChildAgentUpdate(regionhandle, agent);
            }
            else if ("AgentPosition".Equals(messageType))
            {
                AgentPosition agent = new AgentPosition();
                try
                {
                    agent.Unpack(args);
                }
                catch (Exception ex)
                {
                    m_log.InfoFormat("[REST COMMS]: exception on unpacking ChildAgentUpdate message {0}", ex.Message);
                    return;
                }
                //agent.Dump();
                // This is one of the meanings of PUT agent
                result = m_localBackend.SendChildAgentUpdate(regionhandle, agent);
            }

            responsedata["int_response_code"]   = 200;
            responsedata["str_response_string"] = result.ToString();
        }
示例#41
0
        protected void DoObjectPost(Hashtable request, Hashtable responsedata, UUID regionID)
        {
            OSDMap args = Utils.GetOSDMap((string)request["body"]);

            if (args == null)
            {
                responsedata["int_response_code"]   = 400;
                responsedata["str_response_string"] = "false";
                return;
            }
            // retrieve the input arguments
            int     x = 0, y = 0;
            UUID    uuid        = UUID.Zero;
            string  regionname  = string.Empty;
            Vector3 newPosition = Vector3.Zero;

            if (args.ContainsKey("destination_x") && args["destination_x"] != null)
            {
                Int32.TryParse(args["destination_x"].AsString(), out x);
            }
            if (args.ContainsKey("destination_y") && args["destination_y"] != null)
            {
                Int32.TryParse(args["destination_y"].AsString(), out y);
            }
            if (args.ContainsKey("destination_uuid") && args["destination_uuid"] != null)
            {
                UUID.TryParse(args["destination_uuid"].AsString(), out uuid);
            }
            if (args.ContainsKey("destination_name") && args["destination_name"] != null)
            {
                regionname = args["destination_name"].ToString();
            }
            if (args.ContainsKey("new_position") && args["new_position"] != null)
            {
                Vector3.TryParse(args["new_position"], out newPosition);
            }

            GridRegion destination = new GridRegion();

            destination.RegionID   = uuid;
            destination.RegionLocX = x;
            destination.RegionLocY = y;
            destination.RegionName = regionname;

            string sogXmlStr = "", extraStr = "", stateXmlStr = "";

            if (args.ContainsKey("sog") && args["sog"] != null)
            {
                sogXmlStr = args["sog"].AsString();
            }
            if (args.ContainsKey("extra") && args["extra"] != null)
            {
                extraStr = args["extra"].AsString();
            }

            IScene       s   = m_SimulationService.GetScene(destination.RegionHandle);
            ISceneObject sog = null;

            try
            {
                //m_log.DebugFormat("[OBJECT HANDLER]: received {0}", sogXmlStr);
                sog = s.DeserializeObject(sogXmlStr);
                sog.ExtraFromXmlString(extraStr);
            }
            catch (Exception ex)
            {
                m_log.InfoFormat("[OBJECT HANDLER]: exception on deserializing scene object {0}", ex.Message);
                responsedata["int_response_code"]   = HttpStatusCode.BadRequest;
                responsedata["str_response_string"] = "Bad request";
                return;
            }

            if (args.ContainsKey("modified"))
            {
                sog.HasGroupChanged = args["modified"].AsBoolean();
            }
            else
            {
                sog.HasGroupChanged = false;
            }

            if ((args["state"] != null) && s.AllowScriptCrossings)
            {
                stateXmlStr = args["state"].AsString();
                if (stateXmlStr != "")
                {
                    try
                    {
                        sog.SetState(stateXmlStr, s);
                    }
                    catch (Exception ex)
                    {
                        m_log.InfoFormat("[OBJECT HANDLER]: exception on setting state for scene object {0}", ex.Message);
                        // ignore and continue
                    }
                }
            }

            bool result = false;

            try
            {
                // This is the meaning of POST object
                result = CreateObject(destination, newPosition, sog);
            }
            catch (Exception e)
            {
                m_log.DebugFormat("[OBJECT HANDLER]: Exception in CreateObject: {0}", e.StackTrace);
            }

            responsedata["int_response_code"]   = HttpStatusCode.OK;
            responsedata["str_response_string"] = result.ToString();
        }
        public string UpdateAgentPreferences(string request, string path, string param, UUID agent)
        {
            OSDMap resp = new OSDMap();

            // The viewer doesn't do much with the return value, so for now, if there is no preference service,
            // we'll return a null llsd block for debugging purposes. This may change if someone knows what the
            // correct server response would be here.
            if (m_scenes[0].AgentPreferencesService == null)
            {
                return(OSDParser.SerializeLLSDXmlString(resp));
            }
            m_log.DebugFormat("[AgentPrefs]: UpdateAgentPreferences for {0}", agent.ToString());
            OSDMap     req  = (OSDMap)OSDParser.DeserializeLLSDXml(request);
            AgentPrefs data = m_scenes[0].AgentPreferencesService.GetAgentPreferences(agent);

            if (data == null)
            {
                data = new AgentPrefs(agent);
            }

            if (req.ContainsKey("access_prefs"))
            {
                OSDMap accessPrefs = (OSDMap)req["access_prefs"];  // We could check with ContainsKey...
                data.AccessPrefs = accessPrefs["max"].AsString();
            }
            if (req.ContainsKey("default_object_perm_masks"))
            {
                OSDMap permsMap = (OSDMap)req["default_object_perm_masks"];
                data.PermEveryone  = permsMap["Everyone"].AsInteger();
                data.PermGroup     = permsMap["Group"].AsInteger();
                data.PermNextOwner = permsMap["NextOwner"].AsInteger();
            }
            if (req.ContainsKey("hover_height"))
            {
                data.HoverHeight = req["hover_height"].AsReal();
            }
            if (req.ContainsKey("language"))
            {
                data.Language = req["language"].AsString();
            }
            if (req.ContainsKey("language_is_public"))
            {
                data.LanguageIsPublic = req["language_is_public"].AsBoolean();
            }
            m_scenes[0].AgentPreferencesService.StoreAgentPreferences(data);
            OSDMap respAccessPrefs = new OSDMap();

            respAccessPrefs["max"] = data.AccessPrefs;
            resp["access_prefs"]   = respAccessPrefs;
            OSDMap respDefaultPerms = new OSDMap();

            respDefaultPerms["Everyone"]      = data.PermEveryone;
            respDefaultPerms["Group"]         = data.PermGroup;
            respDefaultPerms["NextOwner"]     = data.PermNextOwner;
            resp["default_object_perm_masks"] = respDefaultPerms;
            resp["god_level"]          = 0; // *TODO: Add this
            resp["hover_height"]       = data.HoverHeight;
            resp["language"]           = data.Language;
            resp["language_is_public"] = data.LanguageIsPublic;

            string response = OSDParser.SerializeLLSDXmlString(resp);

            return(response);
        }
示例#43
0
        public override void FromOSD(OSDMap map)
        {
            Data = new Dictionary<string, string>();

            if (map.ContainsKey("AvatarType"))
                AvatarType = map["AvatarType"];

            foreach (KeyValuePair<string, OSD> _kvp in map)
            {
                if (_kvp.Value != null)
                {
                    string key = _kvp.Key;
                    if (_kvp.Key.StartsWith("Wearable"))
                    {
                        key = _kvp.Key.Replace("Wearable", "");
                        key = key.Insert(key.Length == 2 ? 1 : 2, ":");
                        key = "Wearable " + key; //Add the space back
                    }
                    Data[key] = _kvp.Value.ToString();
                }
            }
        }
示例#44
0
        public RelayConsole(RadegastInstance instance)
            : base(instance)
        {
            InitializeComponent();
            Disposed += RelayConsole_Disposed;

            textPrinter = new RichTextBoxPrinter(rtbChatText);

            // Get configuration settings, and initialize if not found.
            config = instance.GlobalSettings["plugin.irc"] as OSDMap;

            if (config == null)
            {
                config                   = new OSDMap();
                config["server"]         = new OSDString("irc.freenode.net");
                config["port"]           = new OSDInteger(6667);
                config["nick"]           = new OSDString(string.Empty);
                config["channel"]        = new OSDString("#");
                config["send_delay"]     = new OSDInteger(200);
                config["auto_reconnect"] = new OSDBoolean(true);
                config["ctcp_version"]   = new OSDString("Radegast IRC");
                instance.GlobalSettings["plugin.irc"] = config;
            }

            if (!config.ContainsKey("server"))
            {
                config["server"] = new OSDString("irc.freenode.net");
            }
            if (!config.ContainsKey("port"))
            {
                config["port"] = new OSDInteger(6667);
            }
            if (!config.ContainsKey("nick"))
            {
                config["nick"] = new OSDString(instance.Client.Self.Name);
            }
            if (!config.ContainsKey("channel"))
            {
                config["channel"] = new OSDString("#");
            }
            if (!config.ContainsKey("send_delay"))
            {
                config["send_delay"] = new OSDInteger(200);
            }
            if (!config.ContainsKey("auto_reconnect"))
            {
                config["auto_reconnect"] = new OSDBoolean(true);
            }
            if (!config.ContainsKey("ctcp_version"))
            {
                config["ctcp_version"] = new OSDString("Radegast IRC");
            }

            txtChan.Text   = config["channel"].AsString();
            txtNick.Text   = config["nick"].AsString();
            txtPort.Text   = config["port"].AsString();
            txtServer.Text = config["server"].AsString();

            irc               = new IrcClient();
            irc.SendDelay     = config["send_delay"].AsInteger();
            irc.AutoReconnect = config["auto_reconnect"].AsBoolean();
            irc.CtcpVersion   = config["ctcp_version"].AsString();
            irc.Encoding      = Encoding.UTF8;

            TC.OnTabAdded        += TC_OnTabAdded;
            TC.OnTabRemoved      += TC_OnTabRemoved;
            irc.OnError          += irc_OnError;
            irc.OnRawMessage     += irc_OnRawMessage;
            irc.OnChannelMessage += irc_OnChannelMessage;
            irc.OnConnected      += irc_OnConnected;
            irc.OnDisconnected   += irc_OnDisconnected;

            client.Self.IM += Self_IM;
            client.Self.ChatFromSimulator += Self_ChatFromSimulator;

            UpdateGui();

            RefreshGroups();
        }
示例#45
0
        /// <summary>
        /// Deserialization of agent data.
        /// Avoiding reflection makes it painful to write, but that's the price!
        /// </summary>
        /// <param name="hash"></param>
        public virtual void Unpack(OSDMap args)
        {
            if (args.ContainsKey("region_handle"))
                UInt64.TryParse(args["region_handle"].AsString(), out RegionHandle);

            if (args["circuit_code"] != null)
                UInt32.TryParse((string)args["circuit_code"].AsString(), out CircuitCode);

            if (args["agent_uuid"] != null)
                AgentID = args["agent_uuid"].AsUUID();

            if (args["session_uuid"] != null)
                SessionID = args["session_uuid"].AsUUID();

            if (args["position"] != null)
                Vector3.TryParse(args["position"].AsString(), out Position);

            if (args["velocity"] != null)
                Vector3.TryParse(args["velocity"].AsString(), out Velocity);

            if (args["center"] != null)
                Vector3.TryParse(args["center"].AsString(), out Center);

            if (args["size"] != null)
                Vector3.TryParse(args["size"].AsString(), out Size);

            if (args["at_axis"] != null)
                Vector3.TryParse(args["at_axis"].AsString(), out AtAxis);

            if (args["left_axis"] != null)
                Vector3.TryParse(args["left_axis"].AsString(), out AtAxis);

            if (args["up_axis"] != null)
                Vector3.TryParse(args["up_axis"].AsString(), out AtAxis);

            if (args["changed_grid"] != null)
                ChangedGrid = args["changed_grid"].AsBoolean();

            if (args["far"] != null)
                Far = (float)(args["far"].AsReal());

            if (args["aspect"] != null)
                Aspect = (float)args["aspect"].AsReal();

            if (args["throttles"] != null)
                Throttles = args["throttles"].AsBinary();

            if (args["locomotion_state"] != null)
                UInt32.TryParse(args["locomotion_state"].AsString(), out LocomotionState);

            if (args["head_rotation"] != null)
                Quaternion.TryParse(args["head_rotation"].AsString(), out HeadRotation);

            if (args["body_rotation"] != null)
                Quaternion.TryParse(args["body_rotation"].AsString(), out BodyRotation);

            if (args["control_flags"] != null)
                UInt32.TryParse(args["control_flags"].AsString(), out ControlFlags);

            if (args["energy_level"] != null)
                EnergyLevel = (float)(args["energy_level"].AsReal());

            if (args["god_level"] != null)
                Byte.TryParse(args["god_level"].AsString(), out GodLevel);

            if (args["always_run"] != null)
                AlwaysRun = args["always_run"].AsBoolean();

            if (args["prey_agent"] != null)
                PreyAgent = args["prey_agent"].AsUUID();

            if (args["agent_access"] != null)
                Byte.TryParse(args["agent_access"].AsString(), out AgentAccess);

            if (args["active_group_id"] != null)
                ActiveGroupID = args["active_group_id"].AsUUID();

            if ((args["groups"] != null) && (args["groups"]).Type == OSDType.Array)
            {
                OSDArray groups = (OSDArray)(args["groups"]);
                Groups = new AgentGroupData[groups.Count];
                int i = 0;
                foreach (OSD o in groups)
                {
                    if (o.Type == OSDType.Map)
                    {
                        Groups[i++] = new AgentGroupData((OSDMap)o);
                    }
                }
            }

            if ((args["animations"] != null) && (args["animations"]).Type == OSDType.Array)
            {
                OSDArray anims = (OSDArray)(args["animations"]);
                Anims = new Animation[anims.Count];
                int i = 0;
                foreach (OSD o in anims)
                {
                    if (o.Type == OSDType.Map)
                    {
                        Anims[i++] = new Animation((OSDMap)o);
                    }
                }
            }

            //if ((args["agent_textures"] != null) && (args["agent_textures"]).Type == OSDType.Array)
            //{
            //    OSDArray textures = (OSDArray)(args["agent_textures"]);
            //    AgentTextures = new UUID[textures.Count];
            //    int i = 0;
            //    foreach (OSD o in textures)
            //        AgentTextures[i++] = o.AsUUID();
            //}

            if (args["texture_entry"] != null)
                AgentTextures = args["texture_entry"].AsBinary();

            if (args["visual_params"] != null)
                VisualParams = args["visual_params"].AsBinary();

            if ((args["wearables"] != null) && (args["wearables"]).Type == OSDType.Array)
            {
                OSDArray wears = (OSDArray)(args["wearables"]);
                Wearables = new UUID[wears.Count];
                int i = 0;
                foreach (OSD o in wears)
                    Wearables[i++] = o.AsUUID();
            }
            
            if (args["callback_uri"] != null)
                CallbackURI = args["callback_uri"].AsString();
        }
示例#46
0
        /// <summary>
        /// Unpack agent circuit data map into an AgentCiruitData object
        /// </summary>
        /// <param name="args"></param>
        public void UnpackAgentCircuitData(OSDMap args)
        {
            if (args["agent_id"] != null)
            {
                AgentID = args["agent_id"].AsUUID();
            }
            if (args["caps_path"] != null)
            {
                CapsPath = args["caps_path"].AsString();
            }

            if (args["child"] != null)
            {
                child = args["child"].AsBoolean();
            }
            if (args["circuit_code"] != null)
            {
                UInt32.TryParse(args["circuit_code"].AsString(), out circuitcode);
            }
            if (args["secure_session_id"] != null)
            {
                SecureSessionID = args["secure_session_id"].AsUUID();
            }
            if (args["session_id"] != null)
            {
                SessionID = args["session_id"].AsUUID();
            }
            if (args["service_session_id"] != null)
            {
                ServiceSessionID = args["service_session_id"].AsString();
            }
            if (args["client_ip"] != null)
            {
                IPAddress = args["client_ip"].AsString();
            }

            if (args["start_pos"] != null)
            {
                Vector3.TryParse(args["start_pos"].AsString(), out startpos);
            }

            if (args["teleport_flags"] != null)
            {
                teleportFlags = args["teleport_flags"].AsUInteger();
            }

            // DEBUG ON
            //m_log.WarnFormat("[AGENTCIRCUITDATA] agentid={0}, child={1}, startpos={2}", AgentID, child, startpos.ToString());
            // DEBUG OFF

            try
            {
                // Unpack various appearance elements
                Appearance = new AvatarAppearance(AgentID);

                // Eventually this code should be deprecated, use full appearance
                // packing in packed_appearance
                if (args["appearance_serial"] != null)
                {
                    Appearance.Serial = args["appearance_serial"].AsInteger();
                }

                if (args.ContainsKey("packed_appearance") && (args["packed_appearance"].Type == OSDType.Map))
                {
                    Appearance.Unpack((OSDMap)args["packed_appearance"]);
                    // DEBUG ON
                    //m_log.WarnFormat("[AGENTCIRCUITDATA] unpacked appearance");
                    // DEBUG OFF
                }
                // DEBUG ON
                else
                {
                    m_log.Warn("[AGENTCIRCUITDATA] failed to find a valid packed_appearance");
                }
                // DEBUG OFF
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[AGENTCIRCUITDATA] failed to unpack appearance; {0}", e.ToString());
            }

            if (args.ContainsKey("otherInfo"))
            {
                OtherInformation = (OSDMap)OSDParser.DeserializeLLSDXml(args["otherInfo"].AsString());
            }
        }
示例#47
0
        /// <summary>
        /// Deserialization of agent data.
        /// Avoiding reflection makes it painful to write, but that's the price!
        /// </summary>
        /// <param name="hash"></param>
        public virtual void Unpack(OSDMap args)
        {
            // DEBUG ON
            m_log.WarnFormat("[CHILDAGENTDATAUPDATE] Unpack data");
            // DEBUG OFF

            if (args.ContainsKey("region_id"))
                UUID.TryParse(args["region_id"].AsString(), out RegionID);

            if (args["circuit_code"] != null)
                UInt32.TryParse((string)args["circuit_code"].AsString(), out CircuitCode);

            if (args["agent_uuid"] != null)
                AgentID = args["agent_uuid"].AsUUID();

            if (args["session_uuid"] != null)
                SessionID = args["session_uuid"].AsUUID();

            if (args["position"] != null)
                Vector3.TryParse(args["position"].AsString(), out Position);

            if (args["velocity"] != null)
                Vector3.TryParse(args["velocity"].AsString(), out Velocity);

            if (args["center"] != null)
                Vector3.TryParse(args["center"].AsString(), out Center);

            if (args["size"] != null)
                Vector3.TryParse(args["size"].AsString(), out Size);

            if (args["at_axis"] != null)
                Vector3.TryParse(args["at_axis"].AsString(), out AtAxis);

            if (args["left_axis"] != null)
                Vector3.TryParse(args["left_axis"].AsString(), out AtAxis);

            if (args["up_axis"] != null)
                Vector3.TryParse(args["up_axis"].AsString(), out AtAxis);

            if (args["changed_grid"] != null)
                ChangedGrid = args["changed_grid"].AsBoolean();

            if (args["far"] != null)
                Far = (float)(args["far"].AsReal());

            if (args["aspect"] != null)
                Aspect = (float)args["aspect"].AsReal();

            if (args["throttles"] != null)
                Throttles = args["throttles"].AsBinary();

            if (args["locomotion_state"] != null)
                UInt32.TryParse(args["locomotion_state"].AsString(), out LocomotionState);

            if (args["head_rotation"] != null)
                Quaternion.TryParse(args["head_rotation"].AsString(), out HeadRotation);

            if (args["body_rotation"] != null)
                Quaternion.TryParse(args["body_rotation"].AsString(), out BodyRotation);

            if (args["control_flags"] != null)
                UInt32.TryParse(args["control_flags"].AsString(), out ControlFlags);

            if (args["energy_level"] != null)
                EnergyLevel = (float)(args["energy_level"].AsReal());

            //This IS checked later
            if (args["god_level"] != null)
                Byte.TryParse(args["god_level"].AsString(), out GodLevel);

            if (args["speed"] != null)
                float.TryParse(args["speed"].AsString(), out Speed);
            else
                Speed = 1;

            if (args["draw_distance"] != null)
                float.TryParse(args["draw_distance"].AsString(), out DrawDistance);
            else
                DrawDistance = 0;

            //Reset this to fix movement... since regions are being bad about this
            if (Speed == 0)
                Speed = 1;

            if (args["always_run"] != null)
                AlwaysRun = args["always_run"].AsBoolean();

            if (args["sent_initial_wearables"] != null)
                SentInitialWearables = args["sent_initial_wearables"].AsBoolean();
            else
                SentInitialWearables = false;

            if (args["prey_agent"] != null)
                PreyAgent = args["prey_agent"].AsUUID();

            if (args["agent_access"] != null)
                Byte.TryParse(args["agent_access"].AsString(), out AgentAccess);

            if (args["active_group_id"] != null)
                ActiveGroupID = args["active_group_id"].AsUUID();

            if ((args["groups"] != null) && (args["groups"]).Type == OSDType.Array)
            {
                OSDArray groups = (OSDArray)(args["groups"]);
                Groups = new AgentGroupData[groups.Count];
                int i = 0;
                foreach (OSD o in groups)
                {
                    if (o.Type == OSDType.Map)
                    {
                        Groups[i++] = new AgentGroupData((OSDMap)o);
                    }
                }
            }

            if ((args["animations"] != null) && (args["animations"]).Type == OSDType.Array)
            {
                OSDArray anims = (OSDArray)(args["animations"]);
                Anims = new Animation[anims.Count];
                int i = 0;
                foreach (OSD o in anims)
                {
                    if (o.Type == OSDType.Map)
                    {
                        Anims[i++] = new Animation((OSDMap)o);
                    }
                }
            }

            //if ((args["agent_textures"] != null) && (args["agent_textures"]).Type == OSDType.Array)
            //{
            //    OSDArray textures = (OSDArray)(args["agent_textures"]);
            //    AgentTextures = new UUID[textures.Count];
            //    int i = 0;
            //    foreach (OSD o in textures)
            //        AgentTextures[i++] = o.AsUUID();
            //}

            Appearance = new AvatarAppearance(AgentID);

            // The code to unpack textures, visuals, wearables and attachments
            // should be removed; packed appearance contains the full appearance
            // This is retained for backward compatibility only
            if (args["texture_entry"] != null)
            {
                byte[] rawtextures = args["texture_entry"].AsBinary();
                Primitive.TextureEntry textures = new Primitive.TextureEntry(rawtextures, 0, rawtextures.Length);
                List<UUID> changed = new List<UUID>();
                Appearance.SetTextureEntries(textures, out changed);
            }

            if (args["visual_params"] != null)
                Appearance.SetVisualParams(args["visual_params"].AsBinary());

            if ((args["wearables"] != null) && (args["wearables"]).Type == OSDType.Array)
            {
                OSDArray wears = (OSDArray)(args["wearables"]);
                for (int i = 0; i < wears.Count / 2; i++)
                {
                    AvatarWearable awear = new AvatarWearable((OSDArray)wears[i]);
                    Appearance.SetWearable(i, awear);
                }
            }

            if ((args["attachments"] != null) && (args["attachments"]).Type == OSDType.Array)
            {
                OSDArray attachs = (OSDArray)(args["attachments"]);
                foreach (OSD o in attachs)
                {
                    if (o.Type == OSDType.Map)
                    {
                        // We know all of these must end up as attachments so we
                        // append rather than replace to ensure multiple attachments
                        // per point continues to work
                        Appearance.AppendAttachment(new AvatarAttachment((OSDMap)o));
                    }
                }
            }
            // end of code to remove

            if (args.ContainsKey("packed_appearance") && (args["packed_appearance"]).Type == OSDType.Map)
                Appearance = new AvatarAppearance(AgentID, (OSDMap)args["packed_appearance"]);
            // DEBUG ON
            else
                m_log.WarnFormat("[CHILDAGENTDATAUPDATE] No packed appearance");
            // DEBUG OFF

            if ((args["controllers"] != null) && (args["controllers"]).Type == OSDType.Array)
            {
                OSDArray controls = (OSDArray)(args["controllers"]);
                Controllers = new ControllerData[controls.Count];
                int i = 0;
                foreach (OSD o in controls)
                {
                    if (o.Type == OSDType.Map)
                    {
                        Controllers[i++] = new ControllerData((OSDMap)o);
                    }
                }
            }

            if (args["callback_uri"] != null)
                CallbackURI = args["callback_uri"].AsString();
        }
        protected void DoAgentPut(Hashtable request, Hashtable responsedata)
        {
            OSDMap args = Utils.GetOSDMap((string)request["body"]);

            if (args == null)
            {
                responsedata["int_response_code"]   = HttpStatusCode.BadRequest;
                responsedata["str_response_string"] = "Bad request";
                return;
            }

            // retrieve the input arguments
            int    x = 0, y = 0;
            UUID   uuid       = UUID.Zero;
            string regionname = string.Empty;

            if (args.ContainsKey("destination_x") && args["destination_x"] != null)
            {
                Int32.TryParse(args["destination_x"].AsString(), out x);
            }
            if (args.ContainsKey("destination_y") && args["destination_y"] != null)
            {
                Int32.TryParse(args["destination_y"].AsString(), out y);
            }
            if (args.ContainsKey("destination_uuid") && args["destination_uuid"] != null)
            {
                UUID.TryParse(args["destination_uuid"].AsString(), out uuid);
            }
            if (args.ContainsKey("destination_name") && args["destination_name"] != null)
            {
                regionname = args["destination_name"].ToString();
            }

            GridRegion destination = new GridRegion();

            destination.RegionID   = uuid;
            destination.RegionLocX = x;
            destination.RegionLocY = y;
            destination.RegionName = regionname;

            string messageType;

            if (args["message_type"] != null)
            {
                messageType = args["message_type"].AsString();
            }
            else
            {
                m_log.Warn("[AGENT HANDLER]: Agent Put Message Type not found. ");
                messageType = "AgentData";
            }

            bool result = true;

            if ("AgentData".Equals(messageType))
            {
                AgentData agent = new AgentData();
                try
                {
                    agent.Unpack(args, m_SimulationService.GetScene(destination.RegionID));
                }
                catch (Exception ex)
                {
                    m_log.InfoFormat("[AGENT HANDLER]: exception on unpacking ChildAgentUpdate message {0}", ex.Message);
                    responsedata["int_response_code"]   = HttpStatusCode.BadRequest;
                    responsedata["str_response_string"] = "Bad request";
                    return;
                }

                //agent.Dump();
                // This is one of the meanings of PUT agent
                result = UpdateAgent(destination, agent);
            }
            else if ("AgentPosition".Equals(messageType))
            {
                AgentPosition agent = new AgentPosition();
                try
                {
                    agent.Unpack(args, m_SimulationService.GetScene(destination.RegionID));
                }
                catch (Exception ex)
                {
                    m_log.InfoFormat("[AGENT HANDLER]: exception on unpacking ChildAgentUpdate message {0}", ex.Message);
                    return;
                }
                //agent.Dump();
                // This is one of the meanings of PUT agent
                result = m_SimulationService.UpdateAgent(destination, agent);
            }

            responsedata["int_response_code"]   = HttpStatusCode.OK;
            responsedata["str_response_string"] = result.ToString();
            //responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp); ??? instead
        }
示例#49
0
        /// <summary>
        /// Unpack agent circuit data map into an AgentCiruitData object
        /// </summary>
        /// <param name="args"></param>
        public void UnpackAgentCircuitData(OSDMap args)
        {
            if (args["agent_id"] != null)
                AgentID = args["agent_id"].AsUUID();
            if (args["base_folder"] != null)
                BaseFolder = args["base_folder"].AsUUID();
            if (args["caps_path"] != null)
                CapsPath = args["caps_path"].AsString();

            if ((args["children_seeds"] != null) && (args["children_seeds"].Type == OSDType.Array))
            {
                OSDArray childrenSeeds = (OSDArray)(args["children_seeds"]);
                ChildrenCapSeeds = new Dictionary<ulong, string>();
                foreach (OSD o in childrenSeeds)
                {
                    if (o.Type == OSDType.Map)
                    {
                        ulong handle = 0;
                        string seed = "";
                        OSDMap pair = (OSDMap)o;
                        if (pair["handle"] != null)
                            if (!UInt64.TryParse(pair["handle"].AsString(), out handle))
                                continue;
                        if (pair["seed"] != null)
                            seed = pair["seed"].AsString();
                        if (!ChildrenCapSeeds.ContainsKey(handle))
                            ChildrenCapSeeds.Add(handle, seed);
                    }
                }
            }
            else
                ChildrenCapSeeds = new Dictionary<ulong, string>();

            if (args["child"] != null)
                child = args["child"].AsBoolean();
            if (args["circuit_code"] != null)
                UInt32.TryParse(args["circuit_code"].AsString(), out circuitcode);
            if (args["first_name"] != null)
                firstname = args["first_name"].AsString();
            if (args["last_name"] != null)
                lastname = args["last_name"].AsString();
            if (args["inventory_folder"] != null)
                InventoryFolder = args["inventory_folder"].AsUUID();
            if (args["secure_session_id"] != null)
                SecureSessionID = args["secure_session_id"].AsUUID();
            if (args["session_id"] != null)
                SessionID = args["session_id"].AsUUID();
            if (args["service_session_id"] != null)
                ServiceSessionID = args["service_session_id"].AsString();
            if (args["client_ip"] != null)
                IPAddress = args["client_ip"].AsString();
            if (args["viewer"] != null)
                Viewer = args["viewer"].AsString();
            if (args["channel"] != null)
                Channel = args["channel"].AsString();
            if (args["mac"] != null)
                Mac = args["mac"].AsString();
            if (args["id0"] != null)
                Id0 = args["id0"].AsString();

            if (args["start_pos"] != null)
                Vector3.TryParse(args["start_pos"].AsString(), out startpos);

            // DEBUG ON
            //m_log.WarnFormat("[AGENTCIRCUITDATA] agentid={0}, child={1}, startpos={2}", AgentID, child, startpos.ToString());
            // DEBUG OFF

            try
            {
                // Unpack various appearance elements
                Appearance = new AvatarAppearance(AgentID);

                // Eventually this code should be deprecated, use full appearance
                // packing in packed_appearance
                if (args["appearance_serial"] != null)
                    Appearance.Serial = args["appearance_serial"].AsInteger();

                if (args.ContainsKey("packed_appearance") && (args["packed_appearance"].Type == OSDType.Map))
                {
                    Appearance.Unpack((OSDMap)args["packed_appearance"]);
                    // DEBUG ON
                    //m_log.WarnFormat("[AGENTCIRCUITDATA] unpacked appearance");
                    // DEBUG OFF
                }
                // DEBUG ON
                else
                    m_log.Warn("[AGENTCIRCUITDATA] failed to find a valid packed_appearance");
                // DEBUG OFF
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[AGENTCIRCUITDATA] failed to unpack appearance; {0}", e.Message);
            }

            ServiceURLs = new Dictionary<string, object>();
            if (args.ContainsKey("service_urls") && args["service_urls"] != null && (args["service_urls"]).Type == OSDType.Array)
            {
                OSDArray urls = (OSDArray)(args["service_urls"]);
                for (int i = 0; i < urls.Count / 2; i++)
                {
                    ServiceURLs[urls[i * 2].AsString()] = urls[(i * 2) + 1].AsString();
                    //System.Console.WriteLine("XXX " + urls[i * 2].AsString() + "=" + urls[(i * 2) + 1].AsString());

                }
            }
        }
示例#50
0
        public override void FromOSD(OSDMap map)
        {
            if (map.ContainsKey("uuid"))
            {
                RegionID = map["uuid"].AsUUID();
            }

            if (map.ContainsKey("locX"))
            {
                RegionLocX = map["locX"].AsInteger();
            }

            if (map.ContainsKey("locY"))
            {
                RegionLocY = map["locY"].AsInteger();
            }

            if (map.ContainsKey("locZ"))
            {
                RegionLocZ = map["locZ"].AsInteger();
            }

            if (map.ContainsKey("regionName"))
            {
                RegionName = map["regionName"].AsString();
            }

            if (map.ContainsKey("regionType"))
            {
                RegionType = map["regionType"].AsString();
            }

            ExternalHostName = map.ContainsKey("serverIP") ? map["serverIP"].AsString() : "127.0.0.1";

            InternalPort = map["serverPort"].AsInteger();

            if (map.ContainsKey("serverHttpPort"))
            {
                UInt32 port = map["serverHttpPort"].AsUInteger();
                HttpPort = port;
            }

            if (map.ContainsKey("regionMapTexture"))
            {
                TerrainImage = map["regionMapTexture"].AsUUID();
            }

            if (map.ContainsKey("regionTerrainTexture"))
            {
                TerrainMapImage = map["regionTerrainTexture"].AsUUID();
            }

            if (map.ContainsKey("ParcelMapImage"))
            {
                ParcelMapImage = map["ParcelMapImage"].AsUUID();
            }

            if (map.ContainsKey("access"))
            {
                Access = (byte)map["access"].AsInteger();
            }

            if (map.ContainsKey("owner_uuid"))
            {
                EstateOwner = map["owner_uuid"].AsUUID();
            }

            if (map.ContainsKey("EstateOwner"))
            {
                EstateOwner = map["EstateOwner"].AsUUID();
            }

            if (map.ContainsKey("sizeX"))
            {
                RegionSizeX = map["sizeX"].AsInteger();
            }

            if (map.ContainsKey("sizeY"))
            {
                RegionSizeY = map["sizeY"].AsInteger();
            }

            if (map.ContainsKey("sizeZ"))
            {
                RegionSizeZ = map["sizeZ"].AsInteger();
            }

            if (map.ContainsKey("LastSeen"))
            {
                LastSeen = map["LastSeen"].AsInteger();
            }

            if (map.ContainsKey("SessionID"))
            {
                SessionID = map["SessionID"].AsUUID();
            }

            if (map.ContainsKey("Flags"))
            {
                Flags = map["Flags"].AsInteger();
            }

            if (map.ContainsKey("ScopeID"))
            {
                ScopeID = map["ScopeID"].AsUUID();
            }

            if (map.ContainsKey("AllScopeIDs"))
            {
                AllScopeIDs = ((OSDArray)map["AllScopeIDs"]).ConvertAll <UUID>(o => o);
            }

            if (map.ContainsKey("remoteEndPointIP"))
            {
                IPAddress add  = new IPAddress(map["remoteEndPointIP"].AsBinary());
                int       port = map["remoteEndPointPort"].AsInteger();
                m_remoteEndPoint = new IPEndPoint(add, port);
            }
        }
        protected OSDMap OnMessageReceived(OSDMap message)
        {
            if (message.ContainsKey("Method") && message["Method"] == "GridWideMessage")
            {
                //We got a message, now display it
                string user = message["User"].AsString();
                string value = message["Value"].AsString();

                //Get the Scene registry since IDialogModule is a region module, and isn't in the ISimulationBase registry
                ISceneManager manager = m_registry.RequestModuleInterface<ISceneManager>();
                if (manager != null)
                {
                    foreach (IScene scene in manager.Scenes)
                    {
                        IScenePresence sp = null;
                        if (scene.TryGetScenePresence(UUID.Parse(user), out sp) && !sp.IsChildAgent)
                        {
                            IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>();
                            if (dialogModule != null)
                            {
                                //Send the message to the user now
                                dialogModule.SendAlertToUser(UUID.Parse(user), value);
                            }
                        }
                    }
                }
            }
            else if (message.ContainsKey("Method") && message["Method"] == "KickUserMessage")
            {
                //We got a message, now display it
                string user = message["User"].AsString();
                string value = message["Value"].AsString();

                //Get the Scene registry since IDialogModule is a region module, and isn't in the ISimulationBase registry
                ISceneManager manager = m_registry.RequestModuleInterface<ISceneManager>();
                if (manager != null)
                {
                    foreach (IScene scene in manager.Scenes)
                    {
                        IScenePresence sp = null;
                        if (scene.TryGetScenePresence(UUID.Parse(user), out sp))
                        {
                            sp.ControllingClient.Kick(value == "" ? "The WhiteCore Grid Manager kicked you out." : value);
                            IEntityTransferModule transferModule =
                                scene.RequestModuleInterface<IEntityTransferModule>();
                            if (transferModule != null)
                                transferModule.IncomingCloseAgent(scene, sp.UUID);
                        }
                    }
                }
            }
            return null;
        }
示例#52
0
        protected OSDMap OnMessageReceived(OSDMap message)
        {
            //We need to check and see if this is an GroupSessionAgentUpdate
            if (message.ContainsKey("Method") && message["Method"] == "GroupSessionAgentUpdate")
            {
                //Comes in on the Universe.Server side
                //Send it on to whomever it concerns
                OSDMap innerMessage = (OSDMap)message["Message"];
                if (innerMessage["message"] == "ChatterBoxSessionAgentListUpdates")
                //ONLY forward on this type of message
                {
                    UUID agentID                 = message["AgentID"];
                    IEventQueueService eqs       = m_registry.RequestModuleInterface <IEventQueueService>();
                    IAgentInfoService  agentInfo = m_registry.RequestModuleInterface <IAgentInfoService>();
                    if (agentInfo != null)
                    {
                        UserInfo user = agentInfo.GetUserInfo(agentID.ToString());
                        if (user != null && user.IsOnline)
                        {
                            eqs.Enqueue(innerMessage, agentID, user.CurrentRegionID);
                        }
                    }
                }
            }
            else if (message.ContainsKey("Method") && message["Method"] == "FixGroupRoleTitles")
            {
                //Comes in on the Universe.Server side from region
                UUID groupID = message["GroupID"].AsUUID();
                UUID agentID = message["AgentID"].AsUUID();
                UUID roleID  = message["RoleID"].AsUUID();
                byte type    = (byte)message["Type"].AsInteger();
                IGroupsServiceConnector     con     = Framework.Utilities.DataManager.RequestPlugin <IGroupsServiceConnector>();
                List <GroupRoleMembersData> members = con.GetGroupRoleMembers(agentID, groupID);
                List <GroupRolesData>       roles   = con.GetGroupRoles(agentID, groupID);
                GroupRolesData everyone             = null;

                foreach (GroupRolesData role in roles.Where(role => role.Name == "Everyone"))
                {
                    everyone = role;
                }

                List <UserInfo> regionsToBeUpdated = new List <UserInfo>();
                foreach (GroupRoleMembersData data in members)
                {
                    if (data.RoleID == roleID)
                    {
                        //They were affected by the change
                        switch ((GroupRoleUpdate)type)
                        {
                        case GroupRoleUpdate.Create:
                        case GroupRoleUpdate.NoUpdate:
                            //No changes...
                            break;

                        case GroupRoleUpdate.UpdatePowers:     //Possible we don't need to send this?
                        case GroupRoleUpdate.UpdateAll:
                        case GroupRoleUpdate.UpdateData:
                        case GroupRoleUpdate.Delete:
                            if (type == (byte)GroupRoleUpdate.Delete)
                            {
                                //Set them to the most limited role since their role is gone
                                con.SetAgentGroupSelectedRole(data.MemberID, groupID, everyone.RoleID);
                            }
                            //Need to update their title inworld

                            IAgentInfoService agentInfoService =
                                m_registry.RequestModuleInterface <IAgentInfoService>();
                            UserInfo info;
                            if (agentInfoService != null &&
                                (info = agentInfoService.GetUserInfo(agentID.ToString())) != null && info.IsOnline)
                            {
                                //Forward the message
                                regionsToBeUpdated.Add(info);
                            }
                            break;
                        }
                    }
                }
                if (regionsToBeUpdated.Count != 0)
                {
                    ISyncMessagePosterService messagePost =
                        m_registry.RequestModuleInterface <ISyncMessagePosterService>();
                    if (messagePost != null)
                    {
                        foreach (UserInfo userInfo in regionsToBeUpdated)
                        {
                            OSDMap outgoingMessage = new OSDMap();
                            outgoingMessage["Method"]   = "ForceUpdateGroupTitles";
                            outgoingMessage["GroupID"]  = groupID;
                            outgoingMessage["RoleID"]   = roleID;
                            outgoingMessage["RegionID"] = userInfo.CurrentRegionID;
                            messagePost.Post(userInfo.CurrentRegionURI, outgoingMessage);
                        }
                    }
                }
            }
            else if (message.ContainsKey("Method") && message["Method"] == "ForceUpdateGroupTitles")
            {
                //Comes in on the region side from the Universe.Server
                UUID          groupID  = message["GroupID"].AsUUID();
                UUID          roleID   = message["RoleID"].AsUUID();
                UUID          regionID = message["RegionID"].AsUUID();
                IGroupsModule gm       = m_registry.RequestModuleInterface <IGroupsModule>();
                if (gm != null)
                {
                    gm.UpdateUsersForExternalRoleUpdate(groupID, roleID, regionID);
                }
            }
            return(null);
        }
        protected virtual void DoObjectPost(Hashtable request, Hashtable responsedata, ulong regionhandle)
        {
            OSDMap args = RegionClient.GetOSDMap((string)request["body"]);

            if (args == null)
            {
                responsedata["int_response_code"]   = 400;
                responsedata["str_response_string"] = "false";
                return;
            }

            Vector3 pos = Vector3.Zero;
            string  sogXmlStr = String.Empty, extraStr = String.Empty, stateXmlStr = String.Empty;

            if (args.ContainsKey("sog"))
            {
                sogXmlStr = args["sog"].AsString();
            }
            if (args.ContainsKey("extra"))
            {
                extraStr = args["extra"].AsString();
            }
            if (args.ContainsKey("pos"))
            {
                pos = args["pos"].AsVector3();
            }

            UUID             regionID = m_localBackend.GetRegionID(regionhandle);
            SceneObjectGroup sog      = null;

            try
            {
                sog = SceneObjectSerializer.FromXml2Format(sogXmlStr);
                sog.ExtraFromXmlString(extraStr);
            }
            catch (Exception ex)
            {
                m_log.InfoFormat("[REST COMMS]: exception on deserializing scene object {0}", ex.Message);
                responsedata["int_response_code"]   = 400;
                responsedata["str_response_string"] = "false";
                return;
            }

            if (args.ContainsKey("pos"))
            {
                sog.AbsolutePosition = pos;
            }

            if (args.ContainsKey("avatars"))
            {
                sog.AvatarsToExpect = args["avatars"].AsInteger();
            }

            if ((args.ContainsKey("state")) && m_aScene.m_allowScriptCrossings)
            {
                stateXmlStr = args["state"].AsString();
                if (!String.IsNullOrEmpty(stateXmlStr))
                {
                    try
                    {
                        sog.SetState(stateXmlStr, regionID);
                    }
                    catch (Exception ex)
                    {
                        m_log.InfoFormat("[REST COMMS]: exception on setting state for scene object {0}", ex.Message);
                    }
                }
            }
            // This is the meaning of POST object
            bool result = m_localBackend.SendCreateObject(regionhandle, sog, null, false, pos, args["pos"] == null);

            responsedata["int_response_code"]   = 200;
            responsedata["str_response_string"] = result.ToString();
        }
示例#54
0
        OSDMap CreateAccount(OSDMap map)
        {
            bool   Verified = false;
            string Name     = map ["Name"].AsString();

            string Password = "";

            if (map.ContainsKey("Password"))
            {
                Password = map ["Password"].AsString();
            }
            else
            {
                Password = map ["PasswordHash"].AsString();  //is really plaintext password, the system hashes it later. Not sure why it was called PasswordHash to start with. I guess the original design was to have the PHP code generate the salt and password hash, then just simply store it here
            }

            //string PasswordSalt = map["PasswordSalt"].AsString(); //not being used
            string HomeRegion    = map ["HomeRegion"].AsString();
            string Email         = map ["Email"].AsString();
            string AvatarArchive = map ["AvatarArchive"].AsString();
            int    userLevel     = map ["UserLevel"].AsInteger();
            string UserTitle     = map ["UserTitle"].AsString();

            //server expects: 0 is PG, 1 is Mature, 2 is Adult - use this when setting MaxMaturity and MaturityRating
            //viewer expects: 13 is PG, 21 is Mature, 42 is Adult

            int MaxMaturity = 2;                //set to adult by default

            if (map.ContainsKey("MaxMaturity")) //MaxMaturity is the highest level that they can change the maturity rating to in the viewer
            {
                MaxMaturity = map ["MaxMaturity"].AsInteger();
            }

            int MaturityRating = MaxMaturity;      //set the default to whatever MaxMaturity was set tom incase they didn't define MaturityRating

            if (map.ContainsKey("MaturityRating")) //MaturityRating is the rating the user wants to be able to see
            {
                MaturityRating = map ["MaturityRating"].AsInteger();
            }

            bool activationRequired = map.ContainsKey("ActivationRequired") ? map ["ActivationRequired"].AsBoolean() : false;

            IUserAccountService accountService = m_registry.RequestModuleInterface <IUserAccountService> ();

            if (accountService == null)
            {
                return(null);
            }

            if (!Password.StartsWith("$1$", StringComparison.Ordinal))
            {
                Password = "******" + Util.Md5Hash(Password);
            }
            Password = Password.Remove(0, 3);  // remove $1$

            accountService.CreateUser(Name, Password, Email);
            UserAccount       userAcct         = accountService.GetUserAccount(null, Name);
            IAgentInfoService agentInfoService = m_registry.RequestModuleInterface <IAgentInfoService> ();
            IGridService      gridService      = m_registry.RequestModuleInterface <IGridService> ();

            if (agentInfoService != null && gridService != null)
            {
                GridRegion rgn = gridService.GetRegionByName(null, HomeRegion);
                if (rgn != null)
                {
                    agentInfoService.SetHomePosition(userAcct.PrincipalID.ToString(),
                                                     rgn.RegionID,
                                                     new Vector3(rgn.RegionSizeX / 2, rgn.RegionSizeY / 2, 20),
                                                     Vector3.Zero);
                }
                else
                {
                    MainConsole.Instance.DebugFormat("[API]: Could not set home position for user {0}, region \"{1}\" did not produce a result from the grid service", Name, HomeRegion);
                }
                rgn = null; // no longer needed
            }

            Verified = userAcct.Valid;
            UUID userID = UUID.Zero;

            OSDMap resp = new OSDMap();

            resp ["Verified"] = OSD.FromBoolean(Verified);

            if (Verified)
            {
                userID             = userAcct.PrincipalID;
                userAcct.UserLevel = userLevel;

                // could not find a way to save this data here.
                DateTime RLDOB     = map ["RLDOB"].AsDate();
                string   RLGender  = map ["RLGender"].AsString();
                string   RLName    = map ["RLName"].AsString();
                string   RLAddress = map ["RLAddress"].AsString();
                string   RLCity    = map ["RLCity"].AsString();
                string   RLZip     = map ["RLZip"].AsString();
                string   RLCountry = map ["RLCountry"].AsString();
                string   RLIP      = map ["RLIP"].AsString();



                IAgentConnector con = DataPlugins.RequestPlugin <IAgentConnector> ();
                con.CreateNewAgent(userID);

                IAgentInfo agent = con.GetAgent(userID);

                agent.MaxMaturity    = MaxMaturity;
                agent.MaturityRating = MaturityRating;

                agent.OtherAgentInformation ["RLDOB"]     = RLDOB;
                agent.OtherAgentInformation ["RLGender"]  = RLGender;
                agent.OtherAgentInformation ["RLName"]    = RLName;
                agent.OtherAgentInformation ["RLAddress"] = RLAddress;
                agent.OtherAgentInformation ["RLCity"]    = RLCity;
                agent.OtherAgentInformation ["RLZip"]     = RLZip;
                agent.OtherAgentInformation ["RLCountry"] = RLCountry;
                agent.OtherAgentInformation ["RLIP"]      = RLIP;
                if (activationRequired)
                {
                    UUID activationToken = UUID.Random();
                    agent.OtherAgentInformation ["WebUIActivationToken"] = Util.Md5Hash(activationToken.ToString() + ":" + Password);
                    resp ["WebUIActivationToken"] = activationToken;
                }
                con.UpdateAgent(agent);

                accountService.StoreUserAccount(userAcct);

                IProfileConnector profileData = DataPlugins.RequestPlugin <IProfileConnector> ();
                IUserProfileInfo  profile     = profileData.GetUserProfile(userAcct.PrincipalID);
                if (profile == null)
                {
                    profileData.CreateNewProfile(userAcct.PrincipalID);
                    profile = profileData.GetUserProfile(userAcct.PrincipalID);
                }
                if (AvatarArchive.Length > 0)
                {
                    profile.AArchiveName = AvatarArchive;
                }
                //    MainConsole.Instance.InfoFormat("[WebUI] Triggered Archive load of " + profile.AArchiveName);
                profile.IsNewUser = true;

                profile.MembershipGroup = UserTitle;
                profile.CustomType      = UserTitle;

                profileData.UpdateUserProfile(profile);
                //   MainConsole.Instance.RunCommand("load avatar archive " + user.FirstName + " " + user.LastName + " Devil");
            }

            resp ["UUID"] = OSD.FromUUID(userID);
            return(resp);
        }
        private OSDMap RegisterRegionWithGridModule_OnMessageReceived(OSDMap message)
        {
            if (!message.ContainsKey("Method"))
                return null;

            if (message["Method"] == "NeighborChange")
            {
                OSDMap innerMessage = (OSDMap) message["Message"];
                bool down = innerMessage["Down"].AsBoolean();
                UUID regionID = innerMessage["Region"].AsUUID();
                UUID targetregionID = innerMessage["TargetRegion"].AsUUID();

                if (m_knownNeighbors.ContainsKey(targetregionID))
                {
                    if (down)
                    {
                        //Remove it
                        m_knownNeighbors[targetregionID].RemoveAll(delegate(GridRegion r)
                                                                       {
                                                                           if (r.RegionID == regionID)
                                                                               return true;
                                                                           return false;
                                                                       });
                    }
                    else
                    {
                        //Add it if it doesn't already exist
                        if (m_knownNeighbors[targetregionID].Find(delegate(GridRegion rr)
                                                                      {
                                                                          if (rr.RegionID == regionID)
                                                                              return true;
                                                                          return false;
                                                                      }) == null)
                            m_knownNeighbors[targetregionID].Add(m_scenes[0].GridService.GetRegionByUUID(null,
                                                                                                         regionID));
                    }
                }
            }
            return null;
        }
示例#56
0
        public void Initialize(ISimulationBase openSim)
        {
            try
            {
                //Check whether this is enabled
                IConfig updateConfig = openSim.ConfigSource.Configs["Update"];
                if (updateConfig == null || updateConfig.GetString("Module", string.Empty) != Name || !updateConfig.GetBoolean("Enabled", false))
                {
                    return;
                }

                InfoMsg("Checking for updates...");

                string WebSite = m_urlToCheckForUpdates;

                // Call the github API
                OSD data = OSDParser.DeserializeJson(Utilities.ReadExternalWebsite(WebSite));
                if (data.Type != OSDType.Array)
                {
                    ErrorMsg("Failed to get downloads from github API.");
                    return;
                }
                OSDArray JsonData = (OSDArray)data;

                if (JsonData.Count == 0)
                {
                    ErrorMsg("No downloads found.");
                    return;
                }
                else
                {
                    TraceMsg(JsonData.Count + " downloads found, parsing.");
                }

                SortedDictionary <Version, OSDMap> releases = new SortedDictionary <Version, OSDMap>();
                foreach (OSD map in JsonData)
                {
                    if (map.Type == OSDType.Map)
                    {
                        OSDMap download = (OSDMap)map;
                        if (
                            download.ContainsKey("download_count") &&
                            download.ContainsKey("created_at") &&
                            download.ContainsKey("description") &&
                            download.ContainsKey("url") &&
                            download.ContainsKey("html_url") &&
                            download.ContainsKey("size") &&
                            download.ContainsKey("name") &&
                            download.ContainsKey("content_type") &&
                            download.ContainsKey("id") &&
                            download["content_type"].AsString() == ".zip" &&
                            Regex.IsMatch(download["name"].ToString(), m_regexRelease)
                            )
                        {
                            Match matches = Regex.Match(download["name"].ToString(), m_regexRelease);
                            releases[new Version(matches.Groups[1].ToString())] = download;
                        }
                    }
                }

                if (releases.Count < 1)
                {
                    ErrorMsg("No releases found");
                    return;
                }

                KeyValuePair <Version, OSDMap> latest = releases.OrderByDescending(kvp => kvp.Key).First();
                if (latest.Key <= new Version(VersionInfo.VERSION_NUMBER))
                {
                    InfoMsg("You are already using a newer version, no updated is necessary.");
                    return;
                }
                DialogResult result = MessageBox.Show("A new version of Aurora has been released, version " + latest.Key.ToString() + " (" + latest.Value["description"] + ")" + ", do you want to download the update?", "Aurora Update", MessageBoxButtons.YesNo);
                if (result == DialogResult.Yes)
                {
                    Utilities.DownloadFile(latest.Value["html_url"], "Updates" + System.IO.Path.DirectorySeparatorChar + "AuroraVersion" + latest.Key.ToString() + ".zip");
                    MessageBox.Show(string.Format("Downloaded to {0}, exiting for user to upgrade.", "Updates" + System.IO.Path.DirectorySeparatorChar + "AuroraVersion" + latest.Key.ToString() + ".zip"), "Aurora Update");
                    Environment.Exit(0);
                }
                updateConfig.Set("LatestRelease", latest.Key.ToString());
                updateConfig.ConfigSource.Save();
            }
            catch
            {
            }
        }
示例#57
0
        /// <summary>
        /// Unpack agent circuit data map into an AgentCiruitData object
        /// </summary>
        /// <param name="args"></param>
        public virtual void UnpackAgentCircuitData (OSDMap args)
        {
            if (args["agent_id"] != null)
                AgentID = args["agent_id"].AsUUID();
            if (args["caps_path"] != null)
                CapsPath = args["caps_path"].AsString();
            if (args["reallyischild"] != null)
                reallyischild = args["reallyischild"].AsBoolean ();
            if (args["child"] != null)
                child = args["child"].AsBoolean();
            if (args["circuit_code"] != null)
                UInt32.TryParse(args["circuit_code"].AsString(), out circuitcode);
            if (args["secure_session_id"] != null)
                SecureSessionID = args["secure_session_id"].AsUUID();
            if (args["session_id"] != null)
                SessionID = args["session_id"].AsUUID();
            if (args["service_session_id"] != null)
                ServiceSessionID = args["service_session_id"].AsString ();
            if (args["client_ip"] != null)
                IPAddress = args["client_ip"].AsString ();
            if (args["first_name"] != null)
                firstname = args["first_name"].AsString ();
            if (args["last_name"] != null)
                lastname = args["last_name"].AsString ();

            if (args["start_pos"] != null)
                Vector3.TryParse(args["start_pos"].AsString(), out startpos);

            if (args["teleport_flags"] != null)
                teleportFlags = args["teleport_flags"].AsUInteger();

            // DEBUG ON
            //m_log.WarnFormat("[AGENTCIRCUITDATA] agentid={0}, child={1}, startpos={2}", AgentID, child, startpos.ToString());
            // DEBUG OFF

            try
            {
                // Unpack various appearance elements
                Appearance = new AvatarAppearance(AgentID);

                // Eventually this code should be deprecated, use full appearance
                // packing in packed_appearance
                if (args["appearance_serial"] != null)
                    Appearance.Serial = args["appearance_serial"].AsInteger();

                if (args.ContainsKey("packed_appearance") && (args["packed_appearance"].Type == OSDType.Map))
                {
                    Appearance.Unpack((OSDMap)args["packed_appearance"]);
                    // DEBUG ON
                    //m_log.WarnFormat("[AGENTCIRCUITDATA] unpacked appearance");
                    // DEBUG OFF
                }
                // DEBUG ON
                else
                    m_log.Warn("[AGENTCIRCUITDATA] failed to find a valid packed_appearance");
                // DEBUG OFF
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[AGENTCIRCUITDATA] failed to unpack appearance; {0}", e.ToString());
            }

            if (args.ContainsKey("otherInfo"))
                OtherInformation = (OSDMap)OSDParser.DeserializeLLSDXml(args["otherInfo"].AsString());

            ServiceURLs = new Dictionary<string, object> ();
            // Try parse the new way, OSDMap
            if (args.ContainsKey ("serviceurls") && args["serviceurls"] != null && (args["serviceurls"]).Type == OSDType.Map)
            {
                OSDMap urls = (OSDMap)(args["serviceurls"]);
                foreach (KeyValuePair<String, OSD> kvp in urls)
                {
                    ServiceURLs[kvp.Key] = kvp.Value.AsString ();
                    //System.Console.WriteLine("XXX " + kvp.Key + "=" + ServiceURLs[kvp.Key]);

                }
            }
        }
示例#58
0
        protected void DoAgentPost(Hashtable request, Hashtable responsedata, UUID id)
        {
            OSDMap args = Utils.GetOSDMap((string)request["body"]);

            if (args == null)
            {
                responsedata["int_response_code"]   = HttpStatusCode.BadRequest;
                responsedata["str_response_string"] = "Bad request";
                return;
            }

            AgentDestinationData data = CreateAgentDestinationData();

            UnpackData(args, data, request);

            GridRegion destination = new GridRegion();

            destination.RegionID   = data.uuid;
            destination.RegionLocX = data.x;
            destination.RegionLocY = data.y;
            destination.RegionName = data.name;

            GridRegion gatekeeper = ExtractGatekeeper(data);

            AgentCircuitData aCircuit = new AgentCircuitData();

            try
            {
                aCircuit.UnpackAgentCircuitData(args);
            }
            catch (Exception ex)
            {
                m_log.InfoFormat("[AGENT HANDLER]: exception on unpacking ChildCreate message {0}", ex.Message);
                responsedata["int_response_code"]   = HttpStatusCode.BadRequest;
                responsedata["str_response_string"] = "Bad request";
                return;
            }

            GridRegion source = null;

            if (args.ContainsKey("source_uuid"))
            {
                source            = new GridRegion();
                source.RegionLocX = Int32.Parse(args["source_x"].AsString());
                source.RegionLocY = Int32.Parse(args["source_y"].AsString());
                source.RegionName = args["source_name"].AsString();
                source.RegionID   = UUID.Parse(args["source_uuid"].AsString());

                if (args.ContainsKey("source_server_uri"))
                {
                    source.RawServerURI = args["source_server_uri"].AsString();
                }
                else
                {
                    source.RawServerURI = null;
                }
            }

            OSDMap resp   = new OSDMap(2);
            string reason = String.Empty;

            // This is the meaning of POST agent
            //m_regionClient.AdjustUserInformation(aCircuit);
            //bool result = m_SimulationService.CreateAgent(destination, aCircuit, teleportFlags, out reason);
            bool result = CreateAgent(source, gatekeeper, destination, aCircuit, data.flags, data.fromLogin, out reason);

            resp["reason"]  = OSD.FromString(reason);
            resp["success"] = OSD.FromBoolean(result);
            // Let's also send out the IP address of the caller back to the caller (HG 1.5)
            resp["your_ip"] = OSD.FromString(GetCallerIP(request));

            // TODO: add reason if not String.Empty?
            responsedata["int_response_code"]   = HttpStatusCode.OK;
            responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp);
        }