public static void DoChangeUser(string scrobbleUser_, string scrobblePassword_) { olduser = username; oldpass = password; if (username != scrobbleUser_) { queue.Save(); queue = null; MD5Response = String.Empty; string tmpPass = String.Empty; try { EncryptDecrypt Crypter = new EncryptDecrypt(); tmpPass = Crypter.Decrypt(scrobblePassword_); } catch (Exception ex) { Log.Warn("Audioscrobbler: warning on password decryption {0}", ex.Message); } username = scrobbleUser_; password = tmpPass; using (Settings xmlwriter = new MPSettings()) { xmlwriter.SetValue("audioscrobbler", "user", username); } DoHandshake(true, HandshakeType.ChangeUser); } }
private static void LoadSettings() { using (Settings xmlreader = new MPSettings()) { username = xmlreader.GetValueAsString("audioscrobbler", "user", String.Empty); _recordToProfile = xmlreader.GetValueAsBool("audioscrobbler", "submitradiotracks", true); _artistPrefixes = xmlreader.GetValueAsString("musicfiles", "artistprefixes", "The, Les, Die"); _artistsStripped = xmlreader.GetValueAsBool("musicfiles", "stripartistprefixes", false); _getLastfmCover = xmlreader.GetValueAsBool("musicmisc", "fetchlastfmcovers", true); _switchArtist = xmlreader.GetValueAsBool("musicmisc", "switchArtistOnLastFMSubmit", false); string tmpPass; tmpPass = MusicDatabase.Instance.AddScrobbleUserPassword( Convert.ToString(MusicDatabase.Instance.AddScrobbleUser(username)), String.Empty); _useDebugLog = (MusicDatabase.Instance.AddScrobbleUserSettings( Convert.ToString(MusicDatabase.Instance.AddScrobbleUser(username)), "iDebugLog", -1) == 1) ? true : false; if (tmpPass != string.Empty) { try { EncryptDecrypt Crypter = new EncryptDecrypt(); password = Crypter.Decrypt(tmpPass); } catch (Exception ex) { Log.Error("Audioscrobbler: Password decryption failed {0}", ex.Message); } } } queue = new AudioscrobblerQueue(Config.GetFile(Config.Dir.Database, "LastFmCache-" + Username + ".xml")); queueLock = new Object(); submitLock = new Object(); lastHandshake = DateTime.MinValue; handshakeInterval = new TimeSpan(0, HANDSHAKE_INTERVAL, 0); handshakeRadioInterval = new TimeSpan(0, 5 * HANDSHAKE_INTERVAL, 0); // Radio is session based - no need to re-handshake soon lastConnectAttempt = DateTime.MinValue; minConnectWaitTime = new TimeSpan(0, 0, CONNECT_WAIT_TIME); _cookies = new CookieContainer(); _radioStreamLocation = string.Empty; _radioSession = string.Empty; _subscriber = false; _currentSong = new Song(); _currentPostSong = new Song(); }