Ejemplo n.º 1
1
 public void FinishedStartup()
 {
     if (m_registry == null)
         return; //Not enabled
     m_CapsService = m_registry.RequestModuleInterface<ICapsService> ();
     m_GridService = m_registry.RequestModuleInterface<IGridService> ();
     m_PresenceService = m_registry.RequestModuleInterface<IAgentInfoService> ();
     m_UserAccountService = m_registry.RequestModuleInterface<IUserAccountService> ();
     m_UserAgentService = m_registry.RequestModuleInterface<IUserAgentService> ();
     m_SimulationService = m_registry.RequestModuleInterface<ISimulationService> ();
     m_DefaultGatewayRegion = FindDefaultRegion ();
 }
Ejemplo n.º 2
0
        public void Start(IConfigSource config, IRegistryCore registry)
        {
            if (config.Configs["Currency"] == null ||
                config.Configs["Currency"].GetString("Module", "") != "SimpleCurrency")
            {
                return;
            }
            if (!config.Configs["Currency"].GetBoolean("RunServer", false))
            {
                return;
            }

            m_connector = DataManager.RequestPlugin <ISimpleCurrencyConnector>() as SimpleCurrencyConnector;

            if (m_connector.GetConfig().ClientPort == 0 && MainServer.Instance == null)
            {
                return;
            }
            IHttpServer server =
                registry.RequestModuleInterface <ISimulationBase>()
                .GetHttpServer((uint)m_connector.GetConfig().ClientPort);

            server.AddXmlRPCHandler("getCurrencyQuote", QuoteFunc);
            server.AddXmlRPCHandler("buyCurrency", BuyFunc);
            server.AddXmlRPCHandler("preflightBuyLandPrep", PreflightBuyLandPrepFunc);
            server.AddXmlRPCHandler("buyLandPrep", LandBuyFunc);
            server.AddXmlRPCHandler("getBalance", GetbalanceFunc);
            server.AddXmlRPCHandler("/currency.php", GetbalanceFunc);
            server.AddXmlRPCHandler("/landtool.php", GetbalanceFunc);

            m_syncMessagePoster = registry.RequestModuleInterface <ISyncMessagePosterService>();
            m_agentInfoService  = registry.RequestModuleInterface <IAgentInfoService>();
        }
Ejemplo n.º 3
0
        public void RegisterCaps(IRegionClientCapsService service)
        {
            m_service          = service;
            m_agentInfoService = service.Registry.RequestModuleInterface <IAgentInfoService>();

            GenericHTTPMethod method = delegate(Hashtable httpMethod)
            {
                return(ProcessUpdateAgentLanguage(httpMethod, m_service.AgentID));
            };

            service.AddStreamHandler("UpdateAgentLanguage", new RestHTTPHandler("POST", service.CreateCAPS("UpdateAgentLanguage", ""),
                                                                                method));
            method = delegate(Hashtable httpMethod)
            {
                return(ProcessUpdateAgentInfo(httpMethod, m_service.AgentID));
            };
            service.AddStreamHandler("UpdateAgentInformation", new RestHTTPHandler("POST", service.CreateCAPS("UpdateAgentInformation", ""),
                                                                                   method));

            method = delegate(Hashtable httpMethod)
            {
                return(HomeLocation(httpMethod, m_service.AgentID));
            };
            service.AddStreamHandler("HomeLocation", new RestHTTPHandler("POST", service.CreateCAPS("HomeLocation", ""),
                                                                         method));
        }
Ejemplo n.º 4
0
        /// <summary>
        ///   Sets the Home Point. The LoginService uses this to know where to put a user when they log-in
        /// </summary>
        /// <param name = "remoteClient"></param>
        /// <param name = "regionHandle"></param>
        /// <param name = "position"></param>
        /// <param name = "lookAt"></param>
        /// <param name = "flags"></param>
        public void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt,
                                    uint flags)
        {
            IScene scene = remoteClient.Scene;

            IScenePresence SP     = scene.GetScenePresence(remoteClient.AgentId);
            IDialogModule  module = scene.RequestModuleInterface <IDialogModule>();

            if (SP != null)
            {
                if (scene.Permissions.CanSetHome(SP.UUID))
                {
                    IAvatarAppearanceModule appearance = SP.RequestModuleInterface <IAvatarAppearanceModule>();
                    position.Z += appearance.Appearance.AvatarHeight / 2;
                    IAgentInfoService agentInfoService = scene.RequestModuleInterface <IAgentInfoService>();
                    if (agentInfoService != null &&
                        agentInfoService.SetHomePosition(remoteClient.AgentId.ToString(), scene.RegionInfo.RegionID,
                                                         position, lookAt) &&
                        module != null) //Do this last so it doesn't screw up the rest
                    {
                        // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
                        module.SendAlertToUser(remoteClient, "Home position set.");
                    }
                    else if (module != null)
                    {
                        module.SendAlertToUser(remoteClient, "Set Home request failed.");
                    }
                }
                else if (module != null)
                {
                    module.SendAlertToUser(remoteClient,
                                           "Set Home request failed: Permissions do not allow the setting of home here.");
                }
            }
        }
 public AgentInfoServerPostHandler (string url, IRegistryCore registry, IAgentInfoService service, string SessionID) :
         base("POST", url)
 {
     m_AgentInfoService = service;
     m_registry = registry;
     m_SessionID = SessionID;
 }
Ejemplo n.º 6
0
        public void RegisterCaps(IRegionClientCapsService service)
        {
            m_service = service;
            m_agentInfoService = service.Registry.RequestModuleInterface<IAgentInfoService>();
            
            GenericHTTPMethod method = delegate(Hashtable httpMethod)
            {
                return ProcessUpdateAgentLanguage(httpMethod, m_service.AgentID);
            };
            service.AddStreamHandler("UpdateAgentLanguage", new RestHTTPHandler("POST", service.CreateCAPS("UpdateAgentLanguage", ""),
                                                      method));
            method = delegate(Hashtable httpMethod)
            {
                return ProcessUpdateAgentInfo(httpMethod, m_service.AgentID);
            };
            service.AddStreamHandler("UpdateAgentInformation", new RestHTTPHandler("POST", service.CreateCAPS("UpdateAgentInformation", ""),
                                method));

            service.AddStreamHandler ("AvatarPickerSearch", new StreamHandler ("GET", service.CreateCAPS("AvatarPickerSearch", ""),
                                                      ProcessAvatarPickerSearch));

            method = delegate(Hashtable httpMethod)
            {
                return HomeLocation(httpMethod, m_service.AgentID);
            };
            service.AddStreamHandler("HomeLocation", new RestHTTPHandler("POST", service.CreateCAPS("HomeLocation", ""),
                                                      method));
        }
        public void RegisterCaps(IRegionClientCapsService service)
        {
            m_service = service;
            m_agentInfoService = service.Registry.RequestModuleInterface<IAgentInfoService>();
            m_agentProcessing = service.Registry.RequestModuleInterface<IAgentProcessing>();

            HttpServerHandle method;

            service.AddStreamHandler("AvatarPickerSearch",
                                     new GenericStreamHandler("GET", service.CreateCAPS("AvatarPickerSearch", ""),
                                                              ProcessAvatarPickerSearch));

            method = delegate(string path, Stream request,
                              OSHttpRequest httpRequest, OSHttpResponse httpResponse)
                         { return HomeLocation(request, m_service.AgentID); };
            service.AddStreamHandler("HomeLocation",
                                     new GenericStreamHandler("POST", service.CreateCAPS("HomeLocation", ""),
                                                              method));

            method = delegate(string path, Stream request,
                              OSHttpRequest httpRequest, OSHttpResponse httpResponse)
                         { return TeleportLocation(request, m_service.AgentID); };

            service.AddStreamHandler("TeleportLocation",
                                     new GenericStreamHandler("POST", service.CreateCAPS("TeleportLocation", ""),
                                                              method));
        }
Ejemplo n.º 8
0
        string FindRegionURI(UUID agentID)
        {
            IAgentInfoService agentInfoService = m_registry.RequestModuleInterface <IAgentInfoService> ();
            UserInfo          user             = agentInfoService.GetUserInfo(agentID.ToString());

            return((user != null && user.IsOnline) ? user.CurrentRegionURI : "");
        }
Ejemplo n.º 9
0
        private void m_presenceUpdateTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            IAgentInfoService service = m_scenes[0].RequestModuleInterface <IAgentInfoService>();

            if (service == null)
            {
                return;
            }
#if (!ISWIN)
            foreach (IScene scene in m_scenes)
            {
                foreach (IScenePresence sp in scene.GetScenePresences())
                {
                    //This causes the last pos to be updated in the database, along with the last seen time
                    sp.AddChildAgentUpdateTaint(1);
                }
            }
#else
            foreach (IScenePresence sp in m_scenes.SelectMany(scene => scene.GetScenePresences()))
            {
                //This causes the last pos to be updated in the database, along with the last seen time
                sp.AddChildAgentUpdateTaint(1);
            }
#endif
        }
Ejemplo n.º 10
0
        public void Initialize(IConfigSource config, IRegistryCore registry)
        {
            IConfig handlerConfig = config.Configs["Handlers"];
            if (handlerConfig.GetString("AgentInfoHandler", "") != Name)
                return;

            string localAssetHandler = handlerConfig.GetString("LocalAgentInfoHandler", "AgentInfoService");
            List<IAgentInfoService> services = AuroraModuleLoader.PickupModules<IAgentInfoService>();
#if (!ISWIN)
            foreach (IAgentInfoService s in services)
            {
                if (s.GetType().Name == localAssetHandler) m_localService = s;
            }
#else
                foreach (IAgentInfoService s in services.Where(s => s.GetType().Name == localAssetHandler))
                m_localService = s;
#endif
            if (m_localService == null)
                m_localService = new AgentInfoService();
            m_localService.Initialize(config, registry);
            m_remoteService = new AgentInfoConnector();
            m_remoteService.Initialize(config, registry);
            registry.RegisterModuleInterface<IAgentInfoService>(this);
            m_registry = registry;
        }
Ejemplo n.º 11
0
        public void Start(IConfigSource config, IRegistryCore registry)
        {
            if (config.Configs["Currency"] == null ||
                config.Configs["Currency"].GetString("Module", "") != "SimpleCurrency")
                return;
            if (!config.Configs["Currency"].GetBoolean("RunServer", false))
                return;

            m_connector = DataManager.RequestPlugin<ISimpleCurrencyConnector>() as SimpleCurrencyConnector;

            if (m_connector.GetConfig().ClientPort == 0 && MainServer.Instance == null)
                return;
            IHttpServer server =
                registry.RequestModuleInterface<ISimulationBase>()
                        .GetHttpServer((uint) m_connector.GetConfig().ClientPort);
            server.AddXmlRPCHandler("getCurrencyQuote", QuoteFunc);
            server.AddXmlRPCHandler("buyCurrency", BuyFunc);
            server.AddXmlRPCHandler("preflightBuyLandPrep", PreflightBuyLandPrepFunc);
            server.AddXmlRPCHandler("buyLandPrep", LandBuyFunc);
            server.AddXmlRPCHandler("getBalance", GetbalanceFunc);
            server.AddXmlRPCHandler("/currency.php", GetbalanceFunc);
            server.AddXmlRPCHandler("/landtool.php", GetbalanceFunc);

            m_syncMessagePoster = registry.RequestModuleInterface<ISyncMessagePosterService>();
            m_agentInfoService = registry.RequestModuleInterface<IAgentInfoService>();
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Gets user information for change user info page on site
        /// </summary>
        /// <param name="map">UUID</param>
        /// <returns>Verified, HomeName, HomeUUID, Online, Email, FirstName, LastName</returns>
        byte[] GetGridUserInfo(OSDMap map)
        {
            string uuid = String.Empty;

            uuid = map["UUID"].AsString();

            IUserAccountService accountService = m_registry.RequestModuleInterface <IUserAccountService>();
            UserAccount         user           = accountService.GetUserAccount(UUID.Zero, map["UUID"].AsUUID());
            IAgentInfoService   agentService   = m_registry.RequestModuleInterface <IAgentInfoService>();

            UserInfo userinfo;
            OSDMap   resp = new OSDMap();

            bool verified = user != null;

            resp["Verified"] = OSD.FromBoolean(verified);
            if (verified)
            {
                userinfo = agentService.GetUserInfo(uuid);
                IGridService gs = m_registry.RequestModuleInterface <IGridService>();
                Services.Interfaces.GridRegion gr = gs.GetRegionByUUID(UUID.Zero, userinfo.HomeRegionID);

                resp["HomeUUID"] = OSD.FromUUID(userinfo.HomeRegionID);
                resp["HomeName"] = OSD.FromString(gr.RegionName);
                resp["Online"]   = OSD.FromBoolean(userinfo.IsOnline);
                resp["Email"]    = OSD.FromString(user.Email);
                resp["Name"]     = OSD.FromString(user.Name);
            }

            string       xmlString = OSDParser.SerializeJsonString(resp);
            UTF8Encoding encoding  = new UTF8Encoding();

            return(encoding.GetBytes(xmlString));
        }
Ejemplo n.º 13
0
        public void RegisterCaps(IRegionClientCapsService service)
        {
            m_service          = service;
            m_agentInfoService = service.Registry.RequestModuleInterface <IAgentInfoService> ();
            m_agentProcessing  = service.Registry.RequestModuleInterface <IAgentProcessing> ();

            HttpServerHandle method;

            service.AddStreamHandler("AvatarPickerSearch",
                                     new GenericStreamHandler("GET", service.CreateCAPS("AvatarPickerSearch", ""),
                                                              ProcessAvatarPickerSearch));

            method = delegate(string path, Stream request,
                              OSHttpRequest httpRequest, OSHttpResponse httpResponse) {
                return(HomeLocation(request, m_service.AgentID));
            };
            service.AddStreamHandler("HomeLocation",
                                     new GenericStreamHandler("POST", service.CreateCAPS("HomeLocation", ""),
                                                              method));

            method = delegate(string path, Stream request,
                              OSHttpRequest httpRequest, OSHttpResponse httpResponse) {
                return(TeleportLocation(request, m_service.AgentID));
            };

            service.AddStreamHandler("TeleportLocation",
                                     new GenericStreamHandler("POST", service.CreateCAPS("TeleportLocation", ""),
                                                              method));
        }
Ejemplo n.º 14
0
 public AgentInfoServerPostHandler(string url, IRegistryCore registry, IAgentInfoService service, ulong regionHandle) :
     base("POST", url)
 {
     m_AgentInfoService = service;
     m_registry         = registry;
     m_regionHandle     = regionHandle;
 }
        public void Initialize(IConfigSource config, IRegistryCore registry)
        {
            IConfig handlerConfig = config.Configs["Handlers"];

            if (handlerConfig.GetString("AgentInfoHandler", "") != Name)
            {
                return;
            }

            string localAssetHandler          = handlerConfig.GetString("LocalAgentInfoHandler", "AgentInfoService");
            List <IAgentInfoService> services = AuroraModuleLoader.PickupModules <IAgentInfoService>();

#if (!ISWIN)
            foreach (IAgentInfoService s in services)
            {
                if (s.GetType().Name == localAssetHandler)
                {
                    m_localService = s;
                }
            }
#else
            foreach (IAgentInfoService s in services.Where(s => s.GetType().Name == localAssetHandler))
            {
                m_localService = s;
            }
#endif
            if (m_localService == null)
            {
                m_localService = new AgentInfoService();
            }
            m_localService.Initialize(config, registry);
            registry.RegisterModuleInterface <IAgentInfoService>(this);
            m_registry = registry;
            Init(registry, Name);
        }
Ejemplo n.º 16
0
        public bool DistanceCulling(IScenePresence client, IEntity entity)
        {
            float DD = client.DrawDistance;

            if (DD < 32) //Limit to a small distance
            {
                DD = 32;
            }
            if (DD > client.Scene.RegionInfo.RegionSizeX)
            {
                return(true); //Its larger than the region, no culling check even necessary
            }
            Vector3 posToCheckFrom = client.AbsolutePosition;

            if (client.IsChildAgent)
            {
                if (m_cachedXOffset == 0 && m_cachedYOffset == 0) //Not found yet
                {
                    IAgentInfoService agentInfoService = client.Scene.RequestModuleInterface <IAgentInfoService> ();
                    if (agentInfoService != null)
                    {
                        UserInfo info = agentInfoService.GetUserInfo(client.UUID.ToString());
                        if (info != null)
                        {
                            GridRegion r = client.Scene.GridService.GetRegionByUUID(client.Scene.RegionInfo.ScopeID,
                                                                                    info.CurrentRegionID);
                            if (r != null)
                            {
                                m_cachedXOffset = client.Scene.RegionInfo.RegionLocX - r.RegionLocX;
                                m_cachedYOffset = client.Scene.RegionInfo.RegionLocY - r.RegionLocY;
                            }
                        }
                    }
                }
                if (m_cachedXOffset < 0)
                {
                    posToCheckFrom.X = client.Scene.RegionInfo.RegionSizeX - (client.Scene.RegionInfo.RegionSizeX + client.AbsolutePosition.X + m_cachedXOffset);
                }
                if (m_cachedYOffset < 0)
                {
                    posToCheckFrom.Y = client.Scene.RegionInfo.RegionSizeY - (client.Scene.RegionInfo.RegionSizeY + client.AbsolutePosition.Y + m_cachedYOffset);
                }
                if (m_cachedXOffset > client.Scene.RegionInfo.RegionSizeX)
                {
                    posToCheckFrom.X = client.Scene.RegionInfo.RegionSizeX - (client.Scene.RegionInfo.RegionSizeX - (client.AbsolutePosition.X + m_cachedXOffset));
                }
                if (m_cachedYOffset > client.Scene.RegionInfo.RegionSizeY)
                {
                    posToCheckFrom.Y = client.Scene.RegionInfo.RegionSizeY - (client.Scene.RegionInfo.RegionSizeY - (client.AbsolutePosition.Y + m_cachedYOffset));
                }
            }
            //If the distance is greater than the clients draw distance, its out of range
            if (Vector3.DistanceSquared(posToCheckFrom, entity.AbsolutePosition) >
                DD * DD) //Use squares to make it faster than having to do the sqrt
            {
                return(false);
            }

            return(true);
        }
 public AgentInfoServerPostHandler(string url, IRegistryCore registry, IAgentInfoService service,
                                   string SessionID) :
     base("POST", url)
 {
     m_AgentInfoService = service;
     m_registry         = registry;
     m_SessionID        = SessionID;
 }
Ejemplo n.º 18
0
        /// <summary>
        ///     Notify the parcel owner each avatar that owns prims situated on their land.  This notification includes
        ///     aggregate details such as the number of prims.
        /// </summary>
        /// <param name="remote_client">
        ///     <see cref="IClientAPI" />
        /// </param>
        public void SendLandObjectOwners(IClientAPI remote_client)
        {
            if (m_scene.Permissions.CanViewObjectOwners(remote_client.AgentId, this))
            {
                IPrimCountModule primCountModule = m_scene.RequestModuleInterface <IPrimCountModule>();
                if (primCountModule != null)
                {
                    IPrimCounts primCounts = primCountModule.GetPrimCounts(LandData.GlobalID);
                    Dictionary <UUID, LandObjectOwners> owners = new Dictionary <UUID, LandObjectOwners>();
                    foreach (ISceneEntity grp in primCounts.Objects)
                    {
                        bool             newlyAdded = false;
                        LandObjectOwners landObj;
                        if (!owners.TryGetValue(grp.OwnerID, out landObj))
                        {
                            landObj = new LandObjectOwners();
                            owners.Add(grp.OwnerID, landObj);
                            newlyAdded = true;
                        }

                        landObj.Count += grp.PrimCount;
                        //Only do all of this once
                        if (newlyAdded)
                        {
                            if (grp.GroupID != UUID.Zero && grp.GroupID == grp.OwnerID)
                            {
                                landObj.GroupOwned = true;
                            }
                            else
                            {
                                landObj.GroupOwned = false;
                            }
                            if (landObj.GroupOwned)
                            {
                                landObj.Online = false;
                            }
                            else
                            {
                                IAgentInfoService presenceS = m_scene.RequestModuleInterface <IAgentInfoService>();
                                UserInfo          info      = presenceS.GetUserInfo(grp.OwnerID.ToString());
                                if (info != null)
                                {
                                    landObj.Online = info.IsOnline;
                                }
                            }
                            landObj.OwnerID = grp.OwnerID;
                        }
                        if (grp.RootChild.Rezzed > landObj.TimeLastRezzed)
                        {
                            landObj.TimeLastRezzed = grp.RootChild.Rezzed;
                        }
                    }
                    remote_client.SendLandObjectOwners(new List <LandObjectOwners>(owners.Values));
                }
            }
        }
Ejemplo n.º 19
0
        public void RegisterCaps(IRegionClientCapsService service)
        {
            m_service          = service;
            m_agentInfoService = service.Registry.RequestModuleInterface <IAgentInfoService>();
            m_agentProcessing  = service.Registry.RequestModuleInterface <IAgentProcessing>();

#if (!ISWIN)
            GenericHTTPMethod method = delegate(Hashtable httpMethod)
            {
                return(ProcessUpdateAgentLanguage(httpMethod, m_service.AgentID));
            };
#else
            GenericHTTPMethod method = httpMethod => ProcessUpdateAgentLanguage(httpMethod, m_service.AgentID);
#endif
            service.AddStreamHandler("UpdateAgentLanguage", new RestHTTPHandler("POST", service.CreateCAPS("UpdateAgentLanguage", ""),
                                                                                method));


#if (!ISWIN)
            method = delegate(Hashtable httpMethod)
            {
                return(ProcessUpdateAgentInfo(httpMethod, m_service.AgentID));
            };
#else
            method = httpMethod => ProcessUpdateAgentInfo(httpMethod, m_service.AgentID);
#endif
            service.AddStreamHandler("UpdateAgentInformation", new RestHTTPHandler("POST", service.CreateCAPS("UpdateAgentInformation", ""),
                                                                                   method));

            service.AddStreamHandler("AvatarPickerSearch", new StreamHandler("GET", service.CreateCAPS("AvatarPickerSearch", ""),
                                                                             ProcessAvatarPickerSearch));

#if (!ISWIN)
            method = delegate(Hashtable httpMethod)
            {
                return(HomeLocation(httpMethod, m_service.AgentID));
            };
#else
            method = httpMethod => HomeLocation(httpMethod, m_service.AgentID);
#endif

            service.AddStreamHandler("HomeLocation", new RestHTTPHandler("POST", service.CreateCAPS("HomeLocation", ""),
                                                                         method));

#if (!ISWIN)
            method = delegate(Hashtable httpMethod)
            {
                return(TeleportLocation(httpMethod, m_service.AgentID));
            };
#else
            method = httpMethod => TeleportLocation(httpMethod, m_service.AgentID);
#endif

            service.AddStreamHandler("TeleportLocation", new RestHTTPHandler("POST", service.CreateCAPS("TeleportLocation", ""),
                                                                             method));
        }
Ejemplo n.º 20
0
        public void AddMoney(IScene scene, string[] cmd)
        {
            string name   = MainConsole.Instance.Prompt("User Name: ");
            uint   amount = 0;

            while (!uint.TryParse(MainConsole.Instance.Prompt("Amount: ", "0"), out amount))
            {
                MainConsole.Instance.Info("Bad input, must be a number > 0");
            }

            UserAccount account =
                m_registry.RequestModuleInterface <IUserAccountService>()
                .GetUserAccount(new List <UUID> {
                UUID.Zero
            }, name);

            if (account == null)
            {
                MainConsole.Instance.Info("No account found");
                return;
            }
            var currency = GetUserCurrency(account.PrincipalID);

            m_gd.Update(_REALM,
                        new Dictionary <string, object>
            {
                {
                    "Amount", currency.Amount + amount
                }
            }, null, new QueryFilter()
            {
                andFilters =
                    new Dictionary <string, object> {
                    { "PrincipalID", account.PrincipalID }
                }
            }, null, null);
            MainConsole.Instance.Info(account.Name + " now has $" + (currency.Amount + amount));

            if (m_syncMessagePoster == null)
            {
                m_syncMessagePoster = m_registry.RequestModuleInterface <ISyncMessagePosterService>();
                m_userInfoService   = m_registry.RequestModuleInterface <IAgentInfoService>();
            }
            if (m_syncMessagePoster != null)
            {
                UserInfo toUserInfo = m_userInfoService.GetUserInfo(account.PrincipalID.ToString());
                if (toUserInfo != null && toUserInfo.IsOnline)
                {
                    SendUpdateMoneyBalanceToClient(account.PrincipalID, UUID.Zero, toUserInfo.CurrentRegionURI, (currency.Amount + amount), "");
                }
            }
        }
Ejemplo n.º 21
0
        private void ReportAgent(IScenePresence presence)
        {
            IAgentInfoService aservice = m_scene.RequestModuleInterface <IAgentInfoService>();

            if (aservice != null)
            {
                aservice.SetLoggedIn(presence.UUID.ToString(), true, false, presence.Scene.RegionInfo.RegionID);
            }
            Dictionary <string, object> sendData = new Dictionary <string, object>();

            //sendData["SCOPEID"] = scopeID.ToString();
            sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
            sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
            sendData["METHOD"]     = "login";

            sendData["UserID"]          = presence.UUID.ToString();
            sendData["SessionID"]       = presence.ControllingClient.SessionId.ToString();
            sendData["SecureSessionID"] = presence.ControllingClient.SecureSessionId.ToString();

            string        reqString = WebUtils.BuildQueryString(sendData);
            List <string> urls      = m_scene.RequestModuleInterface <IConfigurationService>().FindValueOf("PresenceServerURI");

            foreach (string url in urls)
            {
                SynchronousRestFormsRequester.MakeRequest("POST",
                                                          url,
                                                          reqString);
            }

            sendData = new Dictionary <string, object>();
            //sendData["SCOPEID"] = scopeID.ToString();
            sendData["VERSIONMIN"] = ProtocolVersions.ClientProtocolVersionMin.ToString();
            sendData["VERSIONMAX"] = ProtocolVersions.ClientProtocolVersionMax.ToString();
            sendData["METHOD"]     = "report";

            sendData["SessionID"] = presence.ControllingClient.SessionId.ToString();
            sendData["RegionID"]  = presence.Scene.RegionInfo.RegionID.ToString();

            reqString = WebUtils.BuildQueryString(sendData);
            // MainConsole.Instance.DebugFormat("[PRESENCE CONNECTOR]: queryString = {0}", reqString);
            foreach (string url in urls)
            {
                SynchronousRestFormsRequester.MakeRequest("POST",
                                                          url,
                                                          reqString);
            }
            if (aservice != null)
            {
                aservice.SetLastPosition(presence.UUID.ToString(), presence.Scene.RegionInfo.RegionID, presence.AbsolutePosition, Vector3.Zero);
            }
        }
Ejemplo n.º 22
0
 public void FinishedStartup()
 {
     if (m_registry == null)
     {
         return;//Not enabled
     }
     m_GridService         = m_registry.RequestModuleInterface <IGridService> ();
     m_asyncPostService    = m_registry.RequestModuleInterface <IAsyncMessagePostService> ();
     m_GatekeeperConnector = new GatekeeperServiceConnector(m_registry.RequestModuleInterface <IAssetService> ());
     m_GatekeeperService   = m_registry.RequestModuleInterface <IGatekeeperService> ();
     m_FriendsService      = m_registry.RequestModuleInterface <IFriendsService> ();
     m_PresenceService     = m_registry.RequestModuleInterface <IAgentInfoService> ();
     m_UserAccountService  = m_registry.RequestModuleInterface <IUserAccountService> ();
 }
Ejemplo n.º 23
0
        void m_presenceUpdateTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            IAgentInfoService service = m_scene.RequestModuleInterface <IAgentInfoService> ();

            if (service == null)
            {
                return;
            }
            foreach (IScenePresence sp in m_scene.GetScenePresences())
            {
                //This causes the last pos to be updated in the database, along with the last seen time
                sp.AddChildAgentUpdateTaint(1);
            }
        }
Ejemplo n.º 24
0
 public void FinishedStartup()
 {
     if (m_registry == null)
     {
         return; //Not enabled
     }
     m_CapsService          = m_registry.RequestModuleInterface <ICapsService> ();
     m_GridService          = m_registry.RequestModuleInterface <IGridService> ();
     m_PresenceService      = m_registry.RequestModuleInterface <IAgentInfoService> ();
     m_UserAccountService   = m_registry.RequestModuleInterface <IUserAccountService> ();
     m_UserAgentService     = m_registry.RequestModuleInterface <IUserAgentService>();
     m_SimulationService    = m_registry.RequestModuleInterface <ISimulationService>();
     m_userFinder           = m_registry.RequestModuleInterface <IUserFinder>();
     m_DefaultGatewayRegion = FindDefaultRegion();
 }
Ejemplo n.º 25
0
        /*		#region IService implementation
         *
         *      public void Initialize(IConfigSource config, IRegistryCore registry)
         *      {
         *          throw new System.NotImplementedException();
         *      }
         *
         *      public void Start(IConfigSource config, IRegistryCore registry)
         *      {
         *          throw new System.NotImplementedException();
         *      }
         *
         *      public void FinishedStartup()
         *      {
         *          throw new System.NotImplementedException();
         *      }
         *
         #endregion
         */

        #region user

        /// <summary>
        /// Gets user information for change user info page on site
        /// </summary>
        /// <param name="map">UUID</param>
        /// <returns>Verified, HomeName, HomeUUID, Online, Email, FirstName, LastName</returns>
        OSDMap GetGridUserInfo(OSDMap map)
        {
            string uuid = string.Empty;

            uuid = map ["UUID"].AsString();

            IUserAccountService accountService = m_registry.RequestModuleInterface <IUserAccountService> ();
            UserAccount         userAcct       = accountService.GetUserAccount(null, map ["UUID"].AsUUID());
            IAgentInfoService   agentService   = m_registry.RequestModuleInterface <IAgentInfoService> ();

            UserInfo userinfo;
            OSDMap   resp         = new OSDMap();
            bool     usr_verified = userAcct.Valid;

            resp ["Verified"]  = OSD.FromBoolean(usr_verified);
            resp ["UUID"]      = OSD.FromUUID(userAcct.PrincipalID);
            resp ["Email"]     = OSD.FromString(userAcct.Email);
            resp ["Name"]      = OSD.FromString(userAcct.Name);
            resp ["FirstName"] = OSD.FromString(userAcct.FirstName);
            resp ["LastName"]  = OSD.FromString(userAcct.LastName);

            // just some defaults
            resp ["HomeUUID"] = OSD.FromUUID(UUID.Zero);
            resp ["HomeName"] = OSD.FromString("");
            resp ["Online"]   = OSD.FromBoolean(false);


            if (verified)
            {
                userinfo = agentService.GetUserInfo(uuid);
                if (userinfo != null)
                {
                    resp ["HomeUUID"] = OSD.FromUUID(userinfo.HomeRegionID);
                    resp ["Online"]   = OSD.FromBoolean(userinfo.IsOnline);
                }
                IGridService gs = m_registry.RequestModuleInterface <IGridService> ();
                if (gs != null)
                {
                    GridRegion gr = gs.GetRegionByUUID(null, userinfo.HomeRegionID);
                    if (gr != null)
                    {
                        resp ["HomeName"] = OSD.FromString(gr.RegionName);
                    }
                }
            }

            return(resp);
        }
Ejemplo n.º 26
0
        void m_presenceUpdateTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            IAgentInfoService service = m_scenes[0].RequestModuleInterface <IAgentInfoService> ();

            if (service == null)
            {
                return;
            }
            foreach (Scene scene in m_scenes)
            {
                foreach (IScenePresence sp in scene.GetScenePresences())
                {
                    //Setting the last position updates the 1 hour presence timer, so send this ~ every hour so that the agent does not get logged out
                    service.SetLastPosition(sp.UUID.ToString(), scene.RegionInfo.RegionID, sp.AbsolutePosition, sp.Lookat);
                }
            }
        }
        public void SetMoney(IScene scene, string[] cmd)
        {
            string name = MainConsole.Instance.Prompt("User Name: ");

            UserAccount account =
                m_registry.RequestModuleInterface <IUserAccountService>()
                .GetUserAccount(new List <UUID> {
                UUID.Zero
            }, name);

            if (account == null)
            {
                MainConsole.Instance.Info("No account found");
                return;
            }

            uint amount = 0;

            while (!uint.TryParse(MainConsole.Instance.Prompt("Set User's Money Amount: ", "0"), out amount))
            {
                MainConsole.Instance.Info("Bad input, must be a number > 0");
            }

            // log the transfer
            UserCurrencyTransfer(account.PrincipalID, UUID.Zero, amount, "Set user money", TransactionType.SystemGenerated, UUID.Zero);

            var currency = GetUserCurrency(account.PrincipalID);

            MainConsole.Instance.Info(account.Name + " now has $" + currency.Amount);

            if (m_syncMessagePoster == null)
            {
                m_syncMessagePoster = m_registry.RequestModuleInterface <ISyncMessagePosterService>();
                m_userInfoService   = m_registry.RequestModuleInterface <IAgentInfoService>();
            }
            if (m_syncMessagePoster != null)
            {
                UserInfo toUserInfo = m_userInfoService.GetUserInfo(account.PrincipalID.ToString());
                if (toUserInfo != null && toUserInfo.IsOnline)
                {
                    SendUpdateMoneyBalanceToClient(account.PrincipalID, UUID.Zero, toUserInfo.CurrentRegionURI, currency.Amount, "");
                }
            }
        }
Ejemplo n.º 28
0
        public void Start(IConfigSource config, IRegistryCore registry)
        {
            if (config.Configs["Currency"] == null ||
                config.Configs["Currency"].GetString("Module", "") != "SimpleCurrency")
            {
                return;
            }

            // we only want this if we are local..
            bool    remoteCalls     = false;
            IConfig connectorConfig = config.Configs["UniverseConnectors"];

            if ((connectorConfig != null) && connectorConfig.Contains("DoRemoteCalls"))
            {
                remoteCalls = connectorConfig.GetBoolean("DoRemoteCalls", false);
            }

            if (remoteCalls)
            {
                return;
            }

            m_connector = Framework.Utilities.DataManager.RequestPlugin <ISimpleCurrencyConnector>() as BaseCurrencyConnector;
            var curPort = m_connector.GetConfig().ClientPort;

            if (curPort == 0 && MainServer.Instance == null)
            {
                return;
            }

            IHttpServer server = registry.RequestModuleInterface <ISimulationBase>().GetHttpServer((uint)curPort);

            server.AddXmlRPCHandler("getCurrencyQuote", QuoteFunc);
            server.AddXmlRPCHandler("buyCurrency", BuyFunc);
            server.AddXmlRPCHandler("preflightBuyLandPrep", PreflightBuyLandPrepFunc);
            server.AddXmlRPCHandler("buyLandPrep", LandBuyFunc);
            server.AddXmlRPCHandler("getBalance", GetbalanceFunc);
            server.AddXmlRPCHandler("/currency.php", GetbalanceFunc);
            server.AddXmlRPCHandler("/landtool.php", GetbalanceFunc);

            m_syncMessagePoster = registry.RequestModuleInterface <ISyncMessagePosterService>();
            m_agentInfoService  = registry.RequestModuleInterface <IAgentInfoService>();
        }
Ejemplo n.º 29
0
        protected void SendChildAgentUpdateAsync(AgentPosition agentpos, IRegionClientCapsService regionCaps)
        {
            //We need to send this update out to all the child agents this region has
            INeighborService service = m_registry.RequestModuleInterface <INeighborService>();

            if (service != null)
            {
                ISimulationService SimulationService = m_registry.RequestModuleInterface <ISimulationService>();
                if (SimulationService != null)
                {
                    //Set the last location in the database
                    IAgentInfoService agentInfoService = m_registry.RequestModuleInterface <IAgentInfoService>();
                    if (agentInfoService != null)
                    {
                        //Find the lookAt vector
                        Vector3 lookAt = new Vector3(agentpos.AtAxis.X, agentpos.AtAxis.Y, 0);

                        if (lookAt != Vector3.Zero)
                        {
                            lookAt = Util.GetNormalizedVector(lookAt);
                        }
                        //Update the database
                        agentInfoService.SetLastPosition(regionCaps.AgentID.ToString(), regionCaps.Region.RegionID,
                                                         agentpos.Position, lookAt);
                    }

                    //Also update the service itself
                    regionCaps.LastPosition = agentpos.Position;

                    //Tell all neighbor regions about the new position as well
                    List <GridRegion> ourNeighbors = service.GetNeighbors(regionCaps.Region);
                    foreach (GridRegion region in ourNeighbors)
                    {
                        //Update all the neighbors that we have
                        if (!SimulationService.UpdateAgent(region, agentpos))
                        {
                            m_log.Info("[AgentProcessing]: Failed to inform " + region.RegionName + " about updating agent. ");
                        }
                    }
                }
            }
        }
        public void FinishedStartup()
        {
            if (m_registry == null)
            {
                return;
            }

            m_registry.RegisterModuleInterface <IMoneyModule>(this);

            ISceneManager manager = m_registry.RequestModuleInterface <ISceneManager> ();

            if (manager != null)
            {
                manager.OnAddedScene += (scene) => {
                    m_scenes.Add(scene);
                    scene.EventManager.OnNewClient       += OnNewClient;
                    scene.EventManager.OnClosingClient   += OnClosingClient;
                    scene.EventManager.OnMakeRootAgent   += OnMakeRootAgent;
                    scene.EventManager.OnValidateBuyLand += EventManager_OnValidateBuyLand;
                    scene.RegisterModuleInterface <IMoneyModule> (this);
                };
                manager.OnCloseScene += (scene) => {
                    scene.EventManager.OnNewClient       -= OnNewClient;
                    scene.EventManager.OnClosingClient   -= OnClosingClient;
                    scene.EventManager.OnMakeRootAgent   -= OnMakeRootAgent;
                    scene.EventManager.OnValidateBuyLand -= EventManager_OnValidateBuyLand;
                    scene.RegisterModuleInterface <IMoneyModule> (this);
                    m_scenes.Remove(scene);
                };
            }


            // these are only valid if we are local
            if (m_connector.IsLocalConnector)
            {
                m_userInfoService    = m_registry.RequestModuleInterface <IAgentInfoService> ();
                m_userAccountService = m_registry.RequestModuleInterface <IUserAccountService> ();

                AddCommands();
            }
        }
        public void AddMoney(string[] cmd)
        {
            string name = MainConsole.Instance.Prompt("User Name: ");
            uint amount = 0;
            while (!uint.TryParse(MainConsole.Instance.Prompt("Amount: ", "0"), out amount))
                MainConsole.Instance.Info("Bad input, must be a number > 0");

            UserAccount account =
                m_registry.RequestModuleInterface<IUserAccountService>()
                          .GetUserAccount(new List<UUID> {UUID.Zero}, name);
            if (account == null)
            {
                MainConsole.Instance.Info("No account found");
                return;
            }
            var currency = GetUserCurrency(account.PrincipalID);
            m_gd.Update(_REALM,
                        new Dictionary<string, object>
                            {
                                {
                                    "Amount", currency.Amount + amount
                                }
                            }, null, new QueryFilter()
                                         {
                                             andFilters =
                                                 new Dictionary<string, object> {{"PrincipalID", account.PrincipalID}}
                                         }, null, null);
            MainConsole.Instance.Info(account.Name + " now has $" + (currency.Amount + amount));

            if (m_syncMessagePoster == null)
            {
                m_syncMessagePoster = m_registry.RequestModuleInterface<ISyncMessagePosterService>();
                m_userInfoService = m_registry.RequestModuleInterface<IAgentInfoService>();
            }
            if (m_syncMessagePoster != null)
            {
                UserInfo toUserInfo = m_userInfoService.GetUserInfo(account.PrincipalID.ToString());
                if (toUserInfo != null && toUserInfo.IsOnline)
                    SendUpdateMoneyBalanceToClient(account.PrincipalID, UUID.Zero, toUserInfo.CurrentRegionURI, (currency.Amount + amount), "");
            }
        }
        public void Initialize(IGenericData GenericData, IConfigSource source, IRegistryCore registry,
                               string defaultConnectionString)
        {
            GD         = GenericData;
            m_registry = registry;

            IConfig config = source.Configs["Currency"];

            if (config == null || source.Configs["Currency"].GetString("Module", "") != "BaseCurrency")
            {
                return;
            }

            IConfig gridInfo = source.Configs["GridInfoService"];

            if (gridInfo != null)
            {
                InWorldCurrency = gridInfo.GetString("CurrencySymbol", string.Empty) + " ";
                RealCurrency    = gridInfo.GetString("RealCurrencySymbol", string.Empty) + " ";
            }

            if (source.Configs[Name] != null)
            {
                defaultConnectionString = source.Configs[Name].GetString("ConnectionString", defaultConnectionString);
            }

            if (GenericData != null)
            {
                GenericData.ConnectToDatabase(defaultConnectionString, "SimpleCurrency", true);
            }
            Framework.Utilities.DataManager.RegisterPlugin(Name, this);

            m_config             = new BaseCurrencyConfig(config);
            m_userInfoService    = m_registry.RequestModuleInterface <IAgentInfoService>();
            m_userAccountService = m_registry.RequestModuleInterface <IUserAccountService> ();

            Init(m_registry, Name, "", "/currency/", "CurrencyServerURI");
        }
Ejemplo n.º 33
0
        private void DoPresenceUpdate(IScenePresence presence)
        {
            ReportAgent(presence);
            IFriendsModule    friendsModule = m_scene.RequestModuleInterface <IFriendsModule>();
            IAgentInfoService aservice      = m_scene.RequestModuleInterface <IAgentInfoService>();

            if (friendsModule != null)
            {
                Interfaces.FriendInfo[] friends = friendsModule.GetFriends(presence.UUID);
                List <string>           s       = new List <string>();
                for (int i = 0; i < friends.Length; i++)
                {
                    s.Add(friends[i].Friend);
                }
                List <UserInfo> infos = aservice.GetUserInfos(s);
                foreach (UserInfo u in infos)
                {
                    if (u != null && u.IsOnline)
                    {
                        friendsModule.SendFriendsStatusMessage(presence.UUID, UUID.Parse(u.UserID), true);
                    }
                }
                foreach (UserInfo u in infos)
                {
                    if (u != null && u.IsOnline)
                    {
                        if (!IsLocal(u, presence))
                        {
                            DoNonLocalPresenceUpdateCall(u, presence);
                        }
                        else
                        {
                            friendsModule.SendFriendsStatusMessage(UUID.Parse(u.UserID), presence.UUID, true);
                        }
                    }
                }
            }
        }
Ejemplo n.º 34
0
        /*		#region IService implementation
         *
         *      public void Initialize(IConfigSource config, IRegistryCore registry)
         *      {
         *          throw new System.NotImplementedException();
         *      }
         *
         *      public void Start(IConfigSource config, IRegistryCore registry)
         *      {
         *          throw new System.NotImplementedException();
         *      }
         *
         *      public void FinishedStartup()
         *      {
         *          throw new System.NotImplementedException();
         *      }
         *
         #endregion
         */

        #region user

        /// <summary>
        /// Gets user information for change user info page on site
        /// </summary>
        /// <param name="map">UUID</param>
        /// <returns>Verified, HomeName, HomeUUID, Online, Email, FirstName, LastName</returns>
        OSDMap GetGridUserInfo(OSDMap map)
        {
            string uuid = string.Empty;

            uuid = map ["UUID"].AsString();

            IUserAccountService accountService = m_registry.RequestModuleInterface <IUserAccountService> ();
            UserAccount         user           = accountService.GetUserAccount(null, map ["UUID"].AsUUID());
            IAgentInfoService   agentService   = m_registry.RequestModuleInterface <IAgentInfoService> ();

            UserInfo userinfo;
            OSDMap   resp     = new OSDMap();
            bool     verified = user != null;

            resp ["Verified"] = OSD.FromBoolean(verified);
            if (verified)
            {
                userinfo = agentService.GetUserInfo(uuid);
                IGridService gs = m_registry.RequestModuleInterface <IGridService> ();
                GridRegion   gr = null;
                if (userinfo != null)
                {
                    gr = gs.GetRegionByUUID(null, userinfo.HomeRegionID);
                }

                resp ["UUID"]      = OSD.FromUUID(user.PrincipalID);
                resp ["HomeUUID"]  = OSD.FromUUID((userinfo == null) ? UUID.Zero : userinfo.HomeRegionID);
                resp ["HomeName"]  = OSD.FromString((userinfo == null) ? "" : gr.RegionName);
                resp ["Online"]    = OSD.FromBoolean((userinfo == null) ? false : userinfo.IsOnline);
                resp ["Email"]     = OSD.FromString(user.Email);
                resp ["Name"]      = OSD.FromString(user.Name);
                resp ["FirstName"] = OSD.FromString(user.FirstName);
                resp ["LastName"]  = OSD.FromString(user.LastName);
            }

            return(resp);
        }
Ejemplo n.º 35
0
        public void LogoutAgent(IRegionClientCapsService regionCaps)
        {
            //Close all neighbor agents as well, the root is closing itself, so don't call them
            ISimulationService SimulationService = m_registry.RequestModuleInterface <ISimulationService>();

            if (SimulationService != null)
            {
                IGridService GridService = m_registry.RequestModuleInterface <IGridService>();
                if (GridService != null)
                {
                    foreach (IRegionClientCapsService regionClient in regionCaps.ClientCaps.GetCapsServices())
                    {
                        if (regionClient.RegionHandle != regionCaps.RegionHandle)
                        {
                            SimulationService.CloseAgent(regionClient.Region, regionCaps.AgentID);
                        }
                    }
                }
            }
            //Close all caps
            regionCaps.ClientCaps.Close();

            IAgentInfoService agentInfoService = m_registry.RequestModuleInterface <IAgentInfoService>();

            if (agentInfoService != null)
            {
                agentInfoService.SetLoggedIn(regionCaps.AgentID.ToString(), false, true);
            }

            ICapsService capsService = m_registry.RequestModuleInterface <ICapsService>();

            if (capsService != null)
            {
                capsService.RemoveCAPS(regionCaps.AgentID);
            }
        }
        public bool UserCurrencyTransfer(UUID toID, UUID fromID, UUID toObjectID, UUID fromObjectID, uint amount,
            string description, TransactionType type, UUID transactionID)
        {
            object remoteValue = DoRemoteByURL("CurrencyServerURI", toID, fromID, toObjectID, fromObjectID, amount,
                                               description, type, transactionID);
            if (remoteValue != null || m_doRemoteOnly)
                return (bool) remoteValue;

            UserCurrency toCurrency = GetUserCurrency(toID);
            UserCurrency fromCurrency = fromID == UUID.Zero ? null : GetUserCurrency(fromID);
            if (toCurrency == null)
                return false;
            if (fromCurrency != null)
            {
                //Check to see whether they have enough money
                if ((int) fromCurrency.Amount - (int) amount < 0)
                    return false; //Not enough money
                fromCurrency.Amount -= amount;

                UserCurrencyUpdate(fromCurrency, true);
            }
            if (fromID == toID) toCurrency = GetUserCurrency(toID);

            //Update the user whose getting paid
            toCurrency.Amount += amount;
            UserCurrencyUpdate(toCurrency, true);

            //Must send out noficiations to the users involved so that they get the updates
            if (m_syncMessagePoster == null)
            {
                m_syncMessagePoster = m_registry.RequestModuleInterface<ISyncMessagePosterService>();
                m_userInfoService = m_registry.RequestModuleInterface<IAgentInfoService>();
            }
            if (m_syncMessagePoster != null)
            {
                UserInfo toUserInfo = m_userInfoService.GetUserInfo(toID.ToString());
                UserInfo fromUserInfo = fromID == UUID.Zero ? null : m_userInfoService.GetUserInfo(fromID.ToString());
                UserAccount toAccount = m_registry.RequestModuleInterface<IUserAccountService>()
                                                  .GetUserAccount(null, toID);
                UserAccount fromAccount = m_registry.RequestModuleInterface<IUserAccountService>()
                                                    .GetUserAccount(null, fromID);
                if (fromID == toID)
                {
                    if (toUserInfo != null && toUserInfo.IsOnline)
                    {
                        OSDMap map = new OSDMap();
                        map["Method"] = "UpdateMoneyBalance";
                        map["AgentID"] = toID;
                        map["Amount"] = toCurrency.Amount;
                        if (fromAccount != null)
                            map["Message"] = fromAccount.Name + " paid you $" + amount +
                                             (description == "" ? "" : ": " + description);
                        else
                            map["Message"] = "";
                        map["TransactionID"] = transactionID;
                        m_syncMessagePoster.Post(toUserInfo.CurrentRegionURI, map);
                    }
                }
                else
                {
                    if (toUserInfo != null && toUserInfo.IsOnline)
                    {
                        OSDMap map = new OSDMap();
                        map["Method"] = "UpdateMoneyBalance";
                        map["AgentID"] = toID;
                        map["Amount"] = toCurrency.Amount;
                        if (fromAccount != null)
                            map["Message"] = fromAccount.Name + " paid you $" + amount +
                                             (description == "" ? "" : ": " + description);
                        else
                            map["Message"] = "";
                        map["TransactionID"] = transactionID;
                        m_syncMessagePoster.Post(toUserInfo.CurrentRegionURI, map);
                    }
                    if (fromUserInfo != null && fromUserInfo.IsOnline)
                    {
                        OSDMap map = new OSDMap();
                        map["Method"] = "UpdateMoneyBalance";
                        map["AgentID"] = fromID;
                        map["Amount"] = fromCurrency.Amount;
                        map["Message"] = "You paid " + (toAccount == null ? "" : toAccount.Name) + " $" + amount;
                        map["TransactionID"] = transactionID;
                        m_syncMessagePoster.Post(fromUserInfo.CurrentRegionURI, map);
                    }
                }
            }
            return true;
        }
Ejemplo n.º 37
0
 public void FinishedStartup()
 {
     //Also look for incoming messages to display
     m_agentInfoService = m_registry.RequestModuleInterface<IAgentInfoService>();
     m_registry.RequestModuleInterface<ISyncMessageRecievedService>().OnMessageReceived += OnMessageReceived;
 }
 public virtual void FinishedStartup()
 {
     m_agentInfoService = m_registry.RequestModuleInterface<IAgentInfoService>();
 }
 public virtual void RegionLoaded (IScene scene)
 {
     m_agentInfoService = scene.RequestModuleInterface<IAgentInfoService> ();
 }
Ejemplo n.º 40
0
        public void Start(IConfigSource config, IRegistryCore registry)
        {
            m_UserAccountService = registry.RequestModuleInterface<IUserAccountService>().InnerService;
            m_agentInfoService = registry.RequestModuleInterface<IAgentInfoService>().InnerService;
            m_AuthenticationService = registry.RequestModuleInterface<IAuthenticationService>();
            m_InventoryService = registry.RequestModuleInterface<IInventoryService>();
            m_GridService = registry.RequestModuleInterface<IGridService>();
            m_AvatarService = registry.RequestModuleInterface<IAvatarService>().InnerService;
            m_FriendsService = registry.RequestModuleInterface<IFriendsService>();
            m_SimulationService = registry.RequestModuleInterface<ISimulationService>();
            m_AssetService = registry.RequestModuleInterface<IAssetService> ().InnerService;
            m_LibraryService = registry.RequestModuleInterface<ILibraryService>();
            m_CapsService = registry.RequestModuleInterface<ICapsService>();

            if (!Initialized)
            {
                Initialized = true;
                RegisterCommands();
            }
            //Start the grid profile archiver.
            new GridAvatarProfileArchiver(m_UserAccountService);
            archiver = new GridAvatarArchiver(m_UserAccountService, m_AvatarService, m_InventoryService, m_AssetService);

            LoginModules = Aurora.Framework.AuroraModuleLoader.PickupModules<ILoginModule>();
            foreach (ILoginModule module in LoginModules)
            {
                module.Initialize(this, m_config, m_UserAccountService);
            }

            m_log.DebugFormat("[LLOGIN SERVICE]: Starting...");
        }
        public bool UserCurrencyTransfer(UUID toID, UUID fromID, UUID toObjectID, string toObjectName, UUID fromObjectID,
            string fromObjectName, uint amount, string description, TransactionType type, UUID transactionID)
        {
            object remoteValue = DoRemoteByURL("CurrencyServerURI", toID, fromID, toObjectID, toObjectName, fromObjectID,
                fromObjectName, amount, description, type, transactionID);
            if (remoteValue != null || m_doRemoteOnly)
                return (bool) remoteValue;

            UserCurrency toCurrency = GetUserCurrency(toID);
            UserCurrency fromCurrency = fromID == UUID.Zero ? null : GetUserCurrency(fromID);
            if (toCurrency == null)
                return false;
            if (fromCurrency != null)
            {
                //Check to see whether they have enough money
                if ((int) fromCurrency.Amount - (int) amount < 0)
                    return false; //Not enough money
                fromCurrency.Amount -= amount;

                UserCurrencyUpdate(fromCurrency, true);
            }
            if (fromID == toID) toCurrency = GetUserCurrency(toID);

            //Update the user whose getting paid
            toCurrency.Amount += amount;
            UserCurrencyUpdate(toCurrency, true);

            //Must send out notifications to the users involved so that they get the updates
            if (m_userInfoService == null)
            {
                m_userInfoService = m_registry.RequestModuleInterface<IAgentInfoService>();
                m_userAccountService = m_registry.RequestModuleInterface<IUserAccountService> ();
            }
            if (m_userInfoService != null)
            {
                UserInfo toUserInfo = m_userInfoService.GetUserInfo(toID.ToString());
                UserInfo fromUserInfo = fromID == UUID.Zero ? null : m_userInfoService.GetUserInfo(fromID.ToString());
                UserAccount toAccount = m_userAccountService.GetUserAccount(null, toID);
                UserAccount fromAccount = m_userAccountService.GetUserAccount(null, fromID);

                if (m_config.SaveTransactionLogs)
                    AddTransactionRecord((
                        transactionID == UUID.Zero ? UUID.Random() : transactionID),
                        description,
                        toID,
                        fromID,
                        amount,
                        type,
                        (toCurrency == null ? 0 : toCurrency.Amount),
                        (fromCurrency == null ? 0 : fromCurrency.Amount),
                        (toAccount == null ? "System" : toAccount.Name),
                        (fromAccount == null ? "System" : fromAccount.Name),
                        toObjectName,
                        fromObjectName,
                        (fromUserInfo == null ? UUID.Zero : fromUserInfo.CurrentRegionID)
                    );

                if (fromID == toID)
                {
                    if (toUserInfo != null && toUserInfo.IsOnline)
                        SendUpdateMoneyBalanceToClient(toID, transactionID, toUserInfo.CurrentRegionURI, toCurrency.Amount,
                            toAccount == null ? "" : (toAccount.Name + " paid you $" + amount + (description == "" ? "" : ": " + description)));
                }
                else
                {
                    if (toUserInfo != null && toUserInfo.IsOnline)
                    {
                        SendUpdateMoneyBalanceToClient(toID, transactionID, toUserInfo.CurrentRegionURI, toCurrency.Amount,
                            fromAccount == null ? "" : (fromAccount.Name + " paid you $" + amount + (description == "" ? "" : ": " + description)));
                    }
                    if (fromUserInfo != null && fromUserInfo.IsOnline)
                    {
                        SendUpdateMoneyBalanceToClient(fromID, transactionID, fromUserInfo.CurrentRegionURI, fromCurrency.Amount,
                            "You paid " + (toAccount == null ? "" : toAccount.Name) + " $" + amount);
                    }
                }
            }
            return true;
        }
Ejemplo n.º 42
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>();
            var settings = webInterface.GetWebUISettings();

            bool adminUser         = Authenticator.CheckAdminAuthentication(httpRequest, Constants.USER_GOD_CUSTOMER_SERVICE);
            bool allowRegistration = settings.WebRegistration;
            bool anonymousLogins;

            // allow configuration to override the web settings
            IConfig config = webInterface.Registry.RequestModuleInterface <ISimulationBase>().ConfigSource.Configs ["LoginService"];

            if (config != null)
            {
                anonymousLogins   = config.GetBoolean("AllowAnonymousLogin", allowRegistration);
                allowRegistration = (allowRegistration || anonymousLogins);
            }

            if (!adminUser && !allowRegistration)
            {
                vars.Add("ErrorMessage", "");
                vars.Add("RegistrationText", translator.GetTranslatedString("RegistrationText"));
                vars.Add("RegistrationsDisabled", translator.GetTranslatedString("RegistrationsDisabled"));
                vars.Add("Registrations", false);
                vars.Add("NoRegistrations", true);
                return(vars);
            }

            if (requestParameters.ContainsKey("Submit"))
            {
                string AvatarName          = requestParameters["AvatarName"].ToString();
                string AvatarPassword      = requestParameters["AvatarPassword"].ToString();
                string AvatarPasswordCheck = requestParameters["AvatarPassword2"].ToString();
                string FirstName           = requestParameters["FirstName"].ToString();
                string LastName            = requestParameters["LastName"].ToString();
                //removed - greythane - deemed not used
                //string UserAddress = requestParameters["UserAddress"].ToString();
                //string UserZip = requestParameters["UserZip"].ToString();
                string UserCity       = requestParameters["UserCity"].ToString();
                string UserEmail      = requestParameters["UserEmail"].ToString();
                string UserHomeRegion = requestParameters["UserHomeRegion"].ToString();
                string UserDOBMonth   = requestParameters["UserDOBMonth"].ToString();
                string UserDOBDay     = requestParameters["UserDOBDay"].ToString();
                string UserDOBYear    = requestParameters["UserDOBYear"].ToString();
                string AvatarArchive  = requestParameters.ContainsKey("AvatarArchive")
                                           ? requestParameters["AvatarArchive"].ToString()
                                           : "";
                bool ToSAccept = requestParameters.ContainsKey("ToSAccept") &&
                                 requestParameters["ToSAccept"].ToString() == "Accepted";

                string UserType = requestParameters.ContainsKey("UserType")         // only admins can set membership
                    ? requestParameters ["UserType"].ToString()
                    : "Resident";

                // revise UserDOBMonth to a number
                UserDOBMonth = ShortMonthToNumber(UserDOBMonth);

                // revise Type flags
                int UserFlags = webInterface.UserTypeToUserFlags(UserType);

                // a bit of idiot proofing
                if (AvatarName == "")
                {
                    response = "<h3>" + translator.GetTranslatedString("AvatarNameError") + "</h3>";
                    return(null);
                }
                if ((AvatarPassword == "") || (AvatarPassword != AvatarPasswordCheck))
                {
                    response = "<h3>" + translator.GetTranslatedString("AvatarPasswordError") + "</h3>";
                    return(null);
                }
                if (UserEmail == "")
                {
                    response = "<h3>" + translator.GetTranslatedString("AvatarEmailError") + "</h3>";
                    return(null);
                }

                // Thish -  Only one space is allowed in the name to seperate First and Last of the avatar name
                if (AvatarName.Split(' ').Length != 2)
                {
                    response = "<h3>" + translator.GetTranslatedString("AvatarNameSpacingError") + "</h3>";
                    return(null);
                }

                // so far so good...
                if (ToSAccept)
                {
                    AvatarPassword = Util.Md5Hash(AvatarPassword);

                    IUserAccountService accountService =
                        webInterface.Registry.RequestModuleInterface <IUserAccountService>();
                    UUID   userID = UUID.Random();
                    string error  = accountService.CreateUser(userID, settings.DefaultScopeID, AvatarName, AvatarPassword,
                                                              UserEmail);
                    if (error == "")
                    {
                        // set the user account type
                        UserAccount account = accountService.GetUserAccount(null, userID);
                        account.UserFlags = UserFlags;
                        accountService.StoreUserAccount(account);

                        // create and save agent info
                        IAgentConnector con = Framework.Utilities.DataManager.RequestPlugin <IAgentConnector> ();
                        con.CreateNewAgent(userID);
                        IAgentInfo agent = con.GetAgent(userID);
                        agent.OtherAgentInformation ["RLFirstName"] = FirstName;
                        agent.OtherAgentInformation ["RLLastName"]  = LastName;
                        //agent.OtherAgentInformation ["RLAddress"] = UserAddress;
                        agent.OtherAgentInformation ["RLCity"] = UserCity;
                        //agent.OtherAgentInformation ["RLZip"] = UserZip;
                        agent.OtherAgentInformation ["UserDOBMonth"] = UserDOBMonth;
                        agent.OtherAgentInformation ["UserDOBDay"]   = UserDOBDay;
                        agent.OtherAgentInformation ["UserDOBYear"]  = UserDOBYear;
                        agent.OtherAgentInformation ["UserFlags"]    = UserFlags;

                        /*if (activationRequired)
                         * {
                         *  UUID activationToken = UUID.Random();
                         *  agent.OtherAgentInformation["WebUIActivationToken"] = Util.Md5Hash(activationToken.ToString() + ":" + PasswordHash);
                         *  resp["WebUIActivationToken"] = activationToken;
                         * }*/
                        con.UpdateAgent(agent);

                        // create user profile details
                        IProfileConnector profileData =
                            Framework.Utilities.DataManager.RequestPlugin <IProfileConnector> ();
                        if (profileData != null)
                        {
                            IUserProfileInfo profile = profileData.GetUserProfile(userID);
                            if (profile == null)
                            {
                                profileData.CreateNewProfile(userID);
                                profile = profileData.GetUserProfile(userID);
                            }

                            if (AvatarArchive != "")
                            {
                                profile.AArchiveName = AvatarArchive;

                                List <AvatarArchive> avarchives = webInterface.Registry.RequestModuleInterface <IAvatarAppearanceArchiver>().GetAvatarArchives();
                                UUID snapshotUUID = UUID.Zero;
                                foreach (var archive in avarchives)
                                {
                                    if (archive.FolderName == AvatarArchive)
                                    {
                                        snapshotUUID = archive.Snapshot;
                                    }
                                }

                                if (snapshotUUID != UUID.Zero)
                                {
                                    profile.Image = snapshotUUID;
                                }
                            }
                            profile.MembershipGroup = webInterface.UserFlagToType(UserFlags, webInterface.EnglishTranslator);     // membership is english
                            profile.IsNewUser       = true;
                            profileData.UpdateUserProfile(profile);
                        }

                        IAgentInfoService agentInfoService = webInterface.Registry.RequestModuleInterface <IAgentInfoService> ();
                        Vector3           position         = new Vector3(128, 128, 25);
                        Vector3           lookAt           = new Vector3(0, 0, 22);

                        if (agentInfoService != null)
                        {
                            agentInfoService.SetHomePosition(userID.ToString(), (UUID)UserHomeRegion, position, lookAt);
                        }

                        vars.Add("ErrorMessage", "Successfully created account, redirecting to main page");
                        response = "<h3>Successfully created account, redirecting to main page</h3>" +
                                   "<script language=\"javascript\">" +
                                   "setTimeout(function() {window.location.href = \"index.html\";}, 3000);" +
                                   "</script>";
                    }
                    else
                    {
                        vars.Add("ErrorMessage", "<h3>" + error + "</h3>");
                        response = "<h3>" + error + "</h3>";
                    }
                }
                else
                {
                    response = "<h3>You did not accept the Terms of Service agreement.</h3>";
                }
                return(null);
            }

            List <Dictionary <string, object> > daysArgs = new List <Dictionary <string, object> >();

            for (int i = 1; i <= 31; i++)
            {
                daysArgs.Add(new Dictionary <string, object> {
                    { "Value", i }
                });
            }

            List <Dictionary <string, object> > monthsArgs = new List <Dictionary <string, object> >();

            //for (int i = 1; i <= 12; i++)
            //    monthsArgs.Add(new Dictionary<string, object> {{"Value", i}});

            monthsArgs.Add(new Dictionary <string, object> {
                { "Value", translator.GetTranslatedString("Jan_Short") }
            });
            monthsArgs.Add(new Dictionary <string, object> {
                { "Value", translator.GetTranslatedString("Feb_Short") }
            });
            monthsArgs.Add(new Dictionary <string, object> {
                { "Value", translator.GetTranslatedString("Mar_Short") }
            });
            monthsArgs.Add(new Dictionary <string, object> {
                { "Value", translator.GetTranslatedString("Apr_Short") }
            });
            monthsArgs.Add(new Dictionary <string, object> {
                { "Value", translator.GetTranslatedString("May_Short") }
            });
            monthsArgs.Add(new Dictionary <string, object> {
                { "Value", translator.GetTranslatedString("Jun_Short") }
            });
            monthsArgs.Add(new Dictionary <string, object> {
                { "Value", translator.GetTranslatedString("Jul_Short") }
            });
            monthsArgs.Add(new Dictionary <string, object> {
                { "Value", translator.GetTranslatedString("Aug_Short") }
            });
            monthsArgs.Add(new Dictionary <string, object> {
                { "Value", translator.GetTranslatedString("Sep_Short") }
            });
            monthsArgs.Add(new Dictionary <string, object> {
                { "Value", translator.GetTranslatedString("Oct_Short") }
            });
            monthsArgs.Add(new Dictionary <string, object> {
                { "Value", translator.GetTranslatedString("Nov_Short") }
            });
            monthsArgs.Add(new Dictionary <string, object> {
                { "Value", translator.GetTranslatedString("Dec_Short") }
            });



            List <Dictionary <string, object> > yearsArgs = new List <Dictionary <string, object> >();

            for (int i = 1940; i <= 2013; i++)
            {
                yearsArgs.Add(new Dictionary <string, object> {
                    { "Value", i }
                });
            }

            vars.Add("Days", daysArgs);
            vars.Add("Months", monthsArgs);
            vars.Add("Years", yearsArgs);

            var sortBy = new Dictionary <string, bool>();

            sortBy.Add("RegionName", true);

            var RegionListVars = new List <Dictionary <string, object> >();
            var regions        = Framework.Utilities.DataManager.RequestPlugin <IRegionData>().Get((RegionFlags)0,
                                                                                                   RegionFlags.Hyperlink |
                                                                                                   RegionFlags.Foreign |
                                                                                                   RegionFlags.Hidden,
                                                                                                   null, null, sortBy);

            foreach (var region in regions)
            {
                RegionListVars.Add(new Dictionary <string, object> {
                    { "RegionName", region.RegionName },
                    { "RegionUUID", region.RegionID }
                });
            }

            vars.Add("RegionList", RegionListVars);
            vars.Add("UserHomeRegionText", translator.GetTranslatedString("UserHomeRegionText"));


            vars.Add("UserTypeText", translator.GetTranslatedString("UserTypeText"));
            vars.Add("UserType", webInterface.UserTypeArgs(translator));

            List <AvatarArchive> archives = webInterface.Registry.RequestModuleInterface <IAvatarAppearanceArchiver>().GetAvatarArchives();

            List <Dictionary <string, object> > avatarArchives = new List <Dictionary <string, object> >();
            IWebHttpTextureService webTextureService           = webInterface.Registry.
                                                                 RequestModuleInterface <IWebHttpTextureService>();

            foreach (var archive in archives)
            {
                avatarArchives.Add(new Dictionary <string, object>
                {
                    { "AvatarArchiveName", archive.FolderName },
                    { "AvatarArchiveSnapshotID", archive.Snapshot },
                    {
                        "AvatarArchiveSnapshotURL",
                        webTextureService.GetTextureURL(archive.Snapshot)
                    }
                });
            }

            vars.Add("AvatarArchive", avatarArchives);


            IConfig loginServerConfig =
                webInterface.Registry.RequestModuleInterface <ISimulationBase>().ConfigSource.Configs["LoginService"];
            string tosLocation = "";

            if (loginServerConfig != null && loginServerConfig.GetBoolean("UseTermsOfServiceOnFirstLogin", false))
            {
                tosLocation = loginServerConfig.GetString("FileNameOfTOS", "");
                tosLocation = PathHelpers.VerifyReadFile(tosLocation, ".txt", Constants.DEFAULT_DATA_DIR);
            }
            string ToS = "There are no Terms of Service currently. This may be changed at any point in the future.";

            if (tosLocation != "")
            {
                System.IO.StreamReader reader =
                    new System.IO.StreamReader(System.IO.Path.Combine(Environment.CurrentDirectory, tosLocation));
                ToS = reader.ReadToEnd();
                reader.Close();
            }

            // check for user name seed
            string[] m_userNameSeed = null;
            if (loginServerConfig != null)
            {
                string userNameSeed = loginServerConfig.GetString("UserNameSeed", "");
                if (userNameSeed != "")
                {
                    m_userNameSeed = userNameSeed.Split(',');
                }
            }

            Utilities.MarkovNameGenerator ufNames = new Utilities.MarkovNameGenerator();
            Utilities.MarkovNameGenerator ulNames = new Utilities.MarkovNameGenerator();
            string[] nameSeed = m_userNameSeed == null ? Utilities.UserNames : m_userNameSeed;

            string firstName   = ufNames.FirstName(nameSeed, 3, 4);
            string lastName    = ulNames.FirstName(nameSeed, 5, 6);
            string enteredName = firstName + " " + lastName;

            vars.Add("AvatarName", enteredName);
            vars.Add("ToSMessage", ToS);
            vars.Add("TermsOfServiceAccept", translator.GetTranslatedString("TermsOfServiceAccept"));
            vars.Add("TermsOfServiceText", translator.GetTranslatedString("TermsOfServiceText"));
            vars.Add("RegistrationsDisabled", "");
            //vars.Add("RegistrationsDisabled", translator.GetTranslatedString("RegistrationsDisabled"));
            vars.Add("RegistrationText", translator.GetTranslatedString("RegistrationText"));
            vars.Add("AvatarNameText", translator.GetTranslatedString("AvatarNameText"));
            vars.Add("AvatarPasswordText", translator.GetTranslatedString("Password"));
            vars.Add("AvatarPasswordConfirmationText", translator.GetTranslatedString("PasswordConfirmation"));
            vars.Add("AvatarScopeText", translator.GetTranslatedString("AvatarScopeText"));
            vars.Add("FirstNameText", translator.GetTranslatedString("FirstNameText"));
            vars.Add("LastNameText", translator.GetTranslatedString("LastNameText"));
            vars.Add("UserAddressText", translator.GetTranslatedString("UserAddressText"));
            vars.Add("UserZipText", translator.GetTranslatedString("UserZipText"));
            vars.Add("UserCityText", translator.GetTranslatedString("UserCityText"));
            vars.Add("UserCountryText", translator.GetTranslatedString("UserCountryText"));
            vars.Add("UserDOBText", translator.GetTranslatedString("UserDOBText"));
            vars.Add("UserEmailText", translator.GetTranslatedString("UserEmailText"));
            vars.Add("Accept", translator.GetTranslatedString("Accept"));
            vars.Add("Submit", translator.GetTranslatedString("Submit"));
            vars.Add("SubmitURL", "register.html");
            vars.Add("ErrorMessage", "");
            vars.Add("Registrations", true);
            vars.Add("NoRegistrations", false);

            return(vars);
        }
        public void AddMoney(IScene scene, string[] cmd)
        {
            string name = MainConsole.Instance.Prompt("User Name: ");

            UserAccount account =
                m_registry.RequestModuleInterface<IUserAccountService>()
                          .GetUserAccount(new List<UUID> {UUID.Zero}, name);
            if (account == null)
            {
                MainConsole.Instance.Info("No account found");
                return;
            }

            uint amount = 0;
            while (!uint.TryParse(MainConsole.Instance.Prompt("Amount: ", "0"), out amount))
                MainConsole.Instance.Info("Bad input, must be a number > 0");

            // log the transfer
            UserCurrencyTransfer(account.PrincipalID, UUID.Zero, amount, "Money transfer", TransactionType.SystemGenerated, UUID.Zero);

            var currency = GetUserCurrency(account.PrincipalID);
            MainConsole.Instance.Info(account.Name + " now has $" + (currency.Amount));

            if (m_syncMessagePoster == null)
            {
                m_syncMessagePoster = m_registry.RequestModuleInterface<ISyncMessagePosterService>();
                m_userInfoService = m_registry.RequestModuleInterface<IAgentInfoService>();
            }
            if (m_syncMessagePoster != null)
            {
                UserInfo toUserInfo = m_userInfoService.GetUserInfo(account.PrincipalID.ToString());
                if (toUserInfo != null && toUserInfo.IsOnline)
                    SendUpdateMoneyBalanceToClient(account.PrincipalID, UUID.Zero, toUserInfo.CurrentRegionURI, (currency.Amount), "");
            }
        }
Ejemplo n.º 44
0
 public void FinishedStartup()
 {
     if (m_registry == null)
         return;//Not enabled
     m_GridService = m_registry.RequestModuleInterface<IGridService> ();
     m_asyncPostService = m_registry.RequestModuleInterface<IAsyncMessagePostService> ();
     m_GatekeeperConnector = new GatekeeperServiceConnector (m_registry.RequestModuleInterface<IAssetService> ());
     m_GatekeeperService = m_registry.RequestModuleInterface<IGatekeeperService> ();
     m_FriendsService = m_registry.RequestModuleInterface<IFriendsService> ();
     m_PresenceService = m_registry.RequestModuleInterface<IAgentInfoService> ();
     m_UserAccountService = m_registry.RequestModuleInterface<IUserAccountService> ();
 }
        public bool UserCurrencyTransfer(UUID toID, UUID fromID, UUID toObjectID, string toObjectName, UUID fromObjectID,
            string fromObjectName, uint amount, string description, TransactionType type, UUID transactionID)
        {
            if (m_doRemoteOnly) {
                object remoteValue = DoRemoteByURL ("CurrencyServerURI", toID, fromID, toObjectID, toObjectName, fromObjectID,
                                                    fromObjectName, amount, description, type, transactionID);
                return remoteValue != null && (bool)remoteValue;
            }

            // check if the 'toID' is a group
            var groupService = Framework.Utilities.DataManager.RequestPlugin<IGroupsServiceConnector> ();
            if (groupService.IsGroup(toID))
                return GroupCurrencyTransfer(toID, fromID, false, toObjectName, fromObjectID,
                    fromObjectName, (int) amount, description, type, transactionID);
                
            // use transfer
            UserCurrency toCurrency = GetUserCurrency(toID);
            UserCurrency fromCurrency = fromID == UUID.Zero ? null : GetUserCurrency(fromID);

            if (toCurrency == null)
                return false;

            // Groups (legacy) should not receive stipends
            if ((type == TransactionType.StipendPayment) && toCurrency.IsGroup)
                return false;
            
            if (fromCurrency != null)
            {
                if (fromID == (UUID)Constants.BankerUUID)
                {
                    // payment from the Banker
                    // 20150730 - greythane - need to fiddle 'the books' as -ve balances are not currently available
                    fromCurrency.Amount += amount;
                } else
                {
                    // Normal users cannot have a credit balance.. check to see whether they have enough money
                    if ((int)fromCurrency.Amount - (int)amount < 0)
                        return false; // Not enough money
                }

                // subtract this payment
                fromCurrency.Amount -= amount;
                UserCurrencyUpdate (fromCurrency, true);
            }

            if (fromID == toID)
                toCurrency = GetUserCurrency (toID);

            //Update the user who is getting paid
            toCurrency.Amount += amount;
            UserCurrencyUpdate(toCurrency, true);

            //Must send out notifications to the users involved so that they get the updates
            if (m_userInfoService == null)
            {
                m_userInfoService = m_registry.RequestModuleInterface<IAgentInfoService>();
                m_userAccountService = m_registry.RequestModuleInterface<IUserAccountService> ();
            }
            if (m_userInfoService != null)
            {
                UserInfo toUserInfo = m_userInfoService.GetUserInfo(toID.ToString());
                UserInfo fromUserInfo = fromID == UUID.Zero ? null : m_userInfoService.GetUserInfo(fromID.ToString());
                UserAccount toAccount = m_userAccountService.GetUserAccount(null, toID);
                UserAccount fromAccount = m_userAccountService.GetUserAccount(null, fromID);

                if (m_config.SaveTransactionLogs)
                    AddTransactionRecord(
                        (transactionID == UUID.Zero ? UUID.Random() : transactionID), 
                        description,
                        toID,
                        fromID,
                        amount,
                        type,
                        toCurrency.Amount, 
                        (fromCurrency == null ? 0 : fromCurrency.Amount),
                        (toAccount == null ? "System" : toAccount.Name), 
                        (fromAccount == null ? "System" : fromAccount.Name),
                        toObjectName,
                        fromObjectName,
                        (fromUserInfo == null ? UUID.Zero : fromUserInfo.CurrentRegionID)
                    );

                var paidToMsg = "";
                var paidFromMsg = "";
                var paidDesc = (description == "" ? "" : " for " + description);

                if (amount > 0) {
                    paidFromMsg = 
                        (fromAccount == null ? " received " : fromAccount.Name + " paid you ") +
                        InWorldCurrency + amount + paidDesc;
                    paidToMsg = "You paid " +
                        (toAccount == null ? "" : toAccount.Name + " ") +
                        InWorldCurrency + amount + paidDesc;
                }

                if (fromID == toID)
                {
                    if (toUserInfo != null && toUserInfo.IsOnline)
                        SendUpdateMoneyBalanceToClient(toID, transactionID, toUserInfo.CurrentRegionURI, toCurrency.Amount, 
                                                       toAccount == null ? "" : (toAccount.Name + " paid you ") +
                                                       InWorldCurrency + amount + paidDesc);
                } else
                {
                    if (toUserInfo != null && toUserInfo.IsOnline)
                    {
                        SendUpdateMoneyBalanceToClient (toID, transactionID, toUserInfo.CurrentRegionURI, toCurrency.Amount, paidFromMsg);
                    }
                    if (fromUserInfo != null && fromUserInfo.IsOnline)
                    {
                        SendUpdateMoneyBalanceToClient (fromID, transactionID, fromUserInfo.CurrentRegionURI, fromCurrency.Amount, paidToMsg);
                    }
                }
            }
            return true;
        }
        public void Start(IConfigSource config, IRegistryCore registry)
        {
            if (config.Configs["Currency"] == null ||
                config.Configs["Currency"].GetString("Module", "") != "SimpleCurrency")
                return;

            // we only want this if we are local..
            bool remoteCalls = false;
            IConfig connectorConfig = config.Configs["UniverseConnectors"];
            if ((connectorConfig != null) && connectorConfig.Contains("DoRemoteCalls"))
                remoteCalls = connectorConfig.GetBoolean("DoRemoteCalls", false);

            if (remoteCalls)
                return;

            m_connector = Framework.Utilities.DataManager.RequestPlugin<ISimpleCurrencyConnector>() as BaseCurrencyConnector;
            var curPort = m_connector.GetConfig().ClientPort;
            if (curPort == 0 && MainServer.Instance == null)
                return;

            IHttpServer server = registry.RequestModuleInterface<ISimulationBase>().GetHttpServer((uint)curPort);
            server.AddXmlRPCHandler("getCurrencyQuote", QuoteFunc);
            server.AddXmlRPCHandler("buyCurrency", BuyFunc);
            server.AddXmlRPCHandler("preflightBuyLandPrep", PreflightBuyLandPrepFunc);
            server.AddXmlRPCHandler("buyLandPrep", LandBuyFunc);
            server.AddXmlRPCHandler("getBalance", GetbalanceFunc);
            server.AddXmlRPCHandler("/currency.php", GetbalanceFunc);
            server.AddXmlRPCHandler("/landtool.php", GetbalanceFunc);

            m_syncMessagePoster = registry.RequestModuleInterface<ISyncMessagePosterService>();
            m_agentInfoService = registry.RequestModuleInterface<IAgentInfoService>();
        }
Ejemplo n.º 47
0
        public void Start(IConfigSource config, IRegistryCore registry)
        {
            m_UserAccountService = registry.RequestModuleInterface<IUserAccountService>().InnerService;
            m_agentInfoService = registry.RequestModuleInterface<IAgentInfoService>().InnerService;
            m_AuthenticationService = registry.RequestModuleInterface<IAuthenticationService>();
            m_InventoryService = registry.RequestModuleInterface<IInventoryService>();
            m_GridService = registry.RequestModuleInterface<IGridService>();
            m_AvatarService = registry.RequestModuleInterface<IAvatarService>().InnerService;
            m_FriendsService = registry.RequestModuleInterface<IFriendsService>();
            m_SimulationService = registry.RequestModuleInterface<ISimulationService>();
            m_AssetService = registry.RequestModuleInterface<IAssetService>().InnerService;
            m_LibraryService = registry.RequestModuleInterface<ILibraryService>();
            m_CapsService = registry.RequestModuleInterface<ICapsService>();
            m_ArchiveService = registry.RequestModuleInterface<IAvatarAppearanceArchiver>();

            if (!Initialized)
            {
                Initialized = true;
                RegisterCommands();
            }

            LoginModules = WhiteCoreModuleLoader.PickupModules<ILoginModule>();
            foreach (ILoginModule module in LoginModules)
            {
                module.Initialize(this, m_config, registry);
            }

            MainConsole.Instance.DebugFormat("[LLOGIN SERVICE]: Starting...");
        }
Ejemplo n.º 48
0
        OSDMap CreateAccount(OSDMap map)
        {
            bool   Verified = false;
            string Name     = map ["Name"].AsString();

            string Password = "";

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

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

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

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

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

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

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

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

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

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

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

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

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

            Verified = user != null;
            UUID userID = UUID.Zero;

            OSDMap resp = new OSDMap();

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

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

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



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

                IAgentInfo agent = con.GetAgent(userID);

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

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

                accountService.StoreUserAccount(user);

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

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

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

            resp ["UUID"] = OSD.FromUUID(userID);
            return(resp);
        }
        public bool GroupCurrencyTransfer(UUID groupID, UUID userId, bool payUser, string toObjectName, UUID fromObjectID,
            string fromObjectName, int amount, string description, TransactionType type, UUID transactionID)
        {
            GroupBalance gb = new GroupBalance {
                StartingDate = DateTime.UtcNow
            };

            // Not sure if a group will receive a system payment but..
            UserCurrency fromCurrency = userId == UUID.Zero ? null : GetUserCurrency(userId);

            // Groups (legacy) should not receive stipends
            if (type == TransactionType.StipendPayment) 
                return false;

            if (fromCurrency != null)
            {
                // Normal users cannot have a credit balance.. check to see whether they have enough money
                if ((int)fromCurrency.Amount - amount < 0)
                    return false; // Not enough money
            }

            // is thiis a payment to the group or to the user?
            if (payUser)
                amount = -1 * amount;

            uint fromBalance = 0;
            if (fromCurrency != null) {
                // user payment
                fromCurrency.Amount -= (uint)amount;
                UserCurrencyUpdate (fromCurrency, true);
                fromBalance = fromCurrency.Amount;
            }

            // track specific group fees
            switch (type)
            {
            case TransactionType.GroupJoin:
                gb.GroupFee += amount;
                break;
            case TransactionType.LandAuction:
                gb.LandFee += amount;
                break;
            case TransactionType.ParcelDirFee:
                gb.ParcelDirectoryFee += amount;
                break;
            }

            if (payUser)
                gb.TotalTierDebit -= amount;          // not sure if this the correct place yet? Are these currency or land credits?
            else
                gb.TotalTierCredits += amount;        // .. or this?

            // update the group balance
            gb.Balance += amount;                
            GroupCurrencyUpdate(groupID, gb, true);

            //Must send out notifications to the users involved so that they get the updates
            if (m_userInfoService == null)
            {
                m_userInfoService = m_registry.RequestModuleInterface<IAgentInfoService>();
                m_userAccountService = m_registry.RequestModuleInterface<IUserAccountService> ();
            }
            if (m_userInfoService != null)
            {
                UserInfo agentInfo = userId == UUID.Zero ? null : m_userInfoService.GetUserInfo(userId.ToString());
                UserAccount agentAccount = m_userAccountService.GetUserAccount(null, userId);
                var groupService = Framework.Utilities.DataManager.RequestPlugin<IGroupsServiceConnector> ();
                var groupInfo = groupService.GetGroupRecord (userId, groupID, null);
                var groupName = "Unknown";

                if (groupInfo != null)
                    groupName = groupInfo.GroupName;

                if (m_config.SaveTransactionLogs)
                    AddGroupTransactionRecord(
                        (transactionID == UUID.Zero ? UUID.Random() : transactionID), 
                        description,
                        groupID,
                        groupName, 
                        userId,
                        (agentAccount == null ? "System" : agentAccount.Name),
                        amount,
                        type,
                        gb.TotalTierCredits,        // assume this it the 'total credit for the group but it may be land tier credit??
                        (int) fromBalance,          // this will be zero if this isa system <> group transaction
                        toObjectName,
                        fromObjectName,
                        (agentInfo == null ? UUID.Zero : agentInfo.CurrentRegionID)
                    );

                if (agentInfo != null && agentInfo.IsOnline)
                {
                    SendUpdateMoneyBalanceToClient(userId, transactionID, agentInfo.CurrentRegionURI, fromBalance,
                    "You paid " + groupName + " " +InWorldCurrency + amount);
                }
            }
            return true;
        }
        public void FinishedStartup()
        {
            if (m_registry == null)
                return;

            m_registry.RegisterModuleInterface<IMoneyModule>(this);

            ISceneManager manager = m_registry.RequestModuleInterface<ISceneManager> ();
            if (manager != null) {
                manager.OnAddedScene += (scene) => {
                    m_scenes.Add (scene);
                    scene.EventManager.OnNewClient += OnNewClient;
                    scene.EventManager.OnClosingClient += OnClosingClient;
                    scene.EventManager.OnMakeRootAgent += OnMakeRootAgent;
                    scene.EventManager.OnValidateBuyLand += EventManager_OnValidateBuyLand;
                    scene.RegisterModuleInterface<IMoneyModule> (this);
                };
                manager.OnCloseScene += (scene) => {
                    scene.EventManager.OnNewClient -= OnNewClient;
                    scene.EventManager.OnClosingClient -= OnClosingClient;
                    scene.EventManager.OnMakeRootAgent -= OnMakeRootAgent;
                    scene.EventManager.OnValidateBuyLand -= EventManager_OnValidateBuyLand;
                    scene.RegisterModuleInterface<IMoneyModule> (this);
                    m_scenes.Remove (scene);
                };
            }


            // these are only valid if we are local
            if (m_connector.IsLocalConnector)
            {
                m_userInfoService = m_registry.RequestModuleInterface<IAgentInfoService> ();
                m_userAccountService = m_registry.RequestModuleInterface<IUserAccountService> ();
                    
                AddCommands ();
                
            }
        }