コード例 #1
0
 private void AddToActiveHandlers(PluginHandler handler)
 {
     PluginHandler existingHandler;
     if (handlers.TryGetValue(handler.ID, out existingHandler)) {
         logger.Info("Plugin handler conflict - handler {0} [{1}] will replace {2} [{3}]", handler.PluginName, handler.ID, existingHandler.PluginName, existingHandler.ID);
         AddToInactiveHandlers(existingHandler);
     }
     handlers[handler.ID] = handler;
 }
コード例 #2
0
 private void AddToInactiveHandlers(PluginHandler handler)
 {
     naHandlers.Add(handler);
 }
コード例 #3
0
ファイル: SubCentralGUI.cs プロジェクト: oetspoker/subcentral
        private bool CheckMediaForSubtitlesOnOpen(PluginHandler properHandler, bool questionsOnly)
        {
            bool resultContinue = true;

            if (properHandler == null) return resultContinue;

            if (!_checkMediaForSubtitlesOnOpenDone) {
                _subtitlesExistForCurrentMedia = SubCentralUtils.MediaHasSubtitles(properHandler.MediaDetail.Files, true, properHandler.GetEmbeddedSubtitles(), false, ref _subtitleFilesForCurrentMedia);
                _mediaAvailable = FileUtils.mediaIsAvailable(properHandler.MediaDetail.Files);
                _checkMediaForSubtitlesOnOpenDone = true;
            }

            if (_subtitlesExistForCurrentMedia && !properHandler.GetHasSubtitles(false) && properHandler.Type == PluginHandlerType.BASIC) {
                AskAndTrueHasSubtitles(properHandler, Localization.MediaWrongMarkNoSubtitles, false);
            }
            else if (!questionsOnly && _subtitlesExistForCurrentMedia) {
                //GUIUtils.ShowNotifyDialog(Localization.Warning, string.Format(Localization.MediaHasSubtitles, CurrentHandler == null ? Localization.ExternalPlugin : CurrentHandler.PluginName));
                GUIUtils.ShowNotifyDialog(Localization.Warning, Localization.MediaHasSubtitles);
            }
            else if (!_subtitlesExistForCurrentMedia && properHandler.GetHasSubtitles(false)) {
                AskAndFalseHasSubtitles(properHandler, Localization.MediaWrongMarkHasSubtitles, false);
                resultContinue = false;
            }

            return resultContinue;
        }
コード例 #4
0
ファイル: SubCentralGUI.cs プロジェクト: oetspoker/subcentral
 private void AskAndTrueHasSubtitles(PluginHandler properHandler, string baseText, bool defaultYes)
 {
     string question = baseText;
     if (GUIUtils.ShowYesNoDialog(Localization.Warning, string.Format(question, properHandler == null ? Localization.ExternalPlugin : properHandler.PluginName), defaultYes)) {
         foreach (FileInfo fi in properHandler.MediaDetail.Files) {
             properHandler.SetHasSubtitles(fi.FullName, true);
         }
     }
     _subtitlesExistForCurrentMedia = true;
 }
コード例 #5
0
ファイル: SubCentralGUI.cs プロジェクト: oetspoker/subcentral
 private bool CheckMediaForSubtitlesOnOpen(PluginHandler properHandler)
 {
     return CheckMediaForSubtitlesOnOpen(properHandler, false);
 }
コード例 #6
0
ファイル: SubCentralGUI.cs プロジェクト: oetspoker/subcentral
 private void AskAndFalseHasSubtitles(PluginHandler properHandler, string baseText, bool defaultYes)
 {
     string question = baseText;
     if (!_mediaAvailable && properHandler.GetEmbeddedSubtitles() < 0)
         question += "\n" + Localization.MediaMaybeInternalSubtitles;
     if (GUIUtils.ShowYesNoDialog(Localization.Warning, string.Format(question, properHandler == null ? Localization.ExternalPlugin : properHandler.PluginName), defaultYes)) {
         foreach (FileInfo fi in properHandler.MediaDetail.Files) {
             properHandler.SetHasSubtitles(fi.FullName, false);
         }
     }
     _subtitlesExistForCurrentMedia = false;
 }
コード例 #7
0
ファイル: SubCentralGUI.cs プロジェクト: oetspoker/subcentral
        protected override void OnPageLoad()
        {
            _GUIInitialized = false;
            _currentHandler = null;
            _backupHandler = null;
            _backupHandlerSet = false;
            _shouldDeleteButtonVisible = false;
            _clearedMedia = false;
            _subtitleFilesForCurrentMedia.Clear();
            _subtitlesExistForCurrentMedia = false;
            _mediaAvailable = false;
            _checkMediaForSubtitlesOnOpenDone = false;
            View = ViewMode.NONE;
            ModifySearchSearchType = SubtitlesSearchType.NONE;
            _oldModifySearchSearchType = SubtitlesSearchType.NONE;
            ListControlViewState = ListControlViewState.GROUPSANDPROVIDERS;

            _subtitlesSortMethod = Settings.SettingsManager.Properties.GUISettings.SortMethod;
            _subtitlesSortAsc = Settings.SettingsManager.Properties.GUISettings.SortAscending;

            GUIUtils.SetProperty("#currentmodule", SubCentralUtils.PluginName());

            //if (searchButton == null) {
            if (!CheckAndTranslateSkin()) {
                // if the component didn't load properly we probably have a bad skin file
                GUIUtils.ShowOKDialog(Localization.Error, Localization.CannotLoadSkin);
                GUIWindowManager.ShowPreviousWindow();
                logger.Error("Failed to load all components from skin file. Skin is outdated or invalid.");
                return;
            }
            // test SubtitleDownloader assembly
            if (!core.SubtitleDownloaderInitialized) {
                GUIUtils.ShowOKDialog(Localization.Error, string.Concat(Localization.UnableToLoadSubtitleDownloader, "\n", Localization.SubtitleDownloaderUnavailable));
                GUIWindowManager.ShowPreviousWindow();
                logger.Error("SubtitleDownloader: not available");
                return;
            }

            base.OnPageLoad();
            _GUIInitialized = true;

            GUIControl.DisableControl(GetID, deleteButton.GetID);

            if (sortButton != null)
                sortButton.SortChanged += new SortEventHandler(OnSortChanged);

            // initialize properties
            InitSearchProperties();

            // initialize list control
            _lastSelectedGroupsAndProvidersItemIndex = 0;
            _lastSelectedSubtitlesItemIndex = 1;
            FillProviderGroupsAndProviders(false);

            // get last active module
            int lastActiveWindow = GUIWindowManager.GetPreviousActiveWindow();

            // just entering from the home or basic home or plugins screen, show the main screen
            if (MainWindowIDs.Contains(lastActiveWindow)) {
                logger.Debug("Entered plugin from Home or Basic Home or Plugins screen");
                View = ViewMode.MAIN;
                CurrentHandler = null;
            }

            // entering from a plugin
            else {
                //try to load data from it and if we fail return back to the calling plugin.
                if (!LoadFromPlugin(lastActiveWindow)) {
                    logger.Error("Entered plugin from ID #{0}, but failed to load an appropriate handler.", lastActiveWindow);

                    // show a popup notifying the user
                    if (!GUIUtils.ShowCustomYesNoDialog(Localization.Warning, string.Format(Localization.UnableToImportDataFrom, CurrentHandler == null ? Localization.ExternalPlugin : CurrentHandler.PluginName), Localization.ManualSearch, Localization.Back)) {
                        GUIWindowManager.ShowPreviousWindow();
                        return;
                    }
                    //View = ViewMode.MAIN;
                    OnModifySearch();
                }

                // we loaded details successfully, we are now in file view.
                else {
                    logger.Debug("Entered plugin from {0} ({1})", CurrentHandler.PluginName, CurrentHandler.ID);
                    SubtitlesSearchType searchType = SubCentralUtils.getSubtitlesSearchTypeFromMediaDetail(CurrentHandler.MediaDetail);
                    View = ViewMode.SEARCH;

                    //if (searchType != SubtitlesSearchType.NONE)
                    {
                        EnableDisableProviderGroupsAndProviders(searchType != SubtitlesSearchType.NONE);

                        if (CurrentHandler.MediaDetail.Files != null && CurrentHandler.MediaDetail.Files.Count > 0) {
                          _shouldDeleteButtonVisible = true;
                          GUIControl.EnableControl(GetID, deleteButton.GetID);
                        }

                        if (Settings.SettingsManager.Properties.GUISettings.CheckMediaForSubtitlesOnOpen) {
                            CheckMediaForSubtitlesOnOpen(CurrentHandler);
                        }

                        if (Settings.SettingsManager.Properties.GeneralSettings.PluginLoadWithSearchData == OnPluginLoadWithSearchData.SearchDefaults) {
                            SettingsGroup defaultGroup = SubCentralUtils.getDefaultGroupForSearchType(searchType);
                            if (defaultGroup != null) {
                                _lastSelectedGroupsAndProvidersItemIndex = LocateGroupInListControl(defaultGroup);
                                PerformSearch(defaultGroup);
                            }
                        }
                    }
                }
            }
        }
コード例 #8
0
ファイル: SubCentralGUI.cs プロジェクト: oetspoker/subcentral
        private void RevertModifySearch(bool revertProviderList)
        {
            CurrentHandler.Clear();
            ModifySearchSearchType = SubtitlesSearchType.NONE;
            _oldModifySearchSearchType = SubtitlesSearchType.NONE;
            CurrentHandler = _backupHandler;
            _lastSelectedGroupsAndProvidersItemIndex = 0;
            if (_shouldDeleteButtonVisible)
                GUIControl.EnableControl(GetID, deleteButton.GetID);
            else
                GUIControl.DisableControl(GetID, deleteButton.GetID);

            if (CurrentHandler == null) {
                View = ViewMode.MAIN;
                return;
            }
            //else if (SubCentralUtils.getSubtitlesSearchTypeFromMediaDetail(CurrentHandler.MediaDetail) != SubtitlesSearchType.NONE) {
            if (revertProviderList) {
                if (getRealCurrentSearchSearchType(CurrentHandler.MediaDetail) != SubtitlesSearchType.NONE) {
                    FillProviderGroupsAndProviders(true);
                }
                else {
                    FillProviderGroupsAndProviders(false);
                }
            }
            View = ViewMode.SEARCH;
        }
コード例 #9
0
ファイル: SubCentralGUI.cs プロジェクト: oetspoker/subcentral
        private void OnModifySearch()
        {
            if (CurrentHandler == null && SubCentralUtils.getEnabledAndValidFoldersForMedia(null, false).Count < 1) {
                GUIUtils.ShowOKDialog(Localization.Warning, Localization.CannotUseManualSearch);
                return;
            }

            ManualSearchHandler manualSearchHandler = core.PluginHandlers[PluginHandlerType.MANUAL] as ManualSearchHandler;

            // copy data from current handler
            if (CurrentHandler != manualSearchHandler && CurrentHandler != null) {
                manualSearchHandler.MediaDetail = CopyMediaDetail(CurrentHandler.MediaDetail);
                manualSearchHandler.Modified = false;
                manualSearchHandler.UpdateTags();
                ModifySearchSearchType = SubCentralUtils.getSubtitlesSearchTypeFromMediaDetail(manualSearchHandler.MediaDetail);
                if (ModifySearchSearchType == SubtitlesSearchType.NONE)
                    ModifySearchSearchType = SubtitlesSearchType.MOVIE;
            }
            else if (CurrentHandler != manualSearchHandler) {
                manualSearchHandler.UpdateTags();
                ModifySearchSearchType = SubtitlesSearchType.MOVIE;
            }

            _oldModifySearchSearchType = ModifySearchSearchType;

            CurrentHandler = manualSearchHandler;

            View = ViewMode.MODIFYSEARCH;
        }
コード例 #10
0
ファイル: SubCentralGUI.cs プロジェクト: oetspoker/subcentral
        private bool LoadFromPlugin(int pluginID)
        {
            bool success = false;

            // try to grab our handler
            CurrentHandler = core.PluginHandlers[pluginID];
            if (CurrentHandler != null)
                success = CurrentHandler.Update();

            return success;
        }