Example #1
0
            public override void init()
            {
                ProgramSettings pSettings = UpdateCacher.GetPackage(this.Name);

                if (pSettings == null || String.IsNullOrEmpty(pSettings.Path))
                {
                    throw new FileNotRegisteredYetException(Name);
                }
                SavePath = pSettings.Path;
            }
Example #2
0
        private void listViewDetails_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            ListViewItem itm = this.listViewDetails.Items[e.Index];

            // Do not allow checking if there are no updates or it is set to ignore.
            if (itm.SubItems["Status"].Text.Equals(EnumProxy.Create(PackageStatus.NoUpdateAvailable).ToString()) ||
                itm.SubItems["Status"].Text.Equals(EnumProxy.Create(PackageStatus.UpdateIgnored).ToString()) ||
                itm.SubItems["Status"].Text.Equals(EnumProxy.Create(PackageStatus.Disabled).ToString()))
            {
                e.NewValue = CheckState.Unchecked;
            }

            iUpgradeable file = MainForm.Instance.UpdateHandler.UpdateData.FindByName(itm.Name);

            if (e.NewValue == CheckState.Checked)
            {
                file.DownloadChecked = file.AllowUpdate = true;
            }
            else
            {
                file.DownloadChecked = false;
            }

            if (e.NewValue == CheckState.Unchecked &&
                itm.SubItems["Status"].Text.Equals(EnumProxy.Create(PackageStatus.Reinstall).ToString()))
            {
                ProgramSettings pSettings = UpdateCacher.GetPackage(itm.Name);
                if (pSettings != null && !pSettings.UpdateAllowed())
                {
                    itm.SubItems["Status"].Text = EnumProxy.Create(PackageStatus.Disabled).ToString();
                }
                else if (!file.isAvailable())
                {
                    e.NewValue           = CheckState.Checked;
                    file.DownloadChecked = file.AllowUpdate = true;
                }
                else if (!file.AllowUpdate && file.HasAvailableVersion)
                {
                    itm.SubItems["Status"].Text = EnumProxy.Create(PackageStatus.UpdateIgnored).ToString();
                }
                else if (file.HasAvailableVersion)
                {
                    itm.SubItems["Status"].Text = EnumProxy.Create(PackageStatus.UpdateAvailable).ToString();
                }
                else
                {
                    itm.SubItems["Status"].Text = EnumProxy.Create(PackageStatus.NoUpdateAvailable).ToString();
                }
            }
        }
Example #3
0
        public static bool IsPackage(string package)
        {
            if (UpdateCacher.GetPackage(package) != null)
            {
                return(true);
            }

            switch (package)
            {
            case "audio":
            case "TXviD": return(true);

            default: return(false);
            }
        }
Example #4
0
        private void setIgnoreValue_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem ts = (ToolStripMenuItem)sender;

            foreach (ListViewItem item in listViewDetails.SelectedItems)
            {
                ProgramSettings pSettings = UpdateCacher.GetPackage(item.Name);
                iUpgradeable    file      = MainForm.Instance.UpdateHandler.UpdateData.FindByName(item.Name);
                Version         latest    = file.AvailableVersion;
                file.AllowUpdate = !(ts.Checked);

                if (pSettings != null && !pSettings.UpdateAllowed())
                {
                    item.SubItems["Status"].Text = EnumProxy.Create(PackageStatus.Disabled).ToString();
                    item.Checked = false;
                }
                else if (!file.isAvailable())
                {
                    item.SubItems["Status"].Text = EnumProxy.Create(PackageStatus.Reinstall).ToString();
                    item.Checked     = true;
                    file.AllowUpdate = true;
                }
                else if (latest != null && file.CurrentVersion == null || latest.CompareTo(file.CurrentVersion) != 0)
                {
                    if (!file.AllowUpdate)
                    {
                        item.SubItems["Status"].Text = EnumProxy.Create(PackageStatus.UpdateIgnored).ToString();
                        item.Checked = false;
                    }
                    else
                    {
                        item.SubItems["Status"].Text = EnumProxy.Create(PackageStatus.UpdateAvailable).ToString();
                        item.Checked = true;
                    }
                }
                else
                {
                    item.SubItems["Status"].Text = EnumProxy.Create(PackageStatus.NoUpdateAvailable).ToString();
                    item.Checked = false;
                }
            }
        }
Example #5
0
        private void DisplayItems(bool bShowAllFiles)
        {
            if (!this.Visible)
            {
                return;
            }

            ClearListview(this.listViewDetails);

            foreach (iUpgradeable file in MainForm.Instance.UpdateHandler.UpdateData)
            {
                if (!bShowAllFiles)
                {
                    ProgramSettings pSettings = UpdateCacher.GetPackage(file.Name);
                    if (file.DownloadChecked)
                    {
                        AddToListview(file.CreateListViewItem());
                    }
                }
                else
                {
                    AddToListview(file.CreateListViewItem());
                }
            }

            listViewDetails.Sort();

            foreach (ListViewItem item in listViewDetails.Items)
            {
                if (item.Index % 2 != 0)
                {
                    item.BackColor = Color.White;
                }
                else
                {
                    item.BackColor = Color.FromArgb(255, 225, 235, 255);
                }
            }
        }
Example #6
0
        public static bool IsPackage(string package)
        {
            if (UpdateCacher.GetPackage(package) != null)
            {
                return(true);
            }

            switch (package)
            {
            case "audio":
            case "TXviD":
            case "core":
            case "libs":
            case "mediainfo":
            case "mediainfowrapper":
            case "sevenzip":
            case "sevenzipsharp":
            case "data":
            case "avswrapper":
            case "updatecopier": return(true);

            default: return(false);
            }
        }
Example #7
0
            public ListViewItem CreateListViewItem()
            {
                ListViewItem myitem = new ListViewItem();

                ListViewItem.ListViewSubItem name            = new ListViewItem.ListViewSubItem();
                ListViewItem.ListViewSubItem existingVersion = new ListViewItem.ListViewSubItem();
                ListViewItem.ListViewSubItem latestVersion   = new ListViewItem.ListViewSubItem();
                ListViewItem.ListViewSubItem existingDate    = new ListViewItem.ListViewSubItem();
                ListViewItem.ListViewSubItem latestDate      = new ListViewItem.ListViewSubItem();
                ListViewItem.ListViewSubItem lastUsed        = new ListViewItem.ListViewSubItem();
                ListViewItem.ListViewSubItem status          = new ListViewItem.ListViewSubItem();

                myitem.Name = this.Name;

                name.Name            = "Name";
                existingVersion.Name = "Existing Version";
                latestVersion.Name   = "Latest Version";
                existingDate.Name    = "Existing Date";
                latestDate.Name      = "Latest Date";
                lastUsed.Name        = "Last Used";
                status.Name          = "Status";

                name.Text = this.DisplayName;

                Version v = this.availableVersion;

                if (v != null)
                {
                    latestVersion.Text = v.FileVersion;
                    latestDate.Text    = v.UploadDate.ToShortDateString();
                }
                else
                {
                    latestVersion.Text = "unknown";
                    latestDate.Text    = "unknown";
                }

                if (this.CurrentVersion != null && !String.IsNullOrEmpty(this.CurrentVersion.FileVersion))
                {
                    existingVersion.Text = this.CurrentVersion.FileVersion;
                    if (this.CurrentVersion.UploadDate.Year > 1)
                    {
                        existingDate.Text = this.CurrentVersion.UploadDate.ToShortDateString();
                    }
                    else
                    {
                        existingDate.Text = "N/A";
                    }
                }
                else
                {
                    existingVersion.Text = "N/A";
                    existingDate.Text    = "N/A";
                }

                ProgramSettings pSettings = UpdateCacher.GetPackage(this.name);

                if (pSettings != null && !pSettings.UpdateAllowed())
                {
                    status.Text = EnumProxy.Create(PackageStatus.Disabled).ToString();
                }
                else if (!this.isAvailable())
                {
                    status.Text          = EnumProxy.Create(PackageStatus.Reinstall).ToString();
                    this.DownloadChecked = this.AllowUpdate = true;
                }
                else if (!HasAvailableVersion)
                {
                    if (this.DownloadChecked)
                    {
                        status.Text = EnumProxy.Create(PackageStatus.Reinstall).ToString();
                    }
                    else
                    {
                        status.Text = EnumProxy.Create(PackageStatus.NoUpdateAvailable).ToString();
                    }
                }
                else
                {
                    if (this.AllowUpdate)
                    {
                        status.Text = EnumProxy.Create(PackageStatus.UpdateAvailable).ToString();
                    }
                    else
                    {
                        status.Text = EnumProxy.Create(PackageStatus.UpdateIgnored).ToString();
                    }
                }

                if (this.AllowUpdate)
                {
                    if (this.DownloadChecked)
                    {
                        myitem.Checked = true;
                    }
                    else
                    {
                        myitem.Checked = false;
                    }
                }

                if (pSettings != null)
                {
                    if (pSettings.LastUsed.Year > 1)
                    {
                        lastUsed.Text = pSettings.LastUsed.ToShortDateString();
                    }
                    else
                    {
                        lastUsed.Text = "N/A";
                    }
                }
                else
                {
                    lastUsed.Text = "---";
                }

                myitem.SubItems.Add(name);
                myitem.SubItems.Add(existingVersion);
                myitem.SubItems.Add(latestVersion);
                myitem.SubItems.Add(existingDate);
                myitem.SubItems.Add(latestDate);
                myitem.SubItems.Add(lastUsed);
                myitem.SubItems.Add(status);
                return(myitem);
            }
Example #8
0
            public bool isAvailable()
            {
                ArrayList arrPath = new ArrayList();
                string    strPath;

                switch (this.name)
                {
                case "base": arrPath.Add(System.Windows.Forms.Application.ExecutablePath); break;

                case "libs":
                    strPath = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);
                    arrPath.Add((Path.Combine(strPath, @"ICSharpCode.SharpZipLib.dll")));
                    arrPath.Add((Path.Combine(strPath, @"MessageBoxExLib.dll")));
                    arrPath.Add((Path.Combine(strPath, @"LinqBridge.dll")));
                    break;

                case "mediainfo": arrPath.Add(Path.Combine(Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), @"MediaInfo.dll")); break;

                case "mediainfowrapper": arrPath.Add(Path.Combine(Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), @"MediaInfoWrapper.dll")); break;

                case "sevenzip": arrPath.Add(Path.Combine(Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), @"7z.dll")); break;

                case "sevenzipsharp": arrPath.Add(Path.Combine(Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), @"SevenZipSharp.dll")); break;

                case "data": arrPath.Add(Path.Combine(Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), @"Data\ContextHelp.xml")); break;

                case "avswrapper": arrPath.Add((Path.Combine(Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), @"AvisynthWrapper.dll"))); break;

                case "updatecopier": arrPath.Add((Path.Combine(Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), @"updatecopier.exe"))); break;

                case "neroaacenc":
                    if (MainForm.Instance.Settings.UseNeroAacEnc)
                    {
                        arrPath.Add(MainForm.Instance.Settings.NeroAacEnc.Path);
                        if (File.Exists(MainForm.Instance.Settings.NeroAacEnc.Path))
                        {
                            System.Diagnostics.FileVersionInfo finfo = System.Diagnostics.FileVersionInfo.GetVersionInfo(MainForm.Instance.Settings.NeroAacEnc.Path);
                            FileInfo fi = new FileInfo(MainForm.Instance.Settings.NeroAacEnc.Path);
                            CurrentVersion.FileVersion = finfo.FileMajorPart + "." + finfo.FileMinorPart + "." + finfo.FileBuildPart + "." + finfo.FilePrivatePart;
                            CurrentVersion.UploadDate  = fi.LastWriteTimeUtc;
                        }
                    }
                    break;

                default:
                    ProgramSettings pSettings = UpdateCacher.GetPackage(this.name);
                    if (pSettings != null && pSettings.UpdateAllowed())
                    {
                        arrPath.AddRange(pSettings.Files);
                    }
                    break;
                }

                foreach (string strAppPath in arrPath)
                {
                    if (String.IsNullOrEmpty(strAppPath))
                    {
                        return(false);
                    }
                    if (File.Exists(strAppPath) == false)
                    {
                        return(false);
                    }
                    FileInfo fInfo = new FileInfo(strAppPath);
                    if (fInfo.Length == 0)
                    {
                        return(false);
                    }
                }
                return(true);
            }
Example #9
0
        private void listViewDetails_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Right || listViewDetails.SelectedItems.Count != 1)
            {
                return;
            }

            // get the program settings
            ProgramSettings pSettings = UpdateCacher.GetPackage(listViewDetails.SelectedItems[0].Name);
            iUpgradeable    file      = MainForm.Instance.UpdateHandler.UpdateData.FindByName(listViewDetails.SelectedItems[0].Name);

            // set the enable package value
            ToolStripMenuItem ts = (ToolStripMenuItem)statusToolStrip.Items[0];

            if (pSettings == null)
            {
                ts.Checked = true;
                ts.Enabled = false;
            }
            else
            {
                ts.Checked = pSettings.UpdateAllowed();
                ts.Enabled = !pSettings.Required;
            }

            // set the ignore update data value
            ts = (ToolStripMenuItem)statusToolStrip.Items[1];
            if (pSettings != null && !pSettings.UpdateAllowed())
            {
                ts.Checked = true;
                ts.Enabled = false;
            }
            else if (!file.isAvailable())
            {
                ts.Checked = false;
                ts.Enabled = false;
            }
            else
            {
                ts.Checked = !file.AllowUpdate;
                ts.Enabled = true;
            }

            // set the force reinstall data value
            ts = (ToolStripMenuItem)statusToolStrip.Items[2];
            if (pSettings != null && !pSettings.UpdateAllowed())
            {
                ts.Checked = false;
                ts.Enabled = false;
            }
            else if (!file.isAvailable())
            {
                ts.Checked = true;
                ts.Enabled = false;
            }
            else
            {
                ts.Checked = file.DownloadChecked;
                ts.Enabled = true;
            }

            if (file.HasAvailableVersion)
            {
                ts.Text = "Install";
            }
            else
            {
                ts.Text = "Force reinstall";
            }

            statusToolStrip.Show(Cursor.Position);
        }
Example #10
0
        public static UpdateWindow.ErrorState PreparePackageFolder(string packageName)
        {
            ProgramSettings oPackage = UpdateCacher.GetPackage(packageName);

            if (oPackage == null)
            {
                return(UpdateWindow.ErrorState.Successful);
            }

            string packagePath = Path.GetDirectoryName(oPackage.Path);

            if (MainForm.Instance.Settings.AlwaysBackUpFiles)
            {
                try
                {
                    // remove all old backup files found
                    Array.ForEach(Directory.GetFiles(packagePath, "*.backup", SearchOption.AllDirectories), delegate(string path) { File.Delete(path); });
                }
                catch (Exception ex)
                {
                    MainForm.Instance.UpdateHandler.AddTextToLog("Outdated backup version of " + oPackage.DisplayName + " could not be deleted. Check if it is in use. " + ex.Message, ImageType.Error, true);
                    return(UpdateWindow.ErrorState.CouldNotCreateBackup);
                }
            }

            try
            {
                DirectoryInfo fi    = new DirectoryInfo(packagePath);
                FileInfo[]    files = fi.GetFiles("*.*", SearchOption.AllDirectories);
                foreach (FileInfo f in files)
                {
                    // only continue when file can be deleted/renamed
                    bool bFound = false;
                    foreach (string strFile in oPackage.DoNotDeleteFilesOnUpdate)
                    {
                        if (f.FullName.ToLowerInvariant().Equals(strFile.ToLowerInvariant()))
                        {
                            bFound = true;
                            break;
                        }
                    }
                    foreach (string strFolder in oPackage.DoNotDeleteFoldersOnUpdate)
                    {
                        if (f.DirectoryName.ToLowerInvariant().StartsWith(strFolder.ToLowerInvariant()))
                        {
                            bFound = true;
                            break;
                        }
                    }
                    if (bFound)
                    {
                        continue;
                    }

                    if (!MainForm.Instance.Settings.AlwaysBackUpFiles)
                    {
                        f.Delete();
                    }
                    else
                    {
                        f.MoveTo(Path.Combine(f.Directory.FullName, f.Name + ".backup"));
                    }
                }
            }
            catch (Exception ex)
            {
                MainForm.Instance.UpdateHandler.AddTextToLog("Old version of " + oPackage.DisplayName + " could not be accessed correctly. Check if it is in use. " + ex.Message, ImageType.Error, true);
                return(UpdateWindow.ErrorState.CouldNotCreateBackup);
            }

            return(UpdateWindow.ErrorState.Successful);
        }