You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
123 lines
3.1 KiB
123 lines
3.1 KiB
14 years ago
|
/*
|
||
|
* W.J. van der Laan 2011
|
||
|
*/
|
||
14 years ago
|
#include "bitcoingui.h"
|
||
14 years ago
|
#include "clientmodel.h"
|
||
14 years ago
|
#include "util.h"
|
||
14 years ago
|
#include "init.h"
|
||
14 years ago
|
#include "main.h"
|
||
14 years ago
|
#include "externui.h"
|
||
14 years ago
|
|
||
|
#include <QApplication>
|
||
14 years ago
|
#include <QMessageBox>
|
||
14 years ago
|
#include <QThread>
|
||
14 years ago
|
|
||
14 years ago
|
// Need a global reference for the notifications to find the GUI
|
||
14 years ago
|
BitcoinGUI *guiref;
|
||
|
|
||
|
int MyMessageBox(const std::string& message, const std::string& caption, int style, wxWindow* parent, int x, int y)
|
||
|
{
|
||
|
// Message from main thread
|
||
|
if(guiref)
|
||
|
{
|
||
|
guiref->error(QString::fromStdString(caption),
|
||
|
QString::fromStdString(message));
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
QMessageBox::critical(0, QString::fromStdString(caption),
|
||
|
QString::fromStdString(message),
|
||
|
QMessageBox::Ok, QMessageBox::Ok);
|
||
|
}
|
||
|
return 4;
|
||
|
}
|
||
|
|
||
|
int ThreadSafeMessageBox(const std::string& message, const std::string& caption, int style, wxWindow* parent, int x, int y)
|
||
|
{
|
||
|
// Message from network thread
|
||
|
if(guiref)
|
||
|
{
|
||
|
QMetaObject::invokeMethod(guiref, "error", Qt::QueuedConnection,
|
||
|
Q_ARG(QString, QString::fromStdString(caption)),
|
||
|
Q_ARG(QString, QString::fromStdString(message)));
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
printf("%s: %s\n", caption.c_str(), message.c_str());
|
||
|
fprintf(stderr, "%s: %s\n", caption.c_str(), message.c_str());
|
||
|
}
|
||
|
return 4;
|
||
|
}
|
||
|
|
||
|
bool ThreadSafeAskFee(int64 nFeeRequired, const std::string& strCaption, wxWindow* parent)
|
||
|
{
|
||
14 years ago
|
if(!guiref)
|
||
|
return false;
|
||
|
if(nFeeRequired < MIN_TX_FEE || nFeeRequired <= nTransactionFee || fDaemon)
|
||
|
return true;
|
||
|
bool payFee = false;
|
||
|
|
||
|
/* Call slot on GUI thread.
|
||
|
If called from another thread, use a blocking QueuedConnection.
|
||
|
*/
|
||
|
Qt::ConnectionType connectionType = Qt::DirectConnection;
|
||
|
if(QThread::currentThread() != QCoreApplication::instance()->thread())
|
||
|
{
|
||
|
connectionType = Qt::BlockingQueuedConnection;
|
||
|
}
|
||
|
|
||
|
QMetaObject::invokeMethod(guiref, "askFee", connectionType,
|
||
|
Q_ARG(qint64, nFeeRequired),
|
||
|
Q_ARG(bool*, &payFee));
|
||
|
|
||
|
return payFee;
|
||
14 years ago
|
}
|
||
|
|
||
|
void CalledSetStatusBar(const std::string& strText, int nField)
|
||
|
{
|
||
|
// Only used for built-in mining, which is disabled, simple ignore
|
||
|
}
|
||
|
|
||
|
void UIThreadCall(boost::function0<void> fn)
|
||
|
{
|
||
|
// Only used for built-in mining, which is disabled, simple ignore
|
||
|
}
|
||
|
|
||
|
void MainFrameRepaint()
|
||
|
{
|
||
|
}
|
||
14 years ago
|
|
||
|
int main(int argc, char *argv[])
|
||
|
{
|
||
|
QApplication app(argc, argv);
|
||
14 years ago
|
app.setQuitOnLastWindowClosed(false);
|
||
14 years ago
|
|
||
14 years ago
|
try
|
||
|
{
|
||
14 years ago
|
if(AppInit2(argc, argv))
|
||
|
{
|
||
14 years ago
|
BitcoinGUI window;
|
||
14 years ago
|
ClientModel model;
|
||
14 years ago
|
guiref = &window;
|
||
14 years ago
|
window.setModel(&model);
|
||
14 years ago
|
|
||
14 years ago
|
window.show();
|
||
14 years ago
|
|
||
14 years ago
|
int retval = app.exec();
|
||
14 years ago
|
|
||
14 years ago
|
guiref = 0;
|
||
14 years ago
|
Shutdown(NULL);
|
||
14 years ago
|
|
||
14 years ago
|
return retval;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return 1;
|
||
|
}
|
||
|
} catch (std::exception& e) {
|
||
|
PrintException(&e, "Runaway exception");
|
||
|
} catch (...) {
|
||
|
PrintException(NULL, "Runaway exception");
|
||
|
}
|
||
14 years ago
|
}
|