5 #if defined(HAVE_CONFIG_H) 43 #include <boost/thread.hpp> 45 #include <QApplication> 47 #include <QLibraryInfo> 49 #include <QMessageBox> 53 #include <QTranslator> 54 #include <QSslConfiguration> 58 #if defined(QT_STATICPLUGIN) 60 #if QT_VERSION < 0x050000 61 Q_IMPORT_PLUGIN(qcncodecs)
62 Q_IMPORT_PLUGIN(qjpcodecs)
63 Q_IMPORT_PLUGIN(qtwcodecs)
64 Q_IMPORT_PLUGIN(qkrcodecs)
65 Q_IMPORT_PLUGIN(qtaccessiblewidgets)
67 #if QT_VERSION < 0x050400 68 Q_IMPORT_PLUGIN(AccessibleFactory)
70 #if defined(QT_QPA_PLATFORM_XCB) 71 Q_IMPORT_PLUGIN(QXcbIntegrationPlugin);
72 #elif defined(QT_QPA_PLATFORM_WINDOWS) 73 Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin);
74 #elif defined(QT_QPA_PLATFORM_COCOA) 75 Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin);
80 #if QT_VERSION < 0x050000 85 Q_DECLARE_METATYPE(
bool*)
88 static
void InitMessage(const
std::
string &message)
96 static std::string Translate(
const char* psz)
98 return QCoreApplication::translate(
"fabcoin-core", psz).toStdString();
101 static QString GetLangTerritory()
106 QString lang_territory = QLocale::system().name();
108 QString lang_territory_qsettings = settings.value(
"language",
"").toString();
109 if(!lang_territory_qsettings.isEmpty())
110 lang_territory = lang_territory_qsettings;
112 lang_territory = QString::fromStdString(
gArgs.
GetArg(
"-lang", lang_territory.toStdString()));
113 return lang_territory;
117 static void initTranslations(QTranslator &qtTranslatorBase, QTranslator &qtTranslator, QTranslator &translatorBase, QTranslator &translator)
120 QApplication::removeTranslator(&qtTranslatorBase);
121 QApplication::removeTranslator(&qtTranslator);
122 QApplication::removeTranslator(&translatorBase);
123 QApplication::removeTranslator(&translator);
127 QString lang_territory = GetLangTerritory();
130 QString lang = lang_territory;
131 lang.truncate(lang_territory.lastIndexOf(
'_'));
138 if (qtTranslatorBase.load(
"qt_" + lang, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
139 QApplication::installTranslator(&qtTranslatorBase);
142 if (qtTranslator.load(
"qt_" + lang_territory, QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
143 QApplication::installTranslator(&qtTranslator);
146 if (translatorBase.load(lang,
":/translations/"))
147 QApplication::installTranslator(&translatorBase);
150 if (translator.load(lang_territory,
":/translations/"))
151 QApplication::installTranslator(&translator);
155 #if QT_VERSION < 0x050000 158 if (type == QtDebugMsg) {
168 if (type == QtDebugMsg) {
171 LogPrintf(
"GUI: %s\n", msg.toStdString());
178 int index = list.indexOf(param);
181 list.removeAt(index);
224 void createPaymentServer();
227 void parameterSetup();
230 void createOptionsModel(
bool resetSettings);
234 void createSplashScreen(
const NetworkStyle *networkStyle);
237 void requestInitialize();
239 void requestShutdown();
245 WId getMainWinId()
const;
247 void restoreWallet();
256 void requestedInitialize();
257 void requestedShutdown();
259 void splashFinished(QWidget *window);
281 #include <fabcoin.moc> 319 qDebug() << __func__ <<
": Running initialization in thread";
322 }
catch (
const std::exception&
e) {
333 qDebug() << __func__ <<
": Running Shutdown in thread";
337 qDebug() << __func__ <<
": Shutdown finished";
339 }
catch (
const std::exception&
e) {
347 QApplication(argc, argv),
352 pollShutdownTimer(0),
359 setQuitOnLastWindowClosed(
false);
364 std::string platformName;
376 qDebug() << __func__ <<
": Stopping thread";
379 qDebug() << __func__ <<
": Stopped thread";
385 delete paymentServer;
395 void FabcoinApplication::createPaymentServer()
421 connect(
this, SIGNAL(
splashFinished(QWidget*)), splash, SLOT(slotFinish(QWidget*)));
440 connect(
this, SIGNAL(
stopThread()), executor, SLOT(deleteLater()));
454 qDebug() << __func__ <<
": Requesting initialize";
466 qDebug() << __func__ <<
": Requesting shutdown";
477 window->removeAllWallets();
496 qDebug() << __func__ <<
": Initialization result: " << success;
498 returnValue = success ? EXIT_SUCCESS : EXIT_FAILURE;
541 connect(
window, SIGNAL(receivedURI(QString)),
542 paymentServer, SLOT(handleURIOrFile(QString)));
543 connect(paymentServer, SIGNAL(message(QString,QString,
unsigned int)),
544 window, SLOT(message(QString,QString,
unsigned int)));
545 QTimer::singleShot(100, paymentServer, SLOT(uiReady()));
559 QMessageBox::critical(0,
"Runaway exception", FabcoinGUI::tr(
"A fatal error occurred. Fabcoin can no longer continue safely and will quit.") + QString(
"\n\n") + message);
560 ::exit(EXIT_FAILURE);
579 QStringList arg = arguments();
586 commandLine = arg.join(
' ');
590 QString pathWallet = QString::fromStdString(path.string());
591 QFile::remove(pathWallet);
596 QThread::currentThread()->sleep(2);
599 QProcess *process =
new QProcess();
600 process->start(commandLine);
606 #ifndef FABCOIN_QT_TEST 607 int main(
int argc,
char *argv[])
618 #if QT_VERSION < 0x050000 620 QTextCodec::setCodecForTr(QTextCodec::codecForName(
"UTF-8"));
621 QTextCodec::setCodecForCStrings(QTextCodec::codecForTr());
624 Q_INIT_RESOURCE(fabcoin);
625 Q_INIT_RESOURCE(fabcoin_locale);
628 #if QT_VERSION > 0x050100 630 QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
632 #if QT_VERSION >= 0x050600 633 QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
636 QApplication::setAttribute(Qt::AA_DontShowIconsInMenus);
638 #if QT_VERSION >= 0x050500 641 QSslConfiguration sslconf = QSslConfiguration::defaultConfiguration();
642 sslconf.setProtocol(QSsl::TlsV1_0OrLater);
643 QSslConfiguration::setDefaultConfiguration(sslconf);
647 qRegisterMetaType< bool* >();
650 qRegisterMetaType< CAmount >(
"CAmount");
651 qRegisterMetaType< std::function<void(void)> >(
"std::function<void(void)>");
663 QTranslator qtTranslatorBase, qtTranslator, translatorBase, translator;
664 initTranslations(qtTranslatorBase, qtTranslator, translatorBase, translator);
686 QObject::tr(
"Error: Specified data directory \"%1\" does not exist.").arg(QString::fromStdString(
gArgs.
GetArg(
"-datadir",
""))));
691 }
catch (
const std::exception&
e) {
693 QObject::tr(
"Error: Cannot parse configuration file: %1. Only use key=value syntax.").arg(e.what()));
706 }
catch(std::exception &e) {
707 QMessageBox::critical(0, QObject::tr(
PACKAGE_NAME), QObject::tr(
"Error: %1").arg(e.what()));
716 assert(!networkStyle.isNull());
718 QApplication::setApplicationName(networkStyle->getAppName());
720 initTranslations(qtTranslatorBase, qtTranslator, translatorBase, translator);
734 app.createPaymentServer();
740 #if QT_VERSION < 0x050000 744 #if defined(Q_OS_WIN) 746 qApp->installNativeEventFilter(
new WinShutdownMonitor());
762 int rv = EXIT_SUCCESS;
773 #if defined(Q_OS_WIN) && QT_VERSION >= 0x050000 774 WinShutdownMonitor::registerShutdownBlockReason(QObject::tr(
"%1 didn't yet exit safely...").arg(QObject::tr(
PACKAGE_NAME)), (HWND)app.
getMainWinId());
784 }
catch (
const std::exception& e) {
794 #endif // FABCOIN_QT_TEST void SubstituteFonts(const QString &language)
void UnlockDataDirectory()
Unlock the data directory.
void handleRunawayException(const QString &message)
Handle runaway exceptions. Shows a message box with the problem and quits the program.
static void LoadRootCAs(X509_STORE *store=nullptr)
void initializeResult(bool success)
#define SetObjectStyleSheet(object, name)
std::vector< CWalletRef > vpwallets
void ParseParameters(int argc, const char *const argv[])
void InitLogging()
Initialize the logging infrastructure.
bool IsArgSet(const std::string &strArg)
Return true if the given argument has been manually set.
Class for the splashscreen with information of the running client.
void createWindow(const NetworkStyle *networkStyle)
Create main window.
void setClientModel(ClientModel *clientModel)
Set the client model.
static const std::string DEFAULT_UIPLATFORM
QTimer * pollShutdownTimer
bool GetBoolArg(const std::string &strArg, bool fDefault)
Return boolean argument or default value.
void PrintExceptionContinue(const std::exception *pex, const char *pszThread)
void DebugMessageHandler(QtMsgType type, const char *msg)
std::hash for asio::adress
assert(len-trim+(2 *lenIndices)<=WIDTH)
Qt event filter that intercepts ToolTipChange events, and replaces the tooltip with a rich text repre...
void initializeResult(bool success)
Class encapsulating Fabcoin Core startup and shutdown.
bool AppInitBasicSetup()
Initialize fabcoin core: Basic context setup.
void ReadConfigFile(const std::string &confPath)
void handleRunawayException(const std::exception *e)
Pass fatal exception message to UI thread.
static void ipcParseCommandLine(int argc, char *argv[])
void runawayException(const QString &message)
void requestedInitialize()
ClientModel * clientModel
static bool ipcSendCommandLine()
int64_t CAmount
Amount in lius (Can be negative)
boost::thread_group threadGroup
void InitParameterInteraction()
Parameter interaction: change current parameters depending on various rules.
CTranslationInterface translationInterface
WId getMainWinId() const
Get window identifier of QMainWindow (FabcoinGUI)
void removeParam(QStringList &list, const QString ¶m)
bool AppInitSanityChecks()
Initialization sanity checks: ecc init, sanity checks, dir lock.
static bool baseInitialize()
Basic initialization, before starting initialization/shutdown thread.
const char *const FABCOIN_CONF_FILENAME
FabcoinApplication(int &argc, char **argv)
void Interrupt(boost::thread_group &threadGroup)
Interrupt threads.
void SelectParams(const std::string &network)
Sets the params returned by Params() to those for the given BIP70 chain name.
Main Fabcoin application object.
void parameterSetup()
parameter interaction/setup based on rules
void requestInitialize()
Request core initialization.
static QWidget * showShutdownWindow(FabcoinGUI *window)
static const QString DEFAULT_WALLET
Display name for default wallet name.
std::string GetWarnings(const std::string &strFor)
Format a string that describes several potential problems detected by the core.
int main(int argc, char *argv[])
void requestShutdown()
Request core shutdown.
Model for Fabcoin network client.
void splashFinished(QWidget *window)
bool AppInitParameterInteraction()
Initialization: parameter interaction.
#define LogPrint(category,...)
#define QAPP_APP_NAME_DEFAULT
PlatformStyle::TableColorType type
Interface from Qt to configuration data structure for Fabcoin client.
const CChainParams & Params()
Return the currently selected parameters.
std::string GetArg(const std::string &strArg, const std::string &strDefault)
Return string argument or default value.
boost::signals2::signal< std::string(const char *psz)> Translate
Translate a message to the native language of the user.
Interface to Fabcoin wallet from Qt view code.
std::string ChainNameFromCommandLine()
Looks for -regtest, -testnet and returns the appropriate BIP70 chain name.
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances...
"Help message" dialog box
const fs::path & GetDataDir(bool fNetSpecific)
std::unique_ptr< QWidget > shutdownWindow
bool AppInitLockDataDirectory()
Lock fabcoin core data directory.
void createOptionsModel(bool resetSettings)
Create options model.
CClientUIInterface uiInterface
bool AppInitMain(boost::thread_group &threadGroup, CScheduler &scheduler)
Fabcoin core main initialization.
OptionsModel * optionsModel
int getReturnValue()
Get process return value.
const PlatformStyle * platformStyle
static bool pickDataDirectory()
Determine data directory.
boost::signals2::signal< void(const std::string &message)> InitMessage
Progress message during initialization.
void createSplashScreen(const NetworkStyle *networkStyle)
Create splash screen.
static const NetworkStyle * instantiate(const QString &networkId)
Get style associated with provided BIP70 network id, or 0 if not known.