예제 #1
0
        protected void OnBtnApplyClicked(object sender, EventArgs e)
        {
            if (chkAntivirus.Active && chkClamd.Active)
            {
                if (string.IsNullOrEmpty(txtClamdHost.Text))
                {
                    MessageDialog dlgMsg = new MessageDialog(this, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok,
                                                             "clamd host cannot be empty");
                    dlgMsg.Run();
                    dlgMsg.Destroy();
                    return;
                }
            }

            // TODO: Check sanity
            Core.Settings.Current.TemporaryFolder      = txtTmp.Text;
            Core.Settings.Current.UnArchiverPath       = txtUnar.Text;
            Core.Settings.Current.DatabasePath         = txtDatabase.Text;
            Core.Settings.Current.RepositoryPath       = txtRepository.Text;
            Core.Settings.Current.UseAntivirus         = chkAntivirus.Active;
            Core.Settings.Current.UseClamd             = chkClamd.Active;
            Core.Settings.Current.ClamdHost            = txtClamdHost.Text;
            Core.Settings.Current.ClamdPort            = (ushort)spClamdPort.Value;
            Core.Settings.Current.ClamdIsLocal         = chkClamdIsLocal.Active;
            Core.Settings.Current.CompressionAlgorithm = (AlgoEnum)Enum.Parse(typeof(AlgoEnum), cmbCompAlg.ActiveText);
            if (!chkClamd.Active || !chkAntivirus.Active)
            {
                Core.Settings.Current.UseClamd     = false;
                Core.Settings.Current.ClamdHost    = null;
                Core.Settings.Current.ClamdPort    = 3310;
                Core.Settings.Current.ClamdIsLocal = false;
            }

            if (chkVirusTotal.Active && chkAntivirus.Active)
            {
                Core.Settings.Current.UseVirusTotal = true;
                Core.Settings.Current.VirusTotalKey = txtVirusTotal.Text;
                Workers.InitVirusTotal(Core.Settings.Current.VirusTotalKey);
            }
            else
            {
                Core.Settings.Current.UseVirusTotal = false;
                Core.Settings.Current.VirusTotalKey = null;
            }

            Core.Settings.SaveSettings();
            Workers.CloseDB();
            Workers.InitDB();
            Context.ClamdVersion = null;
            Workers.InitClamd();
            Context.CheckUnar();
            btnDialog.Click();
        }
예제 #2
0
        protected void OnBtnApplyClicked(object sender, EventArgs e)
        {
            // TODO: Check sanity
            Settings.Current.TemporaryFolder      = txtTmp.Text;
            Settings.Current.UnArchiverPath       = txtUnar.Text;
            Settings.Current.DatabasePath         = txtDatabase.Text;
            Settings.Current.RepositoryPath       = txtRepository.Text;
            Settings.Current.CompressionAlgorithm = cmbCompAlg.SelectedValue;

            if (!chkClamd.Checked.Value ||
                !chkAntivirus.Checked.Value)
            {
                Settings.Current.UseClamd     = false;
                Settings.Current.ClamdHost    = null;
                Settings.Current.ClamdPort    = 3310;
                Settings.Current.ClamdIsLocal = false;
            }

            if (chkVirusTotal.Checked.Value &&
                chkAntivirus.Checked.Value)
            {
                Settings.Current.UseVirusTotal = true;
                Settings.Current.VirusTotalKey = txtVirusTotal.Text;
                Workers.InitVirusTotal(Settings.Current.VirusTotalKey);
            }
            else
            {
                Settings.Current.UseVirusTotal = false;
                Settings.Current.VirusTotalKey = null;
            }

            Settings.SaveSettings();
            Workers.CloseDB();
            Workers.InitDB();
            Context.ClamdVersion = null;
            Workers.InitClamd();
            Context.CheckUnar();
            Close();
        }
예제 #3
0
        public frmMain()
        {
            XamlReader.Load(this);

            Workers.InitDB();

            lstOSes = new ObservableCollection <DBEntryForEto>();

            treeOSes.DataStore = lstOSes;
            treeOSes.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell {
                    Binding = Binding.Property <DBEntryForEto, string>(r => r.developer)
                },
                HeaderText = "Developer"
            });
            treeOSes.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell {
                    Binding = Binding.Property <DBEntryForEto, string>(r => r.product)
                },
                HeaderText = "Product"
            });
            treeOSes.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell {
                    Binding = Binding.Property <DBEntryForEto, string>(r => r.version)
                },
                HeaderText = "Version"
            });
            treeOSes.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell {
                    Binding = Binding.Property <DBEntryForEto, string>(r => r.languages)
                },
                HeaderText = "Languages"
            });
            treeOSes.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell {
                    Binding = Binding.Property <DBEntryForEto, string>(r => r.architecture)
                },
                HeaderText = "Architecture"
            });
            treeOSes.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell {
                    Binding = Binding.Property <DBEntryForEto, string>(r => r.machine)
                },
                HeaderText = "Machine"
            });
            treeOSes.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell {
                    Binding = Binding.Property <DBEntryForEto, string>(r => r.format)
                },
                HeaderText = "Format"
            });
            treeOSes.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell {
                    Binding = Binding.Property <DBEntryForEto, string>(r => r.description)
                },
                HeaderText = "Description"
            });
            treeOSes.Columns.Add(new GridColumn
            {
                DataCell = new CheckBoxCell {
                    Binding = Binding.Property <DBEntryForEto, bool?>(r => r.oem)
                },
                HeaderText = "OEM?"
            });
            treeOSes.Columns.Add(new GridColumn
            {
                DataCell = new CheckBoxCell {
                    Binding = Binding.Property <DBEntryForEto, bool?>(r => r.upgrade)
                },
                HeaderText = "Upgrade?"
            });
            treeOSes.Columns.Add(new GridColumn
            {
                DataCell = new CheckBoxCell {
                    Binding = Binding.Property <DBEntryForEto, bool?>(r => r.update)
                },
                HeaderText = "Update?"
            });
            treeOSes.Columns.Add(new GridColumn
            {
                DataCell = new CheckBoxCell {
                    Binding = Binding.Property <DBEntryForEto, bool?>(r => r.source)
                },
                HeaderText = "Source?"
            });
            treeOSes.Columns.Add(new GridColumn
            {
                DataCell = new CheckBoxCell {
                    Binding = Binding.Property <DBEntryForEto, bool?>(r => r.files)
                },
                HeaderText = "Files?"
            });
            treeOSes.Columns.Add(new GridColumn
            {
                DataCell = new CheckBoxCell {
                    Binding = Binding.Property <DBEntryForEto, bool?>(r => r.netinstall)
                },
                HeaderText = "NetInstall?"
            });

            treeOSes.AllowMultipleSelection = false;

            lstFiles = new ObservableCollection <DbFile>();

            treeFiles.DataStore = lstFiles;
            treeFiles.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell {
                    Binding = Binding.Property <DbFile, string>(r => r.Sha256)
                },
                HeaderText = "SHA256"
            });
            treeFiles.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell
                {
                    Binding = Binding.Property <DbFile, long>(r => r.Length).Convert(s => s.ToString())
                },
                HeaderText = "Length"
            });
            treeFiles.Columns.Add(new GridColumn
            {
                DataCell = new CheckBoxCell {
                    Binding = Binding.Property <DbFile, bool?>(r => r.Crack)
                },
                HeaderText = "Crack?"
            });
            treeFiles.Columns.Add(new GridColumn
            {
                DataCell = new CheckBoxCell {
                    Binding = Binding.Property <DbFile, bool?>(r => r.HasVirus)
                },
                HeaderText = "Has virus?"
            });
            treeFiles.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell
                {
                    Binding = Binding.Property <DbFile, DateTime?>(r => r.ClamTime)
                              .Convert(s => s == null ? "Never" : s.Value.ToString())
                },
                HeaderText = "Last scanned with clamd"
            });
            treeFiles.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell
                {
                    Binding = Binding.Property <DbFile, DateTime?>(r => r.VirusTotalTime)
                              .Convert(s => s == null ? "Never" : s.Value.ToString())
                },
                HeaderText = "Last checked on VirusTotal"
            });
            treeFiles.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell
                {
                    Binding = Binding.Property <DbFile, string>(r => r.Virus).Convert(s => s ?? "None")
                },
                HeaderText = "Virus"
            });

            treeFiles.AllowMultipleSelection = false;
            treeFiles.CellFormatting        += (sender, e) =>
            {
                if (((DbFile)e.Item).HasVirus.HasValue)
                {
                    e.BackgroundColor = ((DbFile)e.Item).HasVirus.Value ? Colors.Red : Colors.Green;
                }
                else
                {
                    e.BackgroundColor = Colors.Yellow;
                }

                e.ForegroundColor = Colors.Black;
            };

            prgProgress.Indeterminate = true;

            if (!Context.UsableDotNetZip)
            {
                btnCompress.Visible = false;
                mnuCompress.Enabled = false;
            }

            Workers.Failed         += LoadOSesFailed;
            Workers.Finished       += LoadOSesFinished;
            Workers.UpdateProgress += UpdateProgress;
            Workers.AddOS          += AddOs;
            Workers.AddFile        += AddFile;
            Workers.AddFiles       += AddFiles;
            thdPopulateOSes         = new Thread(Workers.GetAllOSes);
            thdPopulateOSes.Start();
        }
예제 #4
0
        public frmMain() : base(WindowType.Toplevel)
        {
            Build();

            Workers.InitDB();

            CellRendererText   developerCell    = new CellRendererText();
            CellRendererText   productCell      = new CellRendererText();
            CellRendererText   versionCell      = new CellRendererText();
            CellRendererText   languagesCell    = new CellRendererText();
            CellRendererText   architectureCell = new CellRendererText();
            CellRendererText   machineCell      = new CellRendererText();
            CellRendererText   formatCell       = new CellRendererText();
            CellRendererText   descriptionCell  = new CellRendererText();
            CellRendererToggle oemCell          = new CellRendererToggle();
            CellRendererToggle upgradeCell      = new CellRendererToggle();
            CellRendererToggle updateCell       = new CellRendererToggle();
            CellRendererToggle sourceCell       = new CellRendererToggle();
            CellRendererToggle filesCell        = new CellRendererToggle();
            CellRendererToggle netinstallCell   = new CellRendererToggle();

            TreeViewColumn developerColumn    = new TreeViewColumn("Developer", developerCell, "text", 0);
            TreeViewColumn productColumn      = new TreeViewColumn("Product", productCell, "text", 1);
            TreeViewColumn versionColumn      = new TreeViewColumn("Version", versionCell, "text", 2);
            TreeViewColumn languagesColumn    = new TreeViewColumn("Languages", languagesCell, "text", 3);
            TreeViewColumn architectureColumn = new TreeViewColumn("Architecture", architectureCell, "text", 4);
            TreeViewColumn machineColumn      = new TreeViewColumn("Machine", machineCell, "text", 5);
            TreeViewColumn formatColumn       = new TreeViewColumn("Format", formatCell, "text", 6);
            TreeViewColumn descriptionColumn  = new TreeViewColumn("Description", descriptionCell, "text");
            TreeViewColumn oemColumn          = new TreeViewColumn("OEM?", oemCell, "active", 8);
            TreeViewColumn upgradeColumn      = new TreeViewColumn("Upgrade?", upgradeCell, "active", 9);
            TreeViewColumn updateColumn       = new TreeViewColumn("Update?", updateCell, "active", 10);
            TreeViewColumn sourceColumn       = new TreeViewColumn("Source?", sourceCell, "active", 11);
            TreeViewColumn filesColumn        = new TreeViewColumn("Files?", filesCell, "active", 12);
            TreeViewColumn netinstallColumn   = new TreeViewColumn("NetInstall?", netinstallCell, "active", 13);

            osView = new ListStore(typeof(string), typeof(string), typeof(string), typeof(string), typeof(string),
                                   typeof(string), typeof(string), typeof(string), typeof(bool), typeof(bool),
                                   typeof(bool), typeof(bool), typeof(bool), typeof(bool), typeof(long),
                                   typeof(string));

            treeOSes.Model = osView;
            treeOSes.AppendColumn(developerColumn);
            treeOSes.AppendColumn(productColumn);
            treeOSes.AppendColumn(versionColumn);
            treeOSes.AppendColumn(languagesColumn);
            treeOSes.AppendColumn(architectureColumn);
            treeOSes.AppendColumn(machineColumn);
            treeOSes.AppendColumn(formatColumn);
            treeOSes.AppendColumn(descriptionColumn);
            treeOSes.AppendColumn(oemColumn);
            treeOSes.AppendColumn(upgradeColumn);
            treeOSes.AppendColumn(updateColumn);
            treeOSes.AppendColumn(sourceColumn);
            treeOSes.AppendColumn(filesColumn);
            treeOSes.AppendColumn(netinstallColumn);

            treeOSes.Selection.Mode = SelectionMode.Single;

            CellRendererText   hashCell     = new CellRendererText();
            CellRendererText   lengthCell   = new CellRendererText();
            CellRendererToggle crackCell    = new CellRendererToggle();
            CellRendererToggle hasvirusCell = new CellRendererToggle();
            CellRendererText   clamtimeCell = new CellRendererText();
            CellRendererText   vtottimeCell = new CellRendererText();
            CellRendererText   virusCell    = new CellRendererText();

            TreeViewColumn hashColumn =
                new TreeViewColumn("SHA256", hashCell, "text", 0, "background", 7, "foreground", 8);
            TreeViewColumn lengthColumn =
                new TreeViewColumn("Length", lengthCell, "text", 1, "background", 7,
                                   "foreground", 8);
            TreeViewColumn crackColumn    = new TreeViewColumn("Crack?", crackCell, "active", 2);
            TreeViewColumn hasvirusColumn =
                new TreeViewColumn("Has virus?", hasvirusCell, "active", 3, "inconsistent", 9);
            TreeViewColumn clamtimeColumn =
                new TreeViewColumn("Last scanned with clamd", clamtimeCell, "text", 4, "background", 7, "foreground",
                                   8);
            TreeViewColumn vtottimeColumn = new TreeViewColumn("Last checked on VirusTotal", vtottimeCell, "text", 5,
                                                               "background", 7, "foreground", 8);
            TreeViewColumn virusColumn =
                new TreeViewColumn("Virus", virusCell, "text", 6, "background", 7, "foreground", 8);

            fileView = new ListStore(typeof(string), typeof(long), typeof(bool), typeof(bool), typeof(string),
                                     typeof(string), typeof(string), typeof(string), typeof(string), typeof(bool),
                                     typeof(bool));

            treeFiles.Model = fileView;
            treeFiles.AppendColumn(hashColumn);
            treeFiles.AppendColumn(lengthColumn);
            treeFiles.AppendColumn(crackColumn);
            treeFiles.AppendColumn(hasvirusColumn);
            treeFiles.AppendColumn(clamtimeColumn);
            treeFiles.AppendColumn(vtottimeColumn);
            treeFiles.AppendColumn(virusColumn);

            treeFiles.Selection.Mode     = SelectionMode.Single;
            treeFiles.Selection.Changed += treeFilesSelectionChanged;

            thdPulseProgress = new Thread(() =>
            {
                while (true)
                {
                    Application.Invoke(delegate { prgProgress.Pulse(); });
                    Thread.Sleep(66);
                }
            });
            Workers.Failed         += LoadOSesFailed;
            Workers.Finished       += LoadOSesFinished;
            Workers.UpdateProgress += UpdateProgress;
            Workers.AddOS          += AddOs;
            Workers.AddFile        += AddFile;
            Workers.AddFiles       += AddFiles;
            thdPopulateOSes         = new Thread(Workers.GetAllOSes);
            thdPopulateOSes.Start();
        }