Merge pull request #16 from kiwix/windows

Make kiwix-desktop work on Windows.
This commit is contained in:
Matthieu Gautier 2018-07-17 16:27:29 +02:00 committed by GitHub
commit 4c8996d95b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 10 deletions

View File

@ -57,7 +57,6 @@ INSTALLS += target
static { static {
PKGCONFIG_OPTION = "--static" PKGCONFIG_OPTION = "--static"
QMAKE_LFLAGS += "-static-libstdc++ --static"
} }
unix { unix {

View File

@ -1,4 +1,5 @@
#include "kiwixapp.h" #include "kiwixapp.h"
#include "zim/error.h"
KiwixApp::KiwixApp(int& argc, char *argv[]) KiwixApp::KiwixApp(int& argc, char *argv[])
: QApplication(argc, argv), : QApplication(argc, argv),
@ -21,7 +22,12 @@ void KiwixApp::openZimFile(const QString &zimfile)
std::cout << "Opening " << zimfile_ << std::endl; std::cout << "Opening " << zimfile_ << std::endl;
try { try {
reader = new kiwix::Reader(zimfile_); reader = new kiwix::Reader(zimfile_);
} catch (...) { } catch (const zim::ZimFileFormatError& e) {
std::cout << "Cannot open " << zimfile_ << std::endl;
std::cout << e.what() << std::endl;
reader = nullptr;
} catch (const std::exception& e) {
std::cout << "oup" << e.what() << std::endl;
reader = nullptr; reader = nullptr;
} }
} }

View File

@ -14,10 +14,12 @@ void KiwixRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo &info)
{ {
std::cout << "Intercept request" << std::endl; std::cout << "Intercept request" << std::endl;
auto url = info.requestUrl(); auto url = info.requestUrl();
std::cout << " - " << url.toString().toUtf8().constData() << std::endl; auto urlString = url.toString();
url.setScheme("zim"); std::cout << " - " << urlString.toUtf8().constData() << std::endl;
std::cout << " + " << url.toString().toUtf8().constData() << std::endl; if (urlString.startsWith("http://")) {
info.redirect(url); urlString.replace(0, 7, "zim://");
}
std::cout << " + " << urlString.toUtf8().constData() << std::endl;
info.redirect(QUrl(urlString));
} }

View File

@ -44,10 +44,9 @@ KiwixSchemeHandler::requestStarted(QWebEngineUrlRequestJob *request)
request->fail(QWebEngineUrlRequestJob::UrlNotFound); request->fail(QWebEngineUrlRequestJob::UrlNotFound);
return; return;
} }
BlobBuffer* buffer = new BlobBuffer(entry.getBlob()); BlobBuffer* buffer = new BlobBuffer(entry.getBlob());
std::cout << " mimetype : " << entry.getMimetype() << std::endl; std::cout << " mimetype : '" << entry.getMimetype() << "'" << std::endl;
auto mimeType = QByteArray::fromRawData(entry.getMimetype().data(), entry.getMimetype().size()); auto mimeType = QByteArray::fromStdString(entry.getMimetype());
connect(buffer, &QIODevice::aboutToClose, buffer, &QObject::deleteLater); connect(buffer, &QIODevice::aboutToClose, buffer, &QObject::deleteLater);
request->reply(mimeType, buffer); request->reply(mimeType, buffer);
} }