]> Git Repo - VerusCoin.git/blame - src/qt/paymentserver.h
Fix all header defines
[VerusCoin.git] / src / qt / paymentserver.h
CommitLineData
57702541 1// Copyright (c) 2011-2014 The Bitcoin developers
e592d43f
WL
2// Distributed under the MIT/X11 software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
84738627
PJ
5#ifndef BITCOIN_QT_PAYMENTSERVER_H
6#define BITCOIN_QT_PAYMENTSERVER_H
7
8269a095
GA
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
bdd0c59a 23// shown, a signal is sent to slot uiReady(), which
8269a095
GA
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//
8269a095 34
a41d5fe0
GA
35#include "paymentrequestplus.h"
36#include "walletmodel.h"
37
51ed9ec9
BD
38#include <QObject>
39#include <QString>
40
a41d5fe0 41class OptionsModel;
d78900cc
PK
42
43QT_BEGIN_NAMESPACE
8269a095 44class QApplication;
a41d5fe0 45class QByteArray;
8269a095 46class QLocalServer;
a41d5fe0
GA
47class QNetworkAccessManager;
48class QNetworkReply;
49class QSslError;
50class QUrl;
d78900cc 51QT_END_NAMESPACE
8269a095 52
51ed9ec9
BD
53class CWallet;
54
8269a095
GA
55class PaymentServer : public QObject
56{
57 Q_OBJECT
b001c871 58
8269a095 59public:
2102ab9f
WL
60 // Parse URIs on command line
61 // Returns false on error
62 static bool ipcParseCommandLine(int argc, char *argv[]);
63
8269a095
GA
64 // Returns true if there were URIs on the command line
65 // which were successfully sent to an already-running
66 // process.
a41d5fe0
GA
67 // Note: if a payment request is given, SelectParams(MAIN/TESTNET)
68 // will be called so we startup in the right mode.
2102ab9f 69 static bool ipcSendCommandLine();
8269a095 70
d78900cc
PK
71 // parent should be QApplication object
72 PaymentServer(QObject* parent, bool startLocalServer = true);
a41d5fe0 73 ~PaymentServer();
8269a095 74
a41d5fe0
GA
75 // Load root certificate authorities. Pass NULL (default)
76 // to read from the file specified in the -rootcertificates setting,
77 // or, if that's not set, to use the system default root certificates.
78 // If you pass in a store, you should not X509_STORE_free it: it will be
79 // freed either at exit or when another set of CAs are loaded.
d78900cc 80 static void LoadRootCAs(X509_STORE* store = NULL);
a41d5fe0
GA
81
82 // Return certificate store
83 static X509_STORE* getCertStore() { return certStore; }
84
bdd0c59a
PK
85 // OptionsModel is used for getting proxy settings and display unit
86 void setOptionsModel(OptionsModel *optionsModel);
87
8269a095 88signals:
a41d5fe0
GA
89 // Fired when a valid payment request is received
90 void receivedPaymentRequest(SendCoinsRecipient);
91
92 // Fired when a valid PaymentACK is received
08dd1b7b 93 void receivedPaymentACK(const QString &paymentACKMsg);
a41d5fe0 94
95d4a2be
PK
95 // Fired when a message should be reported to the user
96 void message(const QString &title, const QString &message, unsigned int style);
8269a095
GA
97
98public slots:
99 // Signal this when the main window's UI is ready
100 // to display payment requests to the user
101 void uiReady();
102
a41d5fe0
GA
103 // Submit Payment message to a merchant, get back PaymentACK:
104 void fetchPaymentACK(CWallet* wallet, SendCoinsRecipient recipient, QByteArray transaction);
105
bd70562f 106 // Handle an incoming URI, URI with local file scheme or file
4c603586
WL
107 void handleURIOrFile(const QString& s);
108
8269a095
GA
109private slots:
110 void handleURIConnection();
a41d5fe0
GA
111 void netRequestFinished(QNetworkReply*);
112 void reportSslErrors(QNetworkReply*, const QList<QSslError> &);
08dd1b7b 113 void handlePaymentACK(const QString& paymentACKMsg);
a41d5fe0 114
4cf34110
PK
115protected:
116 // Constructor registers this on the parent QApplication to
117 // receive QEvent::FileOpen and QEvent:Drop events
118 bool eventFilter(QObject *object, QEvent *event);
119
a41d5fe0
GA
120private:
121 static bool readPaymentRequest(const QString& filename, PaymentRequestPlus& request);
952d2cdb 122 bool processPaymentRequest(PaymentRequestPlus& request, SendCoinsRecipient& recipient);
a41d5fe0
GA
123 void fetchRequest(const QUrl& url);
124
7634e0d8
PK
125 // Setup networking
126 void initNetManager();
127
bdd0c59a 128 bool saveURIs; // true during startup
a41d5fe0 129 QLocalServer* uriServer;
bdd0c59a
PK
130
131 static X509_STORE* certStore; // Trusted root certificates
a41d5fe0
GA
132 static void freeCertStore();
133
bdd0c59a
PK
134 QNetworkAccessManager* netManager; // Used to fetch payment requests
135
136 OptionsModel *optionsModel;
8269a095
GA
137};
138
84738627 139#endif // BITCOIN_QT_PAYMENTSERVER_H
This page took 0.149774 seconds and 4 git commands to generate.