示例#1
0
        private void OpenMpDirectory(Config.Dir dir)
        {
            Process process = new Process();

            process.StartInfo.FileName        = "explorer.exe";
            process.StartInfo.Arguments       = Config.GetFolder(dir);
            process.StartInfo.UseShellExecute = true;
            process.Start();
        }
示例#2
0
        /// <summary>
        /// Retrieve a list of MediaPortal genres from the TV server (calls TvControl.TvServer.GetMpGenres()).
        /// </summary>
        /// <returns>List of MediaPortal genre objects</returns>
        public static List <MpGenre> GetMpGenres()
        {
            List <MpGenre> genres = new List <MpGenre>();

            try
            {
                Assembly assem = Assembly.LoadFrom(Config.GetFolder(Config.Dir.Base) + "\\TvControl.dll");
                if (assem != null)
                {
                    Type[] types = assem.GetExportedTypes();
                    foreach (Type exportedType in types)
                    {
                        try
                        {
                            if (exportedType.Name == "TvServer")
                            {
                                // Execute the remote method call to the tv server.
                                Object exportedObject = null;
                                exportedObject = Activator.CreateInstance(exportedType);
                                MethodInfo methodInfo = exportedType.GetMethod("GetMpGenres",
                                                                               BindingFlags.Public | BindingFlags.Instance);
                                List <MpGenre> result = methodInfo.Invoke(exportedObject, null) as List <MpGenre>;
                                if (result != null)
                                {
                                    genres = result;
                                }
                                break;
                            }
                        }
                        catch (TargetInvocationException ex)
                        {
                            Log.Error("GetMpGenres: Failed to load program genres {0}", ex.ToString());
                        }
                        catch (Exception gex)
                        {
                            Log.Error("GetMpGenres: Failed to load settings {0}", gex.Message);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error("GetMpGenres: Exception loading TvControl assembly - {0}", ex);
            }
            return(genres);
        }
示例#3
0
 /// <summary>
 /// Retrieves the tv database connection string and provider from the Tv server
 /// Calls TvControl.TvServer.GetDatabaseConnectionString().
 /// </summary>
 /// <param name="connectionString">The database connection string</param>
 /// <param name="provider">The database default provider</param>
 public static void GetDatabaseConnectionString(out string connectionString, out string provider)
 {
     connectionString = null;
     provider         = null;
     try
     {
         Assembly assem = Assembly.LoadFrom(Config.GetFolder(Config.Dir.Base) + "\\TvControl.dll");
         if (assem != null)
         {
             Type[] types = assem.GetExportedTypes();
             foreach (Type exportedType in types)
             {
                 try
                 {
                     if (exportedType.Name == "TvServer")
                     {
                         // Execute the remote method call to the tv server.
                         Object     exportedObject  = Activator.CreateInstance(exportedType);
                         object[]   parametersArray = new object[] { null, null };
                         MethodInfo methodInfo      = exportedType.GetMethod("GetDatabaseConnectionString",
                                                                             BindingFlags.Public | BindingFlags.Instance);
                         methodInfo.Invoke(exportedObject, parametersArray);
                         connectionString = (string)parametersArray[0];
                         provider         = (string)parametersArray[1];
                         break;
                     }
                 }
                 catch (TargetInvocationException ex)
                 {
                     Log.Error("GetDatabaseConnectionString: Failed to load the database connection string {0}", ex.ToString());
                 }
                 catch (Exception gex)
                 {
                     Log.Error("GetDatabaseConnectionString: Failed to load settings {0}", gex.Message);
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Log.Error("GetDatabaseConnectionString: Exception loading TvControl assembly - {0}", ex);
     }
 }
示例#4
0
        public Startup(string[] arguments)
        {
            Thread.CurrentThread.Name     = "Config Main";
            Thread.CurrentThread.Priority = ThreadPriority.AboveNormal;

            // Logger should write into Configuration.log
            Log.SetConfigurationMode();
            Log.BackupLogFile(LogType.Config);

            FileVersionInfo versionInfo = FileVersionInfo.GetVersionInfo(Application.ExecutablePath);

            Log.Info("Configuration v" + versionInfo.FileVersion + " is starting up on " + OSInfo.OSInfo.GetOSDisplayVersion());
#if DEBUG
            Log.Info("Debug build: " + Application.ProductVersion);
#else
            Log.Info("Build: " + Application.ProductVersion);
#endif

            //Check for unsupported operating systems
            OSPrerequisites.OSPrerequisites.OsCheck(true);

            Log.Info("Verifying DirectX 9");
            if (!DirectXCheck.IsInstalled())
            {
                string strLine = "Please install a newer DirectX 9.0c redist!\r\n";
                strLine = strLine + "MediaPortal cannot run without DirectX 9.0c redist (August 2008)\r\n";
                strLine = strLine + "http://install.team-mediaportal.com/DirectX";
                MessageBox.Show(strLine, "MediaPortal", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            Log.Info("Using Directories:");
            foreach (string options in Enum.GetNames(typeof(Config.Dir)))
            {
                Log.Info("{0} - {1}", options, Config.GetFolder((Config.Dir)Enum.Parse(typeof(Config.Dir), options)));
            }

            // rtv: disabled Wizard due to frequent bug reports on serveral sections.
            // please fix those before re-enabling.
            //
            //if (!File.Exists(Config.GetFile(Config.Dir.Config, "mediaportal.xml")))
            //  startupMode = StartupMode.Wizard;
            //else
            if (arguments != null)
            {
                foreach (string argument in arguments)
                {
                    string trimmedArgument = argument.ToLower();

                    if (trimmedArgument.StartsWith("/wizard"))
                    {
                        //startupMode = StartupMode.Wizard;
                        //Log.Debug("Startup: Argument did request Wizard mode - {0}", trimmedArgument);
                        Log.Warn("Startup: Wizard mode invoked but currently disabled: argument ignored!");
                    }

                    if (trimmedArgument.StartsWith("/section"))
                    {
                        string[] subArguments = argument.Split('=');

                        if (subArguments.Length >= 2)
                        {
                            sectionsConfiguration = subArguments[1];
                        }
                    }

                    //  deploymode used to upgrade the configuration files
                    if (trimmedArgument == "--deploymode")
                    {
                        Log.Info("Running in deploy mode - upgrading config file");

                        try
                        {
                            ISettingsProvider mpConfig = new XmlSettingsProvider(MPSettings.ConfigPathName);
                            SettingsUpgradeManager.Instance.UpgradeToLatest(mpConfig);
                        }
                        catch (Exception ex)
                        {
                            Log.Error("Unhandled exception when upgrading config file '" + MPSettings.ConfigPathName + "'\r\n\r\n" + ex.ToString());
                        }
                        finally
                        {
                            _preventGUILaunch = true;
                        }
                    }

                    if (trimmedArgument == "/debugoptions")
                    {
                        _debugOptions = true;
                    }

                    if (trimmedArgument.ToLowerInvariant() == "/avoidversioncheck")
                    {
                        _avoidVersionChecking = true;
                        Log.Warn("Version check is disabled by command line switch \"/avoidVersionCheck\"");
                    }
                }
            }
        }
示例#5
0
        /// <summary>
        ///
        /// </summary>
        public void Start()
        {
            //  If the application GUI shouldn't be loaded
            if (_preventGUILaunch)
            {
                return;
            }

            using (ProcessLock processLock = new ProcessLock(configMutex))
            {
                if (processLock.AlreadyExists)
                {
                    Log.Warn("Main: Configuration is already running");
                    Win32API.ActivatePreviousInstance();
                }

                // Check for a MediaPortal Instance running and don't allow Configuration to start
                using (ProcessLock mpLock = new ProcessLock(mpMutex))
                {
                    if (mpLock.AlreadyExists)
                    {
                        DialogResult dialogResult = MessageBox.Show(
                            "MediaPortal has to be closed for configuration.\nClose MediaPortal and start Configuration?",
                            "MediaPortal", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                        if (dialogResult == DialogResult.Yes)
                        {
                            Util.Utils.KillProcess("Watchdog");
                            Util.Utils.KillProcess("MediaPortal");
                            Log.Info("MediaPortal closed, continue running Configuration.");
                        }
                        else
                        {
                            Log.Warn("Main: MediaPortal is running - start of Configuration aborted");
                            return;
                        }
                    }
                }

                string MpConfig = Assembly.GetExecutingAssembly().Location;
#if !DEBUG
                // Check TvPlugin version
                string tvPlugin = Config.GetFolder(Config.Dir.Plugins) + "\\Windows\\TvPlugin.dll";
                if (File.Exists(tvPlugin) && !_avoidVersionChecking)
                {
                    string tvPluginVersion = FileVersionInfo.GetVersionInfo(tvPlugin).ProductVersion;
                    string CfgVersion      = FileVersionInfo.GetVersionInfo(MpConfig).ProductVersion;
                    if (CfgVersion != tvPluginVersion)
                    {
                        string strLine = "TvPlugin and MediaPortal don't have the same version.\r\n";
                        strLine += "Please update the older component to the same version as the newer one.\r\n";
                        strLine += "MpConfig Version: " + CfgVersion + "\r\n";
                        strLine += "TvPlugin Version: " + tvPluginVersion;
                        MessageBox.Show(strLine, "MediaPortal", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        Log.Info(strLine);
                        return;
                    }
                }
#endif

                FileInfo mpFi = new FileInfo(MpConfig);
                Log.Info("Assembly creation time: {0} (UTC)", mpFi.LastWriteTimeUtc.ToUniversalTime());

                Form applicationForm = null;

                Thumbs.CreateFolders();

                switch (startupMode)
                {
                case StartupMode.Normal:
                    Log.Info("Create new standard setup");
                    applicationForm = new SettingsForm(_debugOptions);
                    break;
                }

                if (applicationForm != null)
                {
                    Log.Info("start application");
                    Application.Run(applicationForm);
                }
            }
        }
示例#6
0
        /// <summary>
        /// Upgrades the specified settings collection to the latest structure
        /// </summary>
        /// <param name="settings"></param>
        internal void UpgradeToLatest(ISettingsProvider settings)
        {
            // Deleted entries
            RemoveEntry(settings, "general", "rtllang");
            RemoveEntry(settings, "dvdplayer", "autoplay");
            RemoveEntry(settings, "audioplayer", "autoplay");
            RemoveEntry(settings, "musicfiles", "showid3");
            RemoveEntry(settings, "musicfiles", "showSortButton");
            RemoveEntry(settings, "musicmisc", "enqueuenext");
            RemoveEntry(settings, "plugins", "Burner");
            RemoveEntry(settings, "plugins", "VideoEditor");
            RemoveEntry(settings, "plugins", "Foobar2000");
            RemoveEntry(settings, "plugins", "AutoCropper");
            RemoveEntry(settings, "plugins", "ISDN Caller-ID");
            RemoveEntry(settings, "plugins", "YAC Caller-ID");
            RemoveEntry(settings, "plugins", "MAME Devices");
            RemoveEntry(settings, "home", "Burner");
            RemoveEntry(settings, "home", "VideoEditor");
            RemoveEntry(settings, "myplugins", "Burner");
            RemoveEntry(settings, "myplugins", "VideoEditor");
            RemoveEntry(settings, "pluginswindows", "MediaPortal.GUI.GUIBurner.GUIBurner");
            RemoveEntry(settings, "pluginswindows", "WindowPlugins.VideoEditor.GUIVideoEditor");
            RemoveEntry(settings, "musicmisc", "playnowjumpto");

            // Moved entries
            MoveEntry(settings, "general", "gui", "mousesupport");
            MoveEntry(settings, "general", "gui", "hideextensions");
            MoveEntry(settings, "general", "gui", "allowRememberLastFocusedItem");
            MoveEntry(settings, "general", "gui", "myprefix");
            MoveEntry(settings, "general", "gui", "startbasichome");
            MoveEntry(settings, "general", "gui", "autosize");
            MoveEntry(settings, "general", "gui", "enableguisounds");
            MoveEntry(settings, "general", "gui", "ScrollSpeedRight");
            MoveEntry(settings, "general", "gui", "ScrollSpeedDown");
            MoveEntry(settings, "skin", "gui", "language");
            MoveEntry(settings, "general", "gui", "useonlyonehome");

            //  blue3/wide and blue4/blue4wide are now default/wide
            UpdateEntryDefaultValue(settings, "skin", "name", "Blue3", "Default");
            UpdateEntryDefaultValue(settings, "skin", "name", "Blue3wide", "DefaultWide");
            UpdateEntryDefaultValue(settings, "skin", "name", "Blue4", "Default");
            UpdateEntryDefaultValue(settings, "skin", "name", "Blue4wide", "DefaultWide");

            //Mantis 3772 - Weather.com API is not free any more
            //temporarily disable plugin
            UpdateEntryDefaultValue(settings, "pluginswindows", "MediaPortal.GUI.Weather.GUIWindowWeather", "yes", "no");
            UpdateEntryDefaultValue(settings, "plugins", "weather", "yes", "no");

            settings.Save();

            string skinbase = Config.GetFolder(Config.Dir.Skin) + "\\";

            //Zip Blue3/Blue3Wide skin folders
            string[] skins3 = { "Blue3", "Blue3Wide" };

            foreach (string skin in skins3)
            {
                if (Directory.Exists(skinbase + skin))
                {
                    Log.Info("Adding skin \"" + skinbase + skin + "\" to zip...");
                    ZipDirectory(skinbase, skin);
                }
            }

            // Delete beta Blue4/Blue4Wide and outdated Blue3/Blue3Wide folders
            string[] skins3_4 = { "Blue3", "Blue3Wide", "Blue4", "Blue4Wide" };
            foreach (string skin in skins3_4)
            {
                if (Directory.Exists(skinbase + skin))
                {
                    Log.Info("Deleting old skin \"" + skinbase + skin + "\"...");
                    Directory.Delete(skinbase + skin, true);
                }
            }
        }
        /// <summary>
        /// Upgrades the specified settings collection to the latest structure
        /// </summary>
        /// <param name="settings"></param>
        internal void UpgradeToLatest(ISettingsProvider settings)
        {
            // Deleted entries
            RemoveEntry(settings, "general", "rtllang");
            RemoveEntry(settings, "dvdplayer", "autoplay");
            RemoveEntry(settings, "audioplayer", "autoplay");
            RemoveEntry(settings, "musicfiles", "showid3");
            RemoveEntry(settings, "musicfiles", "showSortButton");
            RemoveEntry(settings, "musicmisc", "enqueuenext");
            RemoveEntry(settings, "plugins", "Burner");
            RemoveEntry(settings, "plugins", "VideoEditor");
            RemoveEntry(settings, "plugins", "Foobar2000");
            RemoveEntry(settings, "plugins", "AutoCropper");
            RemoveEntry(settings, "plugins", "ISDN Caller-ID");
            RemoveEntry(settings, "plugins", "YAC Caller-ID");
            RemoveEntry(settings, "plugins", "MAME Devices");
            RemoveEntry(settings, "plugins", "Audioscrobbler");
            RemoveEntry(settings, "plugins", "Last.fm Radio");
            RemoveEntry(settings, "home", "Burner");
            RemoveEntry(settings, "home", "VideoEditor");
            RemoveEntry(settings, "home", "Last.fm Radio");
            RemoveEntry(settings, "myplugins", "Burner");
            RemoveEntry(settings, "myplugins", "VideoEditor");
            RemoveEntry(settings, "myplugins", "Last.fm Radio");
            RemoveEntry(settings, "pluginswindows", "MediaPortal.GUI.GUIBurner.GUIBurner");
            RemoveEntry(settings, "pluginswindows", "WindowPlugins.VideoEditor.GUIVideoEditor");
            RemoveEntry(settings, "pluginswindows", "MediaPortal.GUI.RADIOLASTFM.GUIRadioLastFM");
            RemoveEntry(settings, "musicmisc", "playnowjumpto");
            RemoveEntry(settings, "gui", "autosize");
            RemoveEntry(settings, "debug", "useS3Hack");
            RemoveEntry(settings, "general", "enables3trick");
            RemoveEntry(settings, "general", "turnmonitoronafterresume");
            RemoveEntry(settings, "general", "restartonresume");
            RemoveEntry(settings, "audioplayer", "player");
            RemoveEntry(settings, "audioplayer", "asio");
            RemoveEntry(settings, "audioplayer", "asiodevice");
            RemoveEntry(settings, "audioplayer", "mixing");
            RemoveEntry(settings, "screenselector", "usescreenselector");
            RemoveEntry(settings, "audioscrobbler", "user");
            RemoveEntry(settings, "audioscrobbler", "usesimilarrandom");
            RemoveEntry(settings, "audioscrobbler", "EnableNowPlaying");
            RemoveEntry(settings, "audioscrobbler", "showtrayicon");
            RemoveEntry(settings, "audioscrobbler", "showballontips");
            RemoveEntry(settings, "audioscrobbler", "submitradiotracks");
            RemoveEntry(settings, "audioscrobbler", "directskip");
            RemoveEntry(settings, "audioscrobbler", "listentrycount");
            RemoveEntry(settings, "audioscrobbler", "streamplayertype");
            RemoveEntry(settings, "audioscrobbler", "oneclickstart");
            RemoveEntry(settings, "audioscrobbler", "usesmskeyboard");
            RemoveEntry(settings, "musicmisc", "fetchlastfmcovers");
            RemoveEntry(settings, "musicmisc", "fetchlastfmtopalbums");
            RemoveEntry(settings, "musicmisc", "lookupSimilarTracks");
            RemoveEntry(settings, "musicmisc", "switchArtistOnLastFMSubmit");
            RemoveEntry(settings, "musicfiles", "autoshuffle");

            // Moved entries
            MoveEntry(settings, "general", "gui", "mousesupport");
            MoveEntry(settings, "general", "gui", "hideextensions");
            MoveEntry(settings, "general", "gui", "allowRememberLastFocusedItem");
            MoveEntry(settings, "general", "gui", "myprefix");
            MoveEntry(settings, "general", "gui", "startbasichome");
            MoveEntry(settings, "general", "gui", "enableguisounds");
            MoveEntry(settings, "general", "gui", "ScrollSpeedRight");
            MoveEntry(settings, "general", "gui", "ScrollSpeedDown");
            MoveEntry(settings, "skin", "gui", "language");
            MoveEntry(settings, "general", "gui", "useonlyonehome");

            //  blue3/wide and blue4/blue4wide are now default/wide
            UpdateEntryDefaultValue(settings, "skin", "name", "Blue3", "Default");
            UpdateEntryDefaultValue(settings, "skin", "name", "Blue3wide", "DefaultWide");
            UpdateEntryDefaultValue(settings, "skin", "name", "Blue4", "Default");
            UpdateEntryDefaultValue(settings, "skin", "name", "Blue4wide", "DefaultWide");

            ApplyDeploySettingUpgrade(settings);

            settings.Save();

            string skinbase = Config.GetFolder(Config.Dir.Skin) + "\\";

            //Zip Blue3/Blue3Wide skin folders
            string[] skins3 = { "Blue3", "Blue3Wide" };

            foreach (string skin in skins3)
            {
                if (Directory.Exists(skinbase + skin))
                {
                    Log.Info("Adding skin \"" + skinbase + skin + "\" to zip...");
                    ZipDirectory(skinbase, skin);
                }
            }

            // Delete beta Blue4/Blue4Wide and outdated Blue3/Blue3Wide folders
            string[] skins34 = { "Blue3", "Blue3Wide", "Blue4", "Blue4Wide" };
            foreach (string skin in skins34)
            {
                if (Directory.Exists(skinbase + skin))
                {
                    Log.Info("Deleting old skin \"" + skinbase + skin + "\"...");
                    Directory.Delete(skinbase + skin, true);
                }
            }
        }