diff options
-rw-r--r-- | Makefile.am | 15 | ||||
-rw-r--r-- | configure.ac | 15 | ||||
-rwxr-xr-x | contrib/macdeploy/macdeployqtplus | 19 | ||||
-rw-r--r-- | src/bitcoin-cli.cpp | 2 | ||||
-rw-r--r-- | src/m4/bitcoin_qt.m4 | 8 | ||||
-rw-r--r-- | src/qt/bitcoin.cpp | 3 | ||||
-rw-r--r-- | src/qt/guiutil.cpp | 27 | ||||
-rw-r--r-- | src/qt/guiutil.h | 4 | ||||
-rw-r--r-- | src/rpcprotocol.cpp | 27 | ||||
-rw-r--r-- | src/rpcprotocol.h | 4 | ||||
-rw-r--r-- | src/rpcserver.cpp | 4 |
11 files changed, 106 insertions, 22 deletions
diff --git a/Makefile.am b/Makefile.am index 951d7581fb..a64666a32b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -46,7 +46,7 @@ distcheck-hook: distcleancheck: @: -$(BITCOIN_WIN_INSTALLER): $(BITCOIND_BIN) $(BITCOIN_QT_BIN) $(BITCOIN_CLI_BIN) +$(BITCOIN_WIN_INSTALLER): all-recursive $(MKDIR_P) $(top_builddir)/release STRIPPROG="$(STRIP)" $(INSTALL_STRIP_PROGRAM) $(BITCOIND_BIN) $(top_builddir)/release STRIPPROG="$(STRIP)" $(INSTALL_STRIP_PROGRAM) $(BITCOIN_QT_BIN) $(top_builddir)/release @@ -83,11 +83,11 @@ OSX_APP_BUILT=$(OSX_APP)/Contents/PkgInfo $(OSX_APP)/Contents/Resources/empty.lp if BUILD_DARWIN $(OSX_DMG): $(OSX_APP_BUILT) $(OSX_PACKAGING) - $(OSX_DEPLOY_SCRIPT) $(OSX_APP) -add-qt-tr $(OSX_QT_TRANSLATIONS) -dmg -fancy $(OSX_FANCY_PLIST) -verbose 2 + $(OSX_DEPLOY_SCRIPT) $(OSX_APP) -add-qt-tr $(OSX_QT_TRANSLATIONS) -translations-dir=$(QT_TRANSLATION_DIR) -dmg -fancy $(OSX_FANCY_PLIST) -verbose 2 else $(OSX_DMG): $(OSX_APP_BUILT) $(OSX_PACKAGING) - INSTALLNAMETOOL=$(INSTALLNAMETOOL) OTOOL=$(OTOOL) STRIP=$(STRIP) $(OSX_DEPLOY_SCRIPT) $(OSX_APP) -add-qt-tr $(OSX_QT_TRANSLATIONS) -verbose 2 + INSTALLNAMETOOL=$(INSTALLNAMETOOL) OTOOL=$(OTOOL) STRIP=$(STRIP) $(OSX_DEPLOY_SCRIPT) $(OSX_APP) -add-qt-tr $(OSX_QT_TRANSLATIONS) -translations-dir=$(QT_TRANSLATION_DIR) -verbose 2 $(MKDIR_P) dist/.background $(INSTALL) contrib/macdeploy/background.png dist/.background $(INSTALL) contrib/macdeploy/DS_Store dist/.DS_Store @@ -103,6 +103,15 @@ if TARGET_WINDOWS deploy: $(BITCOIN_WIN_INSTALLER) endif +$(BITCOIN_QT_BIN): FORCE + $(MAKE) -C src qt/$(@F) + +$(BITCOIND_BIN): FORCE + $(MAKE) -C src $(@F) + +$(BITCOIN_CLI_BIN): FORCE + $(MAKE) -C src $(@F) + if USE_LCOV baseline.info: diff --git a/configure.ac b/configure.ac index 719b06da67..0b2a429e02 100644 --- a/configure.ac +++ b/configure.ac @@ -345,7 +345,6 @@ fi if test x$use_hardening != xno; then AX_CHECK_COMPILE_FLAG([-Wstack-protector],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -Wstack-protector"]) AX_CHECK_COMPILE_FLAG([-fstack-protector-all],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fstack-protector-all"]) - AX_CHECK_COMPILE_FLAG([-fPIE],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fPIE"]) AX_CHECK_PREPROC_FLAG([-D_FORTIFY_SOURCE=2],[ AX_CHECK_PREPROC_FLAG([-U_FORTIFY_SOURCE],[ @@ -360,7 +359,8 @@ if test x$use_hardening != xno; then AX_CHECK_LINK_FLAG([[-Wl,-z,now]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,now"]) if test x$TARGET_OS != xwindows; then - # -pie will link successfully with MinGW, but it's unsupported and leads to undeterministic binaries + # All windows code is PIC, forcing it on just adds useless compile warnings + AX_CHECK_COMPILE_FLAG([-fPIE],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fPIE"]) AX_CHECK_LINK_FLAG([[-pie]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -pie"]) fi @@ -717,3 +717,14 @@ AC_CONFIG_FILES([Makefile src/Makefile share/setup.nsi share/qt/Info.plist]) AC_CONFIG_FILES([qa/pull-tester/run-bitcoind-for-test.sh],[chmod +x qa/pull-tester/run-bitcoind-for-test.sh]) AC_CONFIG_FILES([qa/pull-tester/build-tests.sh],[chmod +x qa/pull-tester/build-tests.sh]) AC_OUTPUT + +dnl Taken from https://wiki.debian.org/RpathIssue +case $host in + *-*-linux-gnu) + AC_MSG_RESULT([Fixing libtool for -rpath problems.]) + sed < libtool > libtool-2 \ + 's/^hardcode_libdir_flag_spec.*$'/'hardcode_libdir_flag_spec=" -D__LIBTOOL_IS_A_FOOL__ "/' + mv libtool-2 libtool + chmod 755 libtool + ;; +esac diff --git a/contrib/macdeploy/macdeployqtplus b/contrib/macdeploy/macdeployqtplus index eece81dd3d..23b57a76b3 100755 --- a/contrib/macdeploy/macdeployqtplus +++ b/contrib/macdeploy/macdeployqtplus @@ -449,6 +449,7 @@ ap.add_argument("-sign", dest="sign", action="store_true", default=False, help=" ap.add_argument("-dmg", nargs="?", const="", metavar="basename", help="create a .dmg disk image; if basename is not specified, a camel-cased version of the app name is used") ap.add_argument("-fancy", nargs=1, metavar="plist", default=[], help="make a fancy looking disk image using the given plist file with instructions; requires -dmg to work") ap.add_argument("-add-qt-tr", nargs=1, metavar="languages", default=[], help="add Qt translation files to the bundle's ressources; the language list must be separated with commas, not with whitespace") +ap.add_argument("-translations-dir", nargs=1, metavar="path", default=None, help="Path to Qt's translation files") ap.add_argument("-add-resources", nargs="+", metavar="path", default=[], help="list of additional files or folders to be copied into the bundle's resources; must be the last argument") config = ap.parse_args() @@ -467,6 +468,15 @@ if not os.path.exists(app_bundle): app_bundle_name = os.path.splitext(os.path.basename(app_bundle))[0] # ------------------------------------------------ +translations_dir = None +if config.translations_dir and config.translations_dir[0]: + if os.path.exists(config.translations_dir[0]): + translations_dir = config.translations_dir[0] + else: + if verbose >= 1: + sys.stderr.write("Error: Could not find translation dir \"%s\"\n" % (translations_dir)) + sys.exit(1) +# ------------------------------------------------ for p in config.add_resources: if verbose >= 3: @@ -590,7 +600,14 @@ if config.plugins: if len(config.add_qt_tr) == 0: add_qt_tr = [] else: - qt_tr_dir = os.path.join(deploymentInfo.qtPath, "translations") + if translations_dir is not None: + qt_tr_dir = translations_dir + else: + if deploymentInfo.qtPath is not None: + qt_tr_dir = os.path.join(deploymentInfo.qtPath, "translations") + else: + sys.stderr.write("Error: Could not find Qt translation path\n") + sys.exit(1) add_qt_tr = ["qt_%s.qm" % lng for lng in config.add_qt_tr[0].split(",")] for lng_file in add_qt_tr: p = os.path.join(qt_tr_dir, lng_file) diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 3b991f9276..0609adcab3 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -126,7 +126,7 @@ Object CallRPC(const string& strMethod, const Array& params) // Receive HTTP reply message headers and body map<string, string> mapHeaders; string strReply; - ReadHTTPMessage(stream, mapHeaders, strReply, nProto); + ReadHTTPMessage(stream, mapHeaders, strReply, nProto, std::numeric_limits<size_t>::max()); if (nStatus == HTTP_UNAUTHORIZED) throw runtime_error("incorrect rpcuser or rpcpassword (authorization failed)"); diff --git a/src/m4/bitcoin_qt.m4 b/src/m4/bitcoin_qt.m4 index 5017742cc2..4c1d40c394 100644 --- a/src/m4/bitcoin_qt.m4 +++ b/src/m4/bitcoin_qt.m4 @@ -62,6 +62,7 @@ AC_DEFUN([BITCOIN_QT_INIT],[ AC_ARG_WITH([qt-incdir],[AS_HELP_STRING([--with-qt-incdir=INC_DIR],[specify qt include path (overridden by pkgconfig)])], [qt_include_path=$withval], []) AC_ARG_WITH([qt-libdir],[AS_HELP_STRING([--with-qt-libdir=LIB_DIR],[specify qt lib path (overridden by pkgconfig)])], [qt_lib_path=$withval], []) AC_ARG_WITH([qt-plugindir],[AS_HELP_STRING([--with-qt-plugindir=PLUGIN_DIR],[specify qt plugin path (overridden by pkgconfig)])], [qt_plugin_path=$withval], []) + AC_ARG_WITH([qt-translationdir],[AS_HELP_STRING([--with-qt-translationdir=PLUGIN_DIR],[specify qt translation path (overridden by pkgconfig)])], [qt_translation_path=$withval], []) AC_ARG_WITH([qt-bindir],[AS_HELP_STRING([--with-qt-bindir=BIN_DIR],[specify qt bin path])], [qt_bin_path=$withval], []) AC_ARG_WITH([qtdbus], @@ -69,6 +70,8 @@ AC_DEFUN([BITCOIN_QT_INIT],[ [enable DBus support (default is yes if qt is enabled and QtDBus is found)])], [use_dbus=$withval], [use_dbus=auto]) + + AC_SUBST(QT_TRANSLATION_DIR,$qt_translation_path) ]) dnl Find the appropriate version of Qt libraries and includes. @@ -123,7 +126,8 @@ AC_DEFUN([BITCOIN_QT_CONFIGURE],[ _BITCOIN_QT_CHECK_STATIC_PLUGINS([Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)],[-lqwindows]) AC_DEFINE(QT_QPA_PLATFORM_WINDOWS, 1, [Define this symbol if the qt platform is windows]) elif test x$TARGET_OS == xlinux; then - _BITCOIN_QT_CHECK_STATIC_PLUGINS([Q_IMPORT_PLUGIN(QXcbIntegrationPlugin)],[-lqxcb -lxcb-static -lxcb]) + PKG_CHECK_MODULES([X11XCB], [x11-xcb], [QT_LIBS="$X11XCB_LIBS $QT_LIBS"]) + _BITCOIN_QT_CHECK_STATIC_PLUGINS([Q_IMPORT_PLUGIN(QXcbIntegrationPlugin)],[-lqxcb -lxcb-static]) AC_DEFINE(QT_QPA_PLATFORM_XCB, 1, [Define this symbol if the qt platform is xcb]) elif test x$TARGET_OS == xdarwin; then if test x$use_pkgconfig = xyes; then @@ -370,7 +374,7 @@ AC_DEFUN([_BITCOIN_QT_FIND_LIBS_WITHOUT_PKGCONFIG],[ BITCOIN_QT_CHECK(AC_CHECK_LIB([z] ,[main],,AC_MSG_WARN([zlib not found. Assuming qt has it built-in]))) BITCOIN_QT_CHECK(AC_CHECK_LIB([png] ,[main],,AC_MSG_WARN([libpng not found. Assuming qt has it built-in]))) BITCOIN_QT_CHECK(AC_CHECK_LIB([jpeg] ,[main],,AC_MSG_WARN([libjpeg not found. Assuming qt has it built-in]))) - BITCOIN_QT_CHECK(AC_CHECK_LIB([pcre] ,[main],,AC_MSG_WARN([libpcre not found. Assuming qt has it built-in]))) + BITCOIN_QT_CHECK(AC_CHECK_LIB([pcre16] ,[main],,AC_MSG_WARN([libpcre16 not found. Assuming qt has it built-in]))) BITCOIN_QT_CHECK(AC_CHECK_LIB([${QT_LIB_PREFIX}Core] ,[main],,BITCOIN_QT_FAIL(lib$QT_LIB_PREFIXCore not found))) BITCOIN_QT_CHECK(AC_CHECK_LIB([${QT_LIB_PREFIX}Gui] ,[main],,BITCOIN_QT_FAIL(lib$QT_LIB_PREFIXGui not found))) BITCOIN_QT_CHECK(AC_CHECK_LIB([${QT_LIB_PREFIX}Network],[main],,BITCOIN_QT_FAIL(lib$QT_LIB_PREFIXNetwork not found))) diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index ea706d9f25..a43e7cb756 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -489,6 +489,9 @@ int main(int argc, char *argv[]) Q_INIT_RESOURCE(bitcoin); Q_INIT_RESOURCE(bitcoin_locale); + + GUIUtil::SubstituteFonts(); + BitcoinApplication app(argc, argv); #if QT_VERSION > 0x050100 // Generate high-dpi pixmaps diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index ed83909608..38fbc48a4d 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -63,6 +63,13 @@ static boost::filesystem::detail::utf8_codecvt_facet utf8; #endif +#if defined(Q_OS_MAC) +extern double NSAppKitVersionNumber; +#if !defined(NSAppKitVersionNumber10_9) +#define NSAppKitVersionNumber10_9 1265 +#endif +#endif + namespace GUIUtil { QString dateTimeStr(const QDateTime &date) @@ -376,6 +383,26 @@ ToolTipToRichTextFilter::ToolTipToRichTextFilter(int size_threshold, QObject *pa } +void SubstituteFonts() +{ +#if defined(Q_OS_MAC) +// Background: +// OSX's default font changed in 10.9 and QT is unable to find it with its +// usual fallback methods when building against the 10.7 sdk or lower. +// The 10.8 SDK added a function to let it find the correct fallback font. +// If this fallback is not properly loaded, some characters may fail to +// render correctly. +// +// Solution: If building with the 10.7 SDK or lower and the user's platform +// is 10.9 or higher at runtime, substitute the correct font. This needs to +// happen before the QApplication is created. +#if defined(MAC_OS_X_VERSION_MAX_ALLOWED) && MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_8 + if (floor(NSAppKitVersionNumber) >= NSAppKitVersionNumber10_9) + QFont::insertSubstitution(".Lucida Grande UI", "Lucida Grande"); +#endif +#endif +} + bool ToolTipToRichTextFilter::eventFilter(QObject *obj, QEvent *evt) { if(evt->type() == QEvent::ToolTipChange) diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h index dd31d051ee..83739a5f13 100644 --- a/src/qt/guiutil.h +++ b/src/qt/guiutil.h @@ -106,6 +106,10 @@ namespace GUIUtil representation if needed. This assures that Qt can word-wrap long tooltip messages. Tooltips longer than the provided size threshold (in characters) are wrapped. */ + + // Replace invalid default fonts with known good ones + void SubstituteFonts(); + class ToolTipToRichTextFilter : public QObject { Q_OBJECT diff --git a/src/rpcprotocol.cpp b/src/rpcprotocol.cpp index 9e18ca847e..643208b3b6 100644 --- a/src/rpcprotocol.cpp +++ b/src/rpcprotocol.cpp @@ -93,8 +93,7 @@ string HTTPError(int nStatus, bool keepalive, bool headersOnly) headersOnly, "text/plain"); } -string HTTPReply(int nStatus, const string& strMsg, bool keepalive, - bool headersOnly, const char *contentType) +string HTTPReplyHeader(int nStatus, bool keepalive, size_t contentLength, const char *contentType) { return strprintf( "HTTP/1.1 %d %s\r\n" @@ -103,17 +102,25 @@ string HTTPReply(int nStatus, const string& strMsg, bool keepalive, "Content-Length: %u\r\n" "Content-Type: %s\r\n" "Server: bitcoin-json-rpc/%s\r\n" - "\r\n" - "%s", + "\r\n", nStatus, httpStatusDescription(nStatus), rfc1123Time(), keepalive ? "keep-alive" : "close", - (headersOnly ? 0 : strMsg.size()), + contentLength, contentType, - FormatFullVersion(), - (headersOnly ? "" : strMsg.c_str()) - ); + FormatFullVersion()); +} + +string HTTPReply(int nStatus, const string& strMsg, bool keepalive, + bool headersOnly, const char *contentType) +{ + if (headersOnly) + { + return HTTPReplyHeader(nStatus, keepalive, 0, contentType); + } else { + return HTTPReplyHeader(nStatus, keepalive, strMsg.size(), contentType) + strMsg; + } } bool ReadHTTPRequestLine(std::basic_istream<char>& stream, int &proto, @@ -194,14 +201,14 @@ int ReadHTTPHeaders(std::basic_istream<char>& stream, map<string, string>& mapHe int ReadHTTPMessage(std::basic_istream<char>& stream, map<string, string>& mapHeadersRet, string& strMessageRet, - int nProto) + int nProto, size_t max_size) { mapHeadersRet.clear(); strMessageRet = ""; // Read header int nLen = ReadHTTPHeaders(stream, mapHeadersRet); - if (nLen < 0 || nLen > (int)MAX_SIZE) + if (nLen < 0 || (size_t)nLen > max_size) return HTTP_INTERNAL_SERVER_ERROR; // Read message diff --git a/src/rpcprotocol.h b/src/rpcprotocol.h index 5627077bfb..8f05c08482 100644 --- a/src/rpcprotocol.h +++ b/src/rpcprotocol.h @@ -143,6 +143,8 @@ private: std::string HTTPPost(const std::string& strMsg, const std::map<std::string,std::string>& mapRequestHeaders); std::string HTTPError(int nStatus, bool keepalive, bool headerOnly = false); +std::string HTTPReplyHeader(int nStatus, bool keepalive, size_t contentLength, + const char *contentType = "application/json"); std::string HTTPReply(int nStatus, const std::string& strMsg, bool keepalive, bool headerOnly = false, const char *contentType = "application/json"); @@ -151,7 +153,7 @@ bool ReadHTTPRequestLine(std::basic_istream<char>& stream, int &proto, int ReadHTTPStatus(std::basic_istream<char>& stream, int &proto); int ReadHTTPHeaders(std::basic_istream<char>& stream, std::map<std::string, std::string>& mapHeadersRet); int ReadHTTPMessage(std::basic_istream<char>& stream, std::map<std::string, std::string>& mapHeadersRet, - std::string& strMessageRet, int nProto); + std::string& strMessageRet, int nProto, size_t max_size); std::string JSONRPCRequest(const std::string& strMethod, const json_spirit::Array& params, const json_spirit::Value& id); json_spirit::Object JSONRPCReplyObj(const json_spirit::Value& result, const json_spirit::Value& error, const json_spirit::Value& id); std::string JSONRPCReply(const json_spirit::Value& result, const json_spirit::Value& error, const json_spirit::Value& id); diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index 716a7fba6a..e7ed73310c 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -862,7 +862,7 @@ static bool HTTPReq_JSONRPC(AcceptedConnection *conn, else throw JSONRPCError(RPC_PARSE_ERROR, "Top-level object parse error"); - conn->stream() << HTTPReply(HTTP_OK, strReply, fRun) << std::flush; + conn->stream() << HTTPReplyHeader(HTTP_OK, fRun, strReply.size()) << strReply << std::flush; } catch (Object& objError) { @@ -891,7 +891,7 @@ void ServiceConnection(AcceptedConnection *conn) break; // Read HTTP message headers and body - ReadHTTPMessage(conn->stream(), mapHeaders, strRequest, nProto); + ReadHTTPMessage(conn->stream(), mapHeaders, strRequest, nProto, MAX_SIZE); // HTTP Keep-Alive is false; close connection immediately if (mapHeaders["connection"] == "close") |