Exemple #1
0
        private void client_OnGroupAccountSummaryRequest(IClientAPI client, UUID agentID, UUID groupID, UUID requestID,
                                                         int currentInterval, int intervalDays)
        {
            IGroupsModule groupsModule = client.Scene.RequestModuleInterface <IGroupsModule>();

            if (groupsModule != null && groupsModule.GroupPermissionCheck(agentID, groupID, GroupPowers.Accountable))
            {
                IMoneyModule moneyModule = client.Scene.RequestModuleInterface <IMoneyModule>();
                if (moneyModule != null)
                {
                    int          amt     = moneyModule.Balance(groupID);
                    GroupBalance balance = moneyModule.GetGroupBalance(groupID);
                    client.SendGroupAccountingSummary(client, groupID, requestID, amt, balance.TotalTierDebit,
                                                      balance.TotalTierCredits,
                                                      Util.BuildYMDDateString(
                                                          balance.StartingDate.AddDays(-currentInterval * intervalDays)),
                                                      currentInterval, intervalDays,
                                                      Util.BuildYMDDateString(balance.StartingDate.AddDays(intervalDays)),
                                                      Util.BuildYMDDateString(
                                                          balance.StartingDate.AddDays(-(currentInterval + 1) *
                                                                                       intervalDays)),
                                                      balance.ParcelDirectoryFee, balance.LandFee, balance.GroupFee,
                                                      balance.ObjectFee);
                }
                else
                {
                    client.SendGroupAccountingSummary(client, groupID, requestID, 0, 0, 0, "Never",
                                                      currentInterval, intervalDays, "Never",
                                                      "Never", 0, 0, 0, 0);
                }
            }
        }
Exemple #2
0
        /// <summary>
        ///     Sends the details about what
        /// </summary>
        /// <param name="client"></param>
        /// <param name="agentID"></param>
        /// <param name="groupID"></param>
        /// <param name="transactionID"></param>
        /// <param name="sessionID"></param>
        /// <param name="currentInterval"></param>
        /// <param name="intervalDays"></param>
        private void client_OnGroupAccountDetailsRequest(IClientAPI client, UUID agentID, UUID groupID,
                                                         UUID transactionID, UUID sessionID, int currentInterval,
                                                         int intervalDays)
        {
            IGroupsModule groupsModule = client.Scene.RequestModuleInterface <IGroupsModule>();

            if (groupsModule != null && groupsModule.GroupPermissionCheck(agentID, groupID, GroupPowers.Accountable))
            {
                IMoneyModule moneyModule = client.Scene.RequestModuleInterface <IMoneyModule>();
                if (moneyModule != null)
                {
                    int amt = moneyModule.Balance(groupID);
                    List <GroupAccountHistory> history = moneyModule.GetTransactions(groupID, agentID, currentInterval,
                                                                                     intervalDays);
                    history = (from h in history where h.Stipend select h).ToList();
                    //We don't want payments, we only want stipends which we sent to users
                    GroupBalance balance = moneyModule.GetGroupBalance(groupID);
                    client.SendGroupAccountingDetails(client, groupID, transactionID, sessionID, amt, currentInterval,
                                                      intervalDays,
                                                      Util.BuildYMDDateString(
                                                          balance.StartingDate.AddDays(-currentInterval * intervalDays)),
                                                      history.ToArray());
                }
                else
                {
                    client.SendGroupAccountingDetails(client, groupID, transactionID, sessionID, 0, currentInterval,
                                                      intervalDays,
                                                      "Never", new GroupAccountHistory[0]);
                }
            }
        }
Exemple #3
0
            public void CheckThreatLevel(string function, ISceneChildEntity m_host, string API)
            {
                if (CheckUser(m_host))
                {
                    return;
                }
                List <UUID> FunctionPerms = new List <UUID>();

                if (!m_FunctionPerms.TryGetValue(function, out FunctionPerms))
                {
                    string perm = m_scriptProtectionModule.m_config.GetString("Allow_" + function, "");
                    if (perm == "")
                    {
                        FunctionPerms = null; // a null value is default, which means check against the max threat level
                    }
                    else
                    {
                        bool allowed;

                        if (bool.TryParse(perm, out allowed))
                        {
                            // Boolean given
                            FunctionPerms = allowed ? new List <UUID> {
                                UUID.Zero
                            } : new List <UUID>();
                        }
                        else
                        {
                            FunctionPerms = new List <UUID>();

                            string[] ids = perm.Split(new[] { ',' });

                            foreach (string current in ids.Select(id => id.Trim()))
                            {
                                UUID uuid;

                                if (UUID.TryParse(current, out uuid))
                                {
                                    if (uuid != UUID.Zero)
                                    {
                                        FunctionPerms.Add(uuid);
                                    }
                                }
                            }
                        }
                        m_FunctionPerms[function] = FunctionPerms;
                    }
                }

                // If the list is null, then the value was true / undefined
                // Threat level governs permissions in this case
                //
                // If the list is non-null, then it is a list of UUIDs allowed
                // to use that particular function. False causes an empty
                // list and therefore means "no one"
                //
                // To allow use by anyone, the list contains UUID.Zero
                //
                if (FunctionPerms == null) // No list = true
                {
                    if (m_threatLevel > m_scriptProtectionModule.GetThreatLevel().m_threatLevel)
                    {
                        m_scriptProtectionModule.Error("Runtime Error: ",
                                                       string.Format(
                                                           "{0} permission denied.  Allowed threat level is {1} but function threat level is {2}.",
                                                           function,
                                                           m_scriptProtectionModule.GetThreatLevel().m_threatLevel,
                                                           m_threatLevel));
                    }
                }
                else
                {
                    if (!FunctionPerms.Contains(UUID.Zero))
                    {
                        if (!FunctionPerms.Contains(m_host.OwnerID))
                        {
                            if (m_allowGroupPermissions)
                            {
                                Dictionary <string, bool> cachedFunctions;
                                //Check to see whether we have already evaluated this function for this user
                                if (m_knownAllowedGroupFunctionsForAvatars.TryGetValue(m_host.OwnerID,
                                                                                       out cachedFunctions))
                                {
                                    if (cachedFunctions.ContainsKey(function))
                                    {
                                        if (cachedFunctions[function])
                                        {
                                            return;
                                        }
                                        else
                                        {
                                            m_scriptProtectionModule.Error("Runtime Error: ",
                                                                           string.Format(
                                                                               "{0} permission denied.  Prim owner is not in the list of users allowed to execute this function.",
                                                                               function));
                                        }
                                    }
                                }
                                else
                                {
                                    cachedFunctions = new Dictionary <string, bool>();
                                }
                                IGroupsModule groupsModule =
                                    m_host.ParentEntity.Scene.RequestModuleInterface <IGroupsModule>();
                                if (groupsModule != null)
                                {
                                    bool success = false;
                                    foreach (UUID id in FunctionPerms)
                                    {
                                        if (groupsModule.GroupPermissionCheck(m_host.OwnerID, id, GroupPowers.None))
                                        {
                                            success = true;
                                            break;
                                        }
                                    }
                                    //Cache the success
                                    cachedFunctions[function] = success;
                                    if (!m_knownAllowedGroupFunctionsForAvatars.ContainsKey(m_host.OwnerID))
                                    {
                                        m_knownAllowedGroupFunctionsForAvatars.Add(m_host.OwnerID,
                                                                                   new Dictionary <string, bool>());
                                    }
                                    m_knownAllowedGroupFunctionsForAvatars[m_host.OwnerID] = cachedFunctions;

                                    if (success)
                                    {
                                        return; //All is good
                                    }
                                }
                            }
                            m_scriptProtectionModule.Error("Runtime Error: ",
                                                           string.Format(
                                                               "{0} permission denied.  Prim owner is not in the list of users allowed to execute this function.",
                                                               function));
                        }
                    }
                }
            }
Exemple #4
0
        private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im)
        {
            IScenePresence presence;

            if ((presence = remoteClient.Scene.GetScenePresence(remoteClient.AgentId)) == null || presence.IsChildAgent)
            {
                return; //Must exist and not be a child
            }
            if (m_debugEnabled)
            {
                MainConsole.Instance.DebugFormat("[GROUPS-MESSAGING]: {0} called", MethodBase.GetCurrentMethod().Name);

                DebugGridInstantMessage(im);
            }

            // Start group IM session
            if ((im.dialog == (byte)InstantMessageDialog.SessionGroupStart))
            {
                if (m_debugEnabled)
                {
                    MainConsole.Instance.InfoFormat("[GROUPS-MESSAGING]: imSessionID({0}) toAgentID({1})", im.imSessionID, im.toAgentID);
                }

                UUID GroupID = im.imSessionID;
                UUID AgentID = im.fromAgentID;

                GroupRecord groupInfo = m_groupData.GetGroupRecord(AgentID, GroupID, null);

                if (groupInfo != null)
                {
                    if (!m_groupsModule.GroupPermissionCheck(AgentID, GroupID, GroupPowers.JoinChat))
                    {
                        return; //They have to be able to join to create a group chat
                    }
                    //Create the session.
                    IEventQueueService queue = remoteClient.Scene.RequestModuleInterface <IEventQueueService>();
                    if (m_groupData.CreateSession(new ChatSession
                    {
                        Members = new List <ChatSessionMember>(),
                        SessionID = GroupID,
                        Name = groupInfo.GroupName
                    }))
                    {
                        m_groupData.AddMemberToGroup(new ChatSessionMember
                        {
                            AvatarKey    = AgentID,
                            CanVoiceChat = false,
                            IsModerator  = GetIsModerator(AgentID, GroupID),
                            MuteText     = false,
                            MuteVoice    = false,
                            HasBeenAdded = true
                        }, GroupID);

#if (!ISWIN)
                        foreach (GroupMembersData gmd in m_groupData.GetGroupMembers(AgentID, GroupID))
                        {
                            if (gmd.AgentID != AgentID)
                            {
                                if ((gmd.AgentPowers & (ulong)GroupPowers.JoinChat) == (ulong)GroupPowers.JoinChat)
                                {
                                    m_groupData.AddMemberToGroup(new ChatSessionMember
                                    {
                                        AvatarKey    = gmd.AgentID,
                                        CanVoiceChat = false,
                                        IsModerator  =
                                            GetIsModerator(gmd.AgentID, GroupID),
                                        MuteText     = false,
                                        MuteVoice    = false,
                                        HasBeenAdded = false
                                    }, GroupID);
                                }
                            }
                        }
#else
                        foreach (GroupMembersData gmd in m_groupData.GetGroupMembers(AgentID, GroupID).Where(gmd => gmd.AgentID != AgentID).Where(gmd => (gmd.AgentPowers & (ulong)GroupPowers.JoinChat) == (ulong)GroupPowers.JoinChat))
                        {
                            m_groupData.AddMemberToGroup(new ChatSessionMember
                            {
                                AvatarKey    = gmd.AgentID,
                                CanVoiceChat = false,
                                IsModerator  =
                                    GetIsModerator(gmd.AgentID, GroupID),
                                MuteText     = false,
                                MuteVoice    = false,
                                HasBeenAdded = false
                            }, GroupID);
                        }
#endif
                        //Tell us that it was made successfully
                        ChatterBoxSessionStartReplyViaCaps(remoteClient, groupInfo.GroupName, GroupID);
                    }
                    else
                    {
                        ChatSession thisSession = m_groupData.GetSession(GroupID);
                        //A session already exists
                        //Add us
                        m_groupData.AddMemberToGroup(new ChatSessionMember
                        {
                            AvatarKey    = AgentID,
                            CanVoiceChat = false,
                            IsModerator  = GetIsModerator(AgentID, GroupID),
                            MuteText     = false,
                            MuteVoice    = false,
                            HasBeenAdded = true
                        }, GroupID);

                        //Tell us that we entered successfully
                        ChatterBoxSessionStartReplyViaCaps(remoteClient, groupInfo.GroupName, GroupID);
                        List <ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock> Us =
                            new List <ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock>();
                        List <ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock> NotUsAgents =
                            new List <ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock>();

                        foreach (ChatSessionMember sessionMember in thisSession.Members)
                        {
                            ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock block =
                                new ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock
                            {
                                AgentID      = sessionMember.AvatarKey,
                                CanVoiceChat = sessionMember.CanVoiceChat,
                                IsModerator  = sessionMember.IsModerator,
                                MuteText     = sessionMember.MuteText,
                                MuteVoice    = sessionMember.MuteVoice,
                                Transition   = "ENTER"
                            };
                            if (AgentID == sessionMember.AvatarKey)
                            {
                                Us.Add(block);
                            }
                            if (sessionMember.HasBeenAdded)
                            {
                                // Don't add not joined yet agents. They don't want to be here.
                                NotUsAgents.Add(block);
                            }
                        }
                        foreach (ChatSessionMember member in thisSession.Members)
                        {
                            if (member.AvatarKey == AgentID)
                            {
                                //Tell 'us' about all the other agents in the group
                                queue.ChatterBoxSessionAgentListUpdates(GroupID, NotUsAgents.ToArray(), member.AvatarKey,
                                                                        "ENTER",
                                                                        remoteClient.Scene.RegionInfo.RegionHandle);
                            }
                            else
                            {
                                //Tell 'other' agents about the new agent ('us')
                                IClientAPI otherAgent = GetActiveClient(member.AvatarKey);
                                if (otherAgent != null) //Local, so we can send it directly
                                {
                                    queue.ChatterBoxSessionAgentListUpdates(GroupID, Us.ToArray(), member.AvatarKey,
                                                                            "ENTER",
                                                                            otherAgent.Scene.RegionInfo.RegionHandle);
                                }
                                else
                                {
                                    ISyncMessagePosterService amps =
                                        m_sceneList[0].RequestModuleInterface <ISyncMessagePosterService>();
                                    if (amps != null)
                                    {
                                        OSDMap message = new OSDMap();
                                        message["Method"]  = "GroupSessionAgentUpdate";
                                        message["AgentID"] = AgentID;
                                        message["Message"] = ChatterBoxSessionAgentListUpdates(GroupID, Us.ToArray(),
                                                                                               "ENTER");
                                        amps.Post(message, remoteClient.Scene.RegionInfo.RegionHandle);
                                    }
                                }
                            }
                        }
                    }

                    //Tell us that we entered
                    ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock ourblock =
                        new ChatterBoxSessionAgentListUpdatesMessage.AgentUpdatesBlock
                    {
                        AgentID      = AgentID,
                        CanVoiceChat = true,
                        IsModerator  = true,
                        MuteText     = false,
                        MuteVoice    = false,
                        Transition   = "ENTER"
                    };
                    queue.ChatterBoxSessionAgentListUpdates(GroupID, new[] { ourblock }, AgentID, "ENTER",
                                                            remoteClient.Scene.RegionInfo.RegionHandle);
                }
            }
            // Send a message from locally connected client to a group
            else if ((im.dialog == (byte)InstantMessageDialog.SessionSend) && im.message != "")
            {
                UUID GroupID = im.imSessionID;
                UUID AgentID = im.fromAgentID;

                if (m_debugEnabled)
                {
                    MainConsole.Instance.DebugFormat("[GROUPS-MESSAGING]: Send message to session for group {0} with session ID {1}",
                                                     GroupID, im.imSessionID.ToString());
                }

                ChatSessionMember memeber = m_groupData.FindMember(im.imSessionID, AgentID);
                if (memeber == null || memeber.MuteText)
                {
                    return; //Not in the chat or muted
                }
                SendMessageToGroup(im, GroupID);
            }
            else if (im.dialog == (byte)InstantMessageDialog.SessionDrop)
            {
                DropMemberFromSession(remoteClient, im, true);
            }
            else if (im.dialog == 212) //Forwarded sessionDrop
            {
                DropMemberFromSession(remoteClient, im, false);
            }
        }