public MainWindow()
 {
     InitializeComponent();
     //_serviceConfig = ServiceConfigData.FromFile(ApplicationPaths.ServiceConfigFile);
     _config = ConfigData.FromFile(ApplicationPaths.ConfigFile);
     Async.Queue("Migration", () =>
     {
         Migrate25();
         Dispatcher.Invoke(DispatcherPriority.Background, (System.Windows.Forms.MethodInvoker)(() => this.Close()));
     });
 }
Exemplo n.º 2
0
        private static ConfigData GetConfig()
        {
            ConfigData config = null;
            try {
                config = ConfigData.FromFile(ApplicationPaths.ConfigFile);
            } catch (Exception ex) {
                MediaCenterEnvironment ev = Microsoft.MediaCenter.Hosting.AddInHost.Current.MediaCenterEnvironment;
                DialogResult r = ev.Dialog(ex.Message + "\nReset to default?", "Error in configuration file", DialogButtons.Yes | DialogButtons.No, 600, true);
                if (r == DialogResult.Yes) {
                    config = new ConfigData(ApplicationPaths.ConfigFile);
                    config.Save();
                } else {
                    Microsoft.MediaCenter.Hosting.AddInHost.Current.ApplicationContext.CloseApplication();

                }
            }

            return config;
        }
Exemplo n.º 3
0
        public ConfigMember(MemberInfo info, ConfigData data)
        {
            this.data = data;
            this.Info = info;
            this.Name = info.Name;
            this.Group = XmlSettings<ConfigData>.GetGroup(info);
            this.Comment = XmlSettings<ConfigData>.GetComment(info);
            this.PresentationStyle = XmlSettings<ConfigData>.GetPresentationStyle(info);
            this.IsDangerous = XmlSettings<ConfigData>.IsDangerous(info);
            if (info.MemberType == MemberTypes.Property)
            {
                this.Type = (info as PropertyInfo).PropertyType;
            }
            else if (info.MemberType == MemberTypes.Field)
            {
                this.Type = (info as FieldInfo).FieldType;
            }

        }
Exemplo n.º 4
0
 public void Migrate26()
 {
     //version 2.6 migration
     Version current = new Version(_config.MBVersion);
     if (current > new Version(2, 0) && current < new Version(2, 6))
     {
         BackupConfig(current);
         //external config
         UpgradeExternalPlayerXml();
         //set install directory and clean any bad ext players and reset image sizes
         try
         {
             _config = ConfigData.FromFile(ApplicationPaths.ConfigFile);  //re-load because ext player migration changed it
             _config.MBInstallDir = Path.GetDirectoryName(Environment.GetCommandLineArgs()[0]);
             _config.ExternalPlayers.RemoveAll(p => String.IsNullOrEmpty(p.ExternalPlayerName));
             _config.FetchedPosterSize = "w500";
             _config.FetchedBackdropSize = "w1280";
             _config.Save();
         }
         catch { }
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Detmines if a given external player configuration is configured to play:
        /// - ALL of MediaTypes supplied. This filter is ignored if an empty list is provided.
        /// - All of the VideoFormats supplied. This filter is ignored if an empty list is provided.
        /// - And is able to play the number of files requested
        /// </summary>
        public static bool CanPlay(ConfigData.ExternalPlayer externalPlayer, IEnumerable<MediaType> mediaTypes, IEnumerable<VideoFormat> videoFormats, bool isMultiFile)
        {
            // Check options to see if this is not a match
            if (Application.RunningOnExtender)
            {
                return false;
            }

            // If it's not even capable of playing multiple files in sequence, it's no good
            if (isMultiFile && !externalPlayer.SupportsMultiFileCommandArguments && !externalPlayer.SupportsPlaylists)
            {
                return false;
            }

            // If configuration wants specific MediaTypes, check that here
            // If no MediaTypes are specified, proceed
            foreach (MediaType mediaType in mediaTypes)
            {
                if (!externalPlayer.MediaTypes.Contains(mediaType))
                {
                    return false;
                }
            }

            // If configuration wants specific VideoFormats, check that here
            // If no VideoFormats are specified, proceed
            foreach (VideoFormat format in videoFormats)
            {
                if (!externalPlayer.VideoFormats.Contains(format))
                {
                    return false;
                }
            }

            return true;
        }
Exemplo n.º 6
0
        /// <summary>
        /// Determines if a given external player configuration is configured to play a list of files
        /// </summary>
        public static bool CanPlay(ConfigData.ExternalPlayer player, IEnumerable<Media> mediaList)
        {
            List<MediaType> types = new List<MediaType>();
            List<VideoFormat> formats = new List<VideoFormat>();

            foreach (Media media in mediaList)
            {
                var video = media as Video;

                if (video != null)
                {
                    if (!string.IsNullOrEmpty(video.VideoFormat))
                    {
                        VideoFormat format = (VideoFormat)Enum.Parse(typeof(VideoFormat), video.VideoFormat);
                        formats.Add(format);
                    }

                    types.Add(video.MediaType);
                }
            }

            bool isMultiFile = mediaList.Count() == 1 ? (mediaList.First().Files.Count() > 1) : (mediaList.Count() > 1);

            return CanPlay(player, types, formats, isMultiFile);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Determines if a given external player configuration is configured to play a list of files
        /// </summary>
        public static bool CanPlay(ConfigData.ExternalPlayer player, IEnumerable<string> files)
        {
            IEnumerable<MediaType> types = files.Select(f => MediaTypeResolver.DetermineType(f));

            // See if there's a configured player matching the ExternalPlayerType and MediaType.
            // We're not able to evaluate VideoFormat in this scenario
            // If none is found it will return null
            return CanPlay(player, types, new List<VideoFormat>(), files.Count() > 1);
        }
Exemplo n.º 8
0
 public static ConfigData FromFile(string file)
 {
     if (!File.Exists(file))
     {
         ConfigData d = new ConfigData(file);
         d.Save();
     }
     XmlSerializer xs = new XmlSerializer(typeof(ConfigData));
     using (FileStream fs = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.Read))
     {
         return (ConfigData)xs.Deserialize(fs);
     }
 }
Exemplo n.º 9
0
 private bool Load()
 {
     try
     {
         this.data = ConfigData.FromFile(ApplicationPaths.ConfigFile);
         return true;
     }
     catch (Exception ex)
     {
         MediaCenterEnvironment ev = Microsoft.MediaCenter.Hosting.AddInHost.Current.MediaCenterEnvironment;
         DialogResult r = ev.Dialog(ex.Message + "\n" + Application.CurrentInstance.StringData("ConfigErrorDial"), Application.CurrentInstance.StringData("ConfigErrorCapDial"), DialogButtons.Yes | DialogButtons.No, 600, true);
         if (r == DialogResult.Yes)
         {
             this.data = new ConfigData();
             Save();
             return true;
         }
         else
             return false;
     }
 }
Exemplo n.º 10
0
 public void Reset()
 {
     lock (this)
     {
         this.data = new ConfigData();
         Save();
     }
 }
Exemplo n.º 11
0
        private void Initialize()
        {
            Kernel.Init(KernelLoadDirective.ShadowPlugins);

            InitializeComponent();
            LoadComboBoxes();

            config = Kernel.Instance.ConfigData;

            infoPanel.Visibility = Visibility.Hidden;
            infoPlayerPanel.Visibility = Visibility.Hidden;

            // first time the wizard has run
            if (config.InitialFolder != ApplicationPaths.AppInitialDirPath) {
                try {
                    MigrateOldInitialFolder();
                } catch {
                    MessageBox.Show("For some reason we were not able to migrate your old initial path, you are going to have to start from scratch.");
                }
            }

            config.InitialFolder = ApplicationPaths.AppInitialDirPath;
            RefreshItems();
            RefreshPodcasts();
            RefreshPlayers();

            LoadConfigurationSettings();

            for (char c = 'D'; c <= 'Z'; c++) {
                daemonToolsDrive.Items.Add(c.ToString());
            }

            try {
                daemonToolsDrive.SelectedValue = config.DaemonToolsDrive;
            } catch {
                // someone bodged up the config
            }

            daemonToolsLocation.Content = config.DaemonToolsLocation;

            RefreshExtenderFormats();
            RefreshDisplaySettings();
            podcastDetails(false);
            SaveConfig();
        }
Exemplo n.º 12
0
 private bool Load()
 {
     try
     {
         this.data = ConfigData.FromFile(ApplicationPaths.ConfigFile);
         return true;
     }
     catch (Exception ex)
     {
         MediaCenterEnvironment ev = Microsoft.MediaCenter.Hosting.AddInHost.Current.MediaCenterEnvironment;
         DialogResult r = ev.Dialog(ex.Message + "\nReset to default?", "Error in configuration file", DialogButtons.Yes | DialogButtons.No, 600, true);
         if (r == DialogResult.Yes)
         {
             this.data = new ConfigData();
             Save();
             return true;
         }
         else
             return false;
     }
 }
Exemplo n.º 13
0
        private void Initialize()
        {
            Instance = this;
            Kernel.Init(KernelLoadDirective.ShadowPlugins);
            ratings = new Ratings();
            //Logger.ReportVerbose("======= Kernel intialized. Building window...");
            InitializeComponent();
            pluginList.MouseDoubleClick += pluginList_DoubleClicked;
            PopUpMsg = new PopupMsg(alertText);
            config = Kernel.Instance.ConfigData;
            //put this check here because it will run before the first run of MB and we need it now
            if (config.MBVersion != Kernel.Instance.Version.ToString() && Kernel.Instance.Version.ToString() == "2.3.0.0")
            {
                try
                {
                    config.PluginSources.RemoveAt(config.PluginSources.FindIndex(s => s.ToLower() == "http://www.mediabrowser.tv/plugins/plugin_info.xml"));
                }
                catch
                {
                    //wasn't there - no biggie
                }
                if (config.PluginSources.Find(s => s == "http://www.mediabrowser.tv/plugins/multi/plugin_info.xml") == null)
                {
                    config.PluginSources.Add("http://www.mediabrowser.tv/plugins/multi/plugin_info.xml");
                    Logger.ReportInfo("Plug-in Source migrated to multi-version source");
                }
                //not going to re-set version in case there is something we want to do in MB itself
            }

            //Logger.ReportVerbose("======= Loading combo boxes...");
            LoadComboBoxes();
            lblVersion.Content = lblVersion2.Content = "Version " + Kernel.Instance.VersionStr;

            //we're showing, but disabling the media collection detail panel until the user selects one
            infoPanel.IsEnabled = false;

            // first time the wizard has run
            if (config.InitialFolder != ApplicationPaths.AppInitialDirPath) {
                try {
                    MigrateOldInitialFolder();
                } catch {
                    MessageBox.Show("For some reason we were not able to migrate your old initial path, you are going to have to start from scratch.");
                }
            }

            config.InitialFolder = ApplicationPaths.AppInitialDirPath;
            //Logger.ReportVerbose("======= Refreshing Items...");
            RefreshItems();
            //Logger.ReportVerbose("======= Refreshing Podcasts...");
            RefreshPodcasts();
            //Logger.ReportVerbose("======= Refreshing Ext Players...");
            RefreshPlayers();

            //Logger.ReportVerbose("======= Loading Config Settings...");
            LoadConfigurationSettings();
            //Logger.ReportVerbose("======= Config Settings Loaded.");

            for (char c = 'D'; c <= 'Z'; c++) {
                daemonToolsDrive.Items.Add(c.ToString());
            }

            try {
                daemonToolsDrive.SelectedValue = config.DaemonToolsDrive;
            } catch {
                // someone bodged up the config
            }

            //daemonToolsLocation.Content = config.DaemonToolsLocation; /// old
            daemonToolsLocation.Text = config.DaemonToolsLocation;

            //Logger.ReportVerbose("======= Refreshing Extender Formats...");
            RefreshExtenderFormats();
            //Logger.ReportVerbose("======= Refreshing Display Settings...");
            RefreshDisplaySettings();
            //Logger.ReportVerbose("======= Podcast Details...");
            podcastDetails(false);
            //Logger.ReportVerbose("======= Saving Config...");
            SaveConfig();

            //Logger.ReportVerbose("======= Initializing Plugin Manager...");
            PluginManager.Instance.Init();
            //Logger.ReportVerbose("======= Loading Plugin List...");
            CollectionViewSource src = new CollectionViewSource();
            src.Source = PluginManager.Instance.InstalledPlugins;
            src.GroupDescriptions.Add(new PropertyGroupDescription("PluginClass"));

            pluginList.ItemsSource = src.View;

            //pluginList.Items.Refresh();

            //Logger.ReportVerbose("======= Kicking off plugin update check thread...");
            Async.Queue("Plugin Update Check", () =>
            {
                using (new MediaBrowser.Util.Profiler("Plugin update check"))
                {
                    while (!PluginManager.Instance.PluginsLoaded) { } //wait for plugins to load
                    ForceUpgradeCheck(); //remove incompatable plug-ins
                    if (PluginManager.Instance.UpgradesAvailable())
                        Dispatcher.Invoke(DispatcherPriority.Background, (System.Windows.Forms.MethodInvoker)(() =>
                        {
                            PopUpMsg.DisplayMessage("Some of your plug-ins have upgrades available.");
                        }));
                }
            });

            SupportImprovementNag();

            //Logger.ReportVerbose("======= Kicking off validations thread...");
            Async.Queue("Startup Validations", () =>
            {
                RefreshEntryPoints(false);
                ValidateMBAppDataFolderPermissions();
            });
            //Logger.ReportVerbose("======= Initialize Finised.");
        }
Exemplo n.º 14
0
        private void EditExternalPlayer(ConfigData.ExternalPlayer externalPlayer, bool isNew)
        {
            var form = new ExternalPlayerForm(isNew);
            form.Owner = this;

            form.WindowStartupLocation = WindowStartupLocation.CenterOwner;

            form.FillControlsFromObject(externalPlayer);

            if (form.ShowDialog() == true)
            {
                form.UpdateObjectFromControls(externalPlayer);

                if (isNew)
                {
                    config.ExternalPlayers.Add(externalPlayer);
                }

                SaveConfig();

                RefreshPlayers();

                lstExternalPlayers.SelectedItem = externalPlayer;
            }
        }