Esempio n. 1
0
 public MuteListEntry(MuteListEntry src)
 {
     MuteName = src.MuteName;
     MuteID   = src.MuteID;
     Type     = src.Type;
     Flags    = src.Flags;
 }
Esempio n. 2
0
        private void DBStoreMuteListEntry(UUID AgentID, UUID MuteID, MuteListEntry entry, bool isUpdate)
        {
            using (ISimpleDB db = _connectionFactory.GetConnection())
            {
                string query;
                if (isUpdate)
                {
                    query = "UPDATE mutelist " +
                            "SET " +
                            "    MuteType = ?muteType" +
                            "    , MuteName = ?muteName" +
                            "    , MuteFlags= ?muteFlags" +
                            " WHERE " +
                            "    AgentID = ?agentID AND MuteID = ?muteID";
                }
                else
                {
                    query = "INSERT INTO mutelist " +
                            "(AgentID, MuteType, MuteID, MuteName, MuteFlags) " +
                            "VALUES(?AgentID, ?MuteType, ?MuteID, ?MuteName, ?MuteFlags)";
                }

                Dictionary <string, object> parms = new Dictionary <string, object>();
                parms.Add("?agentID", AgentID);
                parms.Add("?muteID", MuteID);
                parms.Add("?muteType", entry.m_Type);
                parms.Add("?muteName", entry.m_Name);
                parms.Add("?muteFlags", entry.m_Flags);

                db.QueryNoResults(query, parms);
            }
        }
        private bool CheckEqual(MuteListEntry e1, MuteListEntry e2, bool bequiet = false)
        {
            var mismatch = new List <string>();

            if (e1.MuteName != e2.MuteName)
            {
                mismatch.Add("MuteName");
            }

            if (e1.MuteID != e2.MuteID)
            {
                mismatch.Add("MuteID");
            }

            if (e1.Type != e2.Type)
            {
                mismatch.Add("Type");
            }

            if (e1.Flags != e2.Flags)
            {
                mismatch.Add("Flags");
            }

            if (mismatch.Count > 0 && !bequiet)
            {
                m_Log.InfoFormat("Mismatches: {0}", string.Join(" ", mismatch));
            }

            return(mismatch.Count == 0);
        }
Esempio n. 4
0
        private Dictionary <UUID, MuteListEntry> MapMuteListFromDBResults(List <Dictionary <string, string> > results)
        {
            Dictionary <UUID, MuteListEntry> MuteList = new Dictionary <UUID, MuteListEntry>();

            foreach (Dictionary <string, string> result in results)
            {
                MuteListEntry entry  = new MuteListEntry();
                UUID          MuteID = new UUID(result["MuteID"]);
                entry.m_Type  = Convert.ToInt32(result["MuteType"]);
                entry.m_Name  = result["MuteName"];
                entry.m_Flags = Convert.ToUInt32(result["MuteFlags"]);
                MuteList.Add(MuteID, entry);
            }

            return(MuteList);
        }
 public override void Store(UUID muteListOwnerID, MuteListEntry mute)
 {
     using (var conn = new MySqlConnection(m_ConnectionString))
     {
         conn.Open();
         var vals = new Dictionary <string, object>
         {
             ["agentID"]  = muteListOwnerID,
             ["muteID"]   = mute.MuteID,
             ["muteName"] = mute.MuteName,
             ["flags"]    = mute.Flags,
             ["type"]     = mute.Type
         };
         conn.ReplaceInto("mutelists", vals);
     }
 }
Esempio n. 6
0
        private void OnUpdateMuteListEntry(IClientAPI client, UUID AgentID, int muteType, UUID muteID, string Name, uint muteFlags)
        {
            Dictionary <UUID, MuteListEntry> MuteList;
            bool isUpdate = false;

            MuteList = GetMuteList(AgentID);
            isUpdate = MuteList.ContainsKey(muteID);
            if (isUpdate)
            {
                MuteList.Remove(muteID);
            }

            switch ((MuteType)muteType)
            {
            case MuteType.BY_NAME:
                m_log.DebugFormat("[MUTE LIST] Update from {0} for name: {1} (ID {2}) flags={3}", AgentID, Name, muteID, muteFlags);
                break;

            case MuteType.AGENT:
                m_log.DebugFormat("[MUTE LIST] Update from {0} for agent: {1} ({2}) flags={3}", AgentID, muteID, Name, muteFlags);
                break;

            case MuteType.OBJECT:
                m_log.DebugFormat("[MUTE LIST] Update from {0} for object: {1} ({2}) flags={3}", AgentID, muteID, Name, muteFlags);
                break;

            case MuteType.GROUP:
                m_log.DebugFormat("[MUTE LIST] Update from {0} for group: {1} ({2}) flags={3}", AgentID, muteID, Name, muteFlags);
                break;

            case MuteType.COUNT:
                m_log.DebugFormat("[MUTE LIST] Update from {0} for count: {1} ({2}) flags={3}", AgentID, muteID, Name, muteFlags);
                break;

            default:
                m_log.ErrorFormat("[MUTE LIST] Update from {0} unknown type {1} with ID {2} Name {3} flags={4}", AgentID, muteType, muteID, Name, muteFlags);
                break;
            }
            MuteListEntry entry = new MuteListEntry(muteType, Name, muteFlags);

            MuteList.Add(muteID, entry);
            DBStoreMuteListEntry(AgentID, muteID, entry, isUpdate);
        }
Esempio n. 7
0
        private byte[] GetMuteListFileData(UUID AgentID)
        {
            Dictionary <UUID, MuteListEntry> MuteList;
            string data  = String.Empty;
            int    lines = 0;

            MuteList = GetMuteList(AgentID);
            foreach (KeyValuePair <UUID, MuteListEntry> pair in MuteList)
            {
                UUID          MuteID = new UUID(pair.Key);
                MuteListEntry entry  = pair.Value;

                if (lines++ != 0)
                {
                    data += "\n";
                }
                data += " " + entry.m_Type.ToString() +
                        " " + MuteID.ToString() +
                        " " + entry.m_Name.ToString() +
                        "|" + entry.m_Flags.ToString();
            }
            return(Utils.StringToBytes(data));
        }
Esempio n. 8
0
        private void OnUpdateMuteListEntry(IClientAPI client, UUID AgentID, int muteType, UUID muteID, string Name, uint muteFlags)
        {
            Dictionary<UUID, MuteListEntry> MuteList;
            bool isUpdate = false;

            MuteList = GetMuteList(AgentID);
            isUpdate = MuteList.ContainsKey(muteID);
            if (isUpdate)
                MuteList.Remove(muteID);

            switch ((MuteType)muteType)
            {
                case MuteType.BY_NAME:
                    m_log.DebugFormat("[MUTE LIST] Update from {0} for name: {1} (ID {2}) flags={3}", AgentID, Name, muteID, muteFlags);
                    break;
                case MuteType.AGENT:
                    m_log.DebugFormat("[MUTE LIST] Update from {0} for agent: {1} ({2}) flags={3}", AgentID, muteID, Name, muteFlags);
                    break;
                case MuteType.OBJECT:
                    m_log.DebugFormat("[MUTE LIST] Update from {0} for object: {1} ({2}) flags={3}", AgentID, muteID, Name, muteFlags);
                    break;
                case MuteType.GROUP:
                    m_log.DebugFormat("[MUTE LIST] Update from {0} for group: {1} ({2}) flags={3}", AgentID, muteID, Name, muteFlags);
                    break;
                case MuteType.COUNT:
                    m_log.DebugFormat("[MUTE LIST] Update from {0} for count: {1} ({2}) flags={3}", AgentID, muteID, Name, muteFlags);
                    break;
                default:
                    m_log.ErrorFormat("[MUTE LIST] Update from {0} unknown type {1} with ID {2} Name {3} flags={4}", AgentID, muteType, muteID, Name, muteFlags);
                    break;
            }
            MuteListEntry entry = new MuteListEntry(muteType, Name, muteFlags);
            MuteList.Add(muteID, entry);
            DBStoreMuteListEntry(AgentID, muteID, entry, isUpdate);
        }
Esempio n. 9
0
        private void DBStoreMuteListEntry(UUID AgentID, UUID MuteID, MuteListEntry entry, bool isUpdate)
        {
            using (ISimpleDB db = _connectionFactory.GetConnection())
            {
                string query;
                if (isUpdate)
                    query = "UPDATE mutelist " +
                        "SET " +
                        "    MuteType = ?muteType" +
                        "    , MuteName = ?muteName" +
                        "    , MuteFlags= ?muteFlags" +
                        " WHERE " +
                        "    AgentID = ?agentID AND MuteID = ?muteID";
                else
                    query = "INSERT INTO mutelist " +
                            "(AgentID, MuteType, MuteID, MuteName, MuteFlags) " +
                            "VALUES(?AgentID, ?MuteType, ?MuteID, ?MuteName, ?MuteFlags)";
                
                Dictionary<string, object> parms = new Dictionary<string,object>();
                parms.Add("?agentID", AgentID);
                parms.Add("?muteID", MuteID);
                parms.Add("?muteType", entry.m_Type);
                parms.Add("?muteName", entry.m_Name);
                parms.Add("?muteFlags", entry.m_Flags);

                db.QueryNoResults(query, parms);
            }
        }
Esempio n. 10
0
        private Dictionary<UUID, MuteListEntry> MapMuteListFromDBResults(List<Dictionary<string, string>> results)
        {
            Dictionary<UUID, MuteListEntry> MuteList = new Dictionary<UUID, MuteListEntry>();

            foreach (Dictionary<string, string> result in results) {
                MuteListEntry entry = new MuteListEntry();
                UUID MuteID = new UUID(result["MuteID"]);
                entry.m_Type = Convert.ToInt32(result["MuteType"]);
                entry.m_Name = result["MuteName"];
                entry.m_Flags = Convert.ToUInt32(result["MuteFlags"]);
                MuteList.Add(MuteID, entry);
            }

            return MuteList;
        }
Esempio n. 11
0
 public abstract void Store(UUID muteListOwnerID, MuteListEntry mute);
Esempio n. 12
0
        public override void Store(UUID muteListOwnerID, MuteListEntry mute)
        {
            RwLockedDictionary <string, MuteListEntry> list = m_MuteLists[muteListOwnerID];

            list[GetKey(mute.MuteID, mute.MuteName)] = new MuteListEntry(mute);
        }
Esempio n. 13
0
        public bool Run()
        {
            var muteowner  = new UUID("11111111-2222-3333-4444-112233445566");
            var mute1id    = new UUID("11223344-1122-1122-1122-112233445566");
            var mute2id    = new UUID("11223344-1122-1122-1122-112233445577");
            var mute1entry = new MuteListEntry
            {
                MuteName = "Mute1 name",
                MuteID   = mute1id,
                Type     = MuteType.ByName,
                Flags    = MuteFlags.ObjectSoundsMuted
            };
            var mute2entry = new MuteListEntry
            {
                MuteName = "Mute2 name",
                MuteID   = mute2id,
                Type     = MuteType.ByName,
                Flags    = MuteFlags.ObjectSoundsMuted
            };

            m_Log.InfoFormat("Check that mute list is empty");
            List <MuteListEntry> list = m_MuteListService.GetList(muteowner, 0);

            if (list.Count != 0)
            {
                m_Log.Error("Mute list is not empty");
                return(false);
            }

            m_MuteListService.Store(muteowner, mute1entry);

            m_Log.InfoFormat("Check that mute list has 1 entry");
            list = m_MuteListService.GetList(muteowner, 0);
            if (list.Count != 1)
            {
                m_Log.Error("Mute list does not match");
                return(false);
            }

            if (!CheckEqual(list[0], mute1entry))
            {
                m_Log.Error("Mute entry content does not match");
                return(false);
            }


            m_MuteListService.Store(muteowner, mute2entry);

            m_Log.InfoFormat("Check that mute list has 2 entries");
            list = m_MuteListService.GetList(muteowner, 0);
            if (list.Count != 2)
            {
                m_Log.Error("Mute list does not match");
                return(false);
            }

            bool found1 = false;
            bool found2 = false;

            foreach (MuteListEntry e in list)
            {
                if (CheckEqual(e, mute1entry, true))
                {
                    found1 = true;
                }
                if (CheckEqual(e, mute2entry, true))
                {
                    found2 = true;
                }
            }
            if (!found1 || !found2)
            {
                m_Log.Error("Mute entries content does not match");
                return(false);
            }

            m_Log.Info("Removing second entry");
            if (!m_MuteListService.Remove(muteowner, mute2entry.MuteID, mute2entry.MuteName))
            {
                m_Log.Error("Failed to remove it");
                return(false);
            }

            m_Log.InfoFormat("Check that mute list has 1 entry");
            list = m_MuteListService.GetList(muteowner, 0);
            if (list.Count != 1)
            {
                m_Log.Error("Mute list does not match");
                return(false);
            }

            if (!CheckEqual(list[0], mute1entry))
            {
                m_Log.Error("Mute entry content does not match");
                return(false);
            }

            m_Log.Info("Change mute");
            mute1entry.Flags |= MuteFlags.ParticlesNotMuted;
            m_MuteListService.Store(muteowner, mute1entry);

            m_Log.InfoFormat("Check that mute list has 1 entry");
            list = m_MuteListService.GetList(muteowner, 0);
            if (list.Count != 1)
            {
                m_Log.Error("Mute list does not match");
                return(false);
            }

            if (!CheckEqual(list[0], mute1entry))
            {
                m_Log.Error("Mute entry content does not match");
                return(false);
            }

            m_Log.Info("Removing first entry");
            if (!m_MuteListService.Remove(muteowner, mute1entry.MuteID, mute1entry.MuteName))
            {
                m_Log.Error("Failed to remove it");
                return(false);
            }

            m_Log.InfoFormat("Check that mute list is empty");
            list = m_MuteListService.GetList(muteowner, 0);
            if (list.Count != 0)
            {
                m_Log.Error("Mute list is not empty");
                return(false);
            }

            return(true);
        }