[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.
This commit is contained in:
parent
fb96e28b29
commit
bd70562f66
2 changed files with 37 additions and 17 deletions
|
@ -373,23 +373,30 @@ void PaymentServer::handleURIOrFile(const QString& s)
|
||||||
#else
|
#else
|
||||||
QUrlQuery uri((QUrl(s)));
|
QUrlQuery uri((QUrl(s)));
|
||||||
#endif
|
#endif
|
||||||
if (uri.hasQueryItem("r"))
|
if (uri.hasQueryItem("r")) // payment request URI
|
||||||
{
|
{
|
||||||
QByteArray temp;
|
QByteArray temp;
|
||||||
temp.append(uri.queryItemValue("r"));
|
temp.append(uri.queryItemValue("r"));
|
||||||
QString decoded = QUrl::fromPercentEncoding(temp);
|
QString decoded = QUrl::fromPercentEncoding(temp);
|
||||||
QUrl fetchUrl(decoded, QUrl::StrictMode);
|
QUrl fetchUrl(decoded, QUrl::StrictMode);
|
||||||
|
|
||||||
qDebug() << "PaymentServer::handleURIOrFile : fetchRequest(" << fetchUrl << ")";
|
|
||||||
|
|
||||||
if (fetchUrl.isValid())
|
if (fetchUrl.isValid())
|
||||||
|
{
|
||||||
|
qDebug() << "PaymentServer::handleURIOrFile : fetchRequest(" << fetchUrl << ")";
|
||||||
fetchRequest(fetchUrl);
|
fetchRequest(fetchUrl);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
qDebug() << "PaymentServer::handleURIOrFile : Invalid URL: " << fetchUrl;
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
else // normal URI
|
||||||
|
{
|
||||||
SendCoinsRecipient recipient;
|
SendCoinsRecipient recipient;
|
||||||
if (GUIUtil::parseBitcoinURI(s, &recipient))
|
if (GUIUtil::parseBitcoinURI(s, &recipient))
|
||||||
emit receivedPaymentRequest(recipient);
|
emit receivedPaymentRequest(recipient);
|
||||||
|
@ -400,13 +407,18 @@ void PaymentServer::handleURIOrFile(const QString& s)
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (QFile::exists(s))
|
if (QFile::exists(s)) // payment request file
|
||||||
{
|
{
|
||||||
PaymentRequestPlus request;
|
PaymentRequestPlus request;
|
||||||
SendCoinsRecipient recipient;
|
SendCoinsRecipient recipient;
|
||||||
if (readPaymentRequest(s, request) && processPaymentRequest(request, recipient))
|
if (readPaymentRequest(s, request) && processPaymentRequest(request, recipient))
|
||||||
emit receivedPaymentRequest(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;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -584,7 +596,7 @@ void PaymentServer::netRequestFinished(QNetworkReply* reply)
|
||||||
.arg(reply->errorString());
|
.arg(reply->errorString());
|
||||||
|
|
||||||
qDebug() << "PaymentServer::netRequestFinished : " << msg;
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -596,9 +608,16 @@ void PaymentServer::netRequestFinished(QNetworkReply* reply)
|
||||||
PaymentRequestPlus request;
|
PaymentRequestPlus request;
|
||||||
SendCoinsRecipient recipient;
|
SendCoinsRecipient recipient;
|
||||||
if (request.parse(data) && processPaymentRequest(request, recipient))
|
if (request.parse(data) && processPaymentRequest(request, recipient))
|
||||||
|
{
|
||||||
emit receivedPaymentRequest(recipient);
|
emit receivedPaymentRequest(recipient);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
qDebug() << "PaymentServer::netRequestFinished : Error processing payment request";
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -611,9 +630,10 @@ void PaymentServer::netRequestFinished(QNetworkReply* reply)
|
||||||
.arg(reply->request().url().toString());
|
.arg(reply->request().url().toString());
|
||||||
|
|
||||||
qDebug() << "PaymentServer::netRequestFinished : " << msg;
|
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()));
|
emit receivedPaymentACK(GUIUtil::HtmlEscape(paymentACK.memo()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,7 +98,7 @@ public slots:
|
||||||
// Submit Payment message to a merchant, get back PaymentACK:
|
// Submit Payment message to a merchant, get back PaymentACK:
|
||||||
void fetchPaymentACK(CWallet* wallet, SendCoinsRecipient recipient, QByteArray transaction);
|
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);
|
void handleURIOrFile(const QString& s);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
Loading…
Reference in a new issue