From efb96e80ece9abbd8df73e44f381a4941fddd57c Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Thu, 10 Dec 2015 16:33:09 -0800 Subject: [PATCH] [Qt] Use Qt resources for bundling the certificates --- configure | 1 + platform/qt/platform.gyp | 1 + platform/qt/qmapbox.qrc | 5 +++++ platform/qt/qt.gypi | 8 ++++++++ platform/qt/scripts/configure.sh | 2 ++ platform/qt/src/http_file_source.cpp | 10 +++++++++- 6 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 platform/qt/qmapbox.qrc diff --git a/configure b/configure index 3ce952af4..9fd7c358c 100755 --- a/configure +++ b/configure @@ -64,6 +64,7 @@ function print_qt_flags { CONFIG+=" 'qt_cflags%': [], "$LN CONFIG+=" 'qt_ldflags%': [], "$LN CONFIG+=" 'qt_moc%': [], "$LN + CONFIG+=" 'qt_rcc%': [], "$LN } # Load dependencies diff --git a/platform/qt/platform.gyp b/platform/qt/platform.gyp index 1135ec4a6..0ab6169dd 100644 --- a/platform/qt/platform.gyp +++ b/platform/qt/platform.gyp @@ -43,6 +43,7 @@ '../default/string_stdlib.cpp', '../default/thread.cpp', 'include/qmapboxgl.hpp', + 'qmapbox.qrc', 'src/async_task.cpp', 'src/async_task_impl.hpp', 'src/http_file_source.cpp', diff --git a/platform/qt/qmapbox.qrc b/platform/qt/qmapbox.qrc new file mode 100644 index 000000000..adb4cf20f --- /dev/null +++ b/platform/qt/qmapbox.qrc @@ -0,0 +1,5 @@ + + + ../../common/ca-bundle.crt + + diff --git a/platform/qt/qt.gypi b/platform/qt/qt.gypi index 4bec63cd8..e98b3254b 100644 --- a/platform/qt/qt.gypi +++ b/platform/qt/qt.gypi @@ -8,5 +8,13 @@ 'action': [ '<(qt_moc)', '<(RULE_INPUT_PATH)', '-o', '<(SHARED_INTERMEDIATE_DIR)/<(RULE_INPUT_DIRNAME)/moc_<(RULE_INPUT_ROOT).cpp' ], 'message': 'Generating MOC <(RULE_INPUT_ROOT).cpp', }, + { + 'rule_name': 'QRC files', + 'extension': 'qrc', + 'process_outputs_as_sources': 1, + 'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/<(RULE_INPUT_DIRNAME)/qrc_<(RULE_INPUT_ROOT).cpp' ], + 'action': [ '<(qt_rcc)', '<(RULE_INPUT_PATH)', '-name', '<(RULE_INPUT_ROOT)', '-o', '<(SHARED_INTERMEDIATE_DIR)/<(RULE_INPUT_DIRNAME)/qrc_<(RULE_INPUT_ROOT).cpp' ], + 'message': 'Generating QRC <(RULE_INPUT_ROOT).cpp', + }, ], } diff --git a/platform/qt/scripts/configure.sh b/platform/qt/scripts/configure.sh index 5be71e27b..701207eae 100644 --- a/platform/qt/scripts/configure.sh +++ b/platform/qt/scripts/configure.sh @@ -31,7 +31,9 @@ function print_qt_flags { QT_VERSION_MAJOR=$(qmake -query QT_VERSION | cut -d. -f1) if [ ${QT_VERSION_MAJOR} -gt 4 ] ; then CONFIG+=" 'qt_moc%': '$(pkg-config Qt${QT_VERSION_MAJOR}Core --variable=host_bins)/moc',"$LN + CONFIG+=" 'qt_rcc%': '$(pkg-config Qt${QT_VERSION_MAJOR}Core --variable=host_bins)/rcc',"$LN else CONFIG+=" 'qt_moc%': '$(pkg-config QtCore --variable=moc_location)',"$LN + CONFIG+=" 'qt_rcc%': '$(pkg-config QtCore --variable=rcc_location)',"$LN fi } diff --git a/platform/qt/src/http_file_source.cpp b/platform/qt/src/http_file_source.cpp index a38cf4236..87948609d 100644 --- a/platform/qt/src/http_file_source.cpp +++ b/platform/qt/src/http_file_source.cpp @@ -9,10 +9,18 @@ #include #include +// Needs to be on the global namespace +// for linking purposes. +void initResources() { + Q_INIT_RESOURCE(qmapbox); +} + namespace mbgl { HTTPFileSource::Impl::Impl() : m_manager(new QNetworkAccessManager(this)) { + initResources(); + QNetworkProxyFactory::setUseSystemConfiguration(true); #if QT_VERSION >= 0x050000 @@ -22,7 +30,7 @@ HTTPFileSource::Impl::Impl() : m_manager(new QNetworkAccessManager(this)) m_ssl.setProtocol(QSsl::TlsV1); #endif - m_ssl.setCaCertificates(QSslCertificate::fromPath("ca-bundle.crt")); + m_ssl.setCaCertificates(QSslCertificate::fromPath(":ca-bundle.crt")); if (m_ssl.caCertificates().isEmpty()) { mbgl::Log::Warning(mbgl::Event::HttpRequest, "Could not load list of certificate authorities"); }