Пример #1
0
        public static void Init(KernelLoadDirective directives)
        {
            CommonConfigData config = null;

            config = CommonConfigData.FromFile(ApplicationPaths.CommonConfigFile);

            Init(directives, config);
        }
Пример #2
0
        public void Migrate300()
        {
            var knownCompatibleDlls = new List <string> {
                "BDScreenSaver.dll",
                "Chocolate.dll",
                "CoverSS.dll",
            };

            var current = new Version(_config != null ? _config.MBVersion : "2.6.2.0");

            if (current < new Version(3, 0, 0))
            {
                //Get our old directory structure
                oldPathMap             = new Dictionary <string, string>();
                oldPathMap["app_data"] = System.Environment.GetFolderPath(System.Environment.SpecialFolder.CommonApplicationData);

                BuildTree();

                //Move over external players from old config file
                var oldConfig = CommonConfigData.FromFile(Path.Combine(oldPathMap["AppConfigPath"], "MediaBrowserXml.config"));
                if (oldConfig != null && _config != null)
                {
                    _config.ExternalPlayers = oldConfig.ExternalPlayers;
                }

                //And Plugins that work
                //foreach (var dll in knownCompatibleDlls)
                //{
                //    CopyFile(Path.Combine(oldPathMap["AppPluginPath"], dll), Path.Combine(ApplicationPaths.AppPluginPath, dll));
                //}

                //And the Localization folder
                foreach (var file in Directory.GetFiles(oldPathMap["AppLocalizationPath"]))
                {
                    try
                    {
                        CopyFile(file, Path.Combine(ApplicationPaths.AppLocalizationPath, Path.GetFileName(file)));
                    }
                    catch (Exception e)
                    {
                        Logger.ReportException("Error copying file {0} to {1}", e, file, Path.Combine(ApplicationPaths.AppLocalizationPath, Path.GetFileName(file)));
                    }
                }
            }
        }
Пример #3
0
        public MainWindow()
        {
            // set up assembly resolution hooks, so earlier versions of the plugins resolve properly
            AppDomain.CurrentDomain.AssemblyResolve += Kernel.OnAssemblyResolve;

            InitializeComponent();
            //_serviceConfig = ServiceConfigData.FromFile(ApplicationPaths.ServiceConfigFile);
            Async.Queue("Migration", () =>
            {
                var mbphoto = Path.Combine(ApplicationPaths.AppPluginPath, "mbphoto.classic.dll");
                if (File.Exists(mbphoto))
                {
                    try
                    {
                        File.Delete(mbphoto);
                    }
                    catch (Exception e)
                    {
                        Logger.ReportException("Error deleting old MBPhoto plug-in", e);
                    }
                }

                const string chocolate = @"\windows\ehome\chocolate.dll";
                if (File.Exists(chocolate))
                {
                    try
                    {
                        File.Delete(chocolate);
                    }
                    catch (Exception e)
                    {
                        Logger.ReportException("Error deleting old chocolate plug-in", e);
                    }
                }

                if (File.Exists(ApplicationPaths.CommonConfigFile))
                {
                    _config = CommonConfigData.FromFile(ApplicationPaths.CommonConfigFile);
                }

                if (_config == null) // only do this if a fresh install
                {
                    try
                    {
                        _config = CommonConfigData.FromFile(ApplicationPaths.CommonConfigFile); // create a new one
                        Migrate300();
                    }
                    catch (Exception e)
                    {
                        Logger.ReportException("Error during migration", e);
                    }
                }
                if (_config != null)
                {
                    // Set install directory
                    _config.MBInstallDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase);
                    _config.Save();
                }
                Dispatcher.Invoke(DispatcherPriority.Background, (System.Windows.Forms.MethodInvoker)(Close));
            });
        }