Exemplo n.º 1
0
        //--------------------------------------------------------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));
            }
        }
Exemplo n.º 2
0
        protected override void SetItem(int index, Account item)
        {
            if (AccountChanged != null)
            {
                FrostbiteConnection.RaiseEvent(AccountChanged.GetInvocationList(), item);
            }

            base.SetItem(index, item);
        }
Exemplo n.º 3
0
        /// <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);
            }
        }
Exemplo n.º 4
0
 /// <summary>删除账号
 /// </summary>
 public Task <AsyncTaskResult> HandleAsync(AccountChanged evnt)
 {
     return(TryUpdateRecordAsync(connection => connection.UpdateAsync(new
     {
         UseFlag = evnt.UseFlag,
         Version = evnt.Version,
         EventSequence = evnt.Sequence
     }, new
     {
         AccountId = evnt.AggregateRootId,
         Version = evnt.Version - 1
     }, ConfigSettings.AccountTable)));
 }
Exemplo n.º 5
0
        //--------------------------------------------------------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));
            }
        }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
        /// <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);
            }
        }
Exemplo n.º 8
0
        /// <summary>Update the state of the account from received account info</summary>
        private void Update(IAccount acct)
        {
            var acct_change = AccountId != acct.Number;

            if (acct_change)
            {
                AccountChanging.Raise(this);
            }

            AccountId = acct.Number;
            IsLive    = acct.IsLive;
            Currency  = acct.Currency;
            Balance   = acct.Balance;
            Equity    = acct.Equity;
            Leverage  = acct.PreciseLeverage;

            if (acct_change)
            {
                AccountChanged.Raise(this);
            }
        }
Exemplo n.º 9
0
        /// <summary>Update the state of the account from received account info</summary>
        public void Update(Account acct)
        {
            var acct_change = AccountId != acct.AccountId;

            if (acct_change)
            {
                AccountChanging.Raise(this);
            }

            AccountId = acct.AccountId;
            IsLive    = acct.IsLive;
            Currency  = acct.Currency;
            Balance   = acct.Balance;
            Equity    = acct.Equity;
            Leverage  = acct.Leverage;

            if (acct_change)
            {
                AccountChanged.Raise(this);
            }
        }
Exemplo n.º 10
0
        //--------------------------------------------------------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));
            }
        }
Exemplo n.º 11
0
        //--------------------------------------------------------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));
            }
        }
Exemplo n.º 12
0
 /// <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));
 }
Exemplo n.º 13
0
 private void OnAccountChanged()
 {
     AccountChanged?.Invoke(Account);
 }
 private void OnAccountChanged(AccountModel model) => AccountChanged?.Invoke(this, new ValueEventArgs <AccountModel>(model));
Exemplo n.º 15
0
 private void OnAccountChanged(IAccount account)
 => AccountChanged?.Invoke(this, new AccountChangedEventArgs(account));