private void buttonAddAccount_Click(object sender, RoutedEventArgs e) { EVEAccount newAccount = new EVEAccount(); EVELogin el = new EVELogin(newAccount, false); el.ShowDialog(); if (el.DialogResult.HasValue && el.DialogResult.Value) { // user clicked Go // check password... // string refreshToken; // switch (newAccount.GetRefreshToken(false, out refreshToken)) EVEAccount.Token token; EVEAccount.LoginResult lr = newAccount.GetAccessToken(false, out token); switch (lr) { case EVEAccount.LoginResult.Success: break; case EVEAccount.LoginResult.InvalidUsernameOrPassword: { MessageBox.Show("Invalid Username or Password. Account NOT added."); return; } case EVEAccount.LoginResult.Timeout: { MessageBox.Show("Timed out attempting to log in. Account NOT added."); return; } case EVEAccount.LoginResult.InvalidCharacterChallenge: { MessageBox.Show("Invalid Character Name entered, or Invalid Username or Password. Account NOT added."); return; } case EVEAccount.LoginResult.EmailVerificationRequired: // message already provided return; default: { MessageBox.Show("Failed to log in: " + lr.ToString() + ". Account NOT added."); return; } break; } EVEAccount existingAccount = App.Settings.Accounts.FirstOrDefault(q => q.Username.Equals(newAccount.Username, StringComparison.InvariantCultureIgnoreCase)); if (existingAccount != null) { // update existing account? existingAccount.Username = newAccount.Username; existingAccount.SecurePassword = newAccount.SecurePassword.Copy(); existingAccount.EncryptPassword(); if (newAccount.SecureCharacterName != null && newAccount.SecureCharacterName.Length > 0) { existingAccount.SecureCharacterName = newAccount.SecureCharacterName.Copy(); existingAccount.EncryptCharacterName(); } newAccount.Dispose(); newAccount = existingAccount; } else { // new account App.Settings.Accounts.Add(newAccount); } App.Settings.Store(); } }
void Timer_Tick(object sender, EventArgs e) { if (Accounts.Count == 0) { Stop(); return; } // determine if we're waiting on master key transfer... if (App.Settings.UseMasterKey && !App.Settings.HasPasswordMasterKey) { TimeSpan sinceKeyRequested = DateTime.Now - App.Settings.MasterKeyRequested; if (sinceKeyRequested.TotalSeconds < 2) { // waiting ... DelaySeconds = (float)Math.Truncate((2 - (float)sinceKeyRequested.TotalSeconds) * 100.0f) / 100.0f; return; } } TimeSpan SinceLastLaunch = DateTime.Now - LastLaunch; if (SinceLastLaunch.TotalSeconds < App.Settings.LaunchDelay) { // waiting ... DelaySeconds = (float)Math.Truncate((App.Settings.LaunchDelay - (float)SinceLastLaunch.TotalSeconds) * 100.0f) / 100.0f; return; } else { DelaySeconds = 0; } EVEAccount a = Accounts[0]; EVEAccount.LoginResult lr = EVEAccount.LoginResult.Error; try { lr = Launcher.LaunchAccount(a); } catch (ArgumentNullException ane) { switch (ane.ParamName) { case "sharedCachePath": { AddDetailsLine("Missing EVE SharedCachePath. Aborting!"); } break; case "ssoToken": { AddDetailsLine("Failed to retrieve SSO Token from EVE servers. Aborting!"); } break; case "gameName": { AddDetailsLine("Missing appropriate Game Profile. Aborting!"); } break; case "gameProfileName": { AddDetailsLine("Missing appropriate Game Profile. Aborting!"); } break; default: AddDetailsLine(ane.ToString()); break; } } catch (Exception ex) { AddDetailsLine(ex.ToString()); } switch (lr) { case EVEAccount.LoginResult.Success: AccountsLaunched.Add(a); Accounts.Remove(a); LastLaunch = DateTime.Now; AddDetailsLine("Account '" + a.Username + "' launched"); break; default: AddDetailsLine("Account '" + a.Username + "' failed to launch: " + lr.ToString() + ". Aborting!"); NumErrors++; Stop(); break; } }