/// <summary> /// Updates the API key. /// </summary> /// <param name="e">The <see cref="APIKeyCreationEventArgs" /> instance containing the event data.</param> /// <exception cref="System.ArgumentNullException">e</exception> public void Update(APIKeyCreationEventArgs e) { e.ThrowIfNull(nameof(e)); VerificationCode = e.VerificationCode; AccessMask = e.AccessMask; Type = e.Type; Expiration = e.Expiration; m_apiKeyInfoMonitor.UpdateWith(e.APIKeyInfo); // Notifies for the API key expiration NotifyAPIKeyExpiration(); // Clear the API key for the currently associated identities foreach (CharacterIdentity id in EveMonClient.CharacterIdentities.Where(id => id.APIKeys.Contains(this))) { id.APIKeys.Remove(this); } // Assign this API key to the new identities and create CCP characters foreach (CharacterIdentity id in e.Identities) { // Update the corporation info as they may have changed id.CorporationID = e.Identities.First(x => x.CharacterID == id.CharacterID).CorporationID; id.CorporationName = e.Identities.First(x => x.CharacterID == id.CharacterID).CorporationName; id.APIKeys.Add(this); // Skip if in the ignore list if (IdentityIgnoreList.Contains(id)) { continue; } // Retrieves the ccp character and create one if none if (id.CCPCharacter != null) { // Update the corporation info id.CCPCharacter.CorporationID = id.CorporationID; id.CCPCharacter.CorporationName = id.CorporationName; // Notify subscribers EveMonClient.OnCharacterUpdated(id.CCPCharacter); continue; } EveMonClient.Characters.Add(new CCPCharacter(id)); } }
/// <summary> /// Gets the error page. /// </summary> /// <param name="e">The <see cref="APIKeyCreationEventArgs"/> instance containing the event data.</param> /// <returns></returns> private MultiPanelPage GetErrorPage(APIKeyCreationEventArgs e) { if (e.CCPError.IsAuthenticationFailure) { return(AuthenticationErrorPage); } if (e.CCPError.IsLoginDeniedByAccountStatus) { return(LoginDeniedErrorPage); } if (e.CCPError.IsAPIKeyExpired) { return(APIKeyExpiredErrorPage); } GeneralErrorLabel.Text = String.Format(CultureConstants.DefaultCulture, GeneralErrorLabel.Text, e.KeyTestError); return(GeneralErrorPage); }
/// <summary> /// Gets the error page. /// </summary> /// <param name="e">The <see cref="APIKeyCreationEventArgs"/> instance containing the event data.</param> /// <returns></returns> private MultiPanelPage GetErrorPage(APIKeyCreationEventArgs e) { GeneralErrorLabel.Text = String.Format(CultureConstants.DefaultCulture, GeneralErrorLabel.Text, e.KeyTestError); return(GeneralErrorPage); }
/// <summary> /// On the first page, when a textbox is changed, we ensure the previously generated <see cref="APIKeyCreationEventArgs"/> is destroyed. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void VerificationCodeTextBox_TextChanged(object sender, EventArgs e) { m_creationArgs = null; }
/// <summary> /// On the first page, when a textbox is changed, we ensure the previously generated <see cref="APIKeyCreationEventArgs"/> is destroyed. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void IDTextBox_TextChanged(object sender, EventArgs e) { m_creationArgs = null; }
/// <summary> /// When API credentials have been updated. /// </summary> /// <returns></returns> private void OnUpdated(object sender, APIKeyCreationEventArgs e) { m_creationArgs = e; CharactersGroupBox.Text = "Characters exposed by API key"; // Updates the picture and label for key type switch (e.Type) { default: KeyPicture.Image = Resources.KeyWrong32; KeyLabel.Text = e.KeyTestError; CharactersGroupBox.Text = "Error report"; ResultsMultiPanel.SelectedPage = GetErrorPage(e); break; case CCPAPIKeyType.Account: KeyPicture.Image = Resources.AccountWide32; KeyLabel.Text = "This is an 'Account' wide API key."; ResultsMultiPanel.SelectedPage = CharactersListPage; break; case CCPAPIKeyType.Character: KeyPicture.Image = Resources.DefaultCharacterImage32; KeyLabel.Text = "This is a 'Character' restricted API key."; ResultsMultiPanel.SelectedPage = CharactersListPage; break; case CCPAPIKeyType.Corporation: KeyPicture.Image = Resources.DefaultCorporationImage32; KeyLabel.Text = "This is a 'Corporation' API key."; ResultsMultiPanel.SelectedPage = CharactersListPage; break; } // Updates the characters list CharactersListView.Items.Clear(); foreach (ListViewItem item in e.Identities.Select( id => new ListViewItem(id.CharacterName) { Tag = id, Checked = m_apiKey == null || !m_apiKey.IdentityIgnoreList.Contains(id) })) { CharactersListView.Items.Add(item); } // Issue a warning if the access of the API key is zero if (e.AccessMask == 0) { WarningLabel.Text = "Beware! This API key does not provide any data!"; WarningLabel.Visible = true; } // Issue a warning if the access of API key is less than needed for basic features else if (e.Type != CCPAPIKeyType.Corporation && e.AccessMask < (long)CCPAPIMethodsEnum.BasicCharacterFeatures) { WarningLabel.Text = "Beware! The data this API key provides does not suffice for basic features!"; WarningLabel.Visible = true; } else { WarningLabel.Visible = m_updateMode; } // Selects the last page Throbber.State = ThrobberState.Stopped; MultiPanel.SelectedPage = ResultPage; }
/// <summary> /// Cancel. /// Closes the window. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ButtonCancel_Click(object sender, EventArgs e) { m_creationArgs = null; IDTextBox.CausesValidation = VerificationCodeTextBox.CausesValidation = false; Close(); }