Exemple #1
0
        public void ExecuteQueue()
        {
            //UpdateList(true);
            QueueCommandCollection collection = QueueCommandCollection.Load();

            // close all MP processes without message box, because executing the queue is called from within MP from GUI plugin which warns the user already
            if (collection.Items.Count > 0)
            {
                Util.KillAllMediaPortalProcesses(true);
            }
            foreach (QueueCommand item in collection.Items)
            {
                switch (item.CommandEnum)
                {
                case CommandEnum.Install:
                {
                    PackageClass packageClass = MpeCore.MpeInstaller.KnownExtensions.Get(item.TargetId,
                                                                                         item.TargetVersion.
                                                                                         ToString());
                    if (packageClass == null)
                    {
                        continue;
                    }
                    splashScreen.SetInfo("Installing " + packageClass.GeneralInfo.Name);
                    string newPackageLoacation = ExtensionUpdateDownloader.GetPackageLocation(packageClass, Client_DownloadProgressChanged, Client_DownloadFileCompleted);
                    InstallFile(newPackageLoacation, true, false);
                }
                break;

                case CommandEnum.Uninstall:
                {
                    PackageClass packageClass = MpeCore.MpeInstaller.InstalledExtensions.Get(item.TargetId);
                    if (packageClass == null)
                    {
                        continue;
                    }
                    splashScreen.SetInfo("UnInstalling " + packageClass.GeneralInfo.Name);
                    UnInstall dlg = new UnInstall();
                    dlg.Execute(packageClass, true);
                }
                break;

                default:
                    break;
                }
            }
            collection.Items.Clear();
            collection.Save();
        }
Exemple #2
0
        private void DoUpdateAll(bool askForInfoUpdate)
        {
            var updatelist = new Dictionary <PackageClass, PackageClass>();

            foreach (PackageClass packageClass in MpeCore.MpeInstaller.InstalledExtensions.Items)
            {
                PackageClass update = MpeCore.MpeInstaller.KnownExtensions.GetUpdate(packageClass);
                if (update == null)
                {
                    continue;
                }
                updatelist.Add(packageClass, update);
            }
            if (updatelist.Count > 0)
            {
                this.Hide();
                foreach (KeyValuePair <PackageClass, PackageClass> valuePair in updatelist)
                {
                    if (valuePair.Value == null)
                    {
                        continue;
                    }
                    DoUpdate(valuePair.Key, valuePair.Value, true);
                }
                RefreshListControls();
                this.Show();
            }
            else
            {
                if (askForInfoUpdate && MessageBox.Show("All installed extensions seem up to date.\nRefresh update info and try again?", "No updates found", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    ExtensionUpdateDownloader.UpdateList(false, true, null, null);
                    SetFilterForKnownExtensionsList();
                    RefreshListControls();
                    DoUpdateAll(false);
                }
            }
        }
Exemple #3
0
 private void RefreshUpdateInfo_Click(object sender, EventArgs e)
 {
     ExtensionUpdateDownloader.UpdateList(false, false, Client_DownloadProgressChanged, Client_DownloadFileCompleted);
     SetFilterForKnownExtensionsList();
     RefreshListControls();
 }
Exemple #4
0
        private bool DoUpdate(PackageClass packageClass, PackageClass newpackageClass, bool silent)
        {
            string newPackageLoacation = ExtensionUpdateDownloader.GetPackageLocation(newpackageClass, Client_DownloadProgressChanged, Client_DownloadFileCompleted);

            if (!File.Exists(newPackageLoacation))
            {
                if (!silent)
                {
                    MessageBox.Show("Can't locate the installer package. Update aborted");
                }
                return(false);
            }
            PackageClass pak = new PackageClass();

            pak = pak.ZipProvider.Load(newPackageLoacation);
            if (pak == null)
            {
                if (!silent)
                {
                    MessageBox.Show("Invalid package format ! Update aborted !");
                }
                return(false);
            }
            if (pak.GeneralInfo.Id != newpackageClass.GeneralInfo.Id ||
                pak.GeneralInfo.Version.CompareTo(newpackageClass.GeneralInfo.Version) < 0)
            {
                if (!silent)
                {
                    MessageBox.Show("Invalid update information ! Update aborted!");
                }
                return(false);
            }
            if (!pak.CheckDependency(false))
            {
                if (!silent)
                {
                    if (MessageBox.Show("Dependency check error! Update aborted!\nWould you like to view more details?", pak.GeneralInfo.Name,
                                        MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                    {
                        DependencyForm frm = new DependencyForm(pak);
                        frm.ShowDialog();
                    }
                }
                return(false);
            }
            if (!silent)
            {
                if (
                    MessageBox.Show(
                        "This operation will update the extension " + packageClass.GeneralInfo.Name + " to the version " +
                        pak.GeneralInfo.Version + " \n Do you want to continue ? ", "Install extension", MessageBoxButtons.YesNo,
                        MessageBoxIcon.Exclamation) != DialogResult.Yes)
                {
                    return(false);
                }
            }
            // only uninstall previous version, if the new package has the setting to force uninstall of previous version on update
            if (pak.GeneralInfo.Params[ParamNamesConst.FORCE_TO_UNINSTALL_ON_UPDATE].GetValueAsBool())
            {
                UnInstall dlg = new UnInstall();
                dlg.Execute(packageClass, true);
            }
            else
            {
                MpeCore.MpeInstaller.InstalledExtensions.Remove(packageClass);
            }
            pak.CopyGroupCheck(packageClass);
            pak.Silent = true;
            pak.StartInstallWizard();
            return(true);
        }
Exemple #5
0
        private void extensionListControl_InstallExtension(object sender, PackageClass packageClass)
        {
            string newPackageLoacation = ExtensionUpdateDownloader.GetPackageLocation(packageClass, Client_DownloadProgressChanged, Client_DownloadFileCompleted);

            if (!File.Exists(newPackageLoacation))
            {
                MessageBox.Show("Can't locate the installer package. Install aborted");
                return;
            }
            PackageClass pak = new PackageClass();

            pak = pak.ZipProvider.Load(newPackageLoacation);
            if (pak == null)
            {
                MessageBox.Show("Package loading error ! Install aborted!");
                try
                {
                    if (newPackageLoacation != packageClass.GeneralInfo.Location)
                    {
                        File.Delete(newPackageLoacation);
                    }
                }
                catch { }
                return;
            }
            if (!pak.CheckDependency(false))
            {
                if (MessageBox.Show("Dependency check error! Install aborted!\nWould you like to view more details?", pak.GeneralInfo.Name,
                                    MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                {
                    DependencyForm frm = new DependencyForm(pak);
                    frm.ShowDialog();
                }
                pak.ZipProvider.Dispose();
                try
                {
                    if (newPackageLoacation != packageClass.GeneralInfo.Location)
                    {
                        File.Delete(newPackageLoacation);
                    }
                }
                catch { }
                return;
            }

            if (packageClass.GeneralInfo.Version.CompareTo(pak.GeneralInfo.Version) != 0)
            {
                if (MessageBox.Show(
                        string.Format(@"Downloaded version of {0} is {1} and differs from your selected version: {2}!
Do you want to continue ?", packageClass.GeneralInfo.Name, pak.GeneralInfo.Version, packageClass.GeneralInfo.Version), "Install extension", MessageBoxButtons.YesNo,
                        MessageBoxIcon.Error) != DialogResult.Yes)
                {
                    return;
                }
            }

            if (
                MessageBox.Show(
                    "This operation will install " + packageClass.GeneralInfo.Name + " version " +
                    pak.GeneralInfo.Version + "\n Do you want to continue ?", "Install extension", MessageBoxButtons.YesNo,
                    MessageBoxIcon.Exclamation) != DialogResult.Yes)
            {
                return;
            }
            this.Hide();
            packageClass = MpeCore.MpeInstaller.InstalledExtensions.Get(packageClass.GeneralInfo.Id);
            if (packageClass != null)
            {
                if (pak.GeneralInfo.Params[ParamNamesConst.FORCE_TO_UNINSTALL_ON_UPDATE].GetValueAsBool())
                {
                    if (
                        MessageBox.Show(
                            "Another version of this extension is installed\nand needs to be uninstalled first.\nDo you want to continue?\n" +
                            "Old extension version: " + packageClass.GeneralInfo.Version + "\n" +
                            "New extension version: " + pak.GeneralInfo.Version,
                            "Install extension", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) != DialogResult.Yes)
                    {
                        this.Show();
                        return;
                    }
                    UnInstall dlg = new UnInstall();
                    dlg.Execute(packageClass, false);
                }
                else
                {
                    MpeCore.MpeInstaller.InstalledExtensions.Remove(packageClass);
                }
                pak.CopyGroupCheck(packageClass);
            }
            pak.StartInstallWizard();
            RefreshListControls();
            pak.ZipProvider.Dispose();
            try
            {
                if (newPackageLoacation != packageClass.GeneralInfo.Location)
                {
                    File.Delete(newPackageLoacation);
                }
            }
            catch { }
            this.Show();
        }
        public SectionResponseEnum Execute(PackageClass packageClass, ActionItem actionItem)
        {
            // load extension from zip if provided
            PackageClass embeddedPackage = null;

            if (!string.IsNullOrEmpty(actionItem.Params[Const_Loc].Value))
            {
                embeddedPackage = new PackageClass().ZipProvider.Load(actionItem.Params[Const_Loc].Value);
                if (embeddedPackage == null && string.IsNullOrEmpty(actionItem.Params[Const_Guid].Value))
                {
                    return(SectionResponseEnum.Ok);
                }
            }

            // check if there is already an installed version with a higher version than the embedded
            PackageClass installedPak = MpeInstaller.InstalledExtensions.Get(embeddedPackage != null ? embeddedPackage.GeneralInfo.Id : actionItem.Params[Const_Guid].Value);

            if (installedPak != null && embeddedPackage != null && installedPak.GeneralInfo.Version.CompareTo(embeddedPackage.GeneralInfo.Version) >= 0)
            {
                return(SectionResponseEnum.Ok);
            }

            // download new version when none embedded and (none installed none or lower version than required installed)
            if (embeddedPackage == null && !string.IsNullOrEmpty(actionItem.Params[Const_Guid].Value) &&
                (installedPak == null ||
                 (!string.IsNullOrEmpty(actionItem.Params[Const_Version].Value) && installedPak.GeneralInfo.Version.CompareTo(VersionInfo.Parse(actionItem.Params[Const_Version].Value)) < 0)))
            {
                // we don't want incompatible versions
                MpeInstaller.KnownExtensions.HideByDependencies();
                PackageClass knownPackage = MpeInstaller.KnownExtensions.Get(actionItem.Params[Const_Guid].Value);
                if (knownPackage == null && (DateTime.Now - ApplicationSettings.Instance.LastUpdate).TotalHours > 12)
                {
                    // package unknown and last download of update info was over 12 hours ago -> update the list first
                    ExtensionUpdateDownloader.UpdateList(false, false, null, null);
                    // search for the package again - we don't want incompatible versions
                    MpeInstaller.KnownExtensions.HideByDependencies();
                    knownPackage = MpeInstaller.KnownExtensions.Get(actionItem.Params[Const_Guid].Value);
                }
                if (knownPackage != null)
                {
                    // make sure the package has at least the asked version
                    if (knownPackage.GeneralInfo.Version.CompareTo(new Version(actionItem.Params[Const_Version].Value)) >= 0)
                    {
                        // download extension package
                        string newPackageLoacation = ExtensionUpdateDownloader.GetPackageLocation(knownPackage, null, null);
                        if (File.Exists(newPackageLoacation))
                        {
                            embeddedPackage = new PackageClass().ZipProvider.Load(newPackageLoacation);
                        }
                    }
                }
            }

            if (embeddedPackage == null) // no package was embedded or downloaded
            {
                return(SectionResponseEnum.Ok);
            }

            if (ItemProcessed != null)
            {
                ItemProcessed(this, new InstallEventArgs("Install extension " + embeddedPackage.GeneralInfo.Name));
            }

            if (installedPak != null)
            {
                // uninstall previous version, if the new package has the setting to force uninstall of previous version on update
                if (embeddedPackage.GeneralInfo.Params[ParamNamesConst.FORCE_TO_UNINSTALL_ON_UPDATE].GetValueAsBool())
                {
                    installedPak.Silent        = true;
                    installedPak.UnInstallInfo = new UnInstallInfoCollection(installedPak);
                    installedPak.UnInstallInfo = installedPak.UnInstallInfo.Load();
                    if (installedPak.UnInstallInfo == null)
                    {
                        installedPak.UnInstallInfo = new UnInstallInfoCollection();
                    }
                    installedPak.UnInstall();
                    embeddedPackage.CopyGroupCheck(installedPak);
                    installedPak = null;
                }
            }

            embeddedPackage.Silent = actionItem.Params[Const_Silent].GetValueAsBool();
            if (embeddedPackage.StartInstallWizard())
            {
                if (installedPak != null)
                {
                    MpeCore.MpeInstaller.InstalledExtensions.Remove(installedPak);
                    MpeCore.MpeInstaller.Save();
                }
            }
            return(SectionResponseEnum.Ok);
        }