1 // This file is part of Qt Bitcoin Trader 2 // https://github.com/JulyIGHOR/QtBitcoinTrader 3 // Copyright (C) 2013-2021 July Ighor <julyighor@gmail.com> 4 // 5 // This program is free software: you can redistribute it and/or modify 6 // it under the terms of the GNU General Public License as published by 7 // the Free Software Foundation, either version 3 of the License, or 8 // (at your option) any later version. 9 // 10 // In addition, as a special exception, the copyright holders give 11 // permission to link the code of portions of this program with the 12 // OpenSSL library under certain conditions as described in each 13 // individual source file, and distribute linked combinations including 14 // the two. 15 // 16 // You must obey the GNU General Public License in all respects for all 17 // of the code used other than OpenSSL. If you modify file(s) with this 18 // exception, you may extend this exception to your version of the 19 // file(s), but you are not obligated to do so. If you do not wish to do 20 // so, delete this exception statement from your version. If you delete 21 // this exception statement from all source files in the program, then 22 // also delete it here. 23 // 24 // This program is distributed in the hope that it will be useful, 25 // but WITHOUT ANY WARRANTY; without even the implied warranty of 26 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 27 // GNU General Public License for more details. 28 // 29 // You should have received a copy of the GNU General Public License 30 // along with this program. If not, see <http://www.gnu.org/licenses/>. 31 32 #ifndef MAIN_H 33 #define MAIN_H 34 #include "qtextstream.h" 35 #include <QFontMetrics> 36 #include "julytranslator.h" 37 #include "logthread.h" 38 39 #define textFontWidth(text) baseValues_->fontMetrics_->horizontalAdvance(text) 40 #define debugLevel (baseValues_->debugLevel_) 41 #define appDataDir (baseValues_->appDataDir_) 42 #define grouped (baseValues_->groupPriceValue>0.0?2:0) 43 #define mainWindow (*baseValues_->mainWindow_) 44 #define logThread (baseValues_->logThread_) 45 46 #define julyTr baseValues_->julyTranslator_.translateString 47 #define julyTranslator baseValues_->julyTranslator_ 48 #define currentExchange baseValues_->currentExchange_ 49 50 #define defaultHeightForRow baseValues_->defaultHeightForRow_ 51 #define upArrowStr baseValues_->upArrow 52 #define downArrowStr baseValues_->downArrow 53 #define upArrowNoUtfStr baseValues_->upArrowNoUtf8 54 #define downArrowNoUtfStr baseValues_->downArrowNoUtf8 55 56 #define hmacSha512(key, baseString) QByteArray(reinterpret_cast<const char *>(HMAC(EVP_sha512(),key.constData(), key.size(), reinterpret_cast<const unsigned char *>(baseString.constData()), static_cast<size_t>(baseString.size()), nullptr, nullptr)),64) 57 #define hmacSha384(key, baseString) QByteArray(reinterpret_cast<const char *>(HMAC(EVP_sha384(),key.constData(), key.size(), reinterpret_cast<const unsigned char *>(baseString.constData()), static_cast<size_t>(baseString.size()), nullptr, nullptr)),48) 58 #define hmacSha256(key, baseString) QByteArray(reinterpret_cast<const char *>(HMAC(EVP_sha256(),key.constData(), key.size(), reinterpret_cast<const unsigned char *>(baseString.constData()), static_cast<size_t>(baseString.size()), nullptr, nullptr)),32) 59 #define hmacSha1(key, baseString) QByteArray(reinterpret_cast<const char *>(HMAC(EVP_sha1(),key.constData(), key.size(), reinterpret_cast<const unsigned char *>(baseString.constData()), static_cast<size_t>(baseString.size()), nullptr, nullptr)),20) 60 61 #include "qtbitcointrader.h" 62 #include "apptheme.h" 63 #include "currencypairitem.h" 64 65 class Exchange; 66 class QProcess; 67 68 struct BaseValues 69 { 70 BaseValues(); 71 void selectSystemLanguage(); 72 void initHiDpi(); 73 void initValues(QApplication& a); 74 bool initAppDataDir(QApplication& a); 75 void initThemes(QApplication& a); 76 void initSettings(); 77 78 bool portableMode = false; 79 80 bool defaultEnableHiDPI; 81 82 int scriptsThatUseOrderBookCount; 83 84 QString osStyle; 85 bool forceDotInSpinBoxes; 86 87 int trafficSpeed; 88 qint64 trafficTotal; 89 int trafficTotalType; 90 91 CurrencyPairItem currentPair; 92 QMap<QString, CurrencyPairItem> currencyPairMap; 93 94 int currentTheme; 95 96 QByteArray upArrow; 97 QByteArray downArrow; 98 QByteArray upArrowNoUtf8; 99 QByteArray downArrowNoUtf8; 100 101 QString customUserAgent; 102 QString customCookies; 103 bool gzipEnabled; 104 AppTheme appThemeLight; 105 AppTheme appThemeDark; 106 AppTheme appThemeGray; 107 AppTheme appTheme; 108 int debugLevel_;//0: Disabled; 1: Debug; 2: Log 109 bool supportsUtfUI; 110 bool highResolutionDisplay; 111 int defaultHeightForRow_; 112 double groupPriceValue; 113 QFontMetrics* fontMetrics_; 114 int apiDownCount; 115 int uiUpdateInterval; 116 QByteArray depthCountLimitStr; 117 int depthCountLimit; 118 int httpRetryCount; 119 int httpRequestInterval; 120 int minimumRequestInterval; 121 int httpRequestTimeout; 122 int minimumRequestTimeout; 123 QAtomicInt feeDecimals; 124 Exchange* currentExchange_; 125 QString scriptFolder; 126 QString themeFolder; 127 double jlScriptVersion; 128 QString exchangeName; 129 QString timeFormat; 130 QString dateTimeFormat; 131 bool use24HourTimeFormat; 132 QString defaultLangFile; 133 JulyTranslator julyTranslator_; 134 QString appDataDir_; 135 QByteArray appVerStr; 136 LogThread* logThread_; 137 QByteArray restKey; 138 QByteArray restSign; 139 QByteArray randomPassword; 140 QtBitcoinTrader* mainWindow_; 141 QString logFileName; 142 QString iniFileName; 143 QString desktopLocation; 144 QString tempLocation; 145 double appVerReal; 146 double appVerLastReal; 147 bool appVerIsBeta; 148 149 int decimalsAmountMyTransactions; 150 int decimalsPriceMyTransactions; 151 int decimalsTotalMyTransactions; 152 int decimalsAmountOrderBook; 153 int decimalsPriceOrderBook; 154 int decimalsTotalOrderBook; 155 int decimalsAmountLastTrades; 156 int decimalsPriceLastTrades; 157 int decimalsTotalLastTrades; 158 }; 159 160 #define baseValues (*baseValues_) 161 extern BaseValues* baseValues_; 162 163 #endif // MAIN_H 164