1 // Copyright (c) 2009-2012 The Bitcoin developers
2 // Distributed under the MIT/X11 software license, see the accompanying
3 // file license.txt or http://www.opensource.org/licenses/mit-license.php.
5 #include <boost/algorithm/string.hpp>
6 #include <boost/interprocess/ipc/message_queue.hpp>
7 #include <boost/tokenizer.hpp>
8 #include <boost/date_time/posix_time/posix_time.hpp>
10 #include "ui_interface.h"
12 #include "qtipcserver.h"
14 using namespace boost::interprocess;
15 using namespace boost::posix_time;
16 using namespace boost;
21 message_queue::remove(BITCOINURI_QUEUE_NAME);
24 void ipcThread(void* parg)
26 message_queue* mq = (message_queue*)parg;
29 unsigned int nPriority;
32 ptime d = boost::posix_time::microsec_clock::universal_time() + millisec(100);
33 if(mq->timed_receive(&strBuf, sizeof(strBuf), nSize, nPriority, d))
35 ThreadSafeHandleURI(std::string(strBuf, nSize));
50 // TODO: implement bitcoin: URI handling the Mac Way
54 // TODO: THOROUGHLY test boost::interprocess fix,
55 // and make sure there are no Windows argument-handling exploitable
63 unsigned int nPriority;
65 mq = new message_queue(open_or_create, BITCOINURI_QUEUE_NAME, 2, 256);
67 // Make sure we don't lose any bitcoin: URIs
68 for (int i = 0; i < 2; i++)
70 ptime d = boost::posix_time::microsec_clock::universal_time() + millisec(1);
71 if(mq->timed_receive(&strBuf, sizeof(strBuf), nSize, nPriority, d))
73 ThreadSafeHandleURI(std::string(strBuf, nSize));
79 // Make sure only one bitcoin instance is listening
80 message_queue::remove(BITCOINURI_QUEUE_NAME);
81 mq = new message_queue(open_or_create, BITCOINURI_QUEUE_NAME, 2, 256);
83 catch (interprocess_exception &ex) {
86 if (!CreateThread(ipcThread, mq))