Esempio n. 1
0
        void OnHosts(string data)
        {
            HostsDatabase.Clear(false);

            foreach (var entry in data.Split('|'))
            {
                var param = entry.Split('/');
                if (param.Length == 4)
                {
                    HostsDatabase.Add(false,
                                      param[0].Unescape(EscapeLanguage.Xml),
                                      param[1].Unescape(EscapeLanguage.Xml),
                                      param[2].Unescape(EscapeLanguage.Xml),
                                      param[3] == "1");
                }
            }

            HostsDatabase.Save();
            EventCallbackSystem.InvokeCallback("HostsListUpdated", true);

            HostsDatabase.Lock();
            int numberOfHosts = HostsDatabase.Hosts.Count();

            HostsDatabase.Unlock();
            Logger.Log(LogType.Debug, "Received {0} hosts from server.", numberOfHosts.FormatNumber());
        }
Esempio n. 2
0
 private void addNewHostToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (var dlg = new AddEditHostDlg())
     {
         if (dlg.ShowDialog() == DialogResult.OK)
         {
             if (dlg.LocalDomain)
             {
                 HostsDatabase.Add(true, dlg.DomainName, dlg.IPAddress, dlg.Description, dlg.HiddenDomain);
                 HostsDatabase.Save();
                 EventCallbackSystem.InvokeCallback("HostsListUpdated", true);
             }
             else
             {
                 _client.SendAddDomain(dlg.DomainName, dlg.IPAddress, dlg.Description, dlg.HiddenDomain);
             }
         }
     }
 }
Esempio n. 3
0
        private void LvLocalHosts_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (lvLocalHosts.SelectedItems.Count == 1)
            {
                var entry = lvLocalHosts.SelectedItems[0].Tag as HostEntry;

                using (var dlg = new AddEditHostDlg(entry, true))
                {
                    if (dlg.ShowDialog() == DialogResult.OK)
                    {
                        HostsDatabase.Remove(true, entry.Name);
                        HostsDatabase.Add(true, dlg.DomainName, dlg.IPAddress, dlg.Description, dlg.HiddenDomain);
                        HostsDatabase.Save();

                        EventCallbackSystem.InvokeCallback("HostsListUpdated", true);
                    }
                }
            }
        }
Esempio n. 4
0
        void OnAddDomain(string data)
        {
            var param = data.Split('/');

            if (param.Length == 4)
            {
                HostsDatabase.Add(false,
                                  param[0].Unescape(EscapeLanguage.Xml),
                                  param[1].Unescape(EscapeLanguage.Xml),
                                  param[2].Unescape(EscapeLanguage.Xml),
                                  param[3] == "1");
                HostsDatabase.Save();
                EventCallbackSystem.InvokeCallback("HostsListUpdated", true);

                Logger.Log(LogType.Debug,
                           "Added domain {0} = {1}",
                           param[0].Unescape(EscapeLanguage.Xml),
                           param[1].Unescape(EscapeLanguage.Xml));
            }
        }
Esempio n. 5
0
        void OnAddDomain(UserClient client, string data)
        {
            var param = data.Split('/');

            if (param.Length == 4)
            {
                HostsDatabase.Add(false,
                                  param[0].Unescape(EscapeLanguage.Xml),
                                  param[1].Unescape(EscapeLanguage.Xml),
                                  param[2].Unescape(EscapeLanguage.Xml),
                                  param[3] == "1");
                HostsDatabase.Save();

                Logger.Log(
                    LogType.Debug,
                    "Added domain {0} = {1}",
                    param[0].Unescape(EscapeLanguage.Xml),
                    param[1].Unescape(EscapeLanguage.Xml));

                BroadcastPacket("add-domain {0}\n", data);
            }
        }
Esempio n. 6
0
        void OnEditDomain(UserClient client, string data)
        {
            var param = data.Split('/');

            if (param.Length == 4)
            {
                var added = !HostsDatabase.Remove(false, param[0].Unescape(EscapeLanguage.Xml));
                HostsDatabase.Add(false,
                                  param[0].Unescape(EscapeLanguage.Xml),
                                  param[1].Unescape(EscapeLanguage.Xml),
                                  param[2].Unescape(EscapeLanguage.Xml),
                                  param[3] == "1");
                HostsDatabase.Save();

                Logger.Log(
                    LogType.Debug,
                    "{0} domain {1} = {2}",
                    added ? "Added" : "Edited",
                    param[0].Unescape(EscapeLanguage.Xml),
                    param[1].Unescape(EscapeLanguage.Xml));

                BroadcastPacket("edit-domain {0}\n", data);
            }
        }