Ejemplo n.º 1
0
        public void Initialise(IClientCapsService clientCapsService, IRegionCapsService regionCapsService, string capsBase, AgentCircuitData circuitData)
        {
            m_clientCapsService = clientCapsService;
            m_regionCapsService = regionCapsService;
            m_circuitData = circuitData;
            AddSEEDCap(capsBase);

            AddCAPS();
        }
Ejemplo n.º 2
0
 protected object OnGenericEvent(string FunctionName, object parameters)
 {
     if (FunctionName == "NewUserConnection")
     {
         ICapsService service = m_scene.RequestModuleInterface <ICapsService>();
         if (service != null)
         {
             object[]         obj     = (object[])parameters;
             OSDMap           param   = (OSDMap)obj[0];
             AgentCircuitData circuit = (AgentCircuitData)obj[1];
             if (circuit.reallyischild)//If Aurora is sending this, it'll show that it really is a child agent
             {
                 return(null);
             }
             AvatarAppearance appearance = m_scene.AvatarService.GetAppearance(circuit.AgentID);
             if (appearance != null)
             {
                 circuit.Appearance = appearance;
             }
             else
             {
                 m_scene.AvatarService.SetAppearance(circuit.AgentID, circuit.Appearance);
             }
             //circuit.Appearance.Texture = new Primitive.TextureEntry(UUID.Zero);
             circuit.child = false;//ONLY USE ROOT AGENTS, SINCE OPENSIM SENDS CHILD == TRUE ALL THE TIME
             if (circuit.ServiceURLs != null && circuit.ServiceURLs.ContainsKey("IncomingCAPSHandler"))
             {
                 AddCapsHandler(circuit);
             }
             else
             {
                 IClientCapsService clientService = service.GetOrCreateClientCapsService(circuit.AgentID);
                 clientService.RemoveCAPS(m_scene.RegionInfo.RegionHandle);
                 string caps = service.CreateCAPS(circuit.AgentID, CapsUtil.GetCapsSeedPath(circuit.CapsPath),
                                                  m_scene.RegionInfo.RegionHandle, true, circuit, MainServer.Instance.Port); //We ONLY use root agents because of OpenSim's inability to send the correct data
                 MainConsole.Instance.Output("setting up on " + clientService.HostUri + CapsUtil.GetCapsSeedPath(circuit.CapsPath));
                 IClientCapsService clientCaps = service.GetClientCapsService(circuit.AgentID);
                 if (clientCaps != null)
                 {
                     IRegionClientCapsService regionCaps = clientCaps.GetCapsService(m_scene.RegionInfo.RegionHandle);
                     if (regionCaps != null)
                     {
                         regionCaps.AddCAPS((OSDMap)param["CapsUrls"]);
                     }
                 }
             }
         }
     }
     else if (FunctionName == "UserStatusChange")
     {
         object[] info = (object[])parameters;
         if (!bool.Parse(info[1].ToString())) //Logging out
         {
             ICapsService service = m_scene.RequestModuleInterface <ICapsService>();
             if (service != null)
             {
                 service.RemoveCAPS(UUID.Parse(info[0].ToString()));
             }
         }
     }
     return(null);
 }
Ejemplo n.º 3
0
        public Dictionary <string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest,
                                                OSHttpResponse httpResponse, Dictionary <string, object> requestParameters, ITranslator translator, out string response)
        {
            response = null;
            var vars = new Dictionary <string, object>();

            string      username = filename.Split('/').LastOrDefault();
            UserAccount account  = null;

            if (httpRequest.Query.ContainsKey("userid"))
            {
                string userid = httpRequest.Query["userid"].ToString();

                account = webInterface.Registry.RequestModuleInterface <IUserAccountService>().
                          GetUserAccount(null, UUID.Parse(userid));
            }
            else if (httpRequest.Query.ContainsKey("name"))
            {
                string name = httpRequest.Query.ContainsKey("name") ? httpRequest.Query["name"].ToString() : username;
                name    = name.Replace('.', ' ');
                name    = name.Replace("%20", " ");
                account = webInterface.Registry.RequestModuleInterface <IUserAccountService>().
                          GetUserAccount(null, name);
            }
            else
            {
                username = username.Replace("%20", " ");
                webInterface.Redirect(httpResponse, "/webprofile/?name=" + username);
                return(vars);
            }

            if (account == null)
            {
                return(vars);
            }

            vars.Add("UserName", account.Name);
            vars.Add("UserBorn", Util.ToDateTime(account.Created).ToShortDateString());
            vars.Add("UserType", account.UserTitle == "" ? "Resident" : account.UserTitle);

            IUserProfileInfo profile = Aurora.DataManager.DataManager.RequestPlugin <IProfileConnector>().
                                       GetUserProfile(account.PrincipalID);

            if (profile != null)
            {
                if (profile.Partner != UUID.Zero)
                {
                    account = webInterface.Registry.RequestModuleInterface <IUserAccountService>().
                              GetUserAccount(null, profile.Partner);
                    vars.Add("UserPartner", account.Name);
                }
                else
                {
                    vars.Add("UserPartner", "No partner");
                }
                vars.Add("UserAboutMe", profile.AboutText == "" ? "Nothing here" : profile.AboutText);
                string url = "../images/icons/no_picture.jpg";
                IWebHttpTextureService webhttpService = webInterface.Registry.RequestModuleInterface <IWebHttpTextureService>();
                if (webhttpService != null && profile.Image != UUID.Zero)
                {
                    url = webhttpService.GetTextureURL(profile.Image);
                }
                vars.Add("UserPictureURL", url);
            }
            UserAccount ourAccount = Authenticator.GetAuthentication(httpRequest);

            if (ourAccount != null)
            {
                IFriendsService friendsService = webInterface.Registry.RequestModuleInterface <IFriendsService>();
                var             friends        = friendsService.GetFriends(account.PrincipalID);
                UUID            friendID       = UUID.Zero;
                if (friends.Any(f => UUID.TryParse(f.Friend, out friendID) && friendID == ourAccount.PrincipalID))
                {
                    ICapsService       capsService = webInterface.Registry.RequestModuleInterface <ICapsService>();
                    IClientCapsService clientCaps  = capsService == null ? null : capsService.GetClientCapsService(account.PrincipalID);
                    if (clientCaps != null)
                    {
                        vars.Add("OnlineLocation", clientCaps.GetRootCapsService().Region.RegionName);
                    }
                    vars.Add("UserIsOnline", clientCaps != null);
                    vars.Add("IsOnline", clientCaps != null ? translator.GetTranslatedString("Online") : translator.GetTranslatedString("Offline"));
                }
                else
                {
                    vars.Add("OnlineLocation", "");
                    vars.Add("UserIsOnline", false);
                    vars.Add("IsOnline", translator.GetTranslatedString("Offline"));
                }
            }
            else
            {
                vars.Add("OnlineLocation", "");
                vars.Add("UserIsOnline", false);
                vars.Add("IsOnline", translator.GetTranslatedString("Offline"));
            }

            // Menu Profile
            vars.Add("MenuProfileTitle", translator.GetTranslatedString("MenuProfileTitle"));
            vars.Add("MenuGroupTitle", translator.GetTranslatedString("MenuGroupTitle"));
            vars.Add("MenuPicksTitle", translator.GetTranslatedString("MenuPicksTitle"));

            vars.Add("UserProfileFor", translator.GetTranslatedString("UserProfileFor"));
            vars.Add("ResidentSince", translator.GetTranslatedString("ResidentSince"));
            vars.Add("AccountType", translator.GetTranslatedString("AccountType"));
            vars.Add("PartnersName", translator.GetTranslatedString("PartnersName"));
            vars.Add("AboutMe", translator.GetTranslatedString("AboutMe"));
            vars.Add("IsOnlineText", translator.GetTranslatedString("IsOnlineText"));
            vars.Add("OnlineLocationText", translator.GetTranslatedString("OnlineLocationText"));

            // Style Switcher
            vars.Add("styles1", translator.GetTranslatedString("styles1"));
            vars.Add("styles2", translator.GetTranslatedString("styles2"));
            vars.Add("styles3", translator.GetTranslatedString("styles3"));
            vars.Add("styles4", translator.GetTranslatedString("styles4"));
            vars.Add("styles5", translator.GetTranslatedString("styles5"));

            vars.Add("StyleSwitcherStylesText", translator.GetTranslatedString("StyleSwitcherStylesText"));
            vars.Add("StyleSwitcherLanguagesText", translator.GetTranslatedString("StyleSwitcherLanguagesText"));
            vars.Add("StyleSwitcherChoiceText", translator.GetTranslatedString("StyleSwitcherChoiceText"));

            // Language Switcher
            vars.Add("en", translator.GetTranslatedString("en"));
            vars.Add("fr", translator.GetTranslatedString("fr"));
            vars.Add("de", translator.GetTranslatedString("de"));
            vars.Add("it", translator.GetTranslatedString("it"));
            vars.Add("es", translator.GetTranslatedString("es"));

            IGenericsConnector generics = Aurora.DataManager.DataManager.RequestPlugin <IGenericsConnector>();
            var settings = generics.GetGeneric <GridSettings>(UUID.Zero, "WebSettings", "Settings");

            vars.Add("ShowLanguageTranslatorBar", !settings.HideLanguageTranslatorBar);
            vars.Add("ShowStyleBar", !settings.HideStyleBar);

            return(vars);
        }
        public void Initialise(IClientCapsService clientCapsService, ulong regionHandle, string capsBase, string urlToInform)
        {
            m_clientCapsService = clientCapsService;
            m_RegionHandle = regionHandle;
            AddSEEDCap(capsBase, urlToInform, UUID.Random());

            AddCAPS();
        }
        public void Initialise(IClientCapsService clientCapsService, IRegionCapsService regionCapsService, string capsBase, AgentCircuitData circuitData, uint port)
        {
            m_clientCapsService = clientCapsService;
            m_regionCapsService = regionCapsService;
            m_circuitData = circuitData;
            if (port != 0)//Someone requested a non standard port, probably for OpenSim
            {
                ISimulationBase simBase = Registry.RequestModuleInterface<ISimulationBase> ();
                Server = simBase.GetHttpServer (port);
            }
            AddSEEDCap(capsBase);

            AddCAPS();
        }
Ejemplo n.º 6
0
        protected OSDMap OnMessageReceived(OSDMap message)
        {
            IAsyncMessagePostService asyncPost = m_registry.RequestModuleInterface <IAsyncMessagePostService>();

            //We need to check and see if this is an AgentStatusChange
            if (message.ContainsKey("Method") && message["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 interchangable)
                ISceneManager manager = m_registry.RequestModuleInterface <ISceneManager>();
                if (manager != null && manager.GetAllScenes().Count > 0)
                {
                    IFriendsModule friendsModule = manager.GetCurrentOrFirstScene().RequestModuleInterface <IFriendsModule>();
                    if (friendsModule != null)
                    {
                        //Send the message
                        friendsModule.SendFriendsStatusMessage(FriendToInformID, AgentID, NewStatus);
                    }
                }
            }
            else if (message.ContainsKey("Method") && message["Method"] == "FriendGrantRights")
            {
                OSDMap             body          = (OSDMap)message["Message"];
                UUID               targetID      = body["Target"].AsUUID();
                IClientCapsService friendSession =
                    m_registry.RequestModuleInterface <ICapsService>().GetClientCapsService(targetID);
                if (friendSession != null && friendSession.GetRootCapsService() != null)
                {
                    //Forward the message
                    asyncPost.Post(friendSession.GetRootCapsService().RegionHandle, message);
                }
            }
            else if (message.ContainsKey("Method") && message["Method"] == "FriendshipOffered")
            {
                OSDMap             body          = (OSDMap)message["Message"];
                UUID               targetID      = body["Friend"].AsUUID();
                IClientCapsService friendSession =
                    m_registry.RequestModuleInterface <ICapsService>().GetClientCapsService(targetID);
                if (friendSession != null && friendSession.GetRootCapsService() != null)
                {
                    //Forward the message
                    asyncPost.Post(friendSession.GetRootCapsService().RegionHandle, message);
                }
            }
            else if (message.ContainsKey("Method") && message["Method"] == "FriendTerminated")
            {
                OSDMap             body          = (OSDMap)message["Message"];
                UUID               targetID      = body["ExFriend"].AsUUID();
                IClientCapsService friendSession =
                    m_registry.RequestModuleInterface <ICapsService>().GetClientCapsService(targetID);
                if (friendSession != null && friendSession.GetRootCapsService() != null)
                {
                    //Forward the message
                    asyncPost.Post(friendSession.GetRootCapsService().RegionHandle, message);
                }
            }
            else if (message.ContainsKey("Method") && message["Method"] == "FriendshipDenied")
            {
                OSDMap             body          = (OSDMap)message["Message"];
                UUID               targetID      = body["FriendID"].AsUUID();
                IClientCapsService friendSession =
                    m_registry.RequestModuleInterface <ICapsService>().GetClientCapsService(targetID);
                if (friendSession != null && friendSession.GetRootCapsService() != null)
                {
                    //Forward the message
                    asyncPost.Post(friendSession.GetRootCapsService().RegionHandle, message);
                }
            }
            else if (message.ContainsKey("Method") && message["Method"] == "FriendshipApproved")
            {
                OSDMap             body          = (OSDMap)message["Message"];
                UUID               targetID      = body["FriendID"].AsUUID();
                IClientCapsService friendSession =
                    m_registry.RequestModuleInterface <ICapsService>().GetClientCapsService(targetID);
                if (friendSession != null && friendSession.GetRootCapsService() != null)
                {
                    //Forward the message
                    asyncPost.Post(friendSession.GetRootCapsService().RegionHandle, message);
                }
            }
            return(null);
        }
Ejemplo n.º 7
0
        private List<GridRegion> GetRegions (IClientCapsService iClientCapsService)
        {
            List<GridRegion> regions = new List<GridRegion>();

            foreach(IRegionClientCapsService rccs in iClientCapsService.GetCapsServices())
                regions.Add(rccs.Region);
            return regions;
        }
Ejemplo n.º 8
0
        protected 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)
            {
                //m_log.Info("[AgentProcessing]: Failed OnMessageReceived ICapsService is 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(UUID.Zero, x, y);
                    if (requestingGridRegion != null)
                    {
                        EnableChildAgentsForRegion(requestingGridRegion);
                    }
                }
            }
            else if (message["Method"] == "DisableSimulator")
            {
                //KILL IT!
                if (regionCaps == null || clientCaps == null)
                {
                    return(null);
                }
                regionCaps.Close();
                clientCaps.RemoveCAPS(requestingRegion);
            }
            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);
                    }
                }
            }
            else if (message["Method"] == "SendChildAgentUpdate")
            {
                if (regionCaps == null || clientCaps == null)
                {
                    return(null);
                }
                IRegionClientCapsService rootCaps = clientCaps.GetRootCapsService();
                if (rootCaps != null && rootCaps.RegionHandle == regionCaps.RegionHandle)
                {
                    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;

                    OSDMap result = new OSDMap();
                    string reason = "";
                    result["Success"] = TeleportAgent(destination, TeleportFlags, DrawDistance,
                                                      Circuit, AgentData, AgentID, requestingRegion, out reason);
                    result["Reason"] = reason;
                    return(result);
                }
            }
            else if (message["Method"] == "CrossAgent")
            {
                if (regionCaps == null || clientCaps == null)
                {
                    return(null);
                }
                if (clientCaps.GetRootCapsService().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;

                    OSDMap result = new OSDMap();
                    string reason = "";
                    result["Success"] = CrossAgent(Region, pos, Vel, Circuit, AgentData,
                                                   AgentID, requestingRegion, out reason);
                    result["Reason"] = reason;
                    return(result);
                }
            }
            return(null);
        }
Ejemplo n.º 9
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?");
                    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(new byte[0]);
            }
            return(Util.UTF8.GetBytes(resp));
        }
Ejemplo n.º 10
0
        public XmlRpcResponse PreflightBuyLandPrepFunc(XmlRpcRequest request, IPEndPoint ep)
        {
            Hashtable      requestData = (Hashtable)request.Params[0];
            XmlRpcResponse ret         = new XmlRpcResponse();
            Hashtable      retparam    = new Hashtable();

            Hashtable membershiplevels = new Hashtable();

            membershiplevels.Add("levels", membershiplevels);

            Hashtable landuse = new Hashtable();

            Hashtable level = new Hashtable
            {
                { "id", "00000000-0000-0000-0000-000000000000" },
                { m_dustCurrencyService.m_options.UpgradeMembershipUri, "Premium Membership" }
            };

            if (requestData.ContainsKey("agentId") && requestData.ContainsKey("currencyBuy"))
            {
                UUID agentId;
                UUID.TryParse((string)requestData["agentId"], out agentId);
                StarDustUserCurrency currency = m_dustCurrencyService.UserCurrencyInfo(agentId);
                IUserProfileInfo     profile  = DataManager.RequestPlugin <IProfileConnector>("IProfileConnector").GetUserProfile(agentId);


                IClientCapsService client    = m_dustCurrencyService.Registry.RequestModuleInterface <ICapsService>().GetClientCapsService(agentId);
                OSDMap             replyData = m_dustCurrencyService.GetParcelDetails(agentId);
                if (replyData == null)
                {
                    landuse.Add("action", false);

                    retparam.Add("success", false);
                    retparam.Add("currency", currency);
                    retparam.Add("membership", level);
                    retparam.Add("landuse", landuse);
                    retparam.Add("confirm", "asdfajsdkfjasdkfjalsdfjasdf");
                    ret.Value = retparam;
                }
                else
                {
                    if (client != null)
                    {
                        m_dustCurrencyService.SendGridMessage(agentId, String.Format(m_dustCurrencyService.m_options.MessgeBeforeBuyLand, profile.DisplayName, replyData.ContainsKey("SalePrice")), false, UUID.Zero);
                    }
                    if (replyData.ContainsKey("SalePrice"))
                    {
                        // I think, this might be usable if they don't have the money
                        // Hashtable currencytable = new Hashtable { { "estimatedCost", replyData["SalePrice"].AsInteger() } };

                        int  landTierNeeded = (int)(currency.LandInUse + replyData["Area"].AsInteger());
                        bool needsUpgrade   = false;
                        switch (profile.MembershipGroup)
                        {
                        case "Premium":
                        case "":
                            needsUpgrade = landTierNeeded >= currency.Tier;
                            break;

                        case "Banned":
                            needsUpgrade = true;
                            break;
                        }
                        // landuse.Add("action", m_DustCurrencyService.m_options.upgradeMembershipUri);
                        landuse.Add("action", needsUpgrade);

                        retparam.Add("success", true);
                        retparam.Add("currency", currency);
                        retparam.Add("membership", level);
                        retparam.Add("landuse", landuse);
                        retparam.Add("confirm", "asdfajsdkfjasdkfjalsdfjasdf");
                        ret.Value = retparam;
                    }
                }
            }

            return(ret);
        }
        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 (args[param.Name].Type == OSDType.Unknown)
                            {
                                parameters[paramNum++] = null;
                            }
                            else 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);
        }
Ejemplo n.º 12
0
        protected object OnGenericEvent(string FunctionName, object parameters)
        {
            if (FunctionName == "UserStatusChange")
            {
                //A user has logged in or out... we need to update friends lists across the grid

                IAsyncMessagePostService asyncPoster    = m_registry.RequestModuleInterface <IAsyncMessagePostService>();
                IFriendsService          friendsService = m_registry.RequestModuleInterface <IFriendsService>();
                ICapsService             capsService    = m_registry.RequestModuleInterface <ICapsService>();
                IGridService             gridService    = m_registry.RequestModuleInterface <IGridService>();
                if (asyncPoster != null && friendsService != null && capsService != null && gridService != null)
                {
                    //Get all friends
                    object[] info     = (object[])parameters;
                    UUID     us       = UUID.Parse(info[0].ToString());
                    bool     isOnline = bool.Parse(info[1].ToString());

                    List <FriendInfo> friends                 = friendsService.GetFriends(us);
                    List <UUID>       OnlineFriends           = new List <UUID>();
                    List <string>     previouslyContactedURLs = new List <string>();
                    foreach (FriendInfo friend in friends)
                    {
                        if (friend.TheirFlags == -1 || friend.MyFlags == -1)
                        {
                            continue; //Not validiated yet!
                        }
                        UUID   FriendToInform = UUID.Zero;
                        string url, first, last, secret;
                        if (!UUID.TryParse(friend.Friend, out FriendToInform))
                        {
                            HGUtil.ParseUniversalUserIdentifier(friend.Friend, out FriendToInform, out url, out first,
                                                                out last, out secret);
                        }
                        //Now find their caps service so that we can find where they are root (and if they are logged in)
                        IClientCapsService clientCaps = capsService.GetClientCapsService(FriendToInform);
                        if (clientCaps != null)
                        {
                            //Find the root agent
                            IRegionClientCapsService regionClientCaps = clientCaps.GetRootCapsService();
                            if (regionClientCaps != null)
                            {
                                OnlineFriends.Add(FriendToInform);
                                //Post!
                                asyncPoster.Post(regionClientCaps.RegionHandle,
                                                 SyncMessageHelper.AgentStatusChange(us, FriendToInform, isOnline));
                            }
                            else
                            {
                                //If they don't have a root agent, wtf happened?
                                capsService.RemoveCAPS(clientCaps.AgentID);
                            }
                        }
                        else
                        {
                            IAgentInfoService agentInfoService = m_registry.RequestModuleInterface <IAgentInfoService>();
                            if (agentInfoService != null)
                            {
                                UserInfo friendinfo = agentInfoService.GetUserInfo(FriendToInform.ToString());
                                if (friendinfo != null && friendinfo.IsOnline)
                                {
                                    OnlineFriends.Add(FriendToInform);
                                    //Post!
                                    GridRegion r = gridService.GetRegionByUUID(UUID.Zero, friendinfo.CurrentRegionID);
                                    if (r != null)
                                    {
                                        asyncPoster.Post(r.RegionHandle,
                                                         SyncMessageHelper.AgentStatusChange(us, FriendToInform,
                                                                                             isOnline));
                                    }
                                }
                                else
                                {
                                    IUserAgentService uas = m_registry.RequestModuleInterface <IUserAgentService>();
                                    if (uas != null)
                                    {
                                        bool online = uas.RemoteStatusNotification(friend, us, isOnline);
                                        if (online)
                                        {
                                            OnlineFriends.Add(FriendToInform);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    //If the user is coming online, send all their friends online statuses to them
                    if (isOnline)
                    {
                        GridRegion ourRegion = gridService.GetRegionByUUID(UUID.Zero, UUID.Parse(info[2].ToString()));
                        if (ourRegion != null)
                        {
                            foreach (UUID onlineFriend in OnlineFriends)
                            {
                                asyncPoster.Post(ourRegion.RegionHandle,
                                                 SyncMessageHelper.AgentStatusChange(onlineFriend, us, isOnline));
                            }
                        }
                    }
                }
            }
            return(null);
        }
Ejemplo n.º 13
0
        public bool CrossAgent(GridRegion crossingRegion, Vector3 pos,
                               Vector3 velocity, AgentCircuitData circuit, AgentData cAgent, UUID AgentID, ulong requestingRegion, out string reason)
        {
            try
            {
                IClientCapsService       clientCaps           = m_registry.RequestModuleInterface <ICapsService>().GetClientCapsService(AgentID);
                IRegionClientCapsService requestingRegionCaps = clientCaps.GetCapsService(requestingRegion);
                ISimulationService       SimulationService    = m_registry.RequestModuleInterface <ISimulationService>();
                if (SimulationService != null)
                {
                    //Note: we have to pull the new grid region info as the one from the region cannot be trusted
                    IGridService GridService = m_registry.RequestModuleInterface <IGridService>();
                    if (GridService != null)
                    {
                        //Set the user in transit so that we block duplicate tps and reset any cancelations
                        if (!SetUserInTransit(AgentID))
                        {
                            reason = "Already in a teleport";
                            return(false);
                        }

                        bool result = false;

                        crossingRegion = GridService.GetRegionByUUID(UUID.Zero, crossingRegion.RegionID);
                        if (!SimulationService.UpdateAgent(crossingRegion, cAgent))
                        {
                            m_log.Warn("[AgentProcessing]: Failed to cross agent " + AgentID + " because region did not accept it. Resetting.");
                            reason = "Failed to update an agent";
                        }
                        else
                        {
                            IEventQueueService EQService = m_registry.RequestModuleInterface <IEventQueueService>();

                            //Add this for the viewer, but not for the sim, seems to make the viewer happier
                            int XOffset = crossingRegion.RegionLocX - requestingRegionCaps.RegionX;
                            pos.X += XOffset;

                            int YOffset = crossingRegion.RegionLocY - requestingRegionCaps.RegionY;
                            pos.Y += YOffset;

                            IRegionClientCapsService otherRegion = clientCaps.GetCapsService(crossingRegion.RegionHandle);
                            //Tell the client about the transfer
                            EQService.CrossRegion(crossingRegion.RegionHandle, pos, velocity, crossingRegion.ExternalEndPoint, otherRegion.CapsUrl,
                                                  AgentID, circuit.SessionID,
                                                  crossingRegion.RegionSizeX, crossingRegion.RegionSizeY,
                                                  requestingRegion);

                            result = WaitForCallback(AgentID);
                            if (!result)
                            {
                                m_log.Warn("[AgentProcessing]: Callback never came in crossing agent " + circuit.AgentID + ". Resetting.");
                                reason = "Crossing timed out";
                            }
                            else
                            {
                                // Next, let's close the child agent connections that are too far away.
                                INeighborService service = m_registry.RequestModuleInterface <INeighborService>();
                                if (service != null)
                                {
                                    //Fix the root agent status
                                    otherRegion.RootAgent          = true;
                                    requestingRegionCaps.RootAgent = false;

                                    CloseNeighborAgents(requestingRegionCaps.Region, crossingRegion, AgentID);
                                }
                                reason = "";
                            }
                        }

                        //All done
                        ResetFromTransit(AgentID);
                        return(result);
                    }
                    else
                    {
                        reason = "Could not find the GridService";
                    }
                }
                else
                {
                    reason = "Could not find the SimulationService";
                }
            }
            catch (Exception ex)
            {
                m_log.WarnFormat("[AgentProcessing]: Failed to cross an agent into a new region. {0}", ex.ToString());
            }
            ResetFromTransit(AgentID);
            reason = "Exception occured";
            return(false);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Async component for informing client of which neighbors exist
        /// </summary>
        /// <remarks>
        /// This needs to run asynchronously, as a network timeout may block the thread for a long while
        /// </remarks>
        /// <param name="remoteClient"></param>
        /// <param name="a"></param>
        /// <param name="regionHandle"></param>
        /// <param name="endPoint"></param>
        private bool InformClientOfNeighbor(UUID AgentID, ulong requestingRegion, AgentCircuitData circuitData, GridRegion neighbor,
                                            uint TeleportFlags, AgentData agentData, out string reason)
        {
            if (neighbor == null)
            {
                reason = "Could not find neighbor to inform";
                return(false);
            }
            m_log.Info("[AgentProcessing]: Starting to inform client about neighbor " + neighbor.RegionName);

            //Notes on this method
            // 1) the SimulationService.CreateAgent MUST have a fixed CapsUrl for the region, so we have to create (if needed)
            //       a new Caps handler for it.
            // 2) Then we can call the methods (EnableSimulator and EstatablishAgentComm) to tell the client the new Urls
            // 3) This allows us to make the Caps on the grid server without telling any other regions about what the
            //       Urls are.

            ISimulationService SimulationService = m_registry.RequestModuleInterface <ISimulationService>();

            if (SimulationService != null)
            {
                ICapsService       capsService = m_registry.RequestModuleInterface <ICapsService>();
                IClientCapsService clientCaps  = capsService.GetClientCapsService(AgentID);

                IRegionClientCapsService oldRegionService = clientCaps.GetCapsService(neighbor.RegionHandle);

                //If its disabled, it should be removed, so kill it!
                if (oldRegionService != null && oldRegionService.Disabled)
                {
                    clientCaps.RemoveCAPS(neighbor.RegionHandle);
                    oldRegionService = null;
                }

                bool newAgent = oldRegionService == null;
                IRegionClientCapsService otherRegionService = clientCaps.GetOrCreateCapsService(neighbor.RegionHandle,
                                                                                                CapsUtil.GetCapsSeedPath(CapsUtil.GetRandomCapsObjectPath()), circuitData);

                if (!newAgent)
                {
                    //Note: if the agent is already there, send an agent update then
                    bool result = true;
                    if (agentData != null)
                    {
                        result = SimulationService.UpdateAgent(neighbor, agentData);
                        if (result)
                        {
                            oldRegionService.Disabled = false;
                        }
                    }
                    reason = "";
                    return(result);
                }

                ICommunicationService commsService = m_registry.RequestModuleInterface <ICommunicationService>();
                if (commsService != null)
                {
                    circuitData.OtherInformation["UserUrls"] = commsService.GetUrlsForUser(neighbor, circuitData.AgentID);
                }

                #region OpenSim teleport compatibility!

                if (!m_useCallbacks)
                {
                    circuitData.CapsPath    = CapsUtil.GetRandomCapsObjectPath();
                    circuitData.startpos.X += (neighbor.RegionLocX - clientCaps.GetRootCapsService().RegionX);
                    circuitData.startpos.Y += (neighbor.RegionLocY - clientCaps.GetRootCapsService().RegionY);
                }

                #endregion

                bool regionAccepted = SimulationService.CreateAgent(neighbor, circuitData,
                                                                    TeleportFlags, agentData, out reason);
                if (regionAccepted)
                {
                    string otherRegionsCapsURL;
                    //If the region accepted us, we should get a CAPS url back as the reason, if not, its not updated or not an Aurora region, so don't touch it.
                    if (reason != "")
                    {
                        OSDMap responseMap = (OSDMap)OSDParser.DeserializeJson(reason);
                        OSDMap SimSeedCaps = (OSDMap)responseMap["CapsUrls"];
                        otherRegionService.AddCAPS(SimSeedCaps);
                        otherRegionsCapsURL = otherRegionService.CapsUrl;
                    }
                    else
                    {
                        //We are assuming an OpenSim region now!
                        #region OpenSim teleport compatibility!

                        otherRegionsCapsURL = "http://" + otherRegionService.Region.ExternalEndPoint.ToString() +
                                              CapsUtil.GetCapsSeedPath(circuitData.CapsPath);
                        otherRegionService.CapsUrl = otherRegionsCapsURL;

                        #endregion
                    }

                    IEventQueueService EQService = m_registry.RequestModuleInterface <IEventQueueService>();

                    EQService.EnableSimulator(neighbor.RegionHandle,
                                              neighbor.ExternalEndPoint.Address.GetAddressBytes(),
                                              neighbor.ExternalEndPoint.Port, AgentID,
                                              neighbor.RegionSizeX, neighbor.RegionSizeY, requestingRegion);

                    // EnableSimulator makes the client send a UseCircuitCode message to the destination,
                    // which triggers a bunch of things there.
                    // So let's wait
                    Thread.Sleep(300);
                    EQService.EstablishAgentCommunication(AgentID, neighbor.RegionHandle,
                                                          neighbor.ExternalEndPoint.Address.GetAddressBytes(),
                                                          neighbor.ExternalEndPoint.Port, otherRegionsCapsURL, neighbor.RegionSizeX,
                                                          neighbor.RegionSizeY,
                                                          requestingRegion);

                    if (!m_useCallbacks)
                    {
                        Thread.Sleep(3000);  //Give it a bit of time
                    }
                    m_log.Info("[AgentProcessing]: Completed inform client about neighbor " + neighbor.RegionName);
                }
                else
                {
                    m_log.Error("[AgentProcessing]: Failed to inform client about neighbor " + neighbor.RegionName + ", reason: " + reason);
                    return(false);
                }
                return(true);
            }
            reason = "SimulationService does not exist";
            m_log.Error("[AgentProcessing]: Failed to inform client about neighbor " + neighbor.RegionName + ", reason: " + reason + "!");
            return(false);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// This is the function that everythign really happens Grid and Region Side. We build the transaction here.
        /// </summary>
        /// <param name="toID"></param>
        /// <param name="fromID"></param>
        /// <param name="toObjectID"></param>
        /// <param name="fromObjectID"></param>
        /// <param name="amount"></param>
        /// <param name="description"></param>
        /// <param name="type"></param>
        /// <param name="transactionID"></param>
        /// <returns></returns>
        public virtual bool UserCurrencyTransfer(UUID toID, UUID fromID, UUID toObjectID, UUID fromObjectID, uint amount, string description, TransactionType type, UUID transactionID)
        {
            bool isgridServer = false;

            #region Build the transaction



            string transactionPosition = "";
            IScene scene          = null;
            string fromObjectName = "";
            string toObjectName   = "";


            if ((fromObjectID != UUID.Zero) && (StarDustRegionService != null))
            {
                ISceneChildEntity ce = StarDustRegionService.FindObject(fromObjectID, out scene);
                if (ce != null)
                {
                    fromObjectName      = ce.Name;
                    transactionPosition = ce.AbsolutePosition.ToString();
                }
            }

            if ((toObjectID != UUID.Zero) && (StarDustRegionService != null))
            {
                ISceneChildEntity ce = StarDustRegionService.FindObject(toObjectID, out scene);
                if (ce != null)
                {
                    toObjectName        = ce.Name;
                    transactionPosition = ce.AbsolutePosition.ToString();
                }
            }

            if (transactionPosition.Length == 0)
            {
                transactionPosition = scene.GetScenePresence(fromID).AbsolutePosition.ToString();
            }

            if (transactionPosition.Length == 0)
            {
                transactionPosition = scene.GetScenePresence(toID).AbsolutePosition.ToString();
            }

            if (transactionPosition.Length == 0)
            {
                transactionPosition = "Unknown";
            }

            RegionTransactionDetails r = new RegionTransactionDetails();
            ulong regionHandel         = 0;
            if (scene != null)
            {
                r = new RegionTransactionDetails
                {
                    RegionID       = scene.RegionInfo.RegionID,
                    RegionName     = scene.RegionInfo.RegionName,
                    RegionPosition = transactionPosition
                };
            }
            else if (m_registry != null)
            {
                ICapsService capsService = m_registry.RequestModuleInterface <ICapsService>();
                if (capsService != null)
                {
                    IClientCapsService client = capsService.GetClientCapsService(fromID);
                    if (client != null)
                    {
                        IRegionClientCapsService regionClient = client.GetRootCapsService();
                        if (regionClient != null)
                        {
                            regionHandel     = regionClient.Region.RegionHandle;
                            r.RegionName     = regionClient.Region.RegionName;
                            r.RegionPosition = "<128,128,128>";
                            r.RegionID       = regionClient.Region.RegionID;
                            isgridServer     = true;
                        }
                    }
                }
            }
            else
            {
                return(false);
            }


            string fromName = "";
            if (fromID != UUID.Zero)
            {
                if (StarDustRegionService != null)
                {
                    IClientAPI icapiFrom = StarDustRegionService.GetUserClient(fromID);
                    if (icapiFrom != null)
                    {
                        fromName = icapiFrom.Name;
                    }
                }
                if (fromName == "")
                {
                    UserAccount ua = GetUserAccount(fromID);
                    if (ua != null)
                    {
                        fromName = ua.Name;
                    }
                }
                if (fromName == "")
                {
                    if (StarDustRegionService != null)
                    {
                        ISceneChildEntity ce = StarDustRegionService.FindObject(fromID, out scene);
                        if (ce != null)
                        {
                            fromObjectID = fromID;
                            fromID       = ce.OwnerID;
                            UserAccount ua2 = GetUserAccount(fromID);

                            if (ua2 != null)
                            {
                                fromName = ua2.Name;
                            }
                            else
                            {
                                fromID = UUID.Zero;
                            }

                            fromObjectName = ce.Name;
                        }
                        else
                        {
                            fromID = UUID.Zero;
                        }
                    }
                    else
                    {
                        fromID = UUID.Zero;
                    }
                }
            }

            if (fromID == UUID.Zero)
            {
                MainConsole.Instance.Debug("[StarDust MoneyModule.cs] Could not find who the money was coming from.");
                return(false);
            }

            string toName = "";
            if (toID != UUID.Zero)
            {
                if (StarDustRegionService != null)
                {
                    IClientAPI icapiFrom = StarDustRegionService.GetUserClient(toID);
                    if (icapiFrom != null)
                    {
                        toName = icapiFrom.Name;
                    }
                }
                if (toName == "")
                {
                    UserAccount ua = GetUserAccount(toID);
                    if (ua != null)
                    {
                        toName = ua.Name;
                    }
                }
                if (toName == "")
                {
                    if (StarDustRegionService != null)
                    {
                        ISceneChildEntity ce = StarDustRegionService.FindObject(toID, out scene);
                        if (ce != null)
                        {
                            toObjectID = toID;
                            toID       = ce.OwnerID;
                            UserAccount ua3 = GetUserAccount(toID);
                            if (ua3 != null)
                            {
                                toName = ua3.Name;
                            }
                            toObjectName = ce.Name;
                        }
                        else
                        {
                            toName = "Group";
                        }
                    }
                    else
                    {
                        toName = "Group";
                    }
                }
            }
            else
            {
                toID = m_options.BankerPrincipalID;
            }
            //this ensure no matter what theres a place for the money to go
            UserCurrencyInfo(toID);

            if ((description == "") && ((int)type == 5001) && (fromObjectID == UUID.Zero) && (toObjectID == UUID.Zero))
            {
                description = "Gift";
            }
            if (description == "")
            {
                description = Enum.GetName(typeof(TransactionType), type);
            }
            if (description == "")
            {
                description = type.ToString();
            }



            #endregion

            #region Perform transaction

            Transaction transaction =
                UserCurrencyTransfer(new Transaction
            {
                TransactionID  = transactionID,
                Amount         = amount,
                Description    = description,
                FromID         = fromID,
                FromName       = fromName,
                FromObjectID   = fromObjectID,
                FromObjectName = fromObjectName,
                Region         = r,
                ToID           = toID,
                ToName         = toName,
                ToObjectID     = toObjectID,
                ToObjectName   = toObjectName,
                TypeOfTrans    = type
            });
            bool returnvalue = transaction.Complete == 1;

            if (returnvalue)
            {
                m_moneyModule.FireObjectPaid(toObjectID, fromID, (int)amount);
            }

            #endregion

            #region notifications

            if (transaction.Complete == 1)
            {
                if (transaction.ToID != m_options.BankerPrincipalID)
                {
                    if (transaction.TypeOfTrans == TransactionType.Gift)
                    {
                        SendGridMessage(transaction.FromID,
                                        "You Paid " + transaction.ToName + " $" + transaction.Amount.ToString(), !isgridServer, transaction.TransactionID);
                    }
                    else
                    {
                        SendGridMessage(transaction.FromID,
                                        "You Paid $" + transaction.Amount + " to " + transaction.ToName, !isgridServer, transaction.TransactionID);
                    }
                    SendGridMessage(transaction.ToID,
                                    "You Were Paid $" + transaction.Amount + " by " + transaction.FromName, !isgridServer, transaction.TransactionID);
                }
                else if (transaction.TypeOfTrans == TransactionType.UploadCharge)
                {
                    SendGridMessage(transaction.FromID, "You Paid $" + transaction.Amount + " to upload", !isgridServer, transaction.TransactionID);
                }
                else
                {
                    SendGridMessage(transaction.FromID, "You Paid $" + transaction.Amount, !isgridServer, transaction.TransactionID);
                }
            }
            else
            {
                if (transaction.CompleteReason != "")
                {
                    SendGridMessage(transaction.FromID, "Transaction Failed - " + transaction.CompleteReason, !isgridServer, transaction.TransactionID);
                }
                else
                {
                    SendGridMessage(transaction.FromID, "Transaction Failed", !isgridServer, transaction.TransactionID);
                }
            }

            if ((toObjectID != UUID.Zero) && (!isgridServer))
            {
                m_moneyModule.FireObjectPaid(toObjectID, fromID, (int)amount);
            }

            #endregion

            return(returnvalue);
        }
Ejemplo n.º 16
0
        public bool TeleportAgent(GridRegion destination, uint TeleportFlags, int DrawDistance,
                                  AgentCircuitData circuit, AgentData agentData, UUID AgentID, ulong requestingRegion,
                                  out string reason)
        {
            IClientCapsService       clientCaps = m_registry.RequestModuleInterface <ICapsService>().GetClientCapsService(AgentID);
            IRegionClientCapsService regionCaps = clientCaps.GetCapsService(requestingRegion);

            if (regionCaps == null || !regionCaps.RootAgent)
            {
                reason = "";
                return(false);
            }

            bool result = false;

            try
            {
                bool callWasCanceled = false;

                ISimulationService SimulationService = m_registry.RequestModuleInterface <ISimulationService>();
                if (SimulationService != null)
                {
                    //Set the user in transit so that we block duplicate tps and reset any cancelations
                    if (!SetUserInTransit(AgentID))
                    {
                        reason = "Already in a teleport";
                        return(false);
                    }

                    //Note: we have to pull the new grid region info as the one from the region cannot be trusted
                    IGridService GridService = m_registry.RequestModuleInterface <IGridService>();
                    if (GridService != null)
                    {
                        destination = GridService.GetRegionByUUID(UUID.Zero, destination.RegionID);
                        //Inform the client of the neighbor if needed
                        circuit.child = false; //Force child status to the correct type

                        if (!InformClientOfNeighbor(AgentID, requestingRegion, circuit, destination, TeleportFlags,
                                                    agentData, out reason))
                        {
                            ResetFromTransit(AgentID);
                            return(false);
                        }
                    }
                    else
                    {
                        reason = "Could not find the grid service";
                        ResetFromTransit(AgentID);
                        return(false);
                    }

                    IEventQueueService EQService = m_registry.RequestModuleInterface <IEventQueueService>();

                    IRegionClientCapsService otherRegion = clientCaps.GetCapsService(destination.RegionHandle);

                    EQService.TeleportFinishEvent(destination.RegionHandle, destination.Access, destination.ExternalEndPoint, otherRegion.CapsUrl,
                                                  4, AgentID, TeleportFlags,
                                                  destination.RegionSizeX, destination.RegionSizeY,
                                                  requestingRegion);

                    // TeleportFinish makes the client send CompleteMovementIntoRegion (at the destination), which
                    // trigers a whole shebang of things there, including MakeRoot. So let's wait for confirmation
                    // that the client contacted the destination before we send the attachments and close things here.

                    result = WaitForCallback(AgentID, out callWasCanceled);
                    if (!result)
                    {
                        //It says it failed, lets call the sim and check
                        IAgentData data = null;
                        result = SimulationService.RetrieveAgent(destination, AgentID, out data);
                    }
                    if (!result)
                    {
                        if (!callWasCanceled)
                        {
                            m_log.Warn("[AgentProcessing]: Callback never came for teleporting agent " +
                                       AgentID + ". Resetting.");
                        }
                        INeighborService service = m_registry.RequestModuleInterface <INeighborService>();
                        if (service != null)
                        {
                            //Close the agent at the place we just created if it isn't a neighbor
                            if (service.IsOutsideView(regionCaps.RegionX, destination.RegionLocX, regionCaps.Region.RegionSizeX, destination.RegionSizeX,
                                                      regionCaps.RegionY, destination.RegionLocY, regionCaps.Region.RegionSizeY, destination.RegionSizeY))
                            {
                                SimulationService.CloseAgent(destination, AgentID);
                            }
                        }
                        clientCaps.RemoveCAPS(destination.RegionHandle);
                        if (!callWasCanceled)
                        {
                            reason = "The teleport timed out";
                        }
                        else
                        {
                            reason = "Cancelled";
                        }
                    }
                    else
                    {
                        //Fix the root agent status
                        otherRegion.RootAgent = true;
                        regionCaps.RootAgent  = false;

                        // Next, let's close the child agent connections that are too far away.
                        CloseNeighborAgents(regionCaps.Region, destination, AgentID);
                        reason = "";
                    }
                }
                else
                {
                    reason = "No SimulationService found!";
                }
            }
            catch (Exception ex)
            {
                m_log.WarnFormat("[AgentProcessing]: Exception occured during agent teleport, {0}", ex.ToString());
                reason = "Exception occured.";
            }
            //All done
            ResetFromTransit(AgentID);
            return(result);
        }
Ejemplo n.º 17
0
        public UUID StartPurchaseOrATMTransfer(UUID agentId, uint amountBuying, PurchaseType purchaseType, string gridName)
        {
            bool        success = false;
            UserAccount ua      = Registry.RequestModuleInterface <IUserAccountService>().GetUserAccount(null, agentId);

            if (ua == null)
            {
                return(UUID.Zero);
            }
            string agentName = ua.Name;

            UUID   RegionID   = UUID.Zero;
            string RegionName = "";

            if (purchaseType == PurchaseType.InWorldPurchaseOfCurrency)
            {
                IClientCapsService client = Registry.RequestModuleInterface <ICapsService>().GetClientCapsService(agentId);
                if (client != null)
                {
                    IRegionClientCapsService regionClient = client.GetRootCapsService();
                    RegionID   = regionClient.Region.RegionID;
                    RegionName = regionClient.Region.RegionName;
                }
            }
            else if (purchaseType == PurchaseType.ATMTransferFromAnotherGrid)
            {
                RegionName = "Grid:" + gridName;
            }
            else
            {
                RegionName = "Unknown";
            }


            UUID purchaseID = UUID.Random();

            success = m_database.UserCurrencyBuy(purchaseID, agentId, agentName, amountBuying, m_options.RealCurrencyConversionFactor,
                                                 new RegionTransactionDetails
            {
                RegionID   = RegionID,
                RegionName = RegionName
            }, (int)purchaseType);
            StarDustUserCurrency currency = UserCurrencyInfo(agentId);



            if (m_options.AutoApplyCurrency && success)
            {
                Transaction transaction;
                m_database.UserCurrencyBuyComplete(purchaseID, 1, "AutoComplete",
                                                   m_options
                                                   .AutoApplyCurrency.ToString
                                                       (), "Auto Complete",
                                                   out transaction);

                UserCurrencyTransfer(transaction.ToID,
                                     m_options.
                                     BankerPrincipalID, UUID.Zero, UUID.Zero,
                                     transaction.Amount, "Currency Purchase",
                                     TransactionType.SystemGenerated,
                                     transaction.TransactionID);
                RestrictCurrency(currency, transaction, agentId);
            }
            else if (success && (m_options.AfterCurrencyPurchaseMessage != string.Empty) && (purchaseType == PurchaseType.InWorldPurchaseOfCurrency))
            {
                SendGridMessage(agentId, String.Format(m_options.AfterCurrencyPurchaseMessage, purchaseID.ToString()), false, UUID.Zero);
            }

            if (success)
            {
                return(purchaseID);
            }
            return(UUID.Zero);
        }
Ejemplo n.º 18
0
 List<GridRegion> GetRegions(IClientCapsService iClientCapsService)
 {
     return iClientCapsService.GetCapsServices().Select(rccs => rccs.Region).ToList();
 }
        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 AURORA.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>();
                    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);
                        }
                    }
                }
            }
            else if (message.ContainsKey("Method") && message["Method"] == "FixGroupRoleTitles")
            {
                //COMES IN ON AURORA.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     = DataManager.RequestPlugin <IGroupsServiceConnector>();
                List <GroupRoleMembersData> members = con.GetGroupRoleMembers(agentID, groupID);
                List <GroupRolesData>       roles   = con.GetGroupRoles(agentID, groupID);
                GroupRolesData everyone             = null;
#if (!ISWIN)
                foreach (GroupRolesData role in roles)
                {
                    if (role.Name == "Everyone")
                    {
                        everyone = role;
                    }
                }
#else
                foreach (GroupRolesData role in roles.Where(role => role.Name == "Everyone"))
                {
                    everyone = role;
                }
#endif

                List <ulong> regionsToBeUpdated = new List <ulong>();
                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
                            ICapsService caps = m_registry.RequestModuleInterface <ICapsService>();
                            if (caps != null)
                            {
                                IClientCapsService clientCaps = caps.GetClientCapsService(agentID);
                                if (clientCaps != null && clientCaps.GetRootCapsService() != null)
                                {
                                    regionsToBeUpdated.Add(clientCaps.GetRootCapsService().RegionHandle);
                                }
                            }
                            break;
                        }
                    }
                }
                if (regionsToBeUpdated.Count != 0)
                {
                    IAsyncMessagePostService messagePost = m_registry.RequestModuleInterface <IAsyncMessagePostService>();
                    if (messagePost != null)
                    {
                        foreach (ulong regionhandle in regionsToBeUpdated)
                        {
                            OSDMap outgoingMessage = new OSDMap();
                            outgoingMessage["Method"]   = "ForceUpdateGroupTitles";
                            outgoingMessage["GroupID"]  = groupID;
                            outgoingMessage["RoleID"]   = roleID;
                            outgoingMessage["RegionID"] = regionhandle;
                            messagePost.Post(regionhandle, outgoingMessage);
                        }
                    }
                }
            }
            else if (message.ContainsKey("Method") && message["Method"] == "ForceUpdateGroupTitles")
            {
                //COMES IN ON REGION SIDE FROM AURORA.SERVER
                UUID          groupID  = message["GroupID"].AsUUID();
                UUID          roleID   = message["RoleID"].AsUUID();
                ulong         regionID = message["RegionID"].AsULong();
                IGroupsModule gm       = m_registry.RequestModuleInterface <IGroupsModule>();
                if (gm != null)
                {
                    gm.UpdateUsersForExternalRoleUpdate(groupID, roleID, regionID);
                }
            }
            else if (message.ContainsKey("Method") && message["Method"] == "SendGroupNoticeToUsers")
            {
                //COMES IN ON REGION SIDE FROM AURORA.SERVER
                GroupNoticeInfo notice = new GroupNoticeInfo();
                notice.FromOSD((OSDMap)message["Notice"]);
                IGroupsModule gm = m_registry.RequestModuleInterface <IGroupsModule>();
                if (gm != null)
                {
                    gm.SendGroupNoticeToUsers(null, notice, true);
                }
            }
            return(null);
        }
Ejemplo n.º 20
0
        private List<GridRegion> GetRegions(IClientCapsService iClientCapsService)
        {
#if(!ISWIN)
            List<GridRegion> regions = new List<GridRegion>();
            foreach(IRegionClientCapsService rcc in iClientCapsService.GetCapsServices())
                regions.Add(rcc.Region);
            return regions;
#else
            return iClientCapsService.GetCapsServices().Select(rccs => rccs.Region).ToList();
#endif
        }
Ejemplo n.º 21
0
        public override bool InformClientOfNeighbor(UUID AgentID, ulong requestingRegion, AgentCircuitData circuitData, ref GridRegion neighbor, uint TeleportFlags, AgentData agentData, out string reason, out bool useCallbacks)
        {
            useCallbacks = true;
            if (neighbor == null)
            {
                reason = "Could not find neighbor to inform";
                return(false);
            }

            MainConsole.Instance.Info("[AgentProcessing]: Starting to inform client about neighbor " + neighbor.RegionName);

            //Notes on this method
            // 1) the SimulationService.CreateAgent MUST have a fixed CapsUrl for the region, so we have to create (if needed)
            //       a new Caps handler for it.
            // 2) Then we can call the methods (EnableSimulator and EstatablishAgentComm) to tell the client the new Urls
            // 3) This allows us to make the Caps on the grid server without telling any other regions about what the
            //       Urls are.

            ISimulationService SimulationService = m_registry.RequestModuleInterface <ISimulationService> ();

            if (SimulationService != null)
            {
                ICapsService       capsService  = m_registry.RequestModuleInterface <ICapsService> ();
                IClientCapsService clientCaps   = capsService.GetClientCapsService(AgentID);
                GridRegion         originalDest = neighbor;
                if ((neighbor.Flags & (int)Aurora.Framework.RegionFlags.Hyperlink) == (int)Aurora.Framework.RegionFlags.Hyperlink)
                {
                    neighbor = GetFinalDestination(neighbor);
                    if (neighbor == null || neighbor.RegionHandle == 0)
                    {
                        reason = "Could not find neighbor to inform";
                        return(false);
                    }
                    //Remove any offenders
                    clientCaps.RemoveCAPS(originalDest.RegionHandle);
                    clientCaps.RemoveCAPS(neighbor.RegionHandle);
                }

                IRegionClientCapsService oldRegionService = clientCaps.GetCapsService(neighbor.RegionHandle);

                //If its disabled, it should be removed, so kill it!
                if (oldRegionService != null && oldRegionService.Disabled)
                {
                    clientCaps.RemoveCAPS(neighbor.RegionHandle);
                    oldRegionService = null;
                }

                bool newAgent = oldRegionService == null;
                IRegionClientCapsService otherRegionService = clientCaps.GetOrCreateCapsService(neighbor.RegionHandle,
                                                                                                CapsUtil.GetCapsSeedPath(CapsUtil.GetRandomCapsObjectPath()), circuitData, 0);

                if (!newAgent)
                {
                    //Note: if the agent is already there, send an agent update then
                    bool result = true;
                    if (agentData != null)
                    {
                        agentData.IsCrossing = false;
                        result = SimulationService.UpdateAgent(neighbor, agentData);
                    }
                    if (result)
                    {
                        oldRegionService.Disabled = false;
                    }
                    reason = "";
                    return(result);
                }

                ICommunicationService commsService = m_registry.RequestModuleInterface <ICommunicationService> ();
                if (commsService != null)
                {
                    commsService.GetUrlsForUser(neighbor, circuitData.AgentID); //Make sure that we make userURLs if we need to
                }
                circuitData.CapsPath = CapsUtil.GetCapsPathFromCapsSeed(otherRegionService.CapsUrl);
                if (clientCaps.AccountInfo != null)
                {
                    circuitData.firstname = clientCaps.AccountInfo.FirstName;
                    circuitData.lastname  = clientCaps.AccountInfo.LastName;
                }
                bool regionAccepted   = false;
                int  requestedUDPPort = 0;
                if ((originalDest.Flags & (int)Aurora.Framework.RegionFlags.Hyperlink) == (int)Aurora.Framework.RegionFlags.Hyperlink)
                {
                    if (circuitData.ServiceURLs == null || circuitData.ServiceURLs.Count == 0)
                    {
                        if (clientCaps.AccountInfo != null)
                        {
                            circuitData.ServiceURLs = new Dictionary <string, object> ();
                            circuitData.ServiceURLs[GetHandlers.Helpers_HomeURI]            = GetHandlers.GATEKEEPER_URL;
                            circuitData.ServiceURLs[GetHandlers.Helpers_GatekeeperURI]      = GetHandlers.GATEKEEPER_URL;
                            circuitData.ServiceURLs[GetHandlers.Helpers_InventoryServerURI] = GetHandlers.GATEKEEPER_URL;
                            circuitData.ServiceURLs[GetHandlers.Helpers_AssetServerURI]     = GetHandlers.GATEKEEPER_URL;
                            circuitData.ServiceURLs[GetHandlers.Helpers_ProfileServerURI]   = GetHandlers.GATEKEEPER_URL;
                            circuitData.ServiceURLs[GetHandlers.Helpers_FriendsServerURI]   = GetHandlers.GATEKEEPER_URL;
                            circuitData.ServiceURLs[GetHandlers.Helpers_IMServerURI]        = GetHandlers.IM_URL;
                            clientCaps.AccountInfo.ServiceURLs = circuitData.ServiceURLs;
                            //Store the new urls
                            m_registry.RequestModuleInterface <IUserAccountService> ().StoreUserAccount(clientCaps.AccountInfo);
                        }
                    }
                    string            userAgentDriver = circuitData.ServiceURLs[GetHandlers.Helpers_HomeURI].ToString();
                    IUserAgentService connector       = new UserAgentServiceConnector(userAgentDriver);
                    regionAccepted = connector.LoginAgentToGrid(circuitData, originalDest, neighbor, new IPEndPoint(IPAddress.Parse(circuitData.IPAddress), circuitData.RegionUDPPort), out reason);
                }
                else
                {
                    if (circuitData.child)
                    {
                        circuitData.reallyischild = true;
                    }
                    regionAccepted = SimulationService.CreateAgent(neighbor, circuitData,
                                                                   TeleportFlags, agentData, out requestedUDPPort, out reason);
                }
                if (regionAccepted)
                {
                    IPAddress ipAddress = neighbor.ExternalEndPoint.Address;
                    string    otherRegionsCapsURL;
                    //If the region accepted us, we should get a CAPS url back as the reason, if not, its not updated or not an Aurora region, so don't touch it.
                    if (reason != "" && reason != "authorized")
                    {
                        OSDMap responseMap = (OSDMap)OSDParser.DeserializeJson(reason);
                        OSDMap SimSeedCaps = (OSDMap)responseMap["CapsUrls"];
                        if (responseMap.ContainsKey("OurIPForClient"))
                        {
                            string ip = responseMap["OurIPForClient"].AsString();
                            ipAddress = IPAddress.Parse(ip);
                        }
                        otherRegionService.AddCAPS(SimSeedCaps);
                        otherRegionsCapsURL = otherRegionService.CapsUrl;
                    }
                    else
                    {
                        //We are assuming an OpenSim region now!
                        #region OpenSim teleport compatibility!

                        useCallbacks        = false;
                        otherRegionsCapsURL = neighbor.ServerURI +
                                              CapsUtil.GetCapsSeedPath(circuitData.CapsPath);
                        otherRegionService.CapsUrl = otherRegionsCapsURL;

                        #endregion
                    }

                    if (requestedUDPPort == 0)
                    {
                        requestedUDPPort = neighbor.ExternalEndPoint.Port;
                    }
                    if (ipAddress == null)
                    {
                        ipAddress = neighbor.ExternalEndPoint.Address;
                    }
                    circuitData.RegionUDPPort                    = requestedUDPPort;
                    otherRegionService                           = clientCaps.GetCapsService(neighbor.RegionHandle);
                    otherRegionService.LoopbackRegionIP          = ipAddress;
                    otherRegionService.CircuitData.RegionUDPPort = requestedUDPPort;

                    IEventQueueService EQService = m_registry.RequestModuleInterface <IEventQueueService> ();

                    EQService.EnableSimulator(neighbor.RegionHandle,
                                              ipAddress.GetAddressBytes(),
                                              requestedUDPPort, AgentID,
                                              neighbor.RegionSizeX, neighbor.RegionSizeY, requestingRegion);

                    // EnableSimulator makes the client send a UseCircuitCode message to the destination,
                    // which triggers a bunch of things there.
                    // So let's wait
                    Thread.Sleep(300);
                    EQService.EstablishAgentCommunication(AgentID, neighbor.RegionHandle,
                                                          ipAddress.GetAddressBytes(),
                                                          requestedUDPPort, otherRegionsCapsURL, neighbor.RegionSizeX,
                                                          neighbor.RegionSizeY,
                                                          requestingRegion);

                    if (!useCallbacks)
                    {
                        Thread.Sleep(3000);  //Give it a bit of time, only for OpenSim...
                    }
                    MainConsole.Instance.Info("[AgentProcessing]: Completed inform client about neighbor " + neighbor.RegionName);
                }
                else
                {
                    clientCaps.RemoveCAPS(neighbor.RegionHandle);
                    MainConsole.Instance.Error("[AgentProcessing]: Failed to inform client about neighbor " + neighbor.RegionName + ", reason: " + reason);
                    return(false);
                }
                return(true);
            }
            reason = "SimulationService does not exist";
            MainConsole.Instance.Error("[AgentProcessing]: Failed to inform client about neighbor " + neighbor.RegionName + ", reason: " + reason + "!");
            return(false);
        }