aboutsummaryrefslogtreecommitdiff
path: root/src/qt/bitcoin.cpp
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2013-02-11 18:52:30 -0500
committerGavin Andresen <gavinandresen@gmail.com>2013-02-12 15:41:31 -0500
commit8269a0953ee9ccbdc422433fc37184e60f94b178 (patch)
tree9e5a3c73057afdba5e7351e051072ac2365ca924 /src/qt/bitcoin.cpp
parent2f0fa79db290d5139c27409055b2035099afa6fd (diff)
Reimplement click-to-pay links. Add OSX support.
Switch to using Qt's QLocalServer/QLocalSocket to handle bitcoin payment links (bitcoin:... URIs) Reason for switch: the boost::interprocess mechanism seemed flaky, and doesn't mesh as well with "The Qt Way" qtipcserver.cpp/h is replaced by paymentserver.cpp/h Click-to-pay now also works on OSX, with a custom Info.plist that registers Bitcoin-Qt as a handler for bitcoin: URLs and an event listener on the main QApplication that handles QFileOpenEvents (Qt translates 'url clicked' AppleEvents into QFileOpenEvents automagically).
Diffstat (limited to 'src/qt/bitcoin.cpp')
-rw-r--r--src/qt/bitcoin.cpp33
1 files changed, 12 insertions, 21 deletions
diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp
index e5526a6c09..1b5ef28ba9 100644
--- a/src/qt/bitcoin.cpp
+++ b/src/qt/bitcoin.cpp
@@ -9,12 +9,13 @@
#include "guiconstants.h"
#include "init.h"
#include "ui_interface.h"
-#include "qtipcserver.h"
+#include "paymentserver.h"
#include <QApplication>
#include <QMessageBox>
#include <QTextCodec>
#include <QLocale>
+#include <QTimer>
#include <QTranslator>
#include <QSplashScreen>
#include <QLibraryInfo>
@@ -70,15 +71,6 @@ static bool ThreadSafeAskFee(int64 nFeeRequired)
return payFee;
}
-static void ThreadSafeHandleURI(const std::string& strURI)
-{
- if(!guiref)
- return;
-
- QMetaObject::invokeMethod(guiref, "handleURI", GUIUtil::blockingGUIThreadConnection(),
- Q_ARG(QString, QString::fromStdString(strURI)));
-}
-
static void InitMessage(const std::string &message)
{
if(splashref)
@@ -117,14 +109,6 @@ int main(int argc, char *argv[])
// Command-line options take precedence:
ParseParameters(argc, argv);
- if(GetBoolArg("-testnet")) // Separate message queue name for testnet
- strBitcoinURIQueueName = BITCOINURI_QUEUE_NAME_TESTNET;
- else
- strBitcoinURIQueueName = BITCOINURI_QUEUE_NAME_MAINNET;
-
- // Do this early as we don't want to bother initializing if we are just calling IPC
- ipcScanRelay(argc, argv);
-
// Internal string conversion is all UTF-8
QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
QTextCodec::setCodecForCStrings(QTextCodec::codecForTr());
@@ -132,6 +116,12 @@ int main(int argc, char *argv[])
Q_INIT_RESOURCE(bitcoin);
QApplication app(argc, argv);
+ // Do this early as we don't want to bother initializing if we are just calling IPC
+ // ... but do it after creating app, so QCoreApplication::arguments is initialized:
+ if (PaymentServer::ipcSendCommandLine())
+ exit(0);
+ PaymentServer* paymentServer = new PaymentServer(&app);
+
// Install global event filter that makes sure that long tooltips can be word-wrapped
app.installEventFilter(new GUIUtil::ToolTipToRichTextFilter(TOOLTIP_WRAP_THRESHOLD, &app));
@@ -188,7 +178,6 @@ int main(int argc, char *argv[])
// Subscribe to global signals from core
uiInterface.ThreadSafeMessageBox.connect(ThreadSafeMessageBox);
uiInterface.ThreadSafeAskFee.connect(ThreadSafeAskFee);
- uiInterface.ThreadSafeHandleURI.connect(ThreadSafeHandleURI);
uiInterface.InitMessage.connect(InitMessage);
uiInterface.QueueShutdown.connect(QueueShutdown);
uiInterface.Translate.connect(Translate);
@@ -249,8 +238,10 @@ int main(int argc, char *argv[])
window.show();
}
- // Place this here as guiref has to be defined if we don't want to lose URIs
- ipcInit(argc, argv);
+ // Now that initialization/startup is done, process any command-line
+ // bitcoin: URIs
+ QObject::connect(paymentServer, SIGNAL(receivedURI(QString)), &window, SLOT(handleURI(QString)));
+ QTimer::singleShot(100, paymentServer, SLOT(uiReady()));
app.exec();