PIVX Core  5.6.99
P2P Digital Currency
paymentserver.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2014 The Bitcoin 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 PIVX_QT_PAYMENTSERVER_H
6 #define PIVX_QT_PAYMENTSERVER_H
7 
8 // This class handles payment requests from clicking on
9 // pivx: 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 receivedURL() signal for any payment
25 // requests that happened during startup.
26 //
27 // After startup, receivedURL() 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 #include "walletmodel.h"
36 
37 #include <QObject>
38 #include <QString>
39 
40 class OptionsModel;
41 
42 class CWallet;
43 
44 QT_BEGIN_NAMESPACE
45 class QApplication;
46 class QByteArray;
47 class QLocalServer;
48 class QUrl;
49 QT_END_NAMESPACE
50 
51 class PaymentServer : public QObject
52 {
53  Q_OBJECT
54 
55 public:
56  // Parse URIs on command line
57  // Returns false on error
58  static void ipcParseCommandLine(int argc, char* argv[]);
59 
60  // Returns true if there were URIs on the command line
61  // which were successfully sent to an already-running
62  // process.
63  // Note: if a payment request is given, SelectParams(MAIN/TESTNET)
64  // will be called so we startup in the right mode.
65  static bool ipcSendCommandLine();
66 
67  // parent should be QApplication object
68  explicit PaymentServer(QObject* parent, bool startLocalServer = true);
70 
71  // OptionsModel is used for getting proxy settings and display unit
73 
74 Q_SIGNALS:
75  // Fired when a valid payment request is received
77 
78  // Fired when a message should be reported to the user
79  void message(const QString& title, const QString& message, unsigned int style);
80 
81 public Q_SLOTS:
82  // Signal this when the main window's UI is ready
83  // to display payment requests to the user
84  void uiReady();
85 
86  // Handle an incoming URI, URI with local file scheme or file
87  void handleURIOrFile(const QString& s);
88 
89 private Q_SLOTS:
90  void handleURIConnection();
91 
92 protected:
93  // Constructor registers this on the parent QApplication to
94  // receive QEvent::FileOpen and QEvent:Drop events
95  bool eventFilter(QObject* object, QEvent* event);
96 
97 private:
98  bool saveURIs; // true during startup
99  QLocalServer* uriServer;
101 };
102 
103 #endif // PIVX_QT_PAYMENTSERVER_H
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances,...
Definition: wallet.h:577
Interface from Qt to configuration data structure for PIVX client.
Definition: optionsmodel.h:22
static bool ipcSendCommandLine()
void receivedPaymentRequest(const SendCoinsRecipient &recipient)
void setOptionsModel(OptionsModel *optionsModel)
PaymentServer(QObject *parent, bool startLocalServer=true)
void message(const QString &title, const QString &message, unsigned int style)
void handleURIConnection()
static void ipcParseCommandLine(int argc, char *argv[])
QLocalServer * uriServer
Definition: paymentserver.h:99
void handleURIOrFile(const QString &s)
bool eventFilter(QObject *object, QEvent *event)
OptionsModel * optionsModel
char ** argv
Definition: fuzz.cpp:52