LCOV - code coverage report
Current view: top level - src/qt - paymentserver.h (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 0 1 0.0 %
Date: 2020-09-26 01:30:44 Functions: 0 1 0.0 %

          Line data    Source code
       1             : // Copyright (c) 2011-2019 The Bitcoin Core developers
       2             : // Distributed under the MIT software license, see the accompanying
       3             : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       4             : 
       5             : #ifndef BITCOIN_QT_PAYMENTSERVER_H
       6             : #define BITCOIN_QT_PAYMENTSERVER_H
       7             : 
       8             : // This class handles payment requests from clicking on
       9             : // bitcoin: URIs
      10             : //
      11             : // This is somewhat tricky, because we have to deal with
      12             : // the situation where the user clicks on a link during
      13             : // startup/initialization, when the splash-screen is up
      14             : // but the main window (and the Send Coins tab) is not.
      15             : //
      16             : // So, the strategy is:
      17             : //
      18             : // Create the server, and register the event handler,
      19             : // when the application is created. Save any URIs
      20             : // received at or during startup in a list.
      21             : //
      22             : // When startup is finished and the main window is
      23             : // shown, a signal is sent to slot uiReady(), which
      24             : // emits a receivedURI() signal for any payment
      25             : // requests that happened during startup.
      26             : //
      27             : // After startup, receivedURI() happens as usual.
      28             : //
      29             : // This class has one more feature: a static
      30             : // method that finds URIs passed in the command line
      31             : // and, if a server is running in another process,
      32             : // sends them to the server.
      33             : //
      34             : 
      35             : #if defined(HAVE_CONFIG_H)
      36             : #include <config/bitcoin-config.h>
      37             : #endif
      38             : 
      39             : #include <qt/sendcoinsrecipient.h>
      40             : 
      41             : #include <QObject>
      42             : #include <QString>
      43             : 
      44             : class OptionsModel;
      45             : 
      46             : namespace interfaces {
      47             : class Node;
      48             : } // namespace interfaces
      49             : 
      50             : QT_BEGIN_NAMESPACE
      51             : class QApplication;
      52             : class QByteArray;
      53             : class QLocalServer;
      54             : class QUrl;
      55             : QT_END_NAMESPACE
      56             : 
      57             : class PaymentServer : public QObject
      58             : {
      59           0 :     Q_OBJECT
      60             : 
      61             : public:
      62             :     // Parse URIs on command line
      63             :     // Returns false on error
      64             :     static void ipcParseCommandLine(int argc, char *argv[]);
      65             : 
      66             :     // Returns true if there were URIs on the command line
      67             :     // which were successfully sent to an already-running
      68             :     // process.
      69             :     // Note: if a payment request is given, SelectParams(MAIN/TESTNET)
      70             :     // will be called so we startup in the right mode.
      71             :     static bool ipcSendCommandLine();
      72             : 
      73             :     // parent should be QApplication object
      74             :     explicit PaymentServer(QObject* parent, bool startLocalServer = true);
      75             :     ~PaymentServer();
      76             : 
      77             :     // OptionsModel is used for getting proxy settings and display unit
      78             :     void setOptionsModel(OptionsModel *optionsModel);
      79             : 
      80             : Q_SIGNALS:
      81             :     // Fired when a valid payment request is received
      82             :     void receivedPaymentRequest(SendCoinsRecipient);
      83             : 
      84             :     // Fired when a message should be reported to the user
      85             :     void message(const QString &title, const QString &message, unsigned int style);
      86             : 
      87             : public Q_SLOTS:
      88             :     // Signal this when the main window's UI is ready
      89             :     // to display payment requests to the user
      90             :     void uiReady();
      91             : 
      92             :     // Handle an incoming URI, URI with local file scheme or file
      93             :     void handleURIOrFile(const QString& s);
      94             : 
      95             : private Q_SLOTS:
      96             :     void handleURIConnection();
      97             : 
      98             : protected:
      99             :     // Constructor registers this on the parent QApplication to
     100             :     // receive QEvent::FileOpen and QEvent:Drop events
     101             :     bool eventFilter(QObject *object, QEvent *event) override;
     102             : 
     103             : private:
     104             :     bool saveURIs;                      // true during startup
     105             :     QLocalServer* uriServer;
     106             :     OptionsModel *optionsModel;
     107             : };
     108             : 
     109             : #endif // BITCOIN_QT_PAYMENTSERVER_H

Generated by: LCOV version 1.15