示例#1
0
 private void SaveEncryptedPassword()
 {
     if (!string.IsNullOrEmpty(Password))
     {
         using (MediaPortal.Profile.Settings xmlwriter = new MediaPortal.Profile.MPSettings())
         {
             xmlwriter.SetValue("radiotime", "encryptedPassword",
                                PasswordUtility.EncryptData(Password, DataProtectionScope.LocalMachine));
             xmlwriter.RemoveEntry("radiotime", "password");
         }
     }
 }
示例#2
0
        public void Load()
        {
            var passwordNeedsUpdate = false;

            using (MediaPortal.Profile.Settings xmlreader = new MediaPortal.Profile.MPSettings())
            {
                Mp3            = xmlreader.GetValueAsBool("radiotime", "mp3", true);
                Wma            = xmlreader.GetValueAsBool("radiotime", "wma", true);
                Real           = xmlreader.GetValueAsBool("radiotime", "real", false);
                ShowPresets    = xmlreader.GetValueAsBool("radiotime", "showpresets", false);
                UseVideo       = xmlreader.GetValueAsBool("radiotime", "UseVideo", false);
                JumpNowPlaying = xmlreader.GetValueAsBool("radiotime", "JumpNowPlaying", false);
                User           = xmlreader.GetValueAsString("radiotime", "user", string.Empty);
                var encryptedPassword = xmlreader.GetValueAsString("radiotime", "encryptedPassword", string.Empty);
                if (!string.IsNullOrEmpty(encryptedPassword))
                {
                    {
                        Password = PasswordUtility.DecryptData(encryptedPassword, DataProtectionScope.LocalMachine);
                        if (string.IsNullOrEmpty(Password))
                        {
                            Password = string.Empty;
                        }
                    }
                }
                else
                {
                    Password            = xmlreader.GetValueAsString("radiotime", "password", string.Empty);
                    passwordNeedsUpdate = true;
                }
                FolderId            = xmlreader.GetValueAsString("radiotime", "FolderId", string.Empty);
                PluginName          = xmlreader.GetValueAsString("radiotime", "pluginname", "RadioTime");
                StartWithFastPreset = xmlreader.GetValueAsBool("radiotime", "StartWithFastPreset", false);

                SearchHistory.Clear();
                ArtistSearchHistory.Clear();
                var searchs = xmlreader.GetValueAsString("radiotime", "searchHistory", "");
                if (!string.IsNullOrEmpty(searchs))
                {
                    var array = searchs.Split('|');
                    for (var i = 0; i < array.Length && i < 25; i++)
                    {
                        if (!string.IsNullOrEmpty(array[i]))
                        {
                            SearchHistory.Add(array[i]);
                        }
                    }
                }

                searchs = xmlreader.GetValueAsString("radiotime", "artistSearchHistory", "");
                if (!string.IsNullOrEmpty(searchs))
                {
                    var array = searchs.Split('|');
                    for (var i = 0; i < array.Length && i < 25; i++)
                    {
                        if (!string.IsNullOrEmpty(array[i]))
                        {
                            ArtistSearchHistory.Add(array[i]);
                        }
                    }
                }


                PartnerId = "41";
            }

            if (passwordNeedsUpdate)
            {
                SaveEncryptedPassword();
            }
        }