revert revision 56, going in different direction with boost::asio and JSON-RPC
This commit is contained in:
parent
a43c00c569
commit
1c5d5e58c6
7 changed files with 8 additions and 101 deletions
|
@ -24,8 +24,6 @@
|
||||||
#include <wx/taskbar.h>
|
#include <wx/taskbar.h>
|
||||||
#include <wx/stdpaths.h>
|
#include <wx/stdpaths.h>
|
||||||
#include <wx/utils.h>
|
#include <wx/utils.h>
|
||||||
#include <wx/ipc.h>
|
|
||||||
#include <wx/ipcbase.h>
|
|
||||||
#include <openssl/ecdsa.h>
|
#include <openssl/ecdsa.h>
|
||||||
#include <openssl/evp.h>
|
#include <openssl/evp.h>
|
||||||
#include <openssl/rand.h>
|
#include <openssl/rand.h>
|
||||||
|
@ -104,7 +102,6 @@ using namespace boost;
|
||||||
#include "market.h"
|
#include "market.h"
|
||||||
#include "uibase.h"
|
#include "uibase.h"
|
||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
#include "ipc.h"
|
|
||||||
|
|
||||||
#include "xpm/addressbook16.xpm"
|
#include "xpm/addressbook16.xpm"
|
||||||
#include "xpm/addressbook20.xpm"
|
#include "xpm/addressbook20.xpm"
|
||||||
|
|
33
ipc.cpp
33
ipc.cpp
|
@ -1,33 +0,0 @@
|
||||||
/*
|
|
||||||
* Inter-process calling functionality
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "headers.h"
|
|
||||||
|
|
||||||
wxConnectionBase * CServer::OnAcceptConnection (const wxString &topic) {
|
|
||||||
return new CServerConnection;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxConnectionBase * CClient::OnMakeConnection () {
|
|
||||||
return new CClientConnection;
|
|
||||||
}
|
|
||||||
|
|
||||||
// For request based handling
|
|
||||||
const void * CServerConnection::OnRequest (const wxString &topic, const wxString &item, size_t *size, wxIPCFormat format) {
|
|
||||||
const char * output;
|
|
||||||
|
|
||||||
if (item == "blockamount") {
|
|
||||||
stringstream stream;
|
|
||||||
stream << nBestHeight + 1;
|
|
||||||
output = stream.str().c_str();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
output = "Unknown identifier";
|
|
||||||
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
// For event based handling
|
|
||||||
bool CClientConnection::OnAdvise (const wxString &topic, const wxString &item, const void *data, size_t size, wxIPCFormat format) {
|
|
||||||
return false;
|
|
||||||
}
|
|
28
ipc.h
28
ipc.h
|
@ -1,28 +0,0 @@
|
||||||
#ifndef _IPC_H
|
|
||||||
#define _IPC_H
|
|
||||||
|
|
||||||
class CServer : public wxServer {
|
|
||||||
public:
|
|
||||||
wxConnectionBase * OnAcceptConnection (const wxString &topic);
|
|
||||||
};
|
|
||||||
|
|
||||||
class CClient : public wxClient {
|
|
||||||
public:
|
|
||||||
wxConnectionBase * OnMakeConnection ();
|
|
||||||
};
|
|
||||||
|
|
||||||
class CServerConnection : public wxConnection {
|
|
||||||
public:
|
|
||||||
const void * OnRequest (const wxString &topic, const wxString &item, size_t *size, wxIPCFormat format);
|
|
||||||
};
|
|
||||||
|
|
||||||
class CClientConnection : public wxConnection {
|
|
||||||
public:
|
|
||||||
CClientConnection() : wxConnection() {}
|
|
||||||
~CClientConnection() {}
|
|
||||||
|
|
||||||
bool OnAdvise (const wxString &topic, const wxString &item, const void *data, size_t size, wxIPCFormat format);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* _IPC_H */
|
|
||||||
|
|
4
makefile
4
makefile
|
@ -67,12 +67,10 @@ obj/irc.o: irc.cpp $(HEADERS)
|
||||||
obj/ui_res.o: ui.rc rc/bitcoin.ico rc/check.ico rc/send16.bmp rc/send16mask.bmp rc/send16masknoshadow.bmp rc/send20.bmp rc/send20mask.bmp rc/addressbook16.bmp rc/addressbook16mask.bmp rc/addressbook20.bmp rc/addressbook20mask.bmp
|
obj/ui_res.o: ui.rc rc/bitcoin.ico rc/check.ico rc/send16.bmp rc/send16mask.bmp rc/send16masknoshadow.bmp rc/send20.bmp rc/send20mask.bmp rc/addressbook16.bmp rc/addressbook16mask.bmp rc/addressbook20.bmp rc/addressbook20mask.bmp
|
||||||
windres $(WXDEFS) $(INCLUDEPATHS) -o $@ -i $<
|
windres $(WXDEFS) $(INCLUDEPATHS) -o $@ -i $<
|
||||||
|
|
||||||
obj/ipc.o: ipc.cpp $(HEADERS)
|
|
||||||
g++ -c $(CFLAGS) -o $@ $<
|
|
||||||
|
|
||||||
|
|
||||||
OBJS=obj/util.o obj/script.o obj/db.o obj/net.o obj/main.o obj/market.o \
|
OBJS=obj/util.o obj/script.o obj/db.o obj/net.o obj/main.o obj/market.o \
|
||||||
obj/ui.o obj/uibase.o obj/sha.o obj/irc.o obj/ui_res.o obj/ipc.o
|
obj/ui.o obj/uibase.o obj/sha.o obj/irc.o obj/ui_res.o
|
||||||
|
|
||||||
bitcoin.exe: headers.h.gch $(OBJS)
|
bitcoin.exe: headers.h.gch $(OBJS)
|
||||||
-kill /f bitcoin.exe
|
-kill /f bitcoin.exe
|
||||||
|
|
|
@ -75,12 +75,11 @@ obj/sha.o: sha.cpp sha.h
|
||||||
obj/irc.o: irc.cpp $(HEADERS)
|
obj/irc.o: irc.cpp $(HEADERS)
|
||||||
g++ -c $(CFLAGS) -o $@ $<
|
g++ -c $(CFLAGS) -o $@ $<
|
||||||
|
|
||||||
obj/ipc.o: ipc.cpp $(HEADERS)
|
|
||||||
g++ -c $(CFLAGS) -o $@ $<
|
|
||||||
|
|
||||||
|
|
||||||
OBJS=obj/util.o obj/script.o obj/db.o obj/net.o obj/main.o obj/market.o \
|
OBJS=obj/util.o obj/script.o obj/db.o obj/net.o obj/main.o obj/market.o \
|
||||||
obj/ui.o obj/uibase.o obj/sha.o obj/irc.o obj/ipc.o
|
obj/ui.o obj/uibase.o obj/sha.o obj/irc.o
|
||||||
|
|
||||||
bitcoin: headers.h.gch $(OBJS)
|
bitcoin: headers.h.gch $(OBJS)
|
||||||
g++ $(CFLAGS) -o $@ $(LIBPATHS) $(OBJS) $(LIBS)
|
g++ $(CFLAGS) -o $@ $(LIBPATHS) $(OBJS) $(LIBS)
|
||||||
|
|
|
@ -31,7 +31,7 @@ LIBS= \
|
||||||
-l wx_gtk2u$(D)-2.9 \
|
-l wx_gtk2u$(D)-2.9 \
|
||||||
-Wl,-Bdynamic \
|
-Wl,-Bdynamic \
|
||||||
-l crypto \
|
-l crypto \
|
||||||
-l gtk-x11-2.0 -l gthread-2.0 -l SM \
|
-l gtk-x11-2.0 -l gthread-2.0 -l SM
|
||||||
|
|
||||||
WXDEFS=-D__WXGTK__ -DNOPCH
|
WXDEFS=-D__WXGTK__ -DNOPCH
|
||||||
CFLAGS=-O0 -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(WXDEFS) $(INCLUDEPATHS)
|
CFLAGS=-O0 -Wno-invalid-offsetof -Wformat $(DEBUGFLAGS) $(WXDEFS) $(INCLUDEPATHS)
|
||||||
|
@ -75,12 +75,11 @@ obj/sha.o: sha.cpp sha.h
|
||||||
obj/irc.o: irc.cpp $(HEADERS)
|
obj/irc.o: irc.cpp $(HEADERS)
|
||||||
g++ -c $(CFLAGS) -o $@ $<
|
g++ -c $(CFLAGS) -o $@ $<
|
||||||
|
|
||||||
obj/ipc.o: ipc.cpp $(HEADERS)
|
|
||||||
g++ -c $(CFLAGS) -o $@ $<
|
|
||||||
|
|
||||||
|
|
||||||
OBJS=obj/util.o obj/script.o obj/db.o obj/net.o obj/main.o obj/market.o \
|
OBJS=obj/util.o obj/script.o obj/db.o obj/net.o obj/main.o obj/market.o \
|
||||||
obj/ui.o obj/uibase.o obj/sha.o obj/irc.o obj/ipc.o
|
obj/ui.o obj/uibase.o obj/sha.o obj/irc.o
|
||||||
|
|
||||||
bitcoin: headers.h.gch $(OBJS)
|
bitcoin: headers.h.gch $(OBJS)
|
||||||
g++ $(CFLAGS) -o $@ $(LIBPATHS) $(OBJS) $(LIBS)
|
g++ $(CFLAGS) -o $@ $(LIBPATHS) $(OBJS) $(LIBS)
|
||||||
|
|
29
ui.cpp
29
ui.cpp
|
@ -21,7 +21,6 @@ DEFINE_EVENT_TYPE(wxEVT_REPLY3)
|
||||||
|
|
||||||
CMainFrame* pframeMain = NULL;
|
CMainFrame* pframeMain = NULL;
|
||||||
CMyTaskBarIcon* ptaskbaricon = NULL;
|
CMyTaskBarIcon* ptaskbaricon = NULL;
|
||||||
CServer* pserver = NULL;
|
|
||||||
map<string, string> mapAddressBook;
|
map<string, string> mapAddressBook;
|
||||||
bool fRandSendTest = false;
|
bool fRandSendTest = false;
|
||||||
void RandSend();
|
void RandSend();
|
||||||
|
@ -385,8 +384,6 @@ CMainFrame::~CMainFrame()
|
||||||
pframeMain = NULL;
|
pframeMain = NULL;
|
||||||
delete ptaskbaricon;
|
delete ptaskbaricon;
|
||||||
ptaskbaricon = NULL;
|
ptaskbaricon = NULL;
|
||||||
delete pserver;
|
|
||||||
pserver = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExitTimeout(void* parg)
|
void ExitTimeout(void* parg)
|
||||||
|
@ -1690,8 +1687,8 @@ CAboutDialog::CAboutDialog(wxWindow* parent) : CAboutDialogBase(parent)
|
||||||
#if !wxUSE_UNICODE
|
#if !wxUSE_UNICODE
|
||||||
// Workaround until upgrade to wxWidgets supporting UTF-8
|
// Workaround until upgrade to wxWidgets supporting UTF-8
|
||||||
wxString str = m_staticTextMain->GetLabel();
|
wxString str = m_staticTextMain->GetLabel();
|
||||||
if (str.Find('<EFBFBD>') != wxNOT_FOUND)
|
if (str.Find('Â') != wxNOT_FOUND)
|
||||||
str.Remove(str.Find('<EFBFBD>'), 1);
|
str.Remove(str.Find('Â'), 1);
|
||||||
m_staticTextMain->SetLabel(str);
|
m_staticTextMain->SetLabel(str);
|
||||||
#endif
|
#endif
|
||||||
#ifndef __WXMSW__
|
#ifndef __WXMSW__
|
||||||
|
@ -3551,26 +3548,6 @@ bool CMyApp::OnInit2()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mapArgs.count("-blockamount")) {
|
|
||||||
CClient client;
|
|
||||||
wxString hostname = "localhost";
|
|
||||||
wxString server = GetDataDir() + "service";
|
|
||||||
CClientConnection * pconnection = (CClientConnection *)client.MakeConnection(hostname, server, "ipc test");
|
|
||||||
string output = "";
|
|
||||||
if (pconnection) {
|
|
||||||
char * pbuffer = (char *)pconnection->Request("blockamount");
|
|
||||||
while (*pbuffer != '\n') {
|
|
||||||
output += *pbuffer;
|
|
||||||
pbuffer++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
output = "Cannot access Bitcoin. Are you sure the program is running?\n";
|
|
||||||
}
|
|
||||||
fprintf(stderr, "%s", output.c_str());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mapArgs.count("-datadir"))
|
if (mapArgs.count("-datadir"))
|
||||||
strlcpy(pszSetDataDir, mapArgs["-datadir"].c_str(), sizeof(pszSetDataDir));
|
strlcpy(pszSetDataDir, mapArgs["-datadir"].c_str(), sizeof(pszSetDataDir));
|
||||||
|
|
||||||
|
@ -3778,8 +3755,6 @@ bool CMyApp::OnInit2()
|
||||||
if (fFirstRun)
|
if (fFirstRun)
|
||||||
SetStartOnSystemStartup(true);
|
SetStartOnSystemStartup(true);
|
||||||
|
|
||||||
pserver = new CServer;
|
|
||||||
pserver->Create(GetDataDir() + "service");
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Tests
|
// Tests
|
||||||
|
|
Loading…
Reference in a new issue