diff options
| author | Felix (xq) Queißner <git@mq32.de> | 2020-06-16 22:01:59 +0200 |
|---|---|---|
| committer | Felix (xq) Queißner <git@mq32.de> | 2020-06-16 22:01:59 +0200 |
| commit | a3f3e3933c4a2522e233917a6795c6e9d677e65c (patch) | |
| tree | 6e1bd483bbd5e8ca6fee4566e544de48bfa754a6 /src/filehandler.cpp | |
| parent | bc18d9356828f1ae40d3b4ce5432b30ca13cfc15 (diff) | |
| download | kristall-a3f3e3933c4a2522e233917a6795c6e9d677e65c.tar.gz | |
Refactoring: Changes internal structure of requests and unifies a lot of code. Now all errors are handled the same.
Diffstat (limited to 'src/filehandler.cpp')
| -rw-r--r-- | src/filehandler.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/filehandler.cpp b/src/filehandler.cpp new file mode 100644 index 0000000..a3012ba --- /dev/null +++ b/src/filehandler.cpp @@ -0,0 +1,43 @@ +#include "filehandler.hpp" + +#include <QMimeDatabase> +#include <QUrl> +#include <QFile> + +FileHandler::FileHandler() +{ + +} + +bool FileHandler::supportsScheme(const QString &scheme) const +{ + return (scheme == "file"); +} + +bool FileHandler::startRequest(const QUrl &url) +{ + QFile file { url.path() }; + + if (file.open(QFile::ReadOnly)) + { + QMimeDatabase db; + auto mime = db.mimeTypeForUrl(url).name(); + auto data = file.readAll(); + emit this->requestComplete(data, mime); + } + else + { + emit this->networkError(ResourceNotFound, "The requested file does not exist!"); + } + return true; +} + +bool FileHandler::isInProgress() const +{ + +} + +bool FileHandler::cancelRequest() +{ + +} |
