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 {
PKGCONFIG_OPTION = "--static"
QMAKE_LFLAGS += "-static-libstdc++ --static"
}
unix {

View File

@ -1,4 +1,5 @@
#include "kiwixapp.h"
#include "zim/error.h"
KiwixApp::KiwixApp(int& argc, char *argv[])
: QApplication(argc, argv),
@ -21,7 +22,12 @@ void KiwixApp::openZimFile(const QString &zimfile)
std::cout << "Opening " << zimfile_ << std::endl;
try {
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;
}
}

View File

@ -14,10 +14,12 @@ void KiwixRequestInterceptor::interceptRequest(QWebEngineUrlRequestInfo &info)
{
std::cout << "Intercept request" << std::endl;
auto url = info.requestUrl();
std::cout << " - " << url.toString().toUtf8().constData() << std::endl;
url.setScheme("zim");
std::cout << " + " << url.toString().toUtf8().constData() << std::endl;
info.redirect(url);
auto urlString = url.toString();
std::cout << " - " << urlString.toUtf8().constData() << std::endl;
if (urlString.startsWith("http://")) {
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);
return;
}
BlobBuffer* buffer = new BlobBuffer(entry.getBlob());
std::cout << " mimetype : " << entry.getMimetype() << std::endl;
auto mimeType = QByteArray::fromRawData(entry.getMimetype().data(), entry.getMimetype().size());
std::cout << " mimetype : '" << entry.getMimetype() << "'" << std::endl;
auto mimeType = QByteArray::fromStdString(entry.getMimetype());
connect(buffer, &QIODevice::aboutToClose, buffer, &QObject::deleteLater);
request->reply(mimeType, buffer);
}