diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2014-01-13 17:09:48 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2014-01-13 17:11:05 +0100 |
commit | f126973fd0052a99bb9d8db8416657c43e2b3d94 (patch) | |
tree | a9aa0a406ffe50a52fdc6c37c946ce06f2f3a12d /src/qt | |
parent | a7973c9b6b6c72bca2e6e90aed08553bf708938d (diff) | |
parent | bd70562f660552973dcf99e00c7897ae884661da (diff) |
Merge pull request #3374
bd70562 [Qt] add messages when handling local payment request files (Philip Kaufmann)
Diffstat (limited to 'src/qt')
-rw-r--r-- | src/qt/paymentserver.cpp | 52 | ||||
-rw-r--r-- | src/qt/paymentserver.h | 2 |
2 files changed, 37 insertions, 17 deletions
diff --git a/src/qt/paymentserver.cpp b/src/qt/paymentserver.cpp index 17d80940b7..e22ac43fb2 100644 --- a/src/qt/paymentserver.cpp +++ b/src/qt/paymentserver.cpp @@ -382,40 +382,52 @@ void PaymentServer::handleURIOrFile(const QString& s) #else QUrlQuery uri((QUrl(s))); #endif - if (uri.hasQueryItem("r")) + if (uri.hasQueryItem("r")) // payment request URI { QByteArray temp; temp.append(uri.queryItemValue("r")); QString decoded = QUrl::fromPercentEncoding(temp); QUrl fetchUrl(decoded, QUrl::StrictMode); - qDebug() << "PaymentServer::handleURIOrFile : fetchRequest(" << fetchUrl << ")"; - if (fetchUrl.isValid()) + { + qDebug() << "PaymentServer::handleURIOrFile : fetchRequest(" << fetchUrl << ")"; fetchRequest(fetchUrl); + } else + { qDebug() << "PaymentServer::handleURIOrFile : Invalid URL: " << fetchUrl; + emit message(tr("URI handling"), + tr("Payment request fetch URL is invalid: %1").arg(fetchUrl.toString()), + CClientUIInterface::ICON_WARNING); + } return; } + else // normal URI + { + SendCoinsRecipient recipient; + if (GUIUtil::parseBitcoinURI(s, &recipient)) + emit receivedPaymentRequest(recipient); + else + emit message(tr("URI handling"), + tr("URI can not be parsed! This can be caused by an invalid Bitcoin address or malformed URI parameters."), + CClientUIInterface::ICON_WARNING); - SendCoinsRecipient recipient; - if (GUIUtil::parseBitcoinURI(s, &recipient)) - emit receivedPaymentRequest(recipient); - else - emit message(tr("URI handling"), - tr("URI can not be parsed! This can be caused by an invalid Bitcoin address or malformed URI parameters."), - CClientUIInterface::ICON_WARNING); - - return; + return; + } } - if (QFile::exists(s)) + if (QFile::exists(s)) // payment request file { PaymentRequestPlus request; SendCoinsRecipient recipient; if (readPaymentRequest(s, request) && processPaymentRequest(request, recipient)) emit receivedPaymentRequest(recipient); + else + emit message(tr("Payment request file handling"), + tr("Payment request file can not be read or processed! This can be caused by an invalid payment request file."), + CClientUIInterface::ICON_WARNING); return; } @@ -594,7 +606,7 @@ void PaymentServer::netRequestFinished(QNetworkReply* reply) .arg(reply->errorString()); qDebug() << "PaymentServer::netRequestFinished : " << msg; - emit message(tr("Network request error"), msg, CClientUIInterface::MSG_ERROR); + emit message(tr("Payment request error"), msg, CClientUIInterface::MSG_ERROR); return; } @@ -606,9 +618,16 @@ void PaymentServer::netRequestFinished(QNetworkReply* reply) PaymentRequestPlus request; SendCoinsRecipient recipient; if (request.parse(data) && processPaymentRequest(request, recipient)) + { emit receivedPaymentRequest(recipient); + } else + { qDebug() << "PaymentServer::netRequestFinished : Error processing payment request"; + emit message(tr("Payment request error"), + tr("Payment request can not be parsed or processed!"), + CClientUIInterface::MSG_ERROR); + } return; } @@ -621,9 +640,10 @@ void PaymentServer::netRequestFinished(QNetworkReply* reply) .arg(reply->request().url().toString()); qDebug() << "PaymentServer::netRequestFinished : " << msg; - emit message(tr("Network request error"), msg, CClientUIInterface::MSG_ERROR); + emit message(tr("Payment request error"), msg, CClientUIInterface::MSG_ERROR); } - else { + else + { emit receivedPaymentACK(GUIUtil::HtmlEscape(paymentACK.memo())); } } diff --git a/src/qt/paymentserver.h b/src/qt/paymentserver.h index 5ee85f7db4..af19661bdd 100644 --- a/src/qt/paymentserver.h +++ b/src/qt/paymentserver.h @@ -102,7 +102,7 @@ public slots: // Submit Payment message to a merchant, get back PaymentACK: void fetchPaymentACK(CWallet* wallet, SendCoinsRecipient recipient, QByteArray transaction); - // Handle an incoming URI or file + // Handle an incoming URI, URI with local file scheme or file void handleURIOrFile(const QString& s); private slots: |