Exemple #1
0
        /// <summary>
        /// Checks if file exists on the requested uri
        /// </summary>
        public static bool AddonFileExists(AddonDisplayObject obj)
        {
            bool         exists    = true;
            AddonsObject addon     = obj.currentDisplay.addon;
            string       useSource = string.Format(addonDownloadUrl, obj.currentDisplay.repo, addon.releaseTag, addon.file,
                                                   addon.fileVersion, addon.extension);

            Debug.WriteLine("Checking if file exists at: " + useSource);
            try
            {
                using (WebClient testClient = new WebClient())
                {
                    testClient.CachePolicy = new RequestCachePolicy(RequestCacheLevel.NoCacheNoStore);
                    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
                    Stream stream = testClient.OpenRead(useSource);
                    stream.Dispose();
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                exists = false;
            }

            return(exists);
        }
Exemple #2
0
        /// <summary>
        /// Checks if file exists on the requested uri
        /// </summary>
        public static bool AddonFileExists(AddonObject obj)
        {
            AddonDisplayObject disp = new AddonDisplayObject
            {
                currentDisplay = obj
            };

            return(AddonFileExists(disp));
        }
        public void RemoveAddon(AddonDisplayObject obj)
        {
            installedAddons.Remove(obj.currentDisplay.addon.file);

            Populate();
            //Put it back in the list
            obj.currentDisplay.isInstalled   = false;
            obj.currentDisplay.isDownloading = false;
            tabManager.AddToList(obj);
        }
        public void AddAddon(AddonDisplayObject obj)
        {
            obj.InstalledAddons = this;

            if (!installedAddons.ContainsKey(obj.currentDisplay.addon.file))             //caused by updating
            {
                installedAddons.Add(obj.currentDisplay.addon.file, obj);
                Populate();
            }
        }
Exemple #5
0
        /// <summary>
        /// Queues addon for download
        /// </summary>
        public static void Queue(AddonDisplayObject addon, DownloadProgressChangedEventHandler ProgressCallback = null)
        {
            DownloadQueueItem item = new DownloadQueueItem
            {
                ProgressCallback = ProgressCallback ?? Manager_DownloadProgressChanged, addon = addon
            };

            DownloadQueue.Add(item);

            ProcessQueue();
        }
Exemple #6
0
        /// <summary>
        /// Deletes Addon
        /// </summary>
        public static void DeleteAddon(AddonDisplayObject addonObj, bool deleteFolder = true)
        {
            AddonsObject addon = addonObj.currentDisplay.addon;

            JsonManager.RemoveFile(MainWindow.settings.TosDataFolder,
                                   string.Format(addonFileName, addon.file, addon.unicode, addon.fileVersion, addon.extension));
            if (deleteFolder)
            {
                RemoveAddonFolder(addonObj.currentDisplay.addon);
            }

            addonObj.currentDisplay.isInstalled = false;
        }
        public void GenerateList()
        {
            installedAddons = new Dictionary <string, AddonDisplayObject>();
            var _installedAddons = DownloadManager.GetInstalledAddons();

            foreach (AddonObject addon in _installedAddons)
            {
                AddonDisplayObject _instAddonDisplay = new AddonDisplayObject();

                addon.SetDefaults();

                _instAddonDisplay.currentDisplay  = addon;
                _instAddonDisplay.InstalledAddons = this;
                _instAddonDisplay.addons          = new List <AddonObject> {
                    addon
                };

                if (installedAddons.ContainsKey(addon.addon.file))
                {
                    if (installedAddons[addon.addon.file].addons == null)
                    {
                        installedAddons[addon.addon.file].addons = new List <AddonObject>();
                    }

                    //is it the same version? Technically shouldn't happen but still does
                    if (installedAddons[addon.addon.file].addons[0] == addon)
                    {
                        //Debug.WriteLine("Found same addons: " + addon.addon.file + " V1: " + installedAddons[addon.addon.file].addons[0].addon.fileVersion + " V2: " + addon.addon.fileVersion);
                        installedAddons[addon.addon.file].addons.Add(addon);
                    }
                }
                else
                {
                    installedAddons.Add(addon.addon.file, _instAddonDisplay);
                }
            }
        }
Exemple #8
0
 /// <summary>
 /// Unused
 /// </summary>
 public static void UpdateAddon(AddonDisplayObject oldAddon, AddonDisplayObject newAddon)
 {
     DeleteAddon(oldAddon, false);
     Queue(newAddon);
 }