Exists() public static method

public static Exists ( System.Guid pluginId ) : bool
pluginId System.Guid
return bool
Ejemplo n.º 1
0
 public static Panel GetFindNewPanel(Guid pluginID, object view)
 {
     if (Provider.Exists(pluginID))
     {
         findNewPluginInst = Provider.GetFromId(pluginID).CreateInstance();
         findNewPluginInst.FindNewException  += FindNewPluginInst_FindNewException;
         findNewPluginInst.FindNewViewChange += FindNewPluginInst_FindNewViewChange;
         findNewPluginInst.FoundNew          += FindNewPluginInst_FoundNew;
         return(findNewPluginInst.GetFindNewPanel(view));
     }
     else
     {
         return(new Panel());
     }
 }
Ejemplo n.º 2
0
        private void DownloadProgThread()
        {
            if (this.Progress != null)
            {
                // Raise a progress event to give the user some feedback
                this.Progress(this.episodeInfo.Epid, 0, ProgressType.Downloading);
            }

            if (!Provider.Exists(this.pluginId))
            {
                this.DownloadError(ErrorType.LocalProblem, "The plugin provider required to download this episode is not currently available.  Please try updating the Radio Downloader providers or cancelling the download.");
                return;
            }

            lock (this.pluginInstanceLock)
            {
                this.pluginInstance           = Provider.GetFromId(this.pluginId).CreateInstance();
                this.pluginInstance.Progress += this.DownloadPluginInst_Progress;
            }

            string finalName, fileExtension;

            try
            {
                string saveLocation;

                try
                {
                    saveLocation = FileUtils.GetSaveFolder();
                }
                catch (DirectoryNotFoundException)
                {
                    this.DownloadError(ErrorType.LocalProblem, "Your chosen location for saving downloaded programmes no longer exists.  Select a new one under Options -> Main Options.");
                    return;
                }

                const int FreeMb         = 250;
                ulong     availableSpace = OsUtils.PathAvailableSpace(saveLocation);

                if (availableSpace <= FreeMb * 1024 * 1024)
                {
                    this.DownloadError(ErrorType.LocalProblem, "Your chosen location for saving downloaded programmes does not have enough free space.  Make sure that you have at least " + FreeMb.ToString(CultureInfo.CurrentCulture) + " MB free, or select a new location under Options -> Main Options.");
                    return;
                }

                try
                {
                    finalName = Model.Download.FindFreeSaveFileName(Settings.FileNameFormat, this.progInfo, this.episodeInfo, saveLocation);
                }
                catch (IOException ioExp)
                {
                    this.DownloadError(ErrorType.LocalProblem, "Encountered an error generating the download file name.  " + ioExp.Message + "  You may need to select a new location for saving downloaded programmes under Options -> Main Options.");
                    return;
                }
                catch (UnauthorizedAccessException unAuthExp)
                {
                    this.DownloadError(ErrorType.LocalProblem, "Encountered a permissions problem generating the download file name.  " + unAuthExp.Message + "  You may need to select a new location for saving downloaded programmes under Options -> Main Options.");
                    return;
                }

                fileExtension = this.pluginInstance.DownloadProgramme(this.progExtId, this.episodeExtId, this.providerProgInfo, this.providerEpisodeInfo, finalName);
            }
            catch (DownloadException downloadExp)
            {
                if (downloadExp.ErrorType == ErrorType.UnknownError)
                {
                    this.DownloadError(downloadExp);
                }
                else
                {
                    this.DownloadError(downloadExp.ErrorType, downloadExp.Message);
                }

                return;
            }
            catch (Exception unknownExp)
            {
                this.DownloadError(unknownExp);
                return;
            }

            if (this.cancelled)
            {
                this.cancelResponse = true;
            }

            finalName += "." + fileExtension;

            lock (Database.DbUpdateLock)
            {
                Model.Download.SetComplete(this.episodeInfo.Epid, finalName);
                Model.Programme.SetLatestDownload(this.progInfo.Progid, this.episodeInfo.Date);
            }

            // Remove single episode subscriptions
            if (Model.Subscription.IsSubscribed(this.progInfo.Progid))
            {
                if (this.progInfo.SingleEpisode)
                {
                    Model.Subscription.Remove(this.progInfo.Progid);
                }
            }

            if (!string.IsNullOrEmpty(Settings.RunAfterCommand))
            {
                try
                {
                    // Use VB Interaction.Shell as Process.Start doesn't give the option of a non-focused window
                    // The "comspec" environment variable gives the path to cmd.exe
                    Microsoft.VisualBasic.Interaction.Shell("\"" + Environment.GetEnvironmentVariable("comspec") + "\" /c " + Settings.RunAfterCommand.Replace("%file%", finalName), Microsoft.VisualBasic.AppWinStyle.NormalNoFocus);
                }
                catch
                {
                    // Just ignore the error, as it just means that something has gone wrong with the run after command.
                }
            }

            this.DownloadFinished();
        }