diff options
author | Luke Dashjr <luke-jr+git@utopios.org> | 2012-03-25 17:25:10 -0400 |
---|---|---|
committer | Luke Dashjr <luke-jr+git@utopios.org> | 2012-04-06 14:30:10 -0400 |
commit | d652709abaccff37c1e5ea36a8334ad643809d23 (patch) | |
tree | 787e6514087b867103512fdff0bba0f1bac0c8fd /src | |
parent | 8ae76e0f5d1e9beeeab5f1dfc9b195d0999729d7 (diff) | |
download | bitcoin-d652709abaccff37c1e5ea36a8334ad643809d23.tar.xz |
Bugfix: Replace "URL" with "URI" where we aren't actually working with URLs
Diffstat (limited to 'src')
-rw-r--r-- | src/qt/bitcoin.cpp | 22 | ||||
-rw-r--r-- | src/qt/bitcoingui.cpp | 12 | ||||
-rw-r--r-- | src/qt/bitcoingui.h | 2 | ||||
-rw-r--r-- | src/qt/guiutil.cpp | 18 | ||||
-rw-r--r-- | src/qt/guiutil.h | 8 | ||||
-rw-r--r-- | src/qt/qtipcserver.cpp | 13 | ||||
-rw-r--r-- | src/qt/qtipcserver.h | 2 | ||||
-rw-r--r-- | src/qt/sendcoinsdialog.cpp | 4 | ||||
-rw-r--r-- | src/qt/sendcoinsdialog.h | 2 | ||||
-rw-r--r-- | src/qt/test/test_main.cpp | 4 | ||||
-rw-r--r-- | src/qt/test/uritests.cpp (renamed from src/qt/test/urltests.cpp) | 48 | ||||
-rw-r--r-- | src/qt/test/uritests.h | 15 | ||||
-rw-r--r-- | src/qt/test/urltests.h | 15 | ||||
-rw-r--r-- | src/qtui.h | 2 |
14 files changed, 85 insertions, 82 deletions
diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index 3450bb4570..71e2daf931 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -81,7 +81,7 @@ bool ThreadSafeAskFee(int64 nFeeRequired, const std::string& strCaption, wxWindo return payFee; } -void ThreadSafeHandleURL(const std::string& strURL) +void ThreadSafeHandleURI(const std::string& strURI) { if(!guiref) return; @@ -93,8 +93,8 @@ void ThreadSafeHandleURL(const std::string& strURL) { connectionType = Qt::BlockingQueuedConnection; } - QMetaObject::invokeMethod(guiref, "handleURL", connectionType, - Q_ARG(QString, QString::fromStdString(strURL))); + QMetaObject::invokeMethod(guiref, "handleURI", connectionType, + Q_ARG(QString, QString::fromStdString(strURI))); } void CalledSetStatusBar(const std::string& strText, int nField) @@ -141,10 +141,10 @@ int main(int argc, char *argv[]) { if (strlen(argv[i]) > 7 && strncasecmp(argv[i], "bitcoin:", 8) == 0) { - const char *strURL = argv[i]; + const char *strURI = argv[i]; try { - boost::interprocess::message_queue mq(boost::interprocess::open_only, "BitcoinURL"); - if(mq.try_send(strURL, strlen(strURL), 0)) + boost::interprocess::message_queue mq(boost::interprocess::open_only, BITCOINURI_QUEUE_NAME); + if(mq.try_send(strURI, strlen(strURI), 0)) exit(0); else break; @@ -254,21 +254,21 @@ int main(int argc, char *argv[]) window.show(); } - // Place this here as guiref has to be defined if we dont want to lose URLs + // Place this here as guiref has to be defined if we dont want to lose URIs ipcInit(); #if !defined(MAC_OSX) && !defined(WIN32) // TODO: implement qtipcserver.cpp for Mac and Windows - // Check for URL in argv + // Check for URI in argv for (int i = 1; i < argc; i++) { if (strlen(argv[i]) > 7 && strncasecmp(argv[i], "bitcoin:", 8) == 0) { - const char *strURL = argv[i]; + const char *strURI = argv[i]; try { - boost::interprocess::message_queue mq(boost::interprocess::open_only, "BitcoinURL"); - mq.try_send(strURL, strlen(strURL), 0); + boost::interprocess::message_queue mq(boost::interprocess::open_only, BITCOINURI_QUEUE_NAME); + mq.try_send(strURI, strlen(strURI), 0); } catch (boost::interprocess::interprocess_exception &ex) { } diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index ee5fd32a6d..4a9b420485 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -714,7 +714,7 @@ void BitcoinGUI::gotoMessagePage(QString addr) void BitcoinGUI::dragEnterEvent(QDragEnterEvent *event) { - // Accept only URLs + // Accept only URIs if(event->mimeData()->hasUrls()) event->acceptProposedAction(); } @@ -724,20 +724,20 @@ void BitcoinGUI::dropEvent(QDropEvent *event) if(event->mimeData()->hasUrls()) { gotoSendCoinsPage(); - QList<QUrl> urls = event->mimeData()->urls(); - foreach(const QUrl &url, urls) + QList<QUrl> uris = event->mimeData()->urls(); + foreach(const QUrl &uri, uris) { - sendCoinsPage->handleURL(url.toString()); + sendCoinsPage->handleURI(uri.toString()); } } event->acceptProposedAction(); } -void BitcoinGUI::handleURL(QString strURL) +void BitcoinGUI::handleURI(QString strURI) { gotoSendCoinsPage(); - sendCoinsPage->handleURL(strURL); + sendCoinsPage->handleURI(strURI); if(!isActiveWindow()) activateWindow(); diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index d221f6bad9..744755dbaa 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -127,7 +127,7 @@ public slots: @param[out] payFee true to pay the fee, false to not pay the fee */ void askFee(qint64 nFeeRequired, bool *payFee); - void handleURL(QString strURL); + void handleURI(QString strURI); void gotoMessagePage(); void gotoMessagePage(QString); diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index ac69bd07e9..24bb95d8a3 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -51,15 +51,15 @@ void GUIUtil::setupAmountWidget(QLineEdit *widget, QWidget *parent) widget->setAlignment(Qt::AlignRight|Qt::AlignVCenter); } -bool GUIUtil::parseBitcoinURL(const QUrl &url, SendCoinsRecipient *out) +bool GUIUtil::parseBitcoinURI(const QUrl &uri, SendCoinsRecipient *out) { - if(url.scheme() != QString("bitcoin")) + if(uri.scheme() != QString("bitcoin")) return false; SendCoinsRecipient rv; - rv.address = url.path(); + rv.address = uri.path(); rv.amount = 0; - QList<QPair<QString, QString> > items = url.queryItems(); + QList<QPair<QString, QString> > items = uri.queryItems(); for (QList<QPair<QString, QString> >::iterator i = items.begin(); i != items.end(); i++) { bool fShouldReturnFalse = false; @@ -96,18 +96,18 @@ bool GUIUtil::parseBitcoinURL(const QUrl &url, SendCoinsRecipient *out) return true; } -bool GUIUtil::parseBitcoinURL(QString url, SendCoinsRecipient *out) +bool GUIUtil::parseBitcoinURI(QString uri, SendCoinsRecipient *out) { // Convert bitcoin:// to bitcoin: // // Cannot handle this later, because bitcoin:// will cause Qt to see the part after // as host, // which will lowercase it (and thus invalidate the address). - if(url.startsWith("bitcoin://")) + if(uri.startsWith("bitcoin://")) { - url.replace(0, 10, "bitcoin:"); + uri.replace(0, 10, "bitcoin:"); } - QUrl urlInstance(url); - return parseBitcoinURL(urlInstance, out); + QUrl uriInstance(uri); + return parseBitcoinURI(uriInstance, out); } QString GUIUtil::HtmlEscape(const QString& str, bool fMultiLine) diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h index 75ba53f206..0c78b3ccb0 100644 --- a/src/qt/guiutil.h +++ b/src/qt/guiutil.h @@ -29,10 +29,10 @@ public: static void setupAddressWidget(QLineEdit *widget, QWidget *parent); static void setupAmountWidget(QLineEdit *widget, QWidget *parent); - // Parse "bitcoin:" URL into recipient object, return true on succesful parsing - // See Bitcoin URL definition discussion here: https://bitcointalk.org/index.php?topic=33490.0 - static bool parseBitcoinURL(const QUrl &url, SendCoinsRecipient *out); - static bool parseBitcoinURL(QString url, SendCoinsRecipient *out); + // Parse "bitcoin:" URI into recipient object, return true on succesful parsing + // See Bitcoin URI definition discussion here: https://bitcointalk.org/index.php?topic=33490.0 + static bool parseBitcoinURI(const QUrl &, SendCoinsRecipient *out); + static bool parseBitcoinURI(QString uri, SendCoinsRecipient *out); // HTML escaping for rich text controls static QString HtmlEscape(const QString& str, bool fMultiLine=false); diff --git a/src/qt/qtipcserver.cpp b/src/qt/qtipcserver.cpp index 8b9270e178..3c7889ca71 100644 --- a/src/qt/qtipcserver.cpp +++ b/src/qt/qtipcserver.cpp @@ -8,6 +8,7 @@ #include <boost/date_time/posix_time/posix_time.hpp> #include "headers.h" +#include "qtipcserver.h" using namespace boost::interprocess; using namespace boost::posix_time; @@ -16,7 +17,7 @@ using namespace std; void ipcShutdown() { - message_queue::remove("BitcoinURL"); + message_queue::remove(BITCOINURI_QUEUE_NAME); } void ipcThread(void* parg) @@ -30,7 +31,7 @@ void ipcThread(void* parg) ptime d = boost::posix_time::microsec_clock::universal_time() + millisec(100); if(mq->timed_receive(&strBuf, sizeof(strBuf), nSize, nPriority, d)) { - ThreadSafeHandleURL(std::string(strBuf, nSize)); + ThreadSafeHandleURI(std::string(strBuf, nSize)); Sleep(1000); } if (fShutdown) @@ -60,7 +61,7 @@ void ipcInit() size_t nSize; unsigned int nPriority; try { - mq = new message_queue(open_or_create, "BitcoinURL", 2, 256); + mq = new message_queue(open_or_create, BITCOINURI_QUEUE_NAME, 2, 256); // Make sure we don't lose any bitcoin: URIs for (int i = 0; i < 2; i++) @@ -68,15 +69,15 @@ void ipcInit() ptime d = boost::posix_time::microsec_clock::universal_time() + millisec(1); if(mq->timed_receive(&strBuf, sizeof(strBuf), nSize, nPriority, d)) { - ThreadSafeHandleURL(std::string(strBuf, nSize)); + ThreadSafeHandleURI(std::string(strBuf, nSize)); } else break; } // Make sure only one bitcoin instance is listening - message_queue::remove("BitcoinURL"); - mq = new message_queue(open_or_create, "BitcoinURL", 2, 256); + message_queue::remove(BITCOINURI_QUEUE_NAME); + mq = new message_queue(open_or_create, BITCOINURI_QUEUE_NAME, 2, 256); } catch (interprocess_exception &ex) { return; diff --git a/src/qt/qtipcserver.h b/src/qt/qtipcserver.h index 1de0334afd..fcff10d8da 100644 --- a/src/qt/qtipcserver.h +++ b/src/qt/qtipcserver.h @@ -1,2 +1,4 @@ +#define BITCOINURI_QUEUE_NAME "BitcoinURI" + void ipcInit(); void ipcShutdown(); diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index 964313ea81..592ae6f45a 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -265,10 +265,10 @@ void SendCoinsDialog::pasteEntry(const SendCoinsRecipient &rv) } -void SendCoinsDialog::handleURL(const QString &url) +void SendCoinsDialog::handleURI(const QString &uri) { SendCoinsRecipient rv; - if(!GUIUtil::parseBitcoinURL(url, &rv)) + if(!GUIUtil::parseBitcoinURI(uri, &rv)) { return; } diff --git a/src/qt/sendcoinsdialog.h b/src/qt/sendcoinsdialog.h index 4dc3f08bc5..5dcbfbeb61 100644 --- a/src/qt/sendcoinsdialog.h +++ b/src/qt/sendcoinsdialog.h @@ -30,7 +30,7 @@ public: QWidget *setupTabChain(QWidget *prev); void pasteEntry(const SendCoinsRecipient &rv); - void handleURL(const QString &url); + void handleURI(const QString &uri); public slots: void clear(); diff --git a/src/qt/test/test_main.cpp b/src/qt/test/test_main.cpp index 0a08eafa1e..5b11e39ea3 100644 --- a/src/qt/test/test_main.cpp +++ b/src/qt/test/test_main.cpp @@ -1,11 +1,11 @@ #include <QTest>
#include <QObject>
-#include "urltests.h"
+#include "uritests.h"
// This is all you need to run all the tests
int main(int argc, char *argv[])
{
- URLTests test1;
+ URITests test1;
QTest::qExec(&test1);
}
diff --git a/src/qt/test/urltests.cpp b/src/qt/test/uritests.cpp index 1f11795a9b..70c20be0ea 100644 --- a/src/qt/test/urltests.cpp +++ b/src/qt/test/uritests.cpp @@ -1,4 +1,4 @@ -#include "urltests.h" +#include "uritests.h" #include "../guiutil.h" #include "../walletmodel.h" @@ -13,59 +13,59 @@ struct SendCoinsRecipient }; */ -void URLTests::urlTests() +void URITests::uriTests() { SendCoinsRecipient rv; - QUrl url; - url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?req-dontexist=")); - QVERIFY(!GUIUtil::parseBitcoinURL(url, &rv)); + QUrl uri; + uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?req-dontexist=")); + QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv)); - url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?dontexist=")); - QVERIFY(GUIUtil::parseBitcoinURL(url, &rv)); + uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?dontexist=")); + QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); QVERIFY(rv.label == QString()); QVERIFY(rv.amount == 0); - url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?label=Wikipedia Example Address")); - QVERIFY(GUIUtil::parseBitcoinURL(url, &rv)); + uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?label=Wikipedia Example Address")); + QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); QVERIFY(rv.label == QString("Wikipedia Example Address")); QVERIFY(rv.amount == 0); - url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=0.001")); - QVERIFY(GUIUtil::parseBitcoinURL(url, &rv)); + uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=0.001")); + QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); QVERIFY(rv.label == QString()); QVERIFY(rv.amount == 100000); - url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1.001")); - QVERIFY(GUIUtil::parseBitcoinURL(url, &rv)); + uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1.001")); + QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); QVERIFY(rv.label == QString()); QVERIFY(rv.amount == 100100000); - url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=100&label=Wikipedia Example")); - QVERIFY(GUIUtil::parseBitcoinURL(url, &rv)); + uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=100&label=Wikipedia Example")); + QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); QVERIFY(rv.amount == 10000000000); QVERIFY(rv.label == QString("Wikipedia Example")); - url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?message=Wikipedia Example Address")); - QVERIFY(GUIUtil::parseBitcoinURL(url, &rv)); + uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?message=Wikipedia Example Address")); + QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv)); QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); QVERIFY(rv.label == QString()); - QVERIFY(GUIUtil::parseBitcoinURL("bitcoin://175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?message=Wikipedia Example Address", &rv)); + QVERIFY(GUIUtil::parseBitcoinURI("bitcoin://175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?message=Wikipedia Example Address", &rv)); QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W")); QVERIFY(rv.label == QString()); // We currently dont implement the message paramenter (ok, yea, we break spec...) - url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?req-message=Wikipedia Example Address")); - QVERIFY(!GUIUtil::parseBitcoinURL(url, &rv)); + uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?req-message=Wikipedia Example Address")); + QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv)); - url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1,000&label=Wikipedia Example")); - QVERIFY(!GUIUtil::parseBitcoinURL(url, &rv)); + uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1,000&label=Wikipedia Example")); + QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv)); - url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1,000.0&label=Wikipedia Example")); - QVERIFY(!GUIUtil::parseBitcoinURL(url, &rv)); + uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1,000.0&label=Wikipedia Example")); + QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv)); } diff --git a/src/qt/test/uritests.h b/src/qt/test/uritests.h new file mode 100644 index 0000000000..1237516e5f --- /dev/null +++ b/src/qt/test/uritests.h @@ -0,0 +1,15 @@ +#ifndef URITESTS_H +#define URITESTS_H + +#include <QTest> +#include <QObject> + +class URITests : public QObject +{ + Q_OBJECT + +private slots: + void uriTests(); +}; + +#endif // URITESTS_H diff --git a/src/qt/test/urltests.h b/src/qt/test/urltests.h deleted file mode 100644 index 393c511390..0000000000 --- a/src/qt/test/urltests.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef URLTESTS_H -#define URLTESTS_H - -#include <QTest> -#include <QObject> - -class URLTests : public QObject -{ - Q_OBJECT - -private slots: - void urlTests(); -}; - -#endif // URLTESTS_H diff --git a/src/qtui.h b/src/qtui.h index 7987370270..05a56678d1 100644 --- a/src/qtui.h +++ b/src/qtui.h @@ -42,7 +42,7 @@ extern int MyMessageBox(const std::string& message, const std::string& caption=" #define wxMessageBox MyMessageBox extern int ThreadSafeMessageBox(const std::string& message, const std::string& caption, int style=wxOK, wxWindow* parent=NULL, int x=-1, int y=-1); extern bool ThreadSafeAskFee(int64 nFeeRequired, const std::string& strCaption, wxWindow* parent); -extern void ThreadSafeHandleURL(const std::string& strURL); +extern void ThreadSafeHandleURI(const std::string& strURI); extern void CalledSetStatusBar(const std::string& strText, int nField); extern void UIThreadCall(boost::function0<void> fn); extern void MainFrameRepaint(); |