-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for opening bitcoin: URIs directly.
- Loading branch information
Matt Corallo
committed
Jan 5, 2012
1 parent
9a93c4c
commit 7d145a0
Showing
15 changed files
with
202 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[Protocol] | ||
exec=bitcoin-qt '%u' | ||
protocol=bitcoin | ||
input=none | ||
output=none | ||
helper=true | ||
listing= | ||
reading=false | ||
writing=false | ||
makedir=false | ||
deleting=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
bitcoin (0.5.1-natty1) natty; urgency=low | ||
|
||
* Add GNOME/KDE support for bitcoin-qt's bitcoin: URI support. | ||
Thanks to luke-jr for the KDE .protocol file. | ||
|
||
-- Matt Corallo <[email protected]> Fri, 23 Dec 2011 20:25:00 -0500 | ||
|
||
bitcoin (0.5.1-natty0) natty; urgency=low | ||
|
||
* New upstream release. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
// Copyright (c) 2011 The Bitcoin developers | ||
// Distributed under the MIT/X11 software license, see the accompanying | ||
// file license.txt or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
#include <boost/algorithm/string.hpp> | ||
#include <boost/interprocess/ipc/message_queue.hpp> | ||
#include <boost/tokenizer.hpp> | ||
#include <boost/date_time/posix_time/posix_time.hpp> | ||
|
||
#include "headers.h" | ||
|
||
using namespace boost::interprocess; | ||
using namespace boost::posix_time; | ||
using namespace boost; | ||
using namespace std; | ||
|
||
void ipcShutdown() | ||
{ | ||
message_queue::remove("BitcoinURL"); | ||
} | ||
|
||
void ipcThread(void* parg) | ||
{ | ||
message_queue* mq = (message_queue*)parg; | ||
char strBuf[257]; | ||
size_t nSize; | ||
unsigned int nPriority; | ||
loop | ||
{ | ||
ptime d = boost::posix_time::microsec_clock::universal_time() + millisec(100); | ||
if(mq->timed_receive(&strBuf, sizeof(strBuf), nSize, nPriority, d)) | ||
{ | ||
strBuf[nSize] = '\0'; | ||
// Convert bitcoin:// URLs to bitcoin: URIs | ||
if (strBuf[8] == '/' && strBuf[9] == '/') | ||
{ | ||
for (int i = 8; i < 256; i++) | ||
{ | ||
strBuf[i] = strBuf[i+2]; | ||
} | ||
} | ||
ThreadSafeHandleURL(strBuf); | ||
Sleep(1000); | ||
} | ||
if (fShutdown) | ||
{ | ||
ipcShutdown(); | ||
break; | ||
} | ||
} | ||
ipcShutdown(); | ||
} | ||
|
||
void ipcInit() | ||
{ | ||
message_queue* mq; | ||
char strBuf[257]; | ||
size_t nSize; | ||
unsigned int nPriority; | ||
try { | ||
mq = new message_queue(open_or_create, "BitcoinURL", 2, 256); | ||
|
||
// Make sure we don't lose any bitcoin: URIs | ||
for (int i = 0; i < 2; i++) | ||
{ | ||
ptime d = boost::posix_time::microsec_clock::universal_time() + millisec(1); | ||
if(mq->timed_receive(&strBuf, sizeof(strBuf), nSize, nPriority, d)) | ||
{ | ||
strBuf[nSize] = '\0'; | ||
// Convert bitcoin:// URLs to bitcoin: URIs | ||
if (strBuf[8] == '/' && strBuf[9] == '/') | ||
{ | ||
for (int i = 8; i < 256; i++) | ||
{ | ||
strBuf[i] = strBuf[i+2]; | ||
} | ||
} | ||
ThreadSafeHandleURL(strBuf); | ||
} | ||
else | ||
break; | ||
} | ||
|
||
// Make sure only one bitcoin instance is listening | ||
message_queue::remove("BitcoinURL"); | ||
mq = new message_queue(open_or_create, "BitcoinURL", 2, 256); | ||
} | ||
catch (interprocess_exception &ex) { | ||
return; | ||
} | ||
if (!CreateThread(ipcThread, mq)) | ||
{ | ||
delete mq; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
void ipcInit(); | ||
void ipcShutdown(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters