Skip to content

Commit 138d08c

Browse files
committed
Merge pull request bitcoin#987 from luke-jr/ipc_name_fix
Cleanup: Replace "URL" with "URI" where we aren't actually working with URLs
2 parents 9362da7 + fa2544e commit 138d08c

15 files changed

+87
-84
lines changed

bitcoin-qt.pro

+2-2
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,8 @@ FORMS += src/qt/forms/qrcodedialog.ui
225225

226226
contains(BITCOIN_QT_TEST, 1) {
227227
SOURCES += src/qt/test/test_main.cpp \
228-
src/qt/test/urltests.cpp
229-
HEADERS += src/qt/test/urltests.h
228+
src/qt/test/uritests.cpp
229+
HEADERS += src/qt/test/uritests.h
230230
DEPENDPATH += src/qt/test
231231
QT += testlib
232232
TARGET = bitcoin-qt_test

src/qt/bitcoin.cpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@ bool ThreadSafeAskFee(int64 nFeeRequired, const std::string& strCaption)
7474
return payFee;
7575
}
7676

77-
void ThreadSafeHandleURL(const std::string& strURL)
77+
void ThreadSafeHandleURI(const std::string& strURI)
7878
{
7979
if(!guiref)
8080
return;
8181

82-
QMetaObject::invokeMethod(guiref, "handleURL", GUIUtil::blockingGUIThreadConnection(),
83-
Q_ARG(QString, QString::fromStdString(strURL)));
82+
QMetaObject::invokeMethod(guiref, "handleURI", GUIUtil::blockingGUIThreadConnection(),
83+
Q_ARG(QString, QString::fromStdString(strURI)));
8484
}
8585

8686
void MainFrameRepaint()
@@ -133,10 +133,10 @@ int main(int argc, char *argv[])
133133
{
134134
if (strlen(argv[i]) > 7 && strncasecmp(argv[i], "bitcoin:", 8) == 0)
135135
{
136-
const char *strURL = argv[i];
136+
const char *strURI = argv[i];
137137
try {
138-
boost::interprocess::message_queue mq(boost::interprocess::open_only, "BitcoinURL");
139-
if(mq.try_send(strURL, strlen(strURL), 0))
138+
boost::interprocess::message_queue mq(boost::interprocess::open_only, BITCOINURI_QUEUE_NAME);
139+
if(mq.try_send(strURI, strlen(strURI), 0))
140140
exit(0);
141141
else
142142
break;
@@ -248,21 +248,21 @@ int main(int argc, char *argv[])
248248
window.show();
249249
}
250250

251-
// Place this here as guiref has to be defined if we dont want to lose URLs
251+
// Place this here as guiref has to be defined if we dont want to lose URIs
252252
ipcInit();
253253

254254
#if !defined(MAC_OSX) && !defined(WIN32)
255255
// TODO: implement qtipcserver.cpp for Mac and Windows
256256

257-
// Check for URL in argv
257+
// Check for URI in argv
258258
for (int i = 1; i < argc; i++)
259259
{
260260
if (strlen(argv[i]) > 7 && strncasecmp(argv[i], "bitcoin:", 8) == 0)
261261
{
262-
const char *strURL = argv[i];
262+
const char *strURI = argv[i];
263263
try {
264-
boost::interprocess::message_queue mq(boost::interprocess::open_only, "BitcoinURL");
265-
mq.try_send(strURL, strlen(strURL), 0);
264+
boost::interprocess::message_queue mq(boost::interprocess::open_only, BITCOINURI_QUEUE_NAME);
265+
mq.try_send(strURI, strlen(strURI), 0);
266266
}
267267
catch (boost::interprocess::interprocess_exception &ex) {
268268
}

src/qt/bitcoingui.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,7 @@ void BitcoinGUI::gotoMessagePage(QString addr)
715715

716716
void BitcoinGUI::dragEnterEvent(QDragEnterEvent *event)
717717
{
718-
// Accept only URLs
718+
// Accept only URIs
719719
if(event->mimeData()->hasUrls())
720720
event->acceptProposedAction();
721721
}
@@ -725,20 +725,20 @@ void BitcoinGUI::dropEvent(QDropEvent *event)
725725
if(event->mimeData()->hasUrls())
726726
{
727727
gotoSendCoinsPage();
728-
QList<QUrl> urls = event->mimeData()->urls();
729-
foreach(const QUrl &url, urls)
728+
QList<QUrl> uris = event->mimeData()->urls();
729+
foreach(const QUrl &uri, uris)
730730
{
731-
sendCoinsPage->handleURL(url.toString());
731+
sendCoinsPage->handleURI(uri.toString());
732732
}
733733
}
734734

735735
event->acceptProposedAction();
736736
}
737737

738-
void BitcoinGUI::handleURL(QString strURL)
738+
void BitcoinGUI::handleURI(QString strURI)
739739
{
740740
gotoSendCoinsPage();
741-
sendCoinsPage->handleURL(strURL);
741+
sendCoinsPage->handleURI(strURI);
742742

743743
if(!isActiveWindow())
744744
activateWindow();

src/qt/bitcoingui.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public slots:
125125
@param[out] payFee true to pay the fee, false to not pay the fee
126126
*/
127127
void askFee(qint64 nFeeRequired, bool *payFee);
128-
void handleURL(QString strURL);
128+
void handleURI(QString strURI);
129129

130130
void gotoMessagePage();
131131
void gotoMessagePage(QString);

src/qt/guiutil.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ void GUIUtil::setupAmountWidget(QLineEdit *widget, QWidget *parent)
5252
widget->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
5353
}
5454

55-
bool GUIUtil::parseBitcoinURL(const QUrl &url, SendCoinsRecipient *out)
55+
bool GUIUtil::parseBitcoinURI(const QUrl &uri, SendCoinsRecipient *out)
5656
{
57-
if(url.scheme() != QString("bitcoin"))
57+
if(uri.scheme() != QString("bitcoin"))
5858
return false;
5959

6060
SendCoinsRecipient rv;
61-
rv.address = url.path();
61+
rv.address = uri.path();
6262
rv.amount = 0;
63-
QList<QPair<QString, QString> > items = url.queryItems();
63+
QList<QPair<QString, QString> > items = uri.queryItems();
6464
for (QList<QPair<QString, QString> >::iterator i = items.begin(); i != items.end(); i++)
6565
{
6666
bool fShouldReturnFalse = false;
@@ -97,18 +97,18 @@ bool GUIUtil::parseBitcoinURL(const QUrl &url, SendCoinsRecipient *out)
9797
return true;
9898
}
9999

100-
bool GUIUtil::parseBitcoinURL(QString url, SendCoinsRecipient *out)
100+
bool GUIUtil::parseBitcoinURI(QString uri, SendCoinsRecipient *out)
101101
{
102102
// Convert bitcoin:// to bitcoin:
103103
//
104104
// Cannot handle this later, because bitcoin:// will cause Qt to see the part after // as host,
105105
// which will lowercase it (and thus invalidate the address).
106-
if(url.startsWith("bitcoin://"))
106+
if(uri.startsWith("bitcoin://"))
107107
{
108-
url.replace(0, 10, "bitcoin:");
108+
uri.replace(0, 10, "bitcoin:");
109109
}
110-
QUrl urlInstance(url);
111-
return parseBitcoinURL(urlInstance, out);
110+
QUrl uriInstance(uri);
111+
return parseBitcoinURI(uriInstance, out);
112112
}
113113

114114
QString GUIUtil::HtmlEscape(const QString& str, bool fMultiLine)

src/qt/guiutil.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ class GUIUtil
2929
static void setupAddressWidget(QLineEdit *widget, QWidget *parent);
3030
static void setupAmountWidget(QLineEdit *widget, QWidget *parent);
3131

32-
// Parse "bitcoin:" URL into recipient object, return true on succesful parsing
33-
// See Bitcoin URL definition discussion here: https://bitcointalk.org/index.php?topic=33490.0
34-
static bool parseBitcoinURL(const QUrl &url, SendCoinsRecipient *out);
35-
static bool parseBitcoinURL(QString url, SendCoinsRecipient *out);
32+
// Parse "bitcoin:" URI into recipient object, return true on succesful parsing
33+
// See Bitcoin URI definition discussion here: https://bitcointalk.org/index.php?topic=33490.0
34+
static bool parseBitcoinURI(const QUrl &, SendCoinsRecipient *out);
35+
static bool parseBitcoinURI(QString uri, SendCoinsRecipient *out);
3636

3737
// HTML escaping for rich text controls
3838
static QString HtmlEscape(const QString& str, bool fMultiLine=false);

src/qt/qtipcserver.cpp

+7-6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <boost/date_time/posix_time/posix_time.hpp>
99

1010
#include "headers.h"
11+
#include "qtipcserver.h"
1112

1213
using namespace boost::interprocess;
1314
using namespace boost::posix_time;
@@ -16,7 +17,7 @@ using namespace std;
1617

1718
void ipcShutdown()
1819
{
19-
message_queue::remove("BitcoinURL");
20+
message_queue::remove(BITCOINURI_QUEUE_NAME);
2021
}
2122

2223
void ipcThread(void* parg)
@@ -30,7 +31,7 @@ void ipcThread(void* parg)
3031
ptime d = boost::posix_time::microsec_clock::universal_time() + millisec(100);
3132
if(mq->timed_receive(&strBuf, sizeof(strBuf), nSize, nPriority, d))
3233
{
33-
ThreadSafeHandleURL(std::string(strBuf, nSize));
34+
ThreadSafeHandleURI(std::string(strBuf, nSize));
3435
Sleep(1000);
3536
}
3637
if (fShutdown)
@@ -60,23 +61,23 @@ void ipcInit()
6061
size_t nSize;
6162
unsigned int nPriority;
6263
try {
63-
mq = new message_queue(open_or_create, "BitcoinURL", 2, 256);
64+
mq = new message_queue(open_or_create, BITCOINURI_QUEUE_NAME, 2, 256);
6465

6566
// Make sure we don't lose any bitcoin: URIs
6667
for (int i = 0; i < 2; i++)
6768
{
6869
ptime d = boost::posix_time::microsec_clock::universal_time() + millisec(1);
6970
if(mq->timed_receive(&strBuf, sizeof(strBuf), nSize, nPriority, d))
7071
{
71-
ThreadSafeHandleURL(std::string(strBuf, nSize));
72+
ThreadSafeHandleURI(std::string(strBuf, nSize));
7273
}
7374
else
7475
break;
7576
}
7677

7778
// Make sure only one bitcoin instance is listening
78-
message_queue::remove("BitcoinURL");
79-
mq = new message_queue(open_or_create, "BitcoinURL", 2, 256);
79+
message_queue::remove(BITCOINURI_QUEUE_NAME);
80+
mq = new message_queue(open_or_create, BITCOINURI_QUEUE_NAME, 2, 256);
8081
}
8182
catch (interprocess_exception &ex) {
8283
return;

src/qt/qtipcserver.h

+2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
#define BITCOINURI_QUEUE_NAME "BitcoinURI"
2+
13
void ipcInit();
24
void ipcShutdown();

src/qt/sendcoinsdialog.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,10 @@ void SendCoinsDialog::pasteEntry(const SendCoinsRecipient &rv)
265265
}
266266

267267

268-
void SendCoinsDialog::handleURL(const QString &url)
268+
void SendCoinsDialog::handleURI(const QString &uri)
269269
{
270270
SendCoinsRecipient rv;
271-
if(!GUIUtil::parseBitcoinURL(url, &rv))
271+
if(!GUIUtil::parseBitcoinURI(uri, &rv))
272272
{
273273
return;
274274
}

src/qt/sendcoinsdialog.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class SendCoinsDialog : public QDialog
3030
QWidget *setupTabChain(QWidget *prev);
3131

3232
void pasteEntry(const SendCoinsRecipient &rv);
33-
void handleURL(const QString &url);
33+
void handleURI(const QString &uri);
3434

3535
public slots:
3636
void clear();

src/qt/test/test_main.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#include <QTest>
22
#include <QObject>
33

4-
#include "urltests.h"
4+
#include "uritests.h"
55

66
// This is all you need to run all the tests
77
int main(int argc, char *argv[])
88
{
9-
URLTests test1;
9+
URITests test1;
1010
QTest::qExec(&test1);
1111
}
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "urltests.h"
1+
#include "uritests.h"
22
#include "../guiutil.h"
33
#include "../walletmodel.h"
44

@@ -13,59 +13,59 @@ struct SendCoinsRecipient
1313
};
1414
*/
1515

16-
void URLTests::urlTests()
16+
void URITests::uriTests()
1717
{
1818
SendCoinsRecipient rv;
19-
QUrl url;
20-
url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?req-dontexist="));
21-
QVERIFY(!GUIUtil::parseBitcoinURL(url, &rv));
19+
QUrl uri;
20+
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?req-dontexist="));
21+
QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv));
2222

23-
url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?dontexist="));
24-
QVERIFY(GUIUtil::parseBitcoinURL(url, &rv));
23+
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?dontexist="));
24+
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
2525
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
2626
QVERIFY(rv.label == QString());
2727
QVERIFY(rv.amount == 0);
2828

29-
url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?label=Wikipedia Example Address"));
30-
QVERIFY(GUIUtil::parseBitcoinURL(url, &rv));
29+
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?label=Wikipedia Example Address"));
30+
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
3131
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
3232
QVERIFY(rv.label == QString("Wikipedia Example Address"));
3333
QVERIFY(rv.amount == 0);
3434

35-
url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=0.001"));
36-
QVERIFY(GUIUtil::parseBitcoinURL(url, &rv));
35+
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=0.001"));
36+
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
3737
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
3838
QVERIFY(rv.label == QString());
3939
QVERIFY(rv.amount == 100000);
4040

41-
url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1.001"));
42-
QVERIFY(GUIUtil::parseBitcoinURL(url, &rv));
41+
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1.001"));
42+
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
4343
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
4444
QVERIFY(rv.label == QString());
4545
QVERIFY(rv.amount == 100100000);
4646

47-
url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=100&label=Wikipedia Example"));
48-
QVERIFY(GUIUtil::parseBitcoinURL(url, &rv));
47+
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=100&label=Wikipedia Example"));
48+
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
4949
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
5050
QVERIFY(rv.amount == 10000000000);
5151
QVERIFY(rv.label == QString("Wikipedia Example"));
5252

53-
url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?message=Wikipedia Example Address"));
54-
QVERIFY(GUIUtil::parseBitcoinURL(url, &rv));
53+
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?message=Wikipedia Example Address"));
54+
QVERIFY(GUIUtil::parseBitcoinURI(uri, &rv));
5555
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
5656
QVERIFY(rv.label == QString());
5757

58-
QVERIFY(GUIUtil::parseBitcoinURL("bitcoin://175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?message=Wikipedia Example Address", &rv));
58+
QVERIFY(GUIUtil::parseBitcoinURI("bitcoin://175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?message=Wikipedia Example Address", &rv));
5959
QVERIFY(rv.address == QString("175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W"));
6060
QVERIFY(rv.label == QString());
6161

6262
// We currently dont implement the message paramenter (ok, yea, we break spec...)
63-
url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?req-message=Wikipedia Example Address"));
64-
QVERIFY(!GUIUtil::parseBitcoinURL(url, &rv));
63+
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?req-message=Wikipedia Example Address"));
64+
QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv));
6565

66-
url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1,000&label=Wikipedia Example"));
67-
QVERIFY(!GUIUtil::parseBitcoinURL(url, &rv));
66+
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1,000&label=Wikipedia Example"));
67+
QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv));
6868

69-
url.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1,000.0&label=Wikipedia Example"));
70-
QVERIFY(!GUIUtil::parseBitcoinURL(url, &rv));
69+
uri.setUrl(QString("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=1,000.0&label=Wikipedia Example"));
70+
QVERIFY(!GUIUtil::parseBitcoinURI(uri, &rv));
7171
}

src/qt/test/uritests.h

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#ifndef URITESTS_H
2+
#define URITESTS_H
3+
4+
#include <QTest>
5+
#include <QObject>
6+
7+
class URITests : public QObject
8+
{
9+
Q_OBJECT
10+
11+
private slots:
12+
void uriTests();
13+
};
14+
15+
#endif // URITESTS_H

src/qt/test/urltests.h

-15
This file was deleted.

src/ui_interface.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
extern int ThreadSafeMessageBox(const std::string& message, const std::string& caption, int style=wxOK);
4242
extern bool ThreadSafeAskFee(int64 nFeeRequired, const std::string& strCaption);
43-
extern void ThreadSafeHandleURL(const std::string& strURL);
43+
extern void ThreadSafeHandleURI(const std::string& strURI);
4444
extern void MainFrameRepaint();
4545
extern void AddressBookRepaint();
4646
extern void QueueShutdown();

0 commit comments

Comments
 (0)