diff options
author | Philip Kaufmann <phil.kaufmann@t-online.de> | 2013-12-09 10:48:14 +0100 |
---|---|---|
committer | Philip Kaufmann <phil.kaufmann@t-online.de> | 2013-12-10 11:04:37 +0100 |
commit | bd70562f660552973dcf99e00c7897ae884661da (patch) | |
tree | 1ba3b7c073cf8c7fc2eaf06994bb10f6ff3accdf /src/qt/paymentserver.cpp | |
parent | fb96e28b29487f4fdff81b8852d03da5e3110345 (diff) |
[Qt] add messages when handling local payment request files
- important for the open URI dialog to give users feedback
when a file is invalid etc.
Diffstat (limited to 'src/qt/paymentserver.cpp')
-rw-r--r-- | src/qt/paymentserver.cpp | 52 |
1 files changed, 36 insertions, 16 deletions
diff --git a/src/qt/paymentserver.cpp b/src/qt/paymentserver.cpp index ba5c06064f..120831fc90 100644 --- a/src/qt/paymentserver.cpp +++ b/src/qt/paymentserver.cpp @@ -373,40 +373,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; } @@ -584,7 +596,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; } @@ -596,9 +608,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; } @@ -611,9 +630,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())); } } |