public void KickUser(UUID avatarID, string message)
        {
            //Get required interfaces
            IClientCapsService client = m_capsService.GetClientCapsService(avatarID);

            if (client != null)
            {
                IRegionClientCapsService regionClient = client.GetRootCapsService();
                if (regionClient != null)
                {
                    //Send the message to the client
                    m_messagePost.Get(regionClient.Region.ServerURI,
                                      BuildRequest("KickUserMessage", message, regionClient.AgentID.ToString()),
                                      (resp) =>
                    {
                        IAgentProcessing agentProcessor =
                            m_registry.RequestModuleInterface <IAgentProcessing>();
                        if (agentProcessor != null)
                        {
                            agentProcessor.LogoutAgent(regionClient, true);
                        }
                        MainConsole.Instance.Info("User has been kicked.");
                    });

                    return;
                }
            }
            MainConsole.Instance.Info("Could not find user to send message to.");
        }
Example #2
0
        public void KickUser(UUID avatarID, string message)
        {
            //Get required interfaces
            IAsyncMessagePostService messagePost = m_registry.RequestModuleInterface <IAsyncMessagePostService>();
            ICapsService             capsService = m_registry.RequestModuleInterface <ICapsService>();
            IClientCapsService       client      = capsService.GetClientCapsService(avatarID);

            if (client != null)
            {
                IRegionClientCapsService regionClient = client.GetRootCapsService();
                if (regionClient != null)
                {
                    //Send the message to the client
                    messagePost.Post(regionClient.RegionHandle,
                                     BuildRequest("KickUserMessage", message, regionClient.AgentID.ToString()));
                    IAgentProcessing agentProcessor = m_registry.RequestModuleInterface <IAgentProcessing>();
                    if (agentProcessor != null)
                    {
                        agentProcessor.LogoutAgent(regionClient, true);
                    }
                    MainConsole.Instance.Info("User will be kicked in less than 30 seconds.");
                    return;
                }
            }
            MainConsole.Instance.Info("Could not find user to send message to.");
        }
Example #3
0
        public static bool GetIsForeign(UUID AgentID, string server, IRegistryCore registry, out string serverURL)
        {
            serverURL = "";
            if (registry == null)
            {
                return(true);
            }
            ICapsService       caps       = registry.RequestModuleInterface <ICapsService>();
            IClientCapsService clientCaps = caps.GetClientCapsService(AgentID);

            if (clientCaps == null)
            {
                return(false);
            }
            IRegionClientCapsService regionClientCaps = clientCaps.GetRootCapsService();

            if (regionClientCaps == null)
            {
                return(false);
            }
            Dictionary <string, object> urls = regionClientCaps.CircuitData.ServiceURLs;

            if (urls != null && urls.Count > 0)
            {
                serverURL = urls[server].ToString();
                return(true);
            }
            return(false);
        }
Example #4
0
 void OnMakeRootAgent(IScenePresence presence)
 {
     if ((presence.CallbackURI != null) && !presence.CallbackURI.Equals(""))
     {
         WebUtils.ServiceOSDRequest(presence.CallbackURI, null, "DELETE", 10000, false, false);
         presence.CallbackURI = null;
         ICapsService service = m_scene.RequestModuleInterface <ICapsService>();
         if (service != null)
         {
             IClientCapsService clientCaps = service.GetClientCapsService(presence.UUID);
             if (clientCaps != null)
             {
                 IRegionClientCapsService regionCaps = clientCaps.GetCapsService(m_scene.RegionInfo.RegionHandle);
                 if (regionCaps != null)
                 {
                     regionCaps.RootAgent = true;
                     foreach (IRegionClientCapsService regionClientCaps in clientCaps.GetCapsServices())
                     {
                         if (regionCaps.RegionHandle != regionClientCaps.RegionHandle)
                         {
                             regionClientCaps.RootAgent = false; //Reset any other agents that we might have
                         }
                     }
                 }
             }
         }
     }
 }
Example #5
0
        public override bool StoreFriend(UUID PrincipalID, string Friend, int flags)
        {
            IUserAccountService userAccountService = m_registry.RequestModuleInterface <IUserAccountService> ();
            UserAccount         agentAccount       = userAccountService.GetUserAccount(null, PrincipalID);
            UUID FriendUUID;

            if (!UUID.TryParse(Friend, out FriendUUID))
            {
                return(base.StoreFriend(PrincipalID, Friend, flags));//Already set to a UUI
            }
            else
            {
                UserAccount friendAccount = userAccountService.GetUserAccount(null, FriendUUID);
                if (agentAccount == null || friendAccount == null)
                {
                    // remote grid users
                    ICapsService       capsService = m_registry.RequestModuleInterface <ICapsService> ();
                    IClientCapsService FriendCaps  = capsService.GetClientCapsService(UUID.Parse(Friend));
                    if (FriendCaps != null && FriendCaps.GetRootCapsService() != null)
                    {
                        Friend = HGUtil.ProduceUserUniversalIdentifier(FriendCaps.GetRootCapsService().CircuitData);
                    }
                }
                return(base.StoreFriend(PrincipalID, Friend, flags));
            }
        }
Example #6
0
        protected void SendGridMessage(string module, string[] cmd)
        {
            //Combine the params and figure out the message
            string user    = CombineParams(cmd, 3, 5);
            string message = CombineParams(cmd, 5);

            //Get required interfaces
            IAsyncMessagePostService messagePost = m_registry.RequestModuleInterface <IAsyncMessagePostService>();
            ICapsService             capsService = m_registry.RequestModuleInterface <ICapsService>();
            IUserAccountService      userService = m_registry.RequestModuleInterface <IUserAccountService>();
            UserAccount account = userService.GetUserAccount(UUID.Zero, user.Split(' ')[0], user.Split(' ')[1]);

            if (account == null)
            {
                m_log.Info("User does not exist.");
                return;
            }
            IClientCapsService client = capsService.GetClientCapsService(account.PrincipalID);

            if (client != null)
            {
                IRegionClientCapsService regionClient = client.GetRootCapsService();
                if (regionClient != null)
                {
                    //Send the message to the client
                    messagePost.Post(regionClient.RegionHandle, BuildRequest("GridWideMessage", message, regionClient.AgentID.ToString()));
                    m_log.Info("Message sent.");
                    return;
                }
            }
            m_log.Info("Could not find user to send message to.");
        }
 public bool SendGridMessage(UUID toId, string message, bool goDeep, UUID transactionId)
 {
     try
     {
         if (m_doRemoteCalls)
         {
             return((bool)DoRemote(toId, message, goDeep, transactionId));
         }
         ICapsService       capsService = m_registry.RequestModuleInterface <ICapsService>();
         IClientCapsService client      = capsService.GetClientCapsService(toId);
         if (client != null)
         {
             IRegionClientCapsService regionClient = client.GetRootCapsService();
             if (regionClient != null)
             {
                 regionPostHandler.SendGridMessageRegionPostHandler(regionClient.Region, toId, message,
                                                                    transactionId);
             }
         }
     }
     catch (Exception e)
     {
         MainConsole.Instance.ErrorFormat("[CURRENCY CONNECTOR] UserCurrencyUpdate to m_ServerURI: {0}", e.ToString());
     }
     return(false);
 }
Example #8
0
        private byte[] ProcessEnqueueEQMMessage(OSDMap request)
        {
            OSDMap response = new OSDMap();

            response["success"] = false;
            try
            {
                UUID     agentID      = request["AgentID"].AsUUID();
                ulong    regionHandle = m_ourRegionHandle == 0 ? request["RegionHandle"].AsULong() : m_ourRegionHandle;
                OSDArray events       = new OSDArray();
                if (request.ContainsKey("Events") && request["Events"].Type == OSDType.Array)
                {
                    events = (OSDArray)request["Events"];
                }

                List <OSD> OSDEvents = new List <OSD>();

                foreach (OSD ev in events)
                {
                    OSD Event = OSDParser.DeserializeLLSDXml(ev.AsString());
                    OSDEvents.Add(Event);
                }

                IClientCapsService clientCaps = m_capsService.GetClientCapsService(agentID);
                if (clientCaps != null)
                {
                    IRegionClientCapsService regionClient = clientCaps.GetCapsService(regionHandle);
                    if (regionClient != null)
                    {
                        bool enqueueResult = false;
                        foreach (OSD ev in OSDEvents)
                        {
                            enqueueResult = m_eventQueueService.Enqueue(ev, agentID, regionHandle);
                            if (!enqueueResult) //Break if one fails
                            {
                                break;
                            }
                        }
                        response["success"] = enqueueResult;
                    }
                }
            }
            catch (Exception ex)
            {
                m_log.Error("[EQMHandler]: ERROR IN THE HANDLER: " + ex.ToString());
                response            = new OSDMap();
                response["success"] = false;
            }
            string resp = OSDParser.SerializeJsonString(response);

            if (resp == "")
            {
                return(new byte[0]);
            }
            return(Util.UTF8.GetBytes(resp));
        }
Example #9
0
        IRegionClientCapsService GetRegionClientCapsService(UUID agentID, UUID regionHandle)
        {
            IClientCapsService clientCaps = m_service.GetClientCapsService(agentID);

            if (clientCaps == null)
            {
                return(null);
            }
            //If it doesn't exist, it will be null anyway, so we don't need to check anything else
            return(clientCaps.GetCapsService(regionHandle));
        }
Example #10
0
        protected object OnGenericEvent(string FunctionName, object parameters)
        {
            if (FunctionName == "UserStatusChange")
            {
                //A user has logged in or out... we need to update friends lists across the grid

                IAsyncMessagePostService asyncPoster    = m_registry.RequestModuleInterface <IAsyncMessagePostService>();
                IFriendsService          friendsService = m_registry.RequestModuleInterface <IFriendsService>();
                ICapsService             capsService    = m_registry.RequestModuleInterface <ICapsService>();
                IGridService             gridService    = m_registry.RequestModuleInterface <IGridService>();
                if (asyncPoster != null && friendsService != null && capsService != null && gridService != null)
                {
                    //Get all friends
                    UserInfo     info          = (UserInfo)parameters;
                    FriendInfo[] friends       = friendsService.GetFriends(UUID.Parse(info.UserID));
                    List <UUID>  OnlineFriends = new List <UUID>();
                    UUID         us            = UUID.Parse(info.UserID);
                    foreach (FriendInfo friend in friends)
                    {
                        UUID FriendToInform = UUID.Parse(friend.Friend);
                        //Now find their caps service so that we can find where they are root (and if they are logged in)
                        IClientCapsService clientCaps = capsService.GetClientCapsService(FriendToInform);
                        if (clientCaps != null)
                        {
                            OnlineFriends.Add(FriendToInform);
                            //Find the root agent
                            IRegionClientCapsService regionClientCaps = clientCaps.GetRootCapsService();
                            if (regionClientCaps != null)
                            {
                                //Post!
                                asyncPoster.Post(regionClientCaps.RegionHandle, SyncMessageHelper.AgentStatusChange(us, FriendToInform, info.IsOnline));
                            }
                        }
                    }
                    //If they are online, send all friends online statuses to them
                    if (info.IsOnline)
                    {
                        GridRegion ourRegion = gridService.GetRegionByUUID(UUID.Zero, info.CurrentRegionID);
                        if (ourRegion != null)
                        {
                            foreach (UUID onlineFriend in OnlineFriends)
                            {
                                asyncPoster.Post(ourRegion.RegionHandle, SyncMessageHelper.AgentStatusChange(onlineFriend, us, info.IsOnline));
                            }
                        }
                    }
                }
            }
            return(null);
        }
Example #11
0
        void OnClosingClient(IClientAPI client)
        {
            ICapsService service = m_scene.RequestModuleInterface <ICapsService>();

            if (service != null)
            {
                IClientCapsService clientCaps = service.GetClientCapsService(client.AgentId);
                if (clientCaps != null)
                {
                    IRegionClientCapsService regionCaps = clientCaps.GetCapsService(m_scene.RegionInfo.RegionHandle);
                    if (regionCaps != null)
                    {
                        regionCaps.Close();
                        clientCaps.RemoveCAPS(m_scene.RegionInfo.RegionHandle);
                    }
                }
            }
        }
Example #12
0
        protected void KickUserMessage(string module, string[] cmd)
        {
            //Combine the params and figure out the message
            string user = CombineParams(cmd, 2, 4);

            if (user.EndsWith(" "))
            {
                user = user.Remove(user.Length - 1);
            }
            string message = CombineParams(cmd, 5);

            //Get required interfaces
            IAsyncMessagePostService messagePost = m_registry.RequestModuleInterface <IAsyncMessagePostService>();
            ICapsService             capsService = m_registry.RequestModuleInterface <ICapsService>();
            IUserAccountService      userService = m_registry.RequestModuleInterface <IUserAccountService>();
            UserAccount account = userService.GetUserAccount(UUID.Zero, user);

            if (account == null)
            {
                m_log.Info("User does not exist.");
                return;
            }
            IClientCapsService client = capsService.GetClientCapsService(account.PrincipalID);

            if (client != null)
            {
                IRegionClientCapsService regionClient = client.GetRootCapsService();
                if (regionClient != null)
                {
                    //Send the message to the client
                    messagePost.Post(regionClient.RegionHandle, BuildRequest("KickUserMessage", message, regionClient.AgentID.ToString()));
                    IAgentProcessing agentProcessor = m_registry.RequestModuleInterface <IAgentProcessing>();
                    if (agentProcessor != null)
                    {
                        agentProcessor.LogoutAgent(regionClient);
                    }
                    m_log.Info("User Kicked sent.");
                    return;
                }
            }
            m_log.Info("Could not find user to send message to.");
        }
        public void MessageUser(UUID avatarID, string message)
        {
            //Get required interfaces
            IAsyncMessagePostService messagePost = m_registry.RequestModuleInterface <IAsyncMessagePostService> ();
            ICapsService             capsService = m_registry.RequestModuleInterface <ICapsService> ();
            IClientCapsService       client      = capsService.GetClientCapsService(avatarID);

            if (client != null)
            {
                IRegionClientCapsService regionClient = client.GetRootCapsService();
                if (regionClient != null)
                {
                    //Send the message to the client
                    messagePost.Post(regionClient.RegionHandle, BuildRequest("GridWideMessage", message, regionClient.AgentID.ToString()));
                    m_log.Info("Message sent.");
                    return;
                }
            }
            m_log.Info("Could not find user to send message to.");
        }
 public OSDMap GetParcelDetails(UUID agentId)
 {
     try
     {
         ICapsService       capsService = m_registry.RequestModuleInterface <ICapsService>();
         IClientCapsService client      = capsService.GetClientCapsService(agentId);
         if (client != null)
         {
             IRegionClientCapsService regionClient = client.GetRootCapsService();
             if (regionClient != null)
             {
                 LandData land = regionPostHandler.ParcelDetailsRegionPostHandler(regionClient.Region, client.AgentID);
                 return(land.ToOSD());
             }
         }
     }
     catch (Exception e)
     {
         MainConsole.Instance.ErrorFormat("[CURRENCY CONNECTOR] UserCurrencyUpdate to m_ServerURI: {0}", e.ToString());
     }
     return(null);
 }
Example #15
0
 protected object OnGenericEvent(string FunctionName, object parameters)
 {
     if (FunctionName == "NewUserConnection")
     {
         ICapsService service = m_scene.RequestModuleInterface <ICapsService>();
         if (service != null)
         {
             object[]         obj     = (object[])parameters;
             OSDMap           param   = (OSDMap)obj[0];
             AgentCircuitData circuit = (AgentCircuitData)obj[1];
             circuit.child = false;                                              //ONLY USE ROOT AGENTS
             service.CreateCAPS(circuit.AgentID, CapsUtil.GetCapsSeedPath(circuit.CapsPath),
                                m_scene.RegionInfo.RegionHandle, true, circuit); //We ONLY use root agents because of OpenSim's inability to send the correct data
             IClientCapsService clientCaps = service.GetClientCapsService(circuit.AgentID);
             if (clientCaps != null)
             {
                 IRegionClientCapsService regionCaps = clientCaps.GetCapsService(m_scene.RegionInfo.RegionHandle);
                 if (regionCaps != null)
                 {
                     regionCaps.AddCAPS((OSDMap)param["CapsUrls"]);
                 }
             }
         }
     }
     else if (FunctionName == "UserStatusChange")
     {
         UserInfo info = (UserInfo)parameters;
         if (!info.IsOnline) //Logging out
         {
             ICapsService service = m_scene.RequestModuleInterface <ICapsService>();
             if (service != null)
             {
                 service.RemoveCAPS(UUID.Parse(info.UserID));
             }
         }
     }
     return(null);
 }
Example #16
0
        private object StipendsPayOutEvent(string functionName, object parameters)
        {
            if (functionName != "StipendsPayout")
            {
                return(null);
            }
            StipendsInfo si = new StipendsInfo();

            si.FromOSD((OSDMap)OSDParser.DeserializeJson(parameters.ToString()));
            IUserAccountService userService = m_registry.RequestModuleInterface <IUserAccountService>();
            UserAccount         ua          = userService.GetUserAccount(null, si.AgentID);

            if ((ua != null) && (ua.UserFlags >= 0) && ((!m_options.StipendsPremiumOnly) || ((ua.UserLevel & Constants.USER_FLAG_MEMBER) == Constants.USER_FLAG_MEMBER)))
            {
                if (m_options.GiveStipendsOnlyWhenLoggedIn)
                {
                    ICapsService       capsService = m_registry.RequestModuleInterface <ICapsService>();
                    IClientCapsService client      = capsService.GetClientCapsService(ua.PrincipalID);
                    if (client == null)
                    {
                        return("");
                    }
                }
                IMoneyModule mo = m_registry.RequestModuleInterface <IMoneyModule>();
                if (mo == null)
                {
                    return(null);
                }
                UUID transid = UUID.Random();
                MainConsole.Instance.Info("[MONEY MODULE] Stipend Payment for " + ua.FirstName + " " + ua.LastName + " is now running");
                if (m_currencyService.UserCurrencyTransfer(ua.PrincipalID, UUID.Zero, (uint)m_options.Stipend, "Stipend Payment", TransactionType.StipendPayment, transid))
                {
                    return(transid.ToString());
                }
            }
            return("");
        }
Example #17
0
 protected object OnGenericEvent(string FunctionName, object parameters)
 {
     if (FunctionName == "NewUserConnection")
     {
         ICapsService service = m_scene.RequestModuleInterface <ICapsService>();
         if (service != null)
         {
             OSDMap           param   = (OSDMap)parameters;
             AgentCircuitData circuit = new AgentCircuitData();
             circuit.UnpackAgentCircuitData((OSDMap)param["Agent"]);
             service.CreateCAPS(circuit.AgentID, CapsUtil.GetCapsSeedPath(circuit.CapsPath),
                                m_scene.RegionInfo.RegionHandle, !circuit.child, circuit);
             IClientCapsService clientCaps = service.GetClientCapsService(circuit.AgentID);
             if (clientCaps != null)
             {
                 IRegionClientCapsService regionCaps = clientCaps.GetCapsService(m_scene.RegionInfo.RegionHandle);
                 if (regionCaps != null)
                 {
                     regionCaps.AddCAPS((OSDMap)param["CapsUrls"]);
                 }
             }
         }
     }
     else if (FunctionName == "UserStatusChange")
     {
         UserInfo info = (UserInfo)parameters;
         if (!info.IsOnline) //Logging out
         {
             ICapsService service = m_scene.RequestModuleInterface <ICapsService>();
             if (service != null)
             {
                 service.RemoveCAPS(UUID.Parse(info.UserID));
             }
         }
     }
     return(null);
 }
Example #18
0
        void OnMakeRootAgent(IScenePresence presence)
        {
            ICapsService service = m_scene.RequestModuleInterface <ICapsService> ();

            if (service != null)
            {
                IClientCapsService clientCaps = service.GetClientCapsService(presence.UUID);
                if (clientCaps != null)
                {
                    IRegionClientCapsService regionCaps = clientCaps.GetCapsService(m_scene.RegionInfo.RegionHandle);
                    if (regionCaps != null)
                    {
                        regionCaps.RootAgent = true;
                        foreach (IRegionClientCapsService regionClientCaps in clientCaps.GetCapsServices())
                        {
                            if (regionCaps.RegionHandle != regionClientCaps.RegionHandle)
                            {
                                regionClientCaps.RootAgent = false; //Reset any other agents that we might have
                            }
                        }
                    }
                }
            }
            if ((presence.CallbackURI != null) && !presence.CallbackURI.Equals(""))
            {
                WebUtils.ServiceOSDRequest(presence.CallbackURI, null, "DELETE", 10000, false, false, false);
                presence.CallbackURI = null;
            }
#if (!ISWIN)
            Util.FireAndForget(delegate(object o)
            {
                DoPresenceUpdate(presence);
            });
#else
            Util.FireAndForget(o => DoPresenceUpdate(presence));
#endif
        }
Example #19
0
        private object StupendsPayOutEvent(string functionName, object parameters)
        {
            if (functionName != "StipendsPayout")
            {
                return(null);
            }
            StipendsInfo si = new StipendsInfo();

            si.FromOSD((OSDMap)OSDParser.DeserializeJson(parameters.ToString()));
            IUserAccountService userService = m_registry.RequestModuleInterface <IUserAccountService>();
            UserAccount         ua          = userService.GetUserAccount(null, si.AgentID);

            if ((ua != null) && (ua.UserFlags >= 0) && ((!m_options.StipendsPremiumOnly) || ((ua.UserLevel & 600) == 600)))
            {
                if (m_options.GiveStipendsOnlyWhenLoggedIn)
                {
                    ICapsService       capsService = m_registry.RequestModuleInterface <ICapsService>();
                    IClientCapsService client      = capsService.GetClientCapsService(ua.PrincipalID);
                    if (client == null)
                    {
                        return("");
                    }
                }
                IMoneyModule mo = m_registry.RequestModuleInterface <IMoneyModule>();
                if (mo == null)
                {
                    return(null);
                }
                UUID transid = UUID.Random();
                if (m_dustCurrencyService.UserCurrencyTransfer(ua.PrincipalID, m_options.BankerPrincipalID, UUID.Zero, UUID.Zero, (uint)m_options.Stipend, "Stipend Payment", TransactionType.StipendPayment, transid))
                {
                    return(transid.ToString());
                }
            }
            return("");
        }
        public byte[] HandleMap(OSDMap args)
        {
            if (args.ContainsKey("Method"))
            {
                string method = args["Method"].AsString();
                try
                {
                    MethodImplementation methodInfo;
                    if (GetMethodInfo(method, args.Count - 1, out methodInfo))
                    {
                        if (m_SessionID == "")
                        {
                            if (methodInfo.Attribute.ThreatLevel != ThreatLevel.None)
                            {
                                return(MainServer.BadRequest);
                            }
                        }
                        else if (!m_urlModule.CheckThreatLevel(m_SessionID, method, methodInfo.Attribute.ThreatLevel))
                        {
                            return(MainServer.BadRequest);
                        }
                        if (methodInfo.Attribute.UsePassword)
                        {
                            if (!methodInfo.Reference.CheckPassword(args["Password"].AsString()))
                            {
                                return(MainServer.BadRequest);
                            }
                        }
                        if (methodInfo.Attribute.OnlyCallableIfUserInRegion)
                        {
                            UUID userID = args["UserID"].AsUUID();
                            IClientCapsService clientCaps = m_capsService.GetClientCapsService(userID);
                            if (userID == UUID.Zero || clientCaps == null || clientCaps.GetRootCapsService().RegionHandle != ulong.Parse(m_SessionID))
                            {
                                return(MainServer.BadRequest);
                            }
                        }

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

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

            return(MainServer.BadRequest);
        }
Example #21
0
        protected object OnGenericEvent(string FunctionName, object parameters)
        {
            if (FunctionName == "UserStatusChange")
            {
                //A user has logged in or out... we need to update friends lists across the grid

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

                    List <FriendInfo> friends                 = friendsService.GetFriends(us);
                    List <UUID>       OnlineFriends           = new List <UUID>();
                    List <string>     previouslyContactedURLs = new List <string>();
                    foreach (FriendInfo friend in friends)
                    {
                        if (friend.TheirFlags == -1 || friend.MyFlags == -1)
                        {
                            continue; //Not validiated yet!
                        }
                        UUID   FriendToInform = UUID.Zero;
                        string url, first, last, secret;
                        if (!UUID.TryParse(friend.Friend, out FriendToInform))
                        {
                            HGUtil.ParseUniversalUserIdentifier(friend.Friend, out FriendToInform, out url, out first,
                                                                out last, out secret);
                        }
                        //Now find their caps service so that we can find where they are root (and if they are logged in)
                        IClientCapsService clientCaps = capsService.GetClientCapsService(FriendToInform);
                        if (clientCaps != null)
                        {
                            //Find the root agent
                            IRegionClientCapsService regionClientCaps = clientCaps.GetRootCapsService();
                            if (regionClientCaps != null)
                            {
                                OnlineFriends.Add(FriendToInform);
                                //Post!
                                asyncPoster.Post(regionClientCaps.RegionHandle,
                                                 SyncMessageHelper.AgentStatusChange(us, FriendToInform, isOnline));
                            }
                            else
                            {
                                //If they don't have a root agent, wtf happened?
                                capsService.RemoveCAPS(clientCaps.AgentID);
                            }
                        }
                        else
                        {
                            IAgentInfoService agentInfoService = m_registry.RequestModuleInterface <IAgentInfoService>();
                            if (agentInfoService != null)
                            {
                                UserInfo friendinfo = agentInfoService.GetUserInfo(FriendToInform.ToString());
                                if (friendinfo != null && friendinfo.IsOnline)
                                {
                                    OnlineFriends.Add(FriendToInform);
                                    //Post!
                                    GridRegion r = gridService.GetRegionByUUID(UUID.Zero, friendinfo.CurrentRegionID);
                                    if (r != null)
                                    {
                                        asyncPoster.Post(r.RegionHandle,
                                                         SyncMessageHelper.AgentStatusChange(us, FriendToInform,
                                                                                             isOnline));
                                    }
                                }
                                else
                                {
                                    IUserAgentService uas = m_registry.RequestModuleInterface <IUserAgentService>();
                                    if (uas != null)
                                    {
                                        bool online = uas.RemoteStatusNotification(friend, us, isOnline);
                                        if (online)
                                        {
                                            OnlineFriends.Add(FriendToInform);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    //If the user is coming online, send all their friends online statuses to them
                    if (isOnline)
                    {
                        GridRegion ourRegion = gridService.GetRegionByUUID(UUID.Zero, UUID.Parse(info[2].ToString()));
                        if (ourRegion != null)
                        {
                            foreach (UUID onlineFriend in OnlineFriends)
                            {
                                asyncPoster.Post(ourRegion.RegionHandle,
                                                 SyncMessageHelper.AgentStatusChange(onlineFriend, us, isOnline));
                            }
                        }
                    }
                }
            }
            return(null);
        }
Example #22
0
        public override bool InformClientOfNeighbor(UUID AgentID, ulong requestingRegion, AgentCircuitData circuitData, ref GridRegion neighbor, uint TeleportFlags, AgentData agentData, out string reason, out bool useCallbacks)
        {
            useCallbacks = true;
            if (neighbor == null)
            {
                reason = "Could not find neighbor to inform";
                return(false);
            }

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

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

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

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

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

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

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

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

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

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

                        #endregion
                    }

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

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

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

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

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

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

            if (capsService == null)
            {
                //m_log.Info("[AgentProcessing]: Failed OnMessageReceived ICapsService is null");
                return(new OSDMap());
            }
            IClientCapsService clientCaps = capsService.GetClientCapsService(AgentID);

            IRegionClientCapsService regionCaps = null;

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

                regionCaps.Disabled = false;

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

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

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

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

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

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

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

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

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

                    AgentData AgentData = new AgentData();
                    AgentData.Unpack((OSDMap)body["AgentData"]);
                    regionCaps.Disabled = false;

                    OSDMap result = new OSDMap();
                    string reason = "";
                    result["Success"] = TeleportAgent(destination, TeleportFlags, DrawDistance,
                                                      Circuit, AgentData, AgentID, requestingRegion, out reason);
                    result["Reason"] = reason;
                    return(result);
                }
            }
            else if (message["Method"] == "CrossAgent")
            {
                if (regionCaps == null || clientCaps == null)
                {
                    return(null);
                }
                if (clientCaps.GetRootCapsService().RegionHandle == regionCaps.RegionHandle)
                {
                    //This is a simulator message that tells us to cross the agent
                    OSDMap body = ((OSDMap)message["Message"]);

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

                    OSDMap result = new OSDMap();
                    string reason = "";
                    result["Success"] = CrossAgent(Region, pos, Vel, Circuit, AgentData,
                                                   AgentID, requestingRegion, out reason);
                    result["Reason"] = reason;
                    return(result);
                }
            }
            return(null);
        }
Example #24
0
        /// <summary>
        /// Async component for informing client of which neighbors exist
        /// </summary>
        /// <remarks>
        /// This needs to run asynchronously, as a network timeout may block the thread for a long while
        /// </remarks>
        /// <param name="remoteClient"></param>
        /// <param name="a"></param>
        /// <param name="regionHandle"></param>
        /// <param name="endPoint"></param>
        private bool InformClientOfNeighbor(UUID AgentID, ulong requestingRegion, AgentCircuitData circuitData, GridRegion neighbor,
                                            uint TeleportFlags, AgentData agentData, out string reason)
        {
            if (neighbor == null)
            {
                reason = "Could not find neighbor to inform";
                return(false);
            }
            m_log.Info("[AgentProcessing]: Starting to inform client about neighbor " + neighbor.RegionName);

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

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

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

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

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

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

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

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

                #region OpenSim teleport compatibility!

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

                #endregion

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

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

                        #endregion
                    }

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

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

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

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

            #region Build the transaction



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


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

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

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

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

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

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


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

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

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

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

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

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



            #endregion

            #region Perform transaction

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

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

            #endregion

            #region notifications

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

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

            #endregion

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

            string authURL = string.Empty;

            if (aCircuit.ServiceURLs.ContainsKey("HomeURI"))
            {
                authURL = aCircuit.ServiceURLs["HomeURI"].ToString();
            }
            MainConsole.Instance.InfoFormat("[GATEKEEPER SERVICE]: Login request for {0} {1} @ {2}",
                                            authURL, aCircuit.AgentID, destination.RegionName);

            //
            // Authenticate the user
            //
            if (!Authenticate(aCircuit))
            {
                reason = "Unable to verify identity";
                MainConsole.Instance.InfoFormat("[GATEKEEPER SERVICE]: Unable to verify identity of agent {0}. Refusing service.", aCircuit.AgentID);
                return(false);
            }
            MainConsole.Instance.DebugFormat("[GATEKEEPER SERVICE]: Identity verified for {0} @ {1}", aCircuit.AgentID, authURL);

            //
            // Check for impersonations
            //
            UserAccount account = null;

            if (m_UserAccountService != null)
            {
                // Check to see if we have a local user with that UUID
                account = m_UserAccountService.GetUserAccount(null, aCircuit.AgentID);
                if (account != null && m_userFinder.IsLocalGridUser(account.PrincipalID))
                {
                    // Make sure this is the user coming home, and not a foreign user with same UUID as a local user
                    if (m_UserAgentService != null)
                    {
                        if (!m_UserAgentService.AgentIsComingHome(aCircuit.SessionID, m_ExternalName))
                        {
                            // Can't do, sorry
                            reason = "Unauthorized";
                            MainConsole.Instance.InfoFormat("[GATEKEEPER SERVICE]: Foreign agent {0} has same ID as local user. Refusing service.",
                                                            aCircuit.AgentID);
                            return(false);
                        }
                    }
                }
            }
            MainConsole.Instance.InfoFormat("[GATEKEEPER SERVICE]: User is ok");

            // May want to authorize

            //bool isFirstLogin = false;
            //
            // Login the presence, if it's not there yet (by the login service)
            //
            UserInfo presence = m_PresenceService.GetUserInfo(aCircuit.AgentID.ToString());

            if (m_userFinder.IsLocalGridUser(aCircuit.AgentID) && presence != null && presence.IsOnline) // it has been placed there by the login service
            {
                //    isFirstLogin = true;
            }
            else
            {
                IUserAgentService userAgentService = new UserAgentServiceConnector(aCircuit.ServiceURLs["HomeURI"].ToString());
                Vector3           position = Vector3.UnitY, lookAt = Vector3.UnitY;
                GridRegion        finalDestination = userAgentService.GetHomeRegion(aCircuit.AgentID, out position, out lookAt);
                if (finalDestination == null)
                {
                    reason = "You do not have a home position set.";
                    return(false);
                }
                m_PresenceService.SetHomePosition(aCircuit.AgentID.ToString(), finalDestination.RegionID, position, lookAt);
                m_PresenceService.SetLoggedIn(aCircuit.AgentID.ToString(), true, true, destination.RegionID);
            }

            MainConsole.Instance.DebugFormat("[GATEKEEPER SERVICE]: Login presence ok");

            //
            // Get the region
            //
            destination = m_GridService.GetRegionByUUID(null, destination.RegionID);
            if (destination == null)
            {
                reason = "Destination region not found";
                return(false);
            }

            //
            // Adjust the visible name
            //
            if (account != null)
            {
                aCircuit.firstname = account.FirstName;
                aCircuit.lastname  = account.LastName;
            }
            if (account == null && !aCircuit.lastname.StartsWith("@"))
            {
                aCircuit.firstname = aCircuit.firstname + "." + aCircuit.lastname;
                try
                {
                    Uri uri = new Uri(aCircuit.ServiceURLs["HomeURI"].ToString());
                    aCircuit.lastname = "@" + uri.Host; // + ":" + uri.Port;
                }
                catch
                {
                    MainConsole.Instance.WarnFormat("[GATEKEEPER SERVICE]: Malformed HomeURI (this should never happen): {0}", aCircuit.ServiceURLs["HomeURI"]);
                    aCircuit.lastname = "@" + aCircuit.ServiceURLs["HomeURI"].ToString();
                }
                m_userFinder.AddUser(aCircuit.AgentID, aCircuit.firstname, aCircuit.lastname, aCircuit.ServiceURLs);
                m_UserAccountService.CacheAccount(new UserAccount(UUID.Zero, aCircuit.AgentID, aCircuit.firstname + aCircuit.lastname, "")
                {
                    UserFlags = 1024
                });
            }

retry:
            //
            // Finally launch the agent at the destination
            //
            TeleportFlags loginFlag = /*isFirstLogin ? */ TeleportFlags.ViaLogin /* : TeleportFlags.ViaHGLogin*/;
            IRegionClientCapsService regionClientCaps = null;

            if (m_CapsService != null)
            {
                //Remove any previous users
                string ServerCapsBase = Aurora.Framework.Capabilities.CapsUtil.GetRandomCapsObjectPath();
                m_CapsService.CreateCAPS(aCircuit.AgentID,
                                         Aurora.Framework.Capabilities.CapsUtil.GetCapsSeedPath(ServerCapsBase),
                                         destination.RegionHandle, true, aCircuit, 0);

                regionClientCaps = m_CapsService.GetClientCapsService(aCircuit.AgentID).GetCapsService(destination.RegionHandle);
                if (aCircuit.ServiceURLs == null)
                {
                    aCircuit.ServiceURLs = new Dictionary <string, object>();
                }
                aCircuit.ServiceURLs["IncomingCAPSHandler"] = regionClientCaps.CapsUrl;
            }
            aCircuit.child = false;//FIX THIS, OPENSIM ALWAYS SENDS CHILD!
            int  requestedUDPPort = 0;
            bool success          = m_SimulationService.CreateAgent(destination, aCircuit, (uint)loginFlag, null, out requestedUDPPort, out reason);

            if (success)
            {
                if (regionClientCaps != null)
                {
                    if (requestedUDPPort == 0)
                    {
                        requestedUDPPort = destination.ExternalEndPoint.Port;
                    }
                    IPAddress ipAddress = destination.ExternalEndPoint.Address;
                    aCircuit.RegionUDPPort                     = requestedUDPPort;
                    regionClientCaps.LoopbackRegionIP          = ipAddress;
                    regionClientCaps.CircuitData.RegionUDPPort = requestedUDPPort;
                    OSDMap responseMap = (OSDMap)OSDParser.DeserializeJson(reason);
                    OSDMap SimSeedCaps = (OSDMap)responseMap["CapsUrls"];
                    regionClientCaps.AddCAPS(SimSeedCaps);
                }
            }
            else
            {
                if (m_CapsService != null)
                {
                    m_CapsService.RemoveCAPS(aCircuit.AgentID);
                }
                m_GridService.SetRegionUnsafe(destination.RegionID);
                if (!m_foundDefaultRegion)
                {
                    m_DefaultGatewayRegion = FindDefaultRegion();
                }
                if (destination != m_DefaultGatewayRegion)
                {
                    destination = m_DefaultGatewayRegion;
                    goto retry;
                }
                else
                {
                    m_DefaultGatewayRegion = FindDefaultRegion();
                    if (m_DefaultGatewayRegion == destination)
                    {
                        return(false);//It failed to find a new one
                    }
                    destination = m_DefaultGatewayRegion;
                    goto retry;//It found a new default region
                }
            }
            return(success);
        }
        public Dictionary <string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest,
                                                OSHttpResponse httpResponse, Dictionary <string, object> requestParameters, ITranslator translator, out string response)
        {
            response = null;
            var vars = new Dictionary <string, object>();

            string error = "";
            UUID   user  = httpRequest.Query.ContainsKey("userid") ? UUID.Parse(httpRequest.Query["userid"].ToString()) :
                           UUID.Parse(requestParameters["userid"].ToString());

            IUserAccountService userService = webInterface.Registry.RequestModuleInterface <IUserAccountService>();
            var         agentService        = Aurora.DataManager.DataManager.RequestPlugin <IAgentConnector>();
            UserAccount account             = userService.GetUserAccount(null, user);
            IAgentInfo  agent = agentService.GetAgent(user);

            if (requestParameters.ContainsKey("Submit") &&
                requestParameters["Submit"].ToString() == "SubmitPasswordChange")
            {
                string password     = requestParameters["password"].ToString();
                string passwordconf = requestParameters["passwordconf"].ToString();

                if (password != passwordconf)
                {
                    response = "Passwords do not match";
                }
                else
                {
                    IAuthenticationService authService = webInterface.Registry.RequestModuleInterface <IAuthenticationService>();
                    if (authService != null)
                    {
                        response = authService.SetPassword(user, "UserAccount", password) ? "Successfully set password" : "Failed to set your password, try again later";
                    }
                    else
                    {
                        response = "No authentication service was available to change your password";
                    }
                }
                return(null);
            }
            else if (requestParameters.ContainsKey("Submit") &&
                     requestParameters["Submit"].ToString() == "SubmitEmailChange")
            {
                string email = requestParameters["email"].ToString();

                if (userService != null)
                {
                    account.Email = email;
                    userService.StoreUserAccount(account);
                    response = "Successfully updated email";
                }
                else
                {
                    response = "No authentication service was available to change your password";
                }
                return(null);
            }
            else if (requestParameters.ContainsKey("Submit") &&
                     requestParameters["Submit"].ToString() == "SubmitDeleteUser")
            {
                string username = requestParameters["username"].ToString();
                response = "Deleted user successfully";
                if (username == account.Name)
                {
                    userService.DeleteUser(user, "", false, false);
                }
                else
                {
                    response = "The user name did not match";
                }
                return(null);
            }
            if (requestParameters.ContainsKey("Submit") &&
                requestParameters["Submit"].ToString() == "SubmitTempBanUser")
            {
                int timeDays    = int.Parse(requestParameters["TimeDays"].ToString());
                int timeHours   = int.Parse(requestParameters["TimeHours"].ToString());
                int timeMinutes = int.Parse(requestParameters["TimeMinutes"].ToString());
                agent.Flags |= IAgentFlags.TempBan;
                DateTime until = DateTime.Now.AddDays(timeDays).AddHours(timeHours).AddMinutes(timeMinutes);
                agent.OtherAgentInformation["TemperaryBanInfo"] = until;
                agentService.UpdateAgent(agent);
                error = "User has been banned.";
            }
            if (requestParameters.ContainsKey("Submit") &&
                requestParameters["Submit"].ToString() == "SubmitBanUser")
            {
                agent.Flags |= IAgentFlags.PermBan;
                agentService.UpdateAgent(agent);
                error = "User has been banned.";
            }
            if (requestParameters.ContainsKey("Submit") &&
                requestParameters["Submit"].ToString() == "SubmitUnbanUser")
            {
                agent.Flags &= ~IAgentFlags.TempBan;
                agent.Flags &= ~IAgentFlags.PermBan;
                agent.OtherAgentInformation.Remove("TemperaryBanInfo");
                agentService.UpdateAgent(agent);
                error = "User has been unbanned.";
            }
            if (requestParameters.ContainsKey("Submit") &&
                requestParameters["Submit"].ToString() == "SubmitLoginAsUser")
            {
                Authenticator.ChangeAuthentication(httpRequest, account);
                webInterface.Redirect(httpResponse, "/");
                return(vars);
            }
            if (requestParameters.ContainsKey("Submit") &&
                requestParameters["Submit"].ToString() == "SubmitKickUser")
            {
                string message = requestParameters["KickMessage"].ToString();
                IGridWideMessageModule messageModule = webInterface.Registry.RequestModuleInterface <IGridWideMessageModule>();
                if (messageModule != null)
                {
                    messageModule.KickUser(account.PrincipalID, message);
                }
                response = "User has been kicked.";
                return(null);
            }
            if (requestParameters.ContainsKey("Submit") &&
                requestParameters["Submit"].ToString() == "SubmitMessageUser")
            {
                string message = requestParameters["Message"].ToString();
                IGridWideMessageModule messageModule = webInterface.Registry.RequestModuleInterface <IGridWideMessageModule>();
                if (messageModule != null)
                {
                    messageModule.MessageUser(account.PrincipalID, message);
                }
                response = "User has been sent the message.";
                return(null);
            }
            string bannedUntil    = "";
            bool   userBanned     = agent == null ? false : ((agent.Flags & IAgentFlags.PermBan) == IAgentFlags.PermBan || (agent.Flags & IAgentFlags.TempBan) == IAgentFlags.TempBan);
            bool   TempUserBanned = false;

            if (userBanned)
            {
                if ((agent.Flags & IAgentFlags.TempBan) == IAgentFlags.TempBan && agent.OtherAgentInformation["TemperaryBanInfo"].AsDate() < DateTime.Now)
                {
                    userBanned   = false;
                    agent.Flags &= ~IAgentFlags.TempBan;
                    agent.Flags &= ~IAgentFlags.PermBan;
                    agent.OtherAgentInformation.Remove("TemperaryBanInfo");
                    agentService.UpdateAgent(agent);
                }
                else
                {
                    DateTime bannedTime = agent.OtherAgentInformation["TemperaryBanInfo"].AsDate();
                    TempUserBanned = bannedTime != Util.UnixEpoch;
                    bannedUntil    = string.Format("{0} {1}", bannedTime.ToShortDateString(), bannedTime.ToLongTimeString());
                }
            }
            bool         userOnline  = false;
            ICapsService capsService = webInterface.Registry.RequestModuleInterface <ICapsService>();

            if (capsService != null)
            {
                userOnline = capsService.GetClientCapsService(account.PrincipalID) != null;
            }
            vars.Add("UserOnline", userOnline);
            vars.Add("NotUserBanned", !userBanned);
            vars.Add("UserBanned", userBanned);
            vars.Add("TempUserBanned", TempUserBanned);
            vars.Add("BannedUntil", bannedUntil);
            vars.Add("EmailValue", account.Email);
            vars.Add("UserID", account.PrincipalID);
            vars.Add("UserName", account.Name);
            vars.Add("ErrorMessage", error);
            vars.Add("ChangeUserInformationText", translator.GetTranslatedString("ChangeUserInformationText"));
            vars.Add("ChangePasswordText", translator.GetTranslatedString("ChangePasswordText"));
            vars.Add("NewPasswordText", translator.GetTranslatedString("NewPasswordText"));
            vars.Add("NewPasswordConfirmationText", translator.GetTranslatedString("NewPasswordConfirmationText"));
            vars.Add("ChangeEmailText", translator.GetTranslatedString("ChangeEmailText"));
            vars.Add("NewEmailText", translator.GetTranslatedString("NewEmailText"));
            vars.Add("UserNameText", translator.GetTranslatedString("UserNameText"));
            vars.Add("PasswordText", translator.GetTranslatedString("PasswordText"));
            vars.Add("DeleteUserText", translator.GetTranslatedString("DeleteUserText"));
            vars.Add("DeleteText", translator.GetTranslatedString("DeleteText"));
            vars.Add("DeleteUserInfoText", translator.GetTranslatedString("DeleteUserInfoText"));
            vars.Add("Submit", translator.GetTranslatedString("Submit"));
            vars.Add("Login", translator.GetTranslatedString("Login"));
            vars.Add("TypeUserNameToConfirm", translator.GetTranslatedString("TypeUserNameToConfirm"));

            vars.Add("AdminLoginInAsUserText", translator.GetTranslatedString("AdminLoginInAsUserText"));
            vars.Add("AdminLoginInAsUserInfoText", translator.GetTranslatedString("AdminLoginInAsUserInfoText"));
            vars.Add("AdminDeleteUserText", translator.GetTranslatedString("AdminDeleteUserText"));
            vars.Add("AdminDeleteUserInfoText", translator.GetTranslatedString("AdminDeleteUserInfoText"));
            vars.Add("AdminUnbanUserText", translator.GetTranslatedString("AdminUnbanUserText"));
            vars.Add("AdminTempBanUserText", translator.GetTranslatedString("AdminTempBanUserText"));
            vars.Add("AdminTempBanUserInfoText", translator.GetTranslatedString("AdminTempBanUserInfoText"));
            vars.Add("AdminBanUserText", translator.GetTranslatedString("AdminBanUserText"));
            vars.Add("AdminBanUserInfoText", translator.GetTranslatedString("AdminBanUserInfoText"));
            vars.Add("BanText", translator.GetTranslatedString("BanText"));
            vars.Add("UnbanText", translator.GetTranslatedString("UnbanText"));
            vars.Add("TimeUntilUnbannedText", translator.GetTranslatedString("TimeUntilUnbannedText"));
            vars.Add("EdittingText", translator.GetTranslatedString("EdittingText"));
            vars.Add("BannedUntilText", translator.GetTranslatedString("BannedUntilText"));

            vars.Add("KickAUserInfoText", translator.GetTranslatedString("KickAUserInfoText"));
            vars.Add("KickAUserText", translator.GetTranslatedString("KickAUserText"));
            vars.Add("KickMessageText", translator.GetTranslatedString("KickMessageText"));
            vars.Add("KickUserText", translator.GetTranslatedString("KickUserText"));

            vars.Add("MessageAUserText", translator.GetTranslatedString("MessageAUserText"));
            vars.Add("MessageAUserInfoText", translator.GetTranslatedString("MessageAUserInfoText"));
            vars.Add("MessageUserText", translator.GetTranslatedString("MessageUserText"));

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

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

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

            for (int i = 0; i <= 23; i++)
            {
                hoursArgs.Add(new Dictionary <string, object> {
                    { "Value", i }
                });
            }

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

            for (int i = 0; i <= 59; i++)
            {
                minutesArgs.Add(new Dictionary <string, object> {
                    { "Value", i }
                });
            }

            vars.Add("Days", daysArgs);
            vars.Add("Hours", hoursArgs);
            vars.Add("Minutes", minutesArgs);
            vars.Add("DaysText", translator.GetTranslatedString("DaysText"));
            vars.Add("HoursText", translator.GetTranslatedString("HoursText"));
            vars.Add("MinutesText", translator.GetTranslatedString("MinutesText"));

            return(vars);
        }
Example #29
0
        public Dictionary <string, object> Fill(WebInterface webInterface, string filename, OSHttpRequest httpRequest,
                                                OSHttpResponse httpResponse, Dictionary <string, object> requestParameters, ITranslator translator, out string response)
        {
            response = null;
            var vars = new Dictionary <string, object>();

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            return(vars);
        }
        protected OSDMap OnMessageReceived(OSDMap message)
        {
            //We need to check and see if this is an GroupSessionAgentUpdate
            if (message.ContainsKey("Method") && message["Method"] == "GroupSessionAgentUpdate")
            {
                //COMES IN ON AURORA.SERVER SIDE
                //Send it on to whomever it concerns
                OSDMap innerMessage = (OSDMap)message["Message"];
                if (innerMessage["message"] == "ChatterBoxSessionAgentListUpdates")
                //ONLY forward on this type of message
                {
                    UUID agentID            = message["AgentID"];
                    IEventQueueService eqs  = m_registry.RequestModuleInterface <IEventQueueService>();
                    ICapsService       caps = m_registry.RequestModuleInterface <ICapsService>();
                    if (caps != null)
                    {
                        IClientCapsService clientCaps = caps.GetClientCapsService(agentID);
                        if (clientCaps != null && clientCaps.GetRootCapsService() != null)
                        {
                            eqs.Enqueue(innerMessage, agentID, clientCaps.GetRootCapsService().RegionHandle);
                        }
                    }
                }
            }
            else if (message.ContainsKey("Method") && message["Method"] == "FixGroupRoleTitles")
            {
                //COMES IN ON AURORA.SERVER SIDE FROM REGION
                UUID groupID = message["GroupID"].AsUUID();
                UUID agentID = message["AgentID"].AsUUID();
                UUID roleID  = message["RoleID"].AsUUID();
                byte type    = (byte)message["Type"].AsInteger();
                IGroupsServiceConnector     con     = DataManager.RequestPlugin <IGroupsServiceConnector>();
                List <GroupRoleMembersData> members = con.GetGroupRoleMembers(agentID, groupID);
                List <GroupRolesData>       roles   = con.GetGroupRoles(agentID, groupID);
                GroupRolesData everyone             = null;
#if (!ISWIN)
                foreach (GroupRolesData role in roles)
                {
                    if (role.Name == "Everyone")
                    {
                        everyone = role;
                    }
                }
#else
                foreach (GroupRolesData role in roles.Where(role => role.Name == "Everyone"))
                {
                    everyone = role;
                }
#endif

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

                        case GroupRoleUpdate.UpdatePowers:     //Possible we don't need to send this?
                        case GroupRoleUpdate.UpdateAll:
                        case GroupRoleUpdate.UpdateData:
                        case GroupRoleUpdate.Delete:
                            if (type == (byte)GroupRoleUpdate.Delete)
                            {
                                //Set them to the most limited role since their role is gone
                                con.SetAgentGroupSelectedRole(data.MemberID, groupID, everyone.RoleID);
                            }
                            //Need to update their title inworld
                            ICapsService caps = m_registry.RequestModuleInterface <ICapsService>();
                            if (caps != null)
                            {
                                IClientCapsService clientCaps = caps.GetClientCapsService(agentID);
                                if (clientCaps != null && clientCaps.GetRootCapsService() != null)
                                {
                                    regionsToBeUpdated.Add(clientCaps.GetRootCapsService().RegionHandle);
                                }
                            }
                            break;
                        }
                    }
                }
                if (regionsToBeUpdated.Count != 0)
                {
                    IAsyncMessagePostService messagePost = m_registry.RequestModuleInterface <IAsyncMessagePostService>();
                    if (messagePost != null)
                    {
                        foreach (ulong regionhandle in regionsToBeUpdated)
                        {
                            OSDMap outgoingMessage = new OSDMap();
                            outgoingMessage["Method"]   = "ForceUpdateGroupTitles";
                            outgoingMessage["GroupID"]  = groupID;
                            outgoingMessage["RoleID"]   = roleID;
                            outgoingMessage["RegionID"] = regionhandle;
                            messagePost.Post(regionhandle, outgoingMessage);
                        }
                    }
                }
            }
            else if (message.ContainsKey("Method") && message["Method"] == "ForceUpdateGroupTitles")
            {
                //COMES IN ON REGION SIDE FROM AURORA.SERVER
                UUID          groupID  = message["GroupID"].AsUUID();
                UUID          roleID   = message["RoleID"].AsUUID();
                ulong         regionID = message["RegionID"].AsULong();
                IGroupsModule gm       = m_registry.RequestModuleInterface <IGroupsModule>();
                if (gm != null)
                {
                    gm.UpdateUsersForExternalRoleUpdate(groupID, roleID, regionID);
                }
            }
            else if (message.ContainsKey("Method") && message["Method"] == "SendGroupNoticeToUsers")
            {
                //COMES IN ON REGION SIDE FROM AURORA.SERVER
                GroupNoticeInfo notice = new GroupNoticeInfo();
                notice.FromOSD((OSDMap)message["Notice"]);
                IGroupsModule gm = m_registry.RequestModuleInterface <IGroupsModule>();
                if (gm != null)
                {
                    gm.SendGroupNoticeToUsers(null, notice, true);
                }
            }
            return(null);
        }