//--------------------------------------------------------Set-, Get- Methods:---------------------------------------------------------\\ #region --Set-, Get- Methods-- /// <summary> /// Adds the given XMPPAccount to the db or replaces it, if it already exists. /// </summary> /// <param name="account">The account which should get inserted or replaced.</param> public void setAccount(XMPPAccount account, bool triggerAccountChanged) { dB.InsertOrReplace(new AccountTable(account)); Vault.storePassword(account); saveAccountConnectionConfiguration(account); if (account.OMEMO_PRE_KEYS != null) { OmemoSignalKeyDBManager.INSTANCE.setPreKeys(account.OMEMO_PRE_KEYS, account.getBareJid()); } else { OmemoSignalKeyDBManager.INSTANCE.deletePreKeys(account.getBareJid()); } if (account.omemoSignedPreKeyPair != null) { OmemoSignalKeyDBManager.INSTANCE.setSignedPreKey(account.omemoSignedPreKeyId, account.omemoSignedPreKeyPair, account.getBareJid()); } else { OmemoSignalKeyDBManager.INSTANCE.deleteSignedPreKey(account.omemoSignedPreKeyId, account.getBareJid()); } if (triggerAccountChanged) { AccountChanged?.Invoke(this, new AccountChangedEventArgs(account, false)); } }
/// <summary> /// Event invocator for the AccountChanged event /// </summary> /// <param name="e">The AccountEvent</param> protected virtual void OnAccountChanged(AccountEvent e) { try { Log.Trace($"Brokerage.OnAccountChanged(): {e}"); AccountChanged?.Invoke(this, e); } catch (Exception err) { Log.Error(err); } }
//--------------------------------------------------------Set-, Get- Methods:---------------------------------------------------------\\ #region --Set-, Get- Methods-- /// <summary> /// Adds the given XMPPAccount to the db or replaces it, if it already exists. /// </summary> /// <param name="account">The account which should get inserted or replaced.</param> public void setAccount(XMPPAccount account, bool triggerAccountChanged) { update(new AccountTable(account)); Vault.storePassword(account); saveAccountConnectionConfiguration(account); account.savePreKeys(); account.saveSignedPreKey(); if (triggerAccountChanged) { AccountChanged?.Invoke(this, new AccountChangedEventArgs(account, false)); } }
public IAtomixApp UseAccount(IAccount account, bool restartTerminal = false) { var previousAccount = Account; Account = account; AccountChanged?.Invoke(this, new AccountChangedEventArgs(previousAccount, Account)); if (HasTerminal) { Terminal.ChangeAccountAsync(account, restartTerminal).FireAndForget(); } return(this); }
/// <summary> /// Event invocator for the AccountChanged event /// </summary> /// <param name="e">The AccountEvent</param> protected virtual void OnAccountChanged(AccountEvent e) { try { if (!CashSyncEnabled) { Log.Trace($"Brokerage.OnAccountChanged(): {e}. Skipping cash sync disabled"); return; } Log.Trace($"Brokerage.OnAccountChanged(): {e}"); AccountChanged?.Invoke(this, e); } catch (Exception err) { Log.Error(err); } }
//--------------------------------------------------------Misc Methods:---------------------------------------------------------------\\ #region --Misc Methods (Public)-- /// <summary> /// Deletes the given account. /// </summary> /// <param name="account">The account to delete.</param> /// <param name="deleteAllKeys">Whether to delete all OMEMO keys.</param> public void deleteAccount(XMPPAccount account, bool triggerAccountChanged, bool deleteAllKeys) { dB.Execute("DELETE FROM " + DBTableConsts.ACCOUNT_TABLE + " WHERE id = ?;", account.getIdAndDomain()); dB.Execute("DELETE FROM " + DBTableConsts.IGNORED_CERTIFICATE_ERROR_TABLE + " WHERE accountId = ?;", account.getIdAndDomain()); dB.Execute("DELETE FROM " + DBTableConsts.CONNECTION_OPTIONS_TABLE + " WHERE accountId = ?;", account.getIdAndDomain()); if (deleteAllKeys) { account.deleteOmemoKeysAndDevices(); } else { account.deleteAccountPreKeys(); account.deleteAccountSignedPreKey(); } Vault.deletePassword(account); if (triggerAccountChanged) { AccountChanged?.Invoke(this, new AccountChangedEventArgs(account, true)); } }
//--------------------------------------------------------Misc Methods:---------------------------------------------------------------\\ #region --Misc Methods (Public)-- /// <summary> /// Deletes the given account. /// </summary> /// <param name="account">The account to delete.</param> /// <param name="deleteAllKeys">Whether to delete all OMEMO keys.</param> public void deleteAccount(XMPPAccount account, bool triggerAccountChanged, bool deleteAllKeys) { dB.Execute("DELETE FROM " + DBTableConsts.ACCOUNT_TABLE + " WHERE id = ?;", account.getBareJid()); dB.Execute("DELETE FROM " + DBTableConsts.IGNORED_CERTIFICATE_ERROR_TABLE + " WHERE accountId = ?;", account.getBareJid()); dB.Execute("DELETE FROM " + DBTableConsts.CONNECTION_OPTIONS_TABLE + " WHERE accountId = ?;", account.getBareJid()); if (deleteAllKeys) { OmemoDeviceDBManager.INSTANCE.deleteAllForAccount(account.getBareJid()); OmemoSignalKeyDBManager.INSTANCE.deleteAllForAccount(account.getBareJid()); } else { OmemoSignalKeyDBManager.INSTANCE.deletePreKeys(account.getBareJid()); OmemoSignalKeyDBManager.INSTANCE.deleteSignedPreKey(account.omemoSignedPreKeyId, account.getBareJid()); } Vault.deletePassword(account); if (triggerAccountChanged) { AccountChanged?.Invoke(this, new AccountChangedEventArgs(account, true)); } }
/// <summary> /// Sets the disabled property of account and triggers the AccountChanged event. /// </summary> /// <param name="account">The XMPPAccount with updated disabled property.</param> public void setAccountDisabled(XMPPAccount account) { dB.Execute("UPDATE " + DBTableConsts.ACCOUNT_TABLE + " SET disabled = ? WHERE id = ?;", account.disabled, account.getBareJid()); AccountChanged?.Invoke(this, new AccountChangedEventArgs(account, false)); }
private void OnAccountChanged() { AccountChanged?.Invoke(Account); }
private void OnAccountChanged(AccountModel model) => AccountChanged?.Invoke(this, new ValueEventArgs <AccountModel>(model));
private void OnAccountChanged(IAccount account) => AccountChanged?.Invoke(this, new AccountChangedEventArgs(account));