Check for newer versions of the registered mods.
If a newer version is found, it is optionally downloaded.
		/// <summary>
		/// A simple constructor that initializes the object with its dependencies.
		/// </summary>
		/// <param name="p_AutoUpdater">The AutoUpdater.</param>
		/// <param name="p_ModRepository">The current mod repository.</param>
		/// <param name="p_lstModList">The list of mods we need to update.</param>
		/// <param name="p_booOverrideCategorySetup">Whether to force a global update.</param>
		public ModUpdateCheckTask(AutoUpdater p_AutoUpdater, IModRepository p_ModRepository, List<IMod> p_lstModList, bool p_booOverrideCategorySetup)
		{
			AutoUpdater = p_AutoUpdater;
			ModRepository = p_ModRepository;
			m_lstModList.AddRange(p_lstModList);
			m_booOverrideCategorySetup = p_booOverrideCategorySetup;
		}
Пример #2
0
		/// <summary>
		/// A simple constructor that initializes the object with its dependencies.
		/// </summary>
		/// <param name="p_gmdGameMode">The current game mode.</param>
		/// <param name="p_eifEnvironmentInfo">The application's envrionment info.</param>
		/// <param name="p_mrpModRepository">The mod repository from which to get mods and mod metadata.</param>
		/// <param name="p_dmrMonitor">The download monitor to use to track task progress.</param>
		/// <param name="p_frgFormatRegistry">The <see cref="IModFormatRegistry"/> that contains the list
		/// of supported <see cref="IModFormat"/>s.</param>
		/// <param name="p_mdrManagedModRegistry">The <see cref="ModRegistry"/> that contains the list
		/// of managed <see cref="IMod"/>s.</param>
		/// <param name="p_futFileUtility">The file utility class.</param>
		/// <param name="p_scxUIContext">The <see cref="SynchronizationContext"/> to use to marshall UI interactions to the UI thread.</param>
		/// <param name="p_ilgInstallLog">The install log tracking mod activations for the current game mode.</param>
		/// <param name="p_pmgPluginManager">The plugin manager to use to work with plugins.</param>
        private ModManager(IGameMode p_gmdGameMode, IEnvironmentInfo p_eifEnvironmentInfo, IModRepository p_mrpModRepository, DownloadMonitor p_dmrMonitor, ActivateModsMonitor p_ammMonitor, IModFormatRegistry p_frgFormatRegistry, ModRegistry p_mdrManagedModRegistry, FileUtil p_futFileUtility, SynchronizationContext p_scxUIContext, IInstallLog p_ilgInstallLog, IPluginManager p_pmgPluginManager)
		{
			GameMode = p_gmdGameMode;
			EnvironmentInfo = p_eifEnvironmentInfo;
			m_rmmReadMeManager = new ReadMeManager(EnvironmentInfo.Settings.ModFolder[GameMode.ModeId]);
			ModRepository = p_mrpModRepository;
			FormatRegistry = p_frgFormatRegistry;
			ManagedModRegistry = p_mdrManagedModRegistry;
			InstallationLog = p_ilgInstallLog;
            InstallerFactory = new ModInstallerFactory(p_gmdGameMode, p_eifEnvironmentInfo, p_futFileUtility, p_scxUIContext, p_ilgInstallLog, p_pmgPluginManager, this);
			DownloadMonitor = p_dmrMonitor;
            ActivateModsMonitor = p_ammMonitor;
			ModAdditionQueue = new AddModQueue(p_eifEnvironmentInfo, this);
			AutoUpdater = new AutoUpdater(p_mrpModRepository, p_mdrManagedModRegistry, p_eifEnvironmentInfo);
            LoginTask = new LoginFormTask(this);
		}
Пример #3
0
        /// <summary>
        /// Checks for the updated information for the given mods.
        /// </summary>
        /// <param name="p_lstModList">The mods for which to check for updates.</param>
        private void CheckForModListUpdate(List <string> p_lstModList)
        {
            OverallMessage = "Updating mods info: getting online updates...";
            List <IModInfo> mifInfo = new List <IModInfo>();

            try
            {
                //get mod info
                for (int i = 0; i <= m_intRetries; i++)
                {
                    mifInfo = ModRepository.GetModListInfo(p_lstModList);

                    if (mifInfo != null)
                    {
                        break;
                    }

                    Thread.Sleep(1000);
                }

                if (mifInfo != null)
                {
                    ItemProgress           = 0;
                    ItemProgressMaximum    = mifInfo.Count;
                    OverallProgressMaximum = OverallProgress + mifInfo.Count;

                    foreach (ModInfo modUpdate in mifInfo)
                    {
                        if (m_booCancel)
                        {
                            break;
                        }
                        if (OverallProgress < OverallProgressMaximum)
                        {
                            StepOverallProgress();
                        }

                        ItemMessage = modUpdate.ModName;

                        foreach (IMod modMod in m_lstModList.Where(x => (String.IsNullOrEmpty(modUpdate.Id) ? "0" : modUpdate.Id) == x.Id))
                        {
                            if (ItemProgress < ItemProgressMaximum)
                            {
                                StepItemProgress();
                            }

                            if (m_booMissingDownloadId)
                            {
                                string Filename = Path.GetFileName(modMod.Filename);
                                if (!String.Equals(Filename, modUpdate.FileName, StringComparison.InvariantCultureIgnoreCase))
                                {
                                    continue;
                                }
                            }
                            if (!String.IsNullOrEmpty(modMod.DownloadId) && String.IsNullOrWhiteSpace(modUpdate.DownloadId))
                            {
                                modUpdate.DownloadId = modMod.DownloadId;
                            }

                            modUpdate.CustomCategoryId     = modMod.CustomCategoryId;
                            modUpdate.UpdateWarningEnabled = modMod.UpdateWarningEnabled;
                            AutoUpdater.AddNewVersionNumberForMod(modMod, modUpdate);
                            modMod.UpdateInfo(modUpdate, null);
                            ItemProgress = 0;
                        }
                    }
                }
            }
            catch (RepositoryUnavailableException e)
            {
                Trace.WriteLine(String.Format("ModUpdateCheck FAILED: {0}", e.Message));
            }
        }
Пример #4
0
        /// <summary>
        /// The method that is called to start the backgound task.
        /// </summary>
        /// <param name="p_objArgs">Arguments to for the task execution.</param>
        /// <returns>Always <c>null</c>.</returns>
        protected override object DoWork(object[] p_objArgs)
        {
            int intModLimit = 100;

            if (m_booMissingDownloadId)
            {
                intModLimit = 100;
            }

            List <string>       ModList    = new List <string>();
            ConfirmActionMethod camConfirm = (ConfirmActionMethod)p_objArgs[0];

            OverallMessage          = "Updating mods info: setup search...";
            OverallProgress         = 0;
            OverallProgressStepSize = 1;
            ShowItemProgress        = true;
            ItemProgress            = 0;
            ItemProgressStepSize    = 1;
            ItemProgressMaximum     = 1;
            OverallProgressMaximum  = 1;

            OverallProgressMaximum = m_lstModList.Count * 2;
            ItemProgressMaximum    = (m_lstModList.Count > intModLimit) ? intModLimit : m_lstModList.Count;

            for (int i = 0; i < m_lstModList.Count; i++)
            {
                string modID          = String.Empty;
                Int32  isEndorsed     = 0;
                string strLastVersion = String.Empty;
                ItemMessage = m_lstModList[i].ModName;

                if (m_booCancel)
                {
                    break;
                }

                if (!String.IsNullOrEmpty(m_lstModList[i].Id))
                {
                    modID          = m_lstModList[i].Id;
                    isEndorsed     = m_lstModList[i].IsEndorsed == true ? 1 : (m_lstModList[i].IsEndorsed == false ? -1 : 0);
                    strLastVersion = m_lstModList[i].LastKnownVersion;
                }
                else
                {
                    try
                    {
                        IModInfo mifInfo = ModRepository.GetModInfoForFile(m_lstModList[i].Filename);

                        if (mifInfo != null)
                        {
                            modID = mifInfo.Id;
                            m_lstModList[i].Id = modID;
                            strLastVersion     = m_lstModList[i].LastKnownVersion;
                            AutoUpdater.AddNewVersionNumberForMod(m_lstModList[i], mifInfo);
                        }
                    }
                    catch (RepositoryUnavailableException)
                    {
                        //the repository is not available, so don't bother
                    }
                }

                if (!String.IsNullOrEmpty(modID))
                {
                    if (m_booMissingDownloadId)
                    {
                        ModList.Add(String.Format("{0}|{1}", modID, Path.GetFileName(m_lstModList[i].Filename)));
                    }
                    else if ((m_booOverrideCategorySetup) || (String.IsNullOrEmpty(strLastVersion)))
                    {
                        ModList.Add(String.Format("{0}", modID));
                    }
                    else
                    {
                        ModList.Add(String.Format("{0}|{1}|{2}", modID, m_lstModList[i].HumanReadableVersion, isEndorsed));
                    }
                }

                if (ItemProgress < ItemProgressMaximum)
                {
                    StepItemProgress();
                }
                if (OverallProgress < OverallProgressMaximum)
                {
                    StepOverallProgress();
                }

                if (m_booCancel)
                {
                    break;
                }

                // Prevents the repository request string from becoming too long.
                if (ModList.Count == intModLimit)
                {
                    CheckForModListUpdate(ModList);
                    ModList.Clear();
                    OverallMessage      = "Updating mods info: setup search...";
                    ItemProgress        = 0;
                    ItemProgressMaximum = (m_lstModList.Count == intModLimit) ? 1 : (m_lstModList.Count - (i + 1));
                }
            }

            if (!m_booCancel && (ModList.Count > 0))
            {
                CheckForModListUpdate(ModList);
            }

            m_lstModList.Clear();

            return(null);
        }
Пример #5
0
 /// <summary>
 /// Switches the mod category.
 /// </summary>
 /// <param name="p_modMod">The mod.</param>
 /// <param name="p_intCategoryId">The new category id.</param>
 public void SwitchModCategory(IMod p_modMod, Int32 p_intCategoryId)
 {
     AutoUpdater.SwitchModCategory(p_modMod, p_intCategoryId);
 }
Пример #6
0
 /// <summary>
 /// Toggles the endorsement for the given mod.
 /// </summary>
 /// <param name="p_modMod">The mod to endorse/unendorse.</param>
 public void ToggleModEndorsement(IMod p_modMod)
 {
     AutoUpdater.ToggleModEndorsement(p_modMod);
 }