"Fossies" - the Fresh Open Source Software Archive

Member "brave-core-1.31.87/vendor/bat-native-ads/src/bat/ads/internal/account/account.h" (19 Oct 2021, 3775 Bytes) of package /linux/www/brave-core-1.31.87.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "account.h": 1.30.89_vs_1.31.87.

    1 /* Copyright (c) 2020 The Brave Authors. All rights reserved.
    2  * This Source Code Form is subject to the terms of the Mozilla Public
    3  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
    4  * You can obtain one at http://mozilla.org/MPL/2.0/. */
    5 
    6 #ifndef BRAVE_VENDOR_BAT_NATIVE_ADS_SRC_BAT_ADS_INTERNAL_ACCOUNT_ACCOUNT_H_
    7 #define BRAVE_VENDOR_BAT_NATIVE_ADS_SRC_BAT_ADS_INTERNAL_ACCOUNT_ACCOUNT_H_
    8 
    9 #include <cstdint>
   10 #include <memory>
   11 #include <string>
   12 
   13 #include "base/observer_list.h"
   14 #include "bat/ads/internal/account/account_observer.h"
   15 #include "bat/ads/internal/account/ad_rewards/ad_rewards_delegate.h"
   16 #include "bat/ads/internal/account/confirmations/confirmations_observer.h"
   17 #include "bat/ads/internal/privacy/unblinded_tokens/unblinded_token_info_aliases.h"
   18 #include "bat/ads/internal/tokens/redeem_unblinded_payment_tokens/redeem_unblinded_payment_tokens_delegate.h"
   19 #include "bat/ads/internal/tokens/refill_unblinded_tokens/refill_unblinded_tokens_delegate.h"
   20 
   21 namespace ads {
   22 
   23 class AdRewards;
   24 class Confirmations;
   25 class ConfirmationType;
   26 class RedeemUnblindedPaymentTokens;
   27 class RefillUnblindedTokens;
   28 class Statement;
   29 class Wallet;
   30 struct StatementInfo;
   31 struct WalletInfo;
   32 
   33 namespace privacy {
   34 class TokenGeneratorInterface;
   35 }  // namespace privacy
   36 
   37 class Account : public AdRewardsDelegate,
   38                 public ConfirmationsObserver,
   39                 public RedeemUnblindedPaymentTokensDelegate,
   40                 public RefillUnblindedTokensDelegate {
   41  public:
   42   explicit Account(privacy::TokenGeneratorInterface* token_generator);
   43 
   44   ~Account() override;
   45 
   46   void AddObserver(AccountObserver* observer);
   47   void RemoveObserver(AccountObserver* observer);
   48 
   49   bool SetWallet(const std::string& id, const std::string& seed);
   50 
   51   WalletInfo GetWallet() const;
   52 
   53   void SetCatalogIssuers(const CatalogIssuersInfo& catalog_issuers);
   54 
   55   void Deposit(const std::string& creative_instance_id,
   56                const ConfirmationType& confirmation_type);
   57 
   58   StatementInfo GetStatement(const int64_t from_timestamp,
   59                              const int64_t to_timestamp) const;
   60 
   61   void Reconcile();
   62 
   63   void ProcessTransactions();
   64 
   65   void TopUpUnblindedTokens();
   66 
   67  private:
   68   base::ObserverList<AccountObserver> observers_;
   69 
   70   std::unique_ptr<AdRewards> ad_rewards_;
   71   std::unique_ptr<Confirmations> confirmations_;
   72   std::unique_ptr<RedeemUnblindedPaymentTokens>
   73       redeem_unblinded_payment_tokens_;
   74   std::unique_ptr<RefillUnblindedTokens> refill_unblinded_tokens_;
   75   std::unique_ptr<Statement> statement_;
   76   std::unique_ptr<Wallet> wallet_;
   77 
   78   void ProcessUnclearedTransactions();
   79 
   80   void NotifyWalletDidUpdate(const WalletInfo& wallet) const;
   81   void NotifyWalletDidChange(const WalletInfo& wallet) const;
   82   void NotifyInvalidWallet() const;
   83   void NotifyCatalogIssuersDidChange(
   84       const CatalogIssuersInfo& catalog_issuers) const;
   85   void NotifyStatementOfAccountsDidChange() const;
   86 
   87   // AdRewardsDelegate:
   88   void OnDidReconcileAdRewards() override;
   89 
   90   // ConfirmationsObserver:
   91   void OnDidConfirm(const double estimated_redemption_value,
   92                     const ConfirmationInfo& confirmation) override;
   93   void OnFailedToConfirm(const ConfirmationInfo& confirmation) override;
   94 
   95   // RedeemUnblindedPaymentTokensDelegate:
   96   void OnDidRedeemUnblindedPaymentTokens(
   97       const privacy::UnblindedTokenList unblinded_tokens) override;
   98   void OnFailedToRedeemUnblindedPaymentTokens() override;
   99   void OnDidRetryRedeemingUnblindedPaymentTokens() override;
  100 
  101   // RedeemUnblindedTokensDelegate:
  102   void OnDidRefillUnblindedTokens() override;
  103   void OnCaptchaRequiredToRefillUnblindedTokens(
  104       const std::string& captcha_id) override;
  105 };
  106 
  107 }  // namespace ads
  108 
  109 #endif  // BRAVE_VENDOR_BAT_NATIVE_ADS_SRC_BAT_ADS_INTERNAL_ACCOUNT_ACCOUNT_H_